Creating Excel Files Faster With ColdFusion And POI Custom Tag Updates

Posted August 1, 2008 at 8:38 AM

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.

Post Comment  |  Ask Ben  |  Other Searches  |  Print Page




Learning ColdFusion 9 - ColdFusion 9 tutorials, samples, examples, demos

Reader Comments

Aug 1, 2008 at 9:17 AM // reply »
32 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 »
7,539 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 »
7,539 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 »
7,539 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 »
7,539 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 »
7,539 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 »
7,539 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 »
7,539 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.


Post Comment  |  Ask Ben

Recent Blog Comments
Mar 18, 2010 at 1:18 PM
Finally Finished Ayn Rand's Atlas Shrugged Audio Book
@joaopft, Not disputing what you say - but... If I understand you correctly, you are saying that Positivism is based on sense experience (what I experience is what is), but Quantum theory states tha ... read »
Mar 18, 2010 at 11:48 AM
Duplicate() Much Faster Than ColdFusion Query-of-Queries
I am working on a massive xml parsing, qofq app to create 2 seperate xml files. I just don't understand the concept/purpose of duplicate function, are you duplicating the data or the row, into a new ... read »
Mar 18, 2010 at 11:22 AM
Exploring ColdFusion Component Runtime Class Properties And Serialization
@Zarko, Ha ha, you know ColdFusion is my first love ;) ... read »
Mar 18, 2010 at 11:15 AM
Exploring ColdFusion Component Runtime Class Properties And Serialization
Hi Ben, nice to have you back! I already gave up on you, thinking you'll write about jQuery and iPhone for the rest our our lives! :) ... read »
Mar 18, 2010 at 10:36 AM
Ask Ben: Javascript Replace And Multiple Lines / Line Breaks
@Ben Nadel, Hey Ben, thanks for you're response. It works!! However.. if you could please kindly look at http://edeals.zzl.org/divchange2.php where I am trying it out you will see that with the " ... read »
Mar 18, 2010 at 9:56 AM
SQL COUNT( NULLIF( .. ) ) Is Totally Awesome
This works too. I learned this trick a long time ago and it's really powerful for flags. SELECT g.hair , COUNT(*) AS girl_count , sum(did_date) AS did_date_count , sum(abs(did_date - 1)) AS did_ ... read »
Mar 18, 2010 at 9:16 AM
Using A SQL JOIN In A SQL DELETE Statement (Thanks Pinal Dave!)
Forget the last part of that. Wasn't thinking straight and hadn't done it exactly that way myself. It'll work if you're doing an 'In' but if you're doing a 'Not In' as above it'll do each check acr ... read »
Mar 18, 2010 at 9:16 AM
Ask Ben: Blocking WSDL Access In A ColdFusion Application
Ben, Robert great stuff that I can use. Thanks. ... read »