解决poi导出Excel异常org.openxmlformats.schemas.spreadshe
JAVA报表
POI未捕获到 servlet OUTEXCEL 的其中一个服务方法中抛出的异常。抛出的异常:java.lang.NoClassDefFoundError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFileRecoveryPr
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:59)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:120)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:521)
at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createUnattachedNode(SchemaTypeImpl.java:1859)
at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createTypeStoreUser(SchemaTypeImpl.java:1805)
at org.apache.xmlbeans.impl.store.Xobj.setStableType(Xobj.java:1390)
at org.apache.xmlbeans.impl.store.Cur.setType(Cur.java:2497)
at org.apache.xmlbeans.impl.store.Cur.setType(Cur.java:2482)
at org.apache.xmlbeans.impl.store.Locale.newInstance(Locale.java:630)
at org.apache.xmlbeans.impl.store.Locale.newInstance(Locale.java:606)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.newInstance(SchemaTypeLoaderBase.java:198)
经过确认,是由于poi使用的poi-ooxml-schemas是ooxml-schemas的精简版,所以在was服务器上导出Excel可能会报错,tomcat下面使用前者是没有问题的,此时需要统一jar包版本为ooxml-schemas.1.1.jar,这个ooxml-schemas有两个版本的jar包,一个是POI 3.7,之前版本使用的ooxml-schemas-1.0.jar.另一个就是poi3.7以后版本使用的ooxml-schemas-1.1.jar,官网也说了这个问题:http://poi.apache.org/faq.html#faq-N10025,
here are two jar files available, as described inthe components overview section. Thefull jar of all of the schemas is ooxml-schemas-1.1.jar, and it is currently around 15mb. Thesmaller poi-ooxml-schemas jaris only about 4mb. This latter jar file only contains the typically used parts though.
Note that for POI 3.5 and 3.6, the full ooxml schemas jar was named ooxml-schemas-1.0.jar. For POI 3.7, the filename was bumped to ooxml-schemas-1.1.jar when generics support was added. You can use ooxml-schemas-1.1.jar with POI 3.5 and 3.6 if you wish, but POI 3.7 won't wokr with ooxml-schemas-1.0.jar (it needs thew newer one).
意思很简单,把你的poi需要依赖的jar包给从
1.maven下解决方案如下:
<!--适合Tomcat 的缩减版ooxml-schemas-3.9 <dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml-schemas</artifactId><version>3.9</version></dependency>-->
换成下面的
<dependency><groupId>org.apache.poi</groupId><artifactId>ooxml-schemas</artifactId><version>1.1</version></dependency>
重启服务,导出excel就ok了。
ps:poi3.9 一共需要如下几个jar包,才能正常工作。
<!-- poi --><dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.9</version></dependency> <dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.9</version></dependency> <dependency><groupId>dom4j</groupId><artifactId>dom4j</artifactId><version>1.6.1</version></dependency> <dependency><groupId>org.apache.xmlbeans</groupId><artifactId>xmlbeans</artifactId><version>2.3.0</version></dependency> <dependency><groupId>stax</groupId><artifactId>stax-api</artifactId><version>1.0.1</version></dependency> <!--适合Tomcat 的缩减版ooxml-schemas-3.9<dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml-schemas</artifactId><version>3.9</version></dependency>--> <dependency><groupId>org.apache.poi</groupId><artifactId>ooxml-schemas</artifactId><version>1.1</version></dependency> <!-- poi end-->
2.普通的web工程,去下载jar包。
此jar包在maven官网 的 下载地址:http://search.maven.org/#artifactdetails|org.apache.poi|ooxml-schemas|1.1|jar

-
08.25
我是小鱼儿面包位置在哪-我是小鱼儿面包位置如何分析
-
08.25
洛克王国世界背景是什么-洛克王国世界背景说明
-
08.25
洛克王国世界仪式者如何搭配技能-洛克王国世界仪式者技能搭配做法
-
08.25
洛克王国世界绒仙子有哪些技能-洛克王国世界绒仙子技能详情说明
-
08.25
完整指南Webstorm 下的Angular2.0开发之路(图文)
-
08.25
洛克王国世界必抓的隐藏机械宠物有哪些-洛克王国世界必抓隐藏机械宠物的说明
-
-
下载
- |
-
-
下载
- 《行尸走肉第一章》免安装中文汉化硬盘版下载
- 单机|436 MB
- 一款以动作冒险为主题的游戏
-
-
下载
- 《街头霸王X铁拳》免安装中文汉化硬盘版下载
- 单机|111MB
- 一款非常好玩的格斗游戏
-
-
下载
- |
-
-
下载
- 《暗黑破坏神3》免安装繁体中文正式版下载
- 单机|7630 MB
- 一款以角色扮演为主题的游戏
-
-
下载
- 《马克思佩恩3》免安装硬盘版下载
- 单机|27033 MB
- 一款以第三人称射击为主题的游戏