// 执行方法
Workbook workbook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
// response.setContentType("text/html;charset=utf-8");
response.setContentType("multipart/form-data");
try {
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")+".xlsx");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
response.setHeader("Cache-Control", "no-cache");
try {
//这个很有用,解决网址为 http://rental/anormaly 的网页可能暂时无法连接,或者它已永久性地移动到了新网址。
response.flushBuffer();
workbook.write(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != workbook) {
try {
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
excel 导出 response bug
最新推荐文章于 2024-03-31 21:28:33 发布