[alibaba/easyexcel]模板填充导出的时候出现空指针异常

2024-05-17 259 views
2

触发场景描述 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)

回答

1

同问

6

这个bug 修复了吗?

4

请问有人在处理这个issue吗,我对这个issue感兴趣,我会在最近几个月尝试去修复这个bug。 @zhuangjiaju

1

我分析了这个bug出现的可能原因,并提出交了pull request。不知道是否能满足需求修复bug? @zhuangjiaju

0

已经在3.0.0-beta1 版本修复,beta版本会在一个月内升级成正式版。