I have 13 .xlsx files with about 1000 rows in each of them. Now I want to merge it to one .xlsx file with one sheet. I\'m using code from here http://blog.sodhanalibrary.com
POI is notoriously memory-hungry, so running out of memory is not uncommon when handling large Excel-files.
When you are able to load all original files and only get trouble writing the merged file you could try using an SXSSFWorkbook
instead of an XSSFWorkbook
and do regular flushes after adding a certain amount of content (see poi-documentation of the org.apache.poi.xssf.streaming
-package). This way you will not have to keep the whole generated file in memory but only small portions.