easyexcel 最新版本3.1.0+poi 5.2.2 导入数据读取备注时报NoSuchMethodError异常

ih99xse1  于 5个月前  发布在  其他
关注(0)|答案(6)|浏览(112)

触发场景描述
将xlsx07版本得Excel导入时。读取头部备注信息
触发Bug的代码
EasyExcel.read(PATH, new NoModelDataListener())
// 需要读取合并单元格信息 默认不读取
.extraRead(CellExtraTypeEnum.COMMENT).sheet(0).doRead();
这里写代码
/**

  • 导入数据
    */
    @RequestMapping("/dataCheck")
    public void dataCheck() throws FileNotFoundException {
    String PATH="D:\Users\Administrator\Downloads\ouoTest.xlsx";
    // 这里 只要,然后读取第一个sheet 同步读取会自动finish
    EasyExcel.read(PATH, new NoModelDataListener())
    // 需要读取合并单元格信息 默认不读取
    .extraRead(CellExtraTypeEnum.COMMENT).sheet(0).doRead();
    }
    提示的异常或者没有达到的效果
    com.alibaba.excel.exception.ExcelAnalysisException: java.lang.NoSuchMethodError: org.apache.poi.xssf.eventusermodel.XSSFReader$SheetIterator.getSheetComments()Lorg/apache/poi/xssf/model/CommentsTable;
    at com.alibaba.excel.analysis.ExcelAnalyserImpl.(ExcelAnalyserImpl.java:61)
    at com.alibaba.excel.ExcelReader.(ExcelReader.java:27)
    at com.alibaba.excel.read.builder.ExcelReaderBuilder.build(ExcelReaderBuilder.java:202)
    at com.alibaba.excel.read.builder.ExcelReaderBuilder.sheet(ExcelReaderBuilder.java:239)
    at com.alibaba.excel.read.builder.ExcelReaderBuilder.sheet(ExcelReaderBuilder.java:231)
    at com.sgmp.controller.meta.ExcelController.dataCheck(ExcelController.java:119)
    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:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
    at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
    at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
    at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
    at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1787)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.NoSuchMethodError: org.apache.poi.xssf.eventusermodel.XSSFReader$SheetIterator.getSheetComments()Lorg/apache/poi/xssf/model/CommentsTable;
    at com.alibaba.excel.analysis.v07.XlsxSaxAnalyser.(XlsxSaxAnalyser.java:102)
    at com.alibaba.excel.analysis.ExcelAnalyserImpl.choiceExcelExecutor(ExcelAnalyserImpl.java:103)
    at com.alibaba.excel.analysis.ExcelAnalyserImpl.(ExcelAnalyserImpl.java:55)
    ... 73 common frames omitted
wooyq4lh

wooyq4lh1#

并且在easyexcel-core-3.1.1.jar包中,目录:com.alibaba.excel->analysis->07-XlsxSaxAnalyser类中。第124行报红。提示在引用得poi 5.2.2包中提供得是Comments,但需要得CommentsTable

5hcedyr0

5hcedyr02#

将POI版本降级到4.1.2后解决。希望作者大大能修复5.2.2POI版本得问题

yquaqz18

yquaqz183#

将POI版本降级到4.1.2后解决。希望作者大大能修复5.2.2POI版本得问题

同求,easyexcel依赖的poi版本,是否可以升级到5.x系列

ffscu2ro

ffscu2ro4#

想问下这个问题什么时候可以解决呢?目前看起来需要读取Excel Comment的话,POI 5.x.x版本和Easy Excel3.1.0+是不兼容的

zvokhttg

zvokhttg5#

我在项目中也遇到了类似问题。java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument

mm5n2pyu

mm5n2pyu6#

引起报错的代码是需要读取批注: .extraRead(CellExtraTypeEnum.COMMENT)
poi 5.2.5 可以稳定复现, poi 回退到 4.1.2 版本,可以正常运行。

APPLICATION FAILED TO START

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

com.alibaba.excel.analysis.v07.XlsxSaxAnalyser.<init>(XlsxSaxAnalyser.java:126)

The following method did not exist:

'org.apache.poi.xssf.model.CommentsTable org.apache.poi.xssf.eventusermodel.XSSFReader$SheetIterator.getSheetComments()'

The calling method's class, com.alibaba.excel.analysis.v07.XlsxSaxAnalyser, was loaded from the following location:

jar:file:/D:/ProgramFiles/Java/.m2/repository/com/alibaba/easyexcel-core/3.3.4/easyexcel-core-3.3.4.jar!/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.class

The called method's class, org.apache.poi.xssf.eventusermodel.XSSFReader$SheetIterator, is available from the following locations:

jar:file:/D:/ProgramFiles/Java/.m2/repository/org/apache/poi/poi-ooxml/5.2.5/poi-ooxml-5.2.5.jar!/org/apache/poi/xssf/eventusermodel/XSSFReader$SheetIterator.class

The called method's class hierarchy was loaded from the following locations:

org.apache.poi.xssf.eventusermodel.XSSFReader.SheetIterator: file:/D:/ProgramFiles/Java/.m2/repository/org/apache/poi/poi-ooxml/5.2.5/poi-ooxml-5.2.5.jar

Action:

Correct the classpath of your application so that it contains compatible versions of the classes com.alibaba.excel.analysis.v07.XlsxSaxAnalyser and org.apache.poi.xssf.eventusermodel.XSSFReader$SheetIterator

相关问题