0

Trying to load 500 MB of .xlsm file into memory and delete particular sheet from that.

OPCPackage pkg = OPCPackage.open("C:\\PROJECTS\\test.xlsm");
             XSSFWorkbook wb = new XSSFWorkbook(pkg);
             SXSSFWorkbook wb1 = new SXSSFWorkbook(wb, 100);

Getting out of memory while loading the pkg to workbook .

Is there any other alternate way to load such large files without memory issue?

We have another read logic getting performed on same xlsm file using parser concept ie, org.apache.xerces.parsers.SAXParser

It is working fine. Is there any possibility to alter an excel sheet using parser concept ?

James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

1

Just start your JVM with more memory. What are the -Xms and -Xmx parameters when starting JVM?

If you want to load a 500MB file you need considerably more memory than 500MB for your JVM. Try to start with java -Xms2048m -Xmx4096m for example.

cmoetzing
  • 742
  • 3
  • 16
  • Concurrent users are more also increasing JVM in my case would cost more.. is there any other alternate solution ? Expecting something like without loading the complete workbook into memory like parser concept need to fetch particular sheet and delete the same .. – Dhanaraja Rajendiran Apr 09 '19 at 14:45
  • Thanks for the info. Let me try this StreamingReader concept and update my results shortly.. – Dhanaraja Rajendiran Apr 10 '19 at 08:49