fix:解决导出报错问题

This commit is contained in:
fanxb 2024-04-13 22:55:46 +08:00
parent 71678b165b
commit 32a3bae2a6

View File

@ -229,10 +229,11 @@ public class ApplicationServiceImpl implements ApplicationService {
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode(po.getName() + "-站点导出数据", StandardCharsets.UTF_8).replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
ExcelWriter writer = EasyExcel.write(response.getOutputStream()).build();
writer.write(hostList, EasyExcel.writerSheet(0, "站点数据").head(ReportHostBo.class).build());
writer.write(hostDayList, EasyExcel.writerSheet(1, "站点日数据").head(ReportHostDayBo.class).build());
writer.write(detailPageList, EasyExcel.writerSheet(2, "页面数据").head(ReportDetailPageBo.class).build());
writer.finish();
try (ExcelWriter writer = EasyExcel.write(response.getOutputStream()).inMemory(true).build()) {
writer.write(hostList, EasyExcel.writerSheet(0, "站点数据").head(ReportHostBo.class).build());
writer.write(hostDayList, EasyExcel.writerSheet(1, "站点日数据").head(ReportHostDayBo.class).build());
writer.write(detailPageList, EasyExcel.writerSheet(2, "页面数据").head(ReportDetailPageBo.class).build());
writer.finish();
}
}
}