Reputation: 13
I am trying to reading large excel files which has size around 40MB to 50MB.
For XLSX i used OPCPackage it solved the problem,but now I am facing problem with XLS format.
When I use normal POI like POIFSFileSystem to read files, I am getting java heap space error.
Can you help me to solve this problem?
Basically we are converting excel files to tab-delimited files.
OPCPackage pkg = OPCPackage.open(sourceFile.getPath(),
PackageAccess.READ);
Let me know if you need any other information.
Upvotes: 0
Views: 1519
Reputation: 48326
As explained in the Apache POI documentation, don't open with an InputStream when you have a File!
For a .xls
file, you should make sure you're using a new version of Apache POI, then open the container with new POIFSFileSystem(File), eg
POIFSFileSystem fs = new POIFSFileSystem(new File("input.xls"));
// HSSF Event parsing code goes here
Otherwise, make sure you use the HSSF event api if memory is a concern, and likely the record-aware event api if you need to ensure you detect missing cells
Upvotes: 2
Reputation: 9058
When you execute your program, you need to specify a larger maximum heap size with -Xmx2g (for a max of 2 gig). See "man java".
Upvotes: 0