I am working on a Java/JSP application which is heavily database dependent. I need to export the data in xls file, for this I am using Apache's XL Writer utility jar file.
Now the problem is that when the data is less than 6000 records the file is easily exported. But the system aborts the process when the record strength is more than that.
This is due to Out of memory Error thrown by the server. If I write a csv file also the same problem exists.
I need a solution to overcome this issue.
Please if anybody can help....
Though I have never used the XL Writer Utility but
the Out of Memory problem can be avoided to an extent using:
1. StringBuffer instead of String to store the text.
2. Instead of writing the file in one go, the file can be written in chunks of say 1000 records at a time.
3. If you are getting the file to download at the same time, then it is better to create the file first in a local directory on the server and then read it byte by byte and forward it to the outputstream.
4. Last but not least, increase the memory available to Jboss using the -Xms -Xmx options.