使用POI操作Excel时new XSSFWorkbook ()报错java.lang.NoSuchMethodError解决方案

使用最新的POI3.11时,在运行

Workbook  workBook = new XSSFWorkbook ();这段代码时出现错误:

java.lang.NoSuchMethodError: javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory;
    at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45)
    at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
    at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
    at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37)
    at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:65)
    at org.apache.poi.openxml4j.opc.OPCPackage.create(OPCPackage.java:337)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.newPackage(XSSFWorkbook.java:410)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:217)
    at org.apache.poi.xssf.streaming.SXSSFWorkbook.<init>(SXSSFWorkbook.java:216)
    at org.apache.poi.xssf.streaming.SXSSFWorkbook.<init>(SXSSFWorkbook.java:185)
    at org.apache.poi.xssf.streaming.SXSSFWorkbook.<init>(SXSSFWorkbook.java:160)
    at org.apache.poi.xssf.streaming.SXSSFWorkbook.<init>(SXSSFWorkbook.java:135)
    at org.apache.poi.xssf.streaming.SXSSFWorkbook.<init>(SXSSFWorkbook.java:96)
    at TestExport.test(TestExport.java:11)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

将XSSFWorkbook改为HSSFWorkbook即可,即上述代码修改为;

Workbook
 workBook = new HSSFWorkbook ();

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-13 20:24:15

使用POI操作Excel时new XSSFWorkbook ()报错java.lang.NoSuchMethodError解决方案的相关文章

使用POI操作Excel时new XSSFWorkbook ()报错java.lang.NoSuchMethodError解决方式

使用最新的POI3.11时,在执行 Workbook  workBook = new XSSFWorkbook ();这段代码时出现错误: java.lang.NoSuchMethodError: javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory; at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesM

Webservice报错java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlBeanDefinitionRead

用spring集成发布一个Webservice服务,老是报错: java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlBeanDefinitionReader.setValidationMode(I)V at org.apache.xbean.spring.context.v2.XBeanXmlBeanDefinitionReader.<init>(XBeanXmlBeanDefinitionReader.j

tomcat7 启动项目报错 java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()

JDK版本:jdk1.8.0_77 Tomcat 版本:apache-tomcat-7.0.47 异常重现步骤: 1.完成项目部署 2.启动Tomcat 异常头部信息:java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig() 解决方案: 把apache-tomcat-7.0.47/lib/servlet-api.jar 拷贝到$JAVA_HOME/jre/lib/ext目录下去 参考博文:

hive 使用where条件报错 java.lang.NoSuchMethodError: org.apache.hadoop.hive.ql.ppd.ExprWalkerInfo.getConvertedNode

hadoop 版本 2.6.0 hive版本 1.1.1 错误: java.lang.NoSuchMethodError: org.apache.hadoop.hive.ql.ppd.ExprWalkerInfo.getConvertedNod…… 解决办法 1,修改Hive的配置文件conf/hive-site.xmlhive.optimize.ppd==false然后重启hadoop环境 2,hive命令行:执行set hive.optimize.ppd=false;

Android Studio 类库中配置Jpush 报错 java.lang.UnsatisfiedLinkError解决方案

JPush基类库导入需在基类库(注意是基类库,非应用项目)的build.gradle文件-sourceSets项中手动配置jniLibs.srcDir 'src/main/libs',否则JPush无法正确的加载libjpush.so文件 如: sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['

resin发布spring-boot项目报错“java.lang.NoSuchMethodError: org.jboss.logging.Logger.getMessageLogger”

说白了还是jar包冲突问题,直接说解决方式: 首先将resin/lib下的validation-api-1.0.0.GA.jar替换成项目中的包validation-api-2.0.1.Final.jar 再将resin/webapp-jars下的 hibernate-validator-4.3.0.Final.jar jboss-logging-3.1.0.CR2.jar替换为项目中的版本hibernate-validator-5.1.0.Final.jar jboss-logging-3.3

captcha报错java.lang.ArrayIndexOutOfBoundsException

*captcha报错java.lang.ArrayIndexOutOfBoundsException 启动程序时发现了如下错误信息,纠结了好久 Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at sun.font.CompositeFont.getSlotFont(CompositeFont.java:375) at sun.font.CompositeGlyphMapper.initMapper(CompositeGlyphMap

maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener

本篇文章主要介绍了"maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener ",主要涉及到maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener 方面的内容,对于maven web 项目中启动报错jav

报错:java.lang.Long cannot be cast to java.lang.Integer

Long 无法转化成Integer类型. 这个异常 经常出现在hinbernate分页查询的时候. 原因: 这里在Hibernate2.0之前版本list.get(0)返回的是Integer类型. 但是在Hibernate3.0以后版本list.get(0)返回的是Long类型. 解决方法 public Integer getUsersCount() { String hql = "select count(*) from Users"; List list = super.pageQ