I am using ColdFusion to export a fairly few number of rows (around 1000) but large number of columns (around 300) to Excel. It is a multi-sheet Excel file with at least two of the sheets having the large number of columns. Using cfspreadsheet
throws a Java Heap Error. Updating JVM settings value shows no improvement. What is the best way to export to Excel without causing the Java Heap Error?
Edit: I have tried few ways to fix the issue within the program. I am using the xml Workbook within cfsavecontent to build the multiple sheets and render the result using cfcontent. In this case, cfcontent might be utilizing high amount of memory resulting in the heap space error.
<cfsavecontent variables="REQUEST.xmlData">
<cfoutput>
<xml version="1.0"?>
<?mso-application progid="Excel.sheet"?>
<Workbook>
...other contents
</Workbook>
</cfoutput>
</cfsavecontent>
For second workaround, I am using querynew to build the contents and dump the final result in an excel using <Cfspreadsheet action="write">
. For subsequent sheets, I am using <cfspreadsheet action="update">
. The ultimate goal is serve the excel using <cflocation url="excelPath">
, but in this case, cfspreadsheet update is taking forever throwing out of memory error.
If updating jvm is not an option, what other ways do you suggest to implement to overcome the memory issues.
<cfspreadsheet action="update">
(copies existing sheets) probably is not a very memory efficient method. CFSpreadsheet is designed for simple dumps. Anything beyond that and you are better off using spreadsheet functions. What happens if you use spreadsheet functions to populate and generate multiple sheets? – Banderilla