问题遇到的现象和发生背景
poi 3.17版 excel复杂导出,设置了合并单元格和样式
问题相关代码,请勿粘贴截图
//调用下载
public void downloadExcel(HttpServletResponse response, HSSFWorkbook wb, String fileName) throws IOException {
OutputStream outputStream = null;
try {
outputStream = getOutputStream(response, fileName);
wb.write(outputStream);
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
outputStream.close();
}
}
//输出流
private static OutputStream getOutputStream(HttpServletResponse response, String fileName) {
//创建本地文件
String filePath = fileName + ".xls";
File file = new File(filePath);
try {
if (!file.exists() || file.isDirectory()) {
file.createNewFile();
}
fileName = new String(filePath.getBytes(), "ISO-8859-1");
response.setCharacterEncoding(getSystemFileCharset());
response.addHeader("Content-Disposition", "filename=" + fileName);
return response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
运行结果及报错内容
我的解答思路和尝试过的方法
网上能搜到过的 我基本上都试过,无效
我想要达到的结果
各位大,谁能解决poi内容乱码的问题啊,搞了一天愁死了!