HI I am using CFSPREADSHEET to export dynamic data...
# cfml-general
a
HI I am using CFSPREADSHEET to export dynamic data in excel format, actually it's working fine with less data but it's taking too much time to export if i'm having large amount of data. also facing an issue and error message is "The maximum number of cell styles that the exported data exceeds. You can define up to 4000 styles". Can anyone have solution for this, Please help me on this. Thank you🙂
g
cfspreadsheet has issues to work with large data, that is known issue since its initial release. The alternative is to use Apache POI. cfspreadsheet is based on POI with poor implementation. If you use POI, there would be no such limitation. Apache POI is Java based, has a lot of examples online, a couple years back, I could export half million rows of data without any issues.
👍🏻 1
a
Thank you so much for your response, it's helpful for me.
d
I ran into this issue back in CF9 (the version that introduced cfspreadsheet). The problem was that ColdFusion incorrectly created a separate style definition for every cell in a column instead of creating one style definition for the whole column. For some data types, such as dates, CF would automatically apply a style whether you wanted it to or not, making the issue unavoidable in some cases. This bug not only made it take forever to create a spreadsheet file, it also made the file sizes enormous. If you didn't attempt to apply a style to any of the columns, and CF didn't automatically apply one, then everything worked fine. I have not attempted to use cfspreadsheet since CF9. However, a colleague of mine told me that the spreadsheet functions were working fine in a later version of CF, and another colleague had some success using the underlying Apache POI functions.
c
You may get better results with the spreadsheet-cfml library which handles cell styles more efficiently, and also supports streaming (SXSSF) which can work better when writing larger xlsx files.
d
The post-2007 MS-Office file formats (xlsx, docx, etc.) are just zipped archives of xml files (you can see for yourself by changing the extension to .zip), so the way I dealt with this problem originally was to write my own function that generated the xml files and then used cfzip to create the final output file. It was a fun project and it worked well, though you'd almost certainly be better off using an existing library instead.
a
Thank you so much for all these suggestion, i'll try to apply suggestion from you guys and choose the perfect one.🙂