javaexcelapache-poiout-of-memoryxssf

How to load a large xlsx file with POI library?


I have a large .xlsx file (180 MB, containing 300K lines with 150 columns each) I need to perform some operations within. I am having problems with loading this file (OutOfMemoryError), as POI has a large memory footprint on XSSF (xlsx) workbooks. I checked java.exe memory usage, it increases linearly to 17 GB and after that it becomes stale.

In this line :

  XSSFWorkbook workbook=new XSSFWorkbook(EXCELFILEPATH)

Error:

Exception in thread "main" java.lang.OutOFMemoryError: Java heap space. 

Is there any other way that I can read this .xlsx excel file to memory without error?


Solution

  • https://github.com/pjfanning/excel-streaming-reader

    This library solved my problem.