easyexcel 数据写入CSV文件异常:Can not close IO

ttygqcqt  于 4个月前  发布在  其他
关注(0)|答案(2)|浏览(41)

异常出现的case是输出文件格式为CSV,但是如果实际代码执行过程没有数据写入到CSV文件,则在执行excelWrite.finish()时会报上述异常;

完整的异常堆栈:
com.alibaba.excel.exception.ExcelGenerateException: Can not close IO.
at com.alibaba.excel.context.WriteContextImpl.finish(WriteContextImpl.java:420)
at com.alibaba.excel.write.ExcelBuilderImpl.finish(ExcelBuilderImpl.java:99)
at com.alibaba.excel.ExcelWriter.finish(ExcelWriter.java:143)
at com.alipay.xxxxx.biz.bill.impl.QueryBillServiceImpl.queryBill(QueryBillServiceImpl.java:116)
at com.alipay.xxxxx.biz.distributedtask.service.QueryBillDistributedTaskService.dispatchTasks(QueryBillDistributedTaskService.java:101)
at com.alipay.xxxxx.biz.task.ScheduledJob.onApplicationEvent(ScheduledJob.java:31)
at com.alipay.xxxxx.biz.task.ScheduledJob.onApplicationEvent(ScheduledJob.java:21)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:940)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at com.alipay.xxxxx.bootstrap.BootstrapApplication.main(BootstrapApplication.java:38)
Caused by: java.lang.NullPointerException: null
at com.alibaba.excel.metadata.csv.CsvWorkbook.write(CsvWorkbook.java:247)
at com.alibaba.excel.context.WriteContextImpl.finish(WriteContextImpl.java:381)
... 18 common frames omitted

yftpprvb

yftpprvb1#

easyexcel版本:3.3.4, poi版本:5.2.2

nmpmafwu

nmpmafwu2#

easyexcel版本:3.2.1,没有这个问题

相关问题