ErVeY
ErVeY

Reputation: 1524

POI heap space exception or any alternative java api for Excel 2007?

i've been searching around for a solution for this problem and haven't found anything good =(

so the problem is i need to create an excel file up to 50.000 registers and when i do this show me this error at 50.000 app register:

java heap space

as far as i'm looking on, one way to solve this is increasing the heap memory, but quite don't like me (first aids) because the problem persist if the file gets to bigger and the server freezes and comsume a lot of memory trying to do this and gets slow

i think a solution would be writte out the excel file instead of leaving the data in the heap memory, but i don't get it work

any ideas ?? or another framework for excel 2007 files ???????

Upvotes: 0

Views: 1019

Answers (1)

Richard Kettelerij
Richard Kettelerij

Reputation: 2174

Call the write() method on your HSSFWorkbook to persist your Excel workbook to a file:

FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();

But as this thread indicates there's no way to do streaming writes to file in POI. Alternatives to POI are jXLS (open source) or Aspose.Cells for Java (proprietary)

Upvotes: 1

Related Questions