Reading .xlsx file using apache poi gives org.apache.poi.POIXMLException on linux machine

我是研究僧i 提交于 2019-12-06 02:08:26
Gagravarr

Promoting a comment to an answer...

The key part of your stacktrace, which explains what has broken and why, is:

Caused by: java.lang.OutOfMemoryError: Java heap space at 
java.util.Arrays.copyOfRange(Arrays.java:2694)

This is telling us that Java didn't have enough memory allocated to it to store all of the data that processing your file entails

If you need help with increasing your JVM heap size, I would suggest you review this previous question or this one, which both talk you through it all.

I was also getting same exception when reading .xlsx file

org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
Caused By :java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlBeans.typeSystemForClassLoadern

Then I"ve removed my old xmlbeans-2.0.jar and put the latest xmlbeans-2.3.0.jar containing this method and it is solved now

I have inserted org.apache.xmlbeans in in project. It helped.

Like the others answers: add this dependency:

<dependency>
    <groupId>org.apache.xmlbeans</groupId>
    <artifactId>xmlbeans</artifactId>
    <version>2.6.0</version>
</dependency>

It will work after that.

In fact poi-ooxml needs poi and poi-ooxml-schemas but poi-ooxml-schemas needs xmlbeans

You can see these prerequisites at this page https://poi.apache.org/overview.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!