I am trying to open an excel file which is 22MB
in size and contains 9905
rows (not that large in my opinion).
I try to open it like this with java apache poi
:
final File f = Utils.getFileWithRespectToJar(this, filename);
final Workbook workbook = WorkbookFactory.create(f);
final Sheet sheet = workbook.getSheetAt(0);
final int maxRowLength = sheet.getLastRowNum();
After a few seconds, java takes about 3.3GB of RAM and 90% of CPU and after a minute or so my eclipse project crashes with the exception
java.lang.OutOfMemoryError: GC overhead limit exceeded
Is apache poi
just very unperformant or am I doing something wrong?
Edit: I was previously using a .xlsm
file (an excel file with macros enabled). I saved it again as a .xlsx
file (macros disabled) and increased the heap size to 4GB
. Now java takes 4GB
of RAM (=90%) and 90% of CPU for around ~15 minutes before my eclipse application crashes.
I was using apache poi 3.16
and updated my maven pom
file to use 4.0.0
(latest version) but this new version works differently so I get a lot of exceptions, e.g:
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) at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:648) at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:180) at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:286) at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(XSSFWorkbookFactory.java:83) at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(XSSFWorkbookFactory.java:111)
Caused by: java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions; at org.apache.poi.ooxml.POIXMLTypeLoader.(POIXMLTypeLoader.java:43) at org.apache.poi.xssf.model.ThemesTable.(ThemesTable.java:86)