I am querying a table that generates about 60,000 records, which I am getting in a result set. I wish to get the results from the result set in an excel.
I tried using HSSFWorkbook, and I am able to get an excel of about 30,000 records but fails for 80,000 records in result set.
Error: No error, it simply stopped and no excel was generated at the specified location.
Then I tried using, XSSFWorkbook.
Error: java.lang.OutOfMemoryError: Java heap space
I also tried increasing the heap space in eclipse by adding the following in VM arguments:
-Xms512M
Error: No error, but no excel generated.
Next, I did use SXSSFWorkbook (reference: link): code follows:
SXSSFWorkbook wb = new SXSSFWorkbook(wb_template); wb.setCompressTempFiles(true); SXSSFSheet sh = (SXSSFSheet) wb.getSheetAt(0); sh.setRandomAccessWindowSize(100);// keep 100 rows in memory, exceeding rows will be flushed to disk
Error: java.lang.OutOfMemoryError: Java heap space
How can I make this work? I have been stuck on this for days now. Any help is appreciated. Thanks in advance.
Edit : Is there any other way to get fire select query on database and get result in an excel.