本文主要是介绍easypoi 导出报错:Excel导出错误,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
报错
ERROR cn.afterturn.easypoi.excel.export.base.ExportBase - null
java.lang.reflect.InvocationTargetException: nullat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)...
Caused by: java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.CellStyle.setAlignment(S)Vat cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl.stringNoneStyle(ExcelExportStylerDefaultImpl.java:69)at cn.afterturn.easypoi.excel.export.styler.AbstractExcelExportStyler.createStyles(AbstractExcelExportStyler.java:43)
...
ERROR cn.afterturn.easypoi.excel.export.base.ExportBase - Excel导出错误
cn.afterturn.easypoi.exception.excel.ExcelExportException: Excel导出错误at cn.afterturn.easypoi.excel.export.ExcelExportServer.insertDataToSheet(ExcelExportServer.java:207)
...
Caused by: java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.CellStyle.setAlignment(S)Vat cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl.stringNoneStyle(ExcelExportStylerDefaultImpl.java:69)
...
ERROR c.t.slyun.starter.log.logAspectAutoConfiguration - 系统异常
java.lang.NullPointerException: nullat com.tcsl.slyun.app.biz.corp.service.impl.sales.SalesDetailServiceImpl.salesDetailExport(SalesDetailServiceImpl.java:1034)
...
关键报错
Caused by: java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.CellStyle.setAlignment(S)V
源码跟踪
类:ExcelExportServer 177行 报错
this.addStatisticsRow(this.getExcelExportStyler().getStyles(true, (ExcelExportEntity)null), sheet);
查看jar包引用
发现有两个 poi
Maven: org.apache.poi.poi:3.15
Maven: org.apache.poi.poi:3.17
这两个poi的jar似乎有冲突
找到easypoi的gitee
https://gitee.com/lemur/easypoi
找到一个issues
https://gitee.com/lemur/easypoi/issues/INTGY
跟我的问题类似
解决:引用easypoi最新pom
<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId><version>4.2.0</version></dependency>
这篇关于easypoi 导出报错:Excel导出错误的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!