I am using the latest POI 3.5 for Excel reading . I have Excel MS office 2007 installed and for that poi is providing XSSF for executing the data.
For 15000 lines of data it is executing properly, but when exceeding the limit till 30000 or 100000 or 200000, it is prone to a Java heap space Exception.
Code is below :
UATinput = new FileInputStream(UATFilePath);
uatBufferedInputStream = new BufferedInputStream(UATinput);
UATworkbook = new XSSFWorkbook(uatBufferedInputStream);
I am getting the Exception in the last line for Java heap size.
I have increased the size using -Xms256m -Xmx1536m, but still for more data it is giving the Java heap space Exception.
Can anybody help me out for this Exception for the XSSFWorbook?
Instead of reading the entire file in memory try using the eventusermodel api
This is a very memory efficient way to read large files. It works on the principle of SAX parser (as opposed to DOM) in the sense that it will call callback methods when particular data structures are encountered. It might get a little tricky as it expects you to know the nitty-gritty of the underlying data
Here you can find a good tutorial on this topic
Hope this helps!