Home » excel » java – how to read number of record in xlsx file using Apache POI?

java – how to read number of record in xlsx file using Apache POI?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have requirement to read *.xlsx file in java for that i am using Apache POI API.if number of row are less it’s work nicely but when number of row are greater then or equals 65536. i got an exception java.lang.OutOfMemoryError: Java heap space.please help me how i am able to solve that problem.

thanks
sameek

How to&Answers:

This can be fix by Increasing Available Memory (Java heap space)

http://hvanbelle.blogspot.com/2009/07/increase-heap-size-in-java-to-prevent.html

http://confluence.atlassian.com/display/DOC/Fix+Out+of+Memory+Errors+by+Increasing+Available+Memory

http://rifers.org/blogs/gbevin/2005/4/21/get_rid_of_outofmemoryerror

Answer:

If it possible for you save xslx file as xml – you can use SAX which is very quick and hasn’t limitation about number of rows.

Answer:

POI supports a low memory way to read .xlsx files in a streaming way. See http://poi.apache.org/spreadsheet/how-to.html#xssf_sax_api for details on how it works, and how to get started.