0
异常代码
public static void downLoadExcel(String fileName, String sourcePath, Map<String, Object> datas, List list,
CellWriteHandler cellWriteHandler, HttpServletResponse response) {
ExcelWriter excelWriter = null;
try (InputStream templateInputStream = TemplateExcelUtils.class.getClassLoader().getResourceAsStream(sourcePath)) {
OutputStream os = TemplateExcelUtils.getOutputStream(fileName,response);
ExcelWriterBuilder excelWriterBuilder = EasyExcel.write(os).withTemplate(templateInputStream);
if(ToolUtil.isNotEmpty(cellWriteHandler)){
excelWriterBuilder = excelWriterBuilder.registerWriteHandler(cellWriteHandler);
}
excelWriter = excelWriterBuilder.build();
// 创建 Sheet
WriteSheet writeSheet = EasyExcel.writerSheet().build();
if(ToolUtil.isNotEmpty(list)){
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
excelWriter.fill(list, fillConfig, writeSheet);
}
// 填充普通变量
excelWriter.fill(datas, writeSheet);
} catch (Exception e) {
e.printStackTrace();
throw new SysException("导出数据失败",null);
}finally {
if(excelWriter != null){
excelWriter.finish();
}
}
}
异常提示
我的模板 导出结果
问题描述导出后,最后一行的数据不见了