gpt4 book ai didi

java - 使用 Apache POI 4.1.1 从 excel 文件中读取值时出错

转载 作者:行者123 更新时间:2023-12-04 21:47:12 25 4
gpt4 key购买 nike

我正在尝试使用 Apache POI 从 excel 文件中读取值,但遇到以下错误消息:

org.apache.poi.ooxml.POIXMLException: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:66) ~[poi-ooxml-4.1.1.jar:4.1.1]
at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:657) ~[poi-ooxml-4.1.1.jar:4.1.1]
at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:180) ~[poi-ooxml-4.1.1.jar:4.1.1]
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:282) ~[poi-ooxml-4.1.1.jar:4.1.1]
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:303) ~[poi-ooxml-4.1.1.jar:4.1.1]
at cfo.metrics.loading.MetricsMonthlyHelper.getIndvEventValues(MetricsMonthlyHelper.java:117) [lib/:?]
at cfo.metrics.loading.MetricsMonthlyHelper.getAllExcelValues(MetricsMonthlyHelper.java:2190) [lib/:?]
at cfo.metrics.loading.MetricsDBLoaderMonthly.main(MetricsDBLoaderMonthly.java:23) [lib/:?]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_171]
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56) ~[poi-ooxml-4.1.1.jar:4.1.1]
at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:63) ~[poi-ooxml-4.1.1.jar:4.1.1]
... 7 more
Caused by: java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
at org.apache.poi.ooxml.POIXMLTypeLoader.<clinit>(POIXMLTypeLoader.java:43) ~[poi-ooxml-4.1.1.jar:4.1.1]
at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:86) ~[poi-ooxml-4.1.1.jar:4.1.1]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_171]
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56) ~[poi-ooxml-4.1.1.jar:4.1.1]
at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:63) ~[poi-ooxml-4.1.1.jar:4.1.1]
... 7 more

我正在为我的项目 poi-4.1.1.jar、poi-ooxml-4.1.1.jar 和 poi-ooxml-schemas-4.1.1.jar 使用以下 jar 文件。
有没有人遇到过上述错误并且可以阐明根本原因是什么?

最佳答案

对于 poi-ooxml-4.1.1.jar,你应该使用 xmlbeans-3.1.0.jar,参见:

+- org.apache.poi:poi:jar:4.1.1:compile
| +- commons-codec:commons-codec:jar:1.11:compile
| +- org.apache.commons:commons-collections4:jar:4.4:compile
| \- org.apache.commons:commons-math3:jar:3.6.1:compile
+- org.apache.poi:poi-ooxml:jar:4.1.1:compile
| +- org.apache.poi:poi-ooxml-schemas:jar:4.1.1:compile
| | \- org.apache.xmlbeans:xmlbeans:jar:3.1.0:compile
| +- org.apache.commons:commons-compress:jar:1.19:compile
| \- com.github.virtuald:curvesapi:jar:1.06:compile

关于java - 使用 Apache POI 4.1.1 从 excel 文件中读取值时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62177218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com