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内容乱码的问题啊,搞了一天愁死了!
tomcat里面设置一下编码,
uriencode=utf-8
<Connector port="8080" maxThreads="150" minSpareThreads="25"
maxSpareThreads="75" enableLookups="false" redirectPort="8443"
acceptCount="100" debug="99" connectionTimeout="20000"
disableUploadTimeout="true" URIEncoding="UTF-8"/>
直接数据写入?没有对数据进行处理映射列?
解决了解决了,前端请求接口的时候应该定义响应类型为 'blob',没想到搞了一天半原来是前端问题