Reputation: 720
I am trying to produce a large excel (~10 MB) with multiple sheets (5). The current implementation was using XSSFWorkbook
but now we are running into OutOfMemoryError
in the deployed environment so made the switch to use SXSSFWorkbook
. The constructor takes in a window size as an argument. I tried with the default size but ran into this error:
java.lang.IllegalArgumentException: Attempting to write a row[4] in the range [0,8] that is already written to disk.
at org.apache.poi.xssf.streaming.SXSSFSheet.createRow(SXSSFSheet.java:125)
at org.apache.poi.xssf.streaming.SXSSFSheet.createRow(SXSSFSheet.java:61)
at org.apache.poi.ss.util.CellUtil.getRow(CellUtil.java:126)
at org.apache.poi.ss.util.RegionUtil.setBorderLeft(RegionUtil.java:75)
Updating the window size to 500 seems to have 'fixed' the issue but I am still wondering if that is the ideal solution for this problem or should I be doing something else?
SXSSFWorkbook workbook = new SXSSFWorkbook(null, 500);
I saw the answers here but still wasn't clear. I am using JDK 11, poi-ooxml 5.2.2 and am running on a Mac.
Upvotes: 0
Views: 960