フランス語、スペイン語などの異なる言語でレポートを生成しようとしています.MS Excel 2007を使用してレポートを表示しています。 Linux環境で実行されるとスペイン語で表示されます。フランス語、スペイン語のアクセント付き文字がExcelで正しく表示されない
すべての言語はWindows Serverで動作しますが、Linuxで実行すると、上記の問題が発生します。
コードは、私がこのように始めた、Javaであると:
String contentType = "text/csv; charset=utf-8";
// resp is HttpServletResponse
resp.setCharacterEncoding("utf-8");
resp.setHeader("Cache-Control", "max-age=0,must-revalidate");
resp.setHeader("Pragma", "cache");
resp.setDateHeader("Last-Modified", System.currentTimeMillis());
resp.setHeader("Content-disposition", "attachment; filename=\"Report.csv\"");
resp.setContentType(contentType);
OutputStream os = resp.getOutputStream();
os.write(new byte[] { (byte)0xEF, (byte)0xBB, (byte)0xBF });
//os.print("\uFEFF".getBytes()); <<- tried this too, did not worked!
//where sb is StringBuffer sb = new StringBuffer();
//and string values were added by sb.append("\"" + someString + "\",");
os.write(sb.toString().getBytes());
助け、事前にあなたに感謝してください。
私はGetBytesメソッドを試してみました( "UTF-8")しかし、それはあまりにも機能しませんでした。提案していただきありがとうございます、私はそれを感謝します。 –