tags:

views:

21

answers:

1

Hello

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 ???????

+1  A: 

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)

R. Kettelerij
actually as far as i've been testing on when i'm debuggin the program, the excel file creates when fileOut.close(); don't know why, altso i tryied to call write metod in multiples instance to free the heap memory, worked, but only wrote the last part of the file =(
ErVeY
POI is not great on memory. If you want to write a huge file, you should have huge memory.
bwawok
the threaad shows the same error as mine, jxls is based in POI library so don't think it will work, i think the solution could be aspose cell, but i need something free =(, i will keep looking around thx for your time =D
ErVeY