3
触发场景描述
web端点击触发后端代码,到了excelWriter.fill(new FillWrapper("data1", data),fillConfig,writeSheet);
这里就直接报出空指针
触发Bug的代码
String templateFileName = EasyExcelUtil.getPath() + "templates" + File.separator + "dome.xlsx";
ExcelWriter excelWriter = EasyExcel.write("数据.xlsx").withTemplate(templateFileName).build();
WriteSheet writeSheet = EasyExcel.writerSheet().build();
FillConfig fillConfig= FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build();
excelWriter.fill(new FillWrapper("data1", hourReports),fillConfig,writeSheet);
excelWriter.fill(new FillWrapper("data1", hourReports),fillConfig,writeSheet);
excelWriter.fill(new FillWrapper("data2", dayReportList), writeSheet);
excelWriter.fill(new FillWrapper("data2", dayReportList), writeSheet);
excelWriter.fill(new FillWrapper("data3", supplierReports), writeSheet);
excelWriter.fill(new FillWrapper("data3", supplierReports), writeSheet);
Map<String, Object> map = new HashMap<String, Object>();
map.put("date", date);
excelWriter.fill(map, writeSheet);
// 别忘记关闭流
excelWriter.finish();
提示的异常或者没有达到的效果 java.lang.NullPointerException at com.alibaba.excel.write.executor.ExcelWriteFillExecutor.doFill(ExcelWriteFillExecutor.java:191) at com.alibaba.excel.write.executor.ExcelWriteFillExecutor.fill(ExcelWriteFillExecutor.java:118) at com.alibaba.excel.write.ExcelBuilderImpl.fill(ExcelBuilderImpl.java:78) at com.alibaba.excel.ExcelWriter.fill(ExcelWriter.java:185)