Creating Excel Files Faster With ColdFusion And POI Custom Tag Updates

Posted August 1, 2008 at 8:38 AM by Ben Nadel

Tags: ColdFusion

I was using my POI Utility ColdFusion custom tags to create true Excel reports for a client. Some of the reports that they are running were really long (thousands of rows) and the reports were just dying. I had to do something, so I went into the POI custom tags and totally reengineered the way they work. Rather than creating a new instance of the CSSRule.cfc ColdFusion component for every single cell.cfm, I am now creating only one instance of it and caching it in the document.cfm tag. Instead of it housing the CSS properties for a cell, I rebuilt it to be merely act as a utility object to which CSS "struct"s are passed. The drastic decrease in CreateObject() calls was enough to give a good performance boost. In addition to that, I have also cut out as many method calls as I possibly could. On large reports, even calling a simple method could add seconds to the processing time. I am now relying on StructAppend() to take care of must of the cascading logic of "cascading" style sheets; this has also proved to be a good performance boost.

Since I was in there, I have fixed the last few outstanding ColdFusion MX7 compatibility issues. I have also moved the above performance updates to the CFMX 7 version as well. I hope that doesn't create new CFMX 7 bugs (I ran it on a CF8 box and at least it didn't error out for syntax reasons).

The updated code is available from my POIUtility.cfc Project page.




Reader Comments

Aug 1, 2008 at 9:17 AM // reply »
36 Comments

Just 15 minutes ago a client asked me for just this thing due asap. 15 minutes later it's already done and ready for their use. thanks Ben! Good stuff.


Aug 1, 2008 at 9:46 AM // reply »
11,238 Comments

Awesome stuff :)


Aug 1, 2008 at 1:55 PM // reply »
19 Comments

Nice work. A very useful utility, and now even better! :)


Aug 1, 2008 at 1:56 PM // reply »
11,238 Comments

@Adam,

Thanks man. Glad you like.


Aug 1, 2008 at 10:33 PM // reply »
18 Comments

can you add the related blog entries to the project page?


Aug 4, 2008 at 7:37 AM // reply »
2 Comments

Thanks for the information, nice site


Aug 11, 2008 at 12:54 PM // reply »
3 Comments

Hi Ben,

There is a minor bug in CFMX7.

Invalid token '{' found on line 144 at column 48.

File: Document.cfm

Original Line 144:
<cfset VARIABLES.CellAliases = {} />

Change to:
<cfset VARIABLES.CellAliases = StructNew() />

The perfomance is very good !! :)

Thanks Ben.


Aug 11, 2008 at 7:38 PM // reply »
11,238 Comments

@Plutarco,

Oh man, good catch. The problem with running this on a ColdFusion 8 box is that I can only guess that i have caught all the "Errors". Thanks for pointing this out.


Aug 11, 2008 at 7:41 PM // reply »
11,238 Comments

@Plutarco,

I have updated the most recent download to include this fix. Again, thanks for the catch.


ali
Jul 3, 2009 at 1:51 AM // reply »
1 Comments

i am trying to export large data from sql query to excel sheet using coldfusion but i am having full of memory error so i used another way using COM objects but i am having the error that cannot open the excell and activate it because complex object cannot be converted to simple object. any help please?


Jul 3, 2009 at 8:33 AM // reply »
11,238 Comments

@Ali,

The complext to simple object error usually means that you have an incorrect variable reference somewhere.


Dec 24, 2009 at 4:09 PM // reply »
1 Comments

I have a client that can not upload an excel file from a Mac... but when he uploads from a PC it runs fine... Do you know anything about this from before?


Dec 28, 2009 at 10:40 PM // reply »
11,238 Comments

@Summer,

Are you talking about the same exact same Excel files? Or do you just mean a file created on Mac vs. a file created on a PC?


Dec 31, 2009 at 12:51 AM // reply »
2 Comments

@Ben

I believe the file is created on Mac... i will confirm and get back.

Happy Holidays/New year!!!


Jan 4, 2010 at 10:35 AM // reply »
2 Comments

the File is originally created on MAC and uploaded from the same.

also here are some more details... the browsers used on MAC are Firefox and Safari and the Excel verion is either 97 or 95.


Jan 4, 2010 at 6:59 PM // reply »
11,238 Comments

@Summer,

Hmm, I am not sure. If this file works on Windows and not on Macs, I am not sure there is anything that I can do.


Jan 11, 2011 at 10:38 AM // reply »
1 Comments

When creating an Excel file, is there any way to prompt the user as to where to save the file?

This works great and that would REALLY be the icing on the cake.

Thanks!


Aug 15, 2012 at 12:49 PM // reply »
1 Comments

Thanks so much this great POI CFC. It's been extremely useful for exporting data in a usable format.

I've been using custom tags to insert data into an excel template but I've found that you aren't able to edit a particular cell without overwriting the entire row.

Is it possible to leave content in some cells in a row intact while inserting data into others?



Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 17, 2013 at 7:42 PM
HashKeyCopier - An AngularJS Utility Class For Merging Cached And Live Data
Ben - thanks so much for posting these Angular articles and findings, they've been a huge help towards learning one of the more 'complex' JavaScript frameworks out there (IMO). I have been using Angu ... read »
May 16, 2013 at 5:01 PM
UPDATE: Parsing CSV Data Files In ColdFusion With csvToArray()
Your code was the closest thing I've found to obtaining some direction for converting ISO fields to values that CF can translate properly. Thank you for posting! ... read »
May 15, 2013 at 10:37 PM
Very Simple Pusher And ColdFusion Powered Chat
hi id making plz easy ... read »
May 15, 2013 at 6:07 PM
Making SOAP Web Service Requests With ColdFusion And CFHTTP
Ben, you once again saved my bacon at work. Thank you, thank you, thank you! ... read »
May 15, 2013 at 4:15 PM
What If All User Interface (UI) Data Came In Reports?
@Josh, Thanks! @Ben, I definitely recommend the David West book "Object Thinking" I've been quoting from. It goes deeply into the philosophy and history of OO programming. His breadth ... read »
May 15, 2013 at 11:36 AM
Ask Ben: Print Part Of A Web Page With jQuery
I found this helpfull when you need to keep (refresh) the original parent page after closing the iframe child print dialog (Hoping you're not using a form at this time so it won't submit again): On ... read »
May 14, 2013 at 7:13 PM
What If All User Interface (UI) Data Came In Reports?
@Jonah, If there's any books you'd recommend on the subject of domain modelling, I'd love to hear it. I just downloaded the free PDF of "Domain Driven Design Quickly". Figured I'd give it ... read »
May 14, 2013 at 6:57 PM
The UX Of Prototyping: Low-Fidelity Is The New High-Fidelity
@Phillip, I'm not sure I follow what you mean? Are you saying that you looked at the list of widgets provided by the jQuery UI and let that be your style guide? ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools