使用模板导出的时候报错 触发Bug的代码 EasyExcel.write(new FileOutputStream(new File(filePath))).withTemplate(inputStream).sheet().doFill(list); 提示的异常或者没有达到的效果 Caused by: java.lang.IllegalArgumentException: Attempting to write a row[2] in the range [0,6] that is already written to disk. at org.apache.poi.xssf.streaming.SXSSFSheet.createRow(SXSSFSheet.java:136) at org.apache.poi.xssf.streaming.SXSSFSheet.createRow(SXSSFSheet.java:65) at com.alibaba.excel.write.executor.ExcelWriteFillExecutor.getOneCell(ExcelWriteFillExecutor.java:270) at com.alibaba.excel.write.executor.ExcelWriteFillExecutor.doFill(ExcelWriteFillExecutor.java:154) at com.alibaba.excel.write.executor.ExcelWriteFillExecutor.fill(ExcelWriteFillExecutor.java:93) at com.alibaba.excel.write.ExcelBuilderImpl.fill(ExcelBuilderImpl.java:84) at com.alibaba.excel.ExcelWriter.fill(ExcelWriter.java:185) at com.alibaba.excel.write.builder.ExcelWriterSheetBuilder.doFill(ExcelWriterSheetBuilder.java:202) at com.alibaba.excel.write.builder.ExcelWriterSheetBuilder.doFill(ExcelWriterSheetBuilder.java:195) at com.pttl.bdrc.report.ebs.deptmanageanalysis.controller.ExpectReceivablePaymentGoodsAmountController.getExpectReceivablePaymentGoodsAmountDataDownloadFilePath(ExpectReceivablePaymentGoodsAmountController.java:187) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:849) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:760) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ... 57 common frames omitted
Q
[alibaba/easyexcel]使用模板导出的时候报错 java.lang.IllegalArgumentException Attempting to write a row[2] in the range [0,6] that is already written to disk.
4
触发场景描述
A
回答
0
请提供详细代码
2
String filePath = FileUtils.createFile(expectReceivablePaymentGoodsAmount, TemplateEnum.EXPECT_RECEIVABLE_PAYMENT_GOODS_AMOUNT_EXPORT.getFileName());
InputStream inputStream = ExpectReceivablePaymentGoodsAmountController.class.getClassLoader().getResourceAsStream(TemplateEnum.EXPECT_RECEIVABLE_PAYMENT_GOODS_AMOUNT_EXPORT.getPath());
try {
// 将导出数据写到excel中供前台下载
EasyExcel.write(new FileOutputStream(new File(filePath))).withTemplate(inputStream).sheet().doFill(list);
} catch (FileNotFoundException e) {
log.error("导出数据写入文件出错", e);
return BaseResponse.failure(BaseResponeCode.EXPORT_ERROR);
}
EasyExcel.write()这句报错。项目里用了几处都是好的。唯独这个导出报错。检查了好几遍模板也没问题。
7
这个尝试删除模板的一些行试试 估计有空行之类的影像。
6
出现同样的问题, 实测就是excel 出现空行导致,
5
出现同样的问题,删除空行后解决,感谢各位大佬
9
也出现同样的问题,是模版的问题,重新创建一个新的Excel模版就没问题了