POI Utility Freeze Frames, Bug Fixes, And Branded Templates

Posted June 6, 2008 at 9:49 AM

Tags: ColdFusion

I have made some updates to the POI Utility project for creating Microsoft Excel documents with ColdFusion. First, Dan Wilson pointed out some minor bugs that I had failed to test. Specifically with the DateFormat and with the FontSize properties of a cell. Thanks Dan!

Also, after suggestions by Matthew Abbott and Greg Cronkright, I have finally addeded freeze panes to the custom tags. For those of you are not familiar with this concept, a freeze pane allows you to have certains rows or columns become "static" while the rest of the rows and columns scroll beneath it. This kind of effect is great for a header row, espcially column headers on really long sets of data.

There are two ways to create the freeze pane. Either you can set the freeze row and / or column in the desired Sheet tag:

 Launch code in new window » Download code as text file »

  • <poi:sheet name="Sheet One" freezerow="3" freezecolumn="1">

Or, you can set the freeze="true" attribute on the Column tag:

 Launch code in new window » Download code as text file »

  • <poi:column freeze="true" />

Or, you can set the freeze="true" attribute on the Row tag:

 Launch code in new window » Download code as text file »

  • <poi:row class="header" freeze="true">

You can use any combination of those as well; you can set these values in the Sheet tag and then override them in the Row / Column tags. The index for the row and column freezing starts at one; meaning, if you set the freeze be at row 2, rows 1 and 2 will be static and rows 3 and greater will scroll. Using the following code:

 Launch code in new window » Download code as text file »

  • <poi:sheet name="Smokin' Hotties" freezerow="2">

... gives us this output:


 
 
 

 
POI Utility Creates Excel Document With Freeze Pane With ColdFusion  
 
 
 

Notice that after row 2 comes row 5. This is because rows 1 and 2 are now frozen and I have scrolled down in the document to demonstrate that the rest of the rows will scroll underneath these rows.

Branded templates are another thing I just wanted to demonstrate. The POI Utility custom tags have been able to use branded templates when they were first released, but I never really talked about them or demonstrated how they work. They are not perfect, but they can be useful. The biggest caveat to be aware of is that if you use an image that overlaps with a column or row that is resized, your image will also get resized. This is just a side effect of the POI limitations. And so, if you are going to be using an image in your branded template, you neeed to either resize your columns ahead of time (in the template) or do not explicitly resize them in the POI custom tags.

Here is an example of my branded template, included in the POI build:


 
 
 

 
Kinky Solutions Branded Template For Use In POI Utility To Create Excel Documents Using ColdFusion  
 
 
 

Notice that it contains the Kinky Solutions logo in row one. Notice also that the columns have already been properly sized for the report I am about to generate. Again, this is a limitation you need to be aware of. Now, I am going to specify that branded template as the based template to use when I create my new report:

 Launch code in new window » Download code as text file »

  • <poi:document
  • name="REQUEST.ExcelData"
  • template="#ExpandPath( './branded_template.xls' )#">

Running the tag (example included in the POI Utility build), we get the following output:


 
 
 

 
Kinky Solutions Branded Report Created Using ColdFusion And The POI Utility  
 
 
 

Not bad, right? The newest code can be downloaded from the POI Utility Project page.

Download Code Snippet ZIP File

Post Comment  |  Ask Ben  |  Permalink  |  Other Searches  |  Print Page




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

Reader Comments

Mar 3, 2009 at 12:00 PM // reply »
1 Comments

So glad this post turned up. I was on the cusp of writing my own ColdFusion wrapper around POI. Your release of this code will be a huge time-saver for me and I'm sure will be much better than the wrapper I would have came up with. Thanks!


Post Comment  |  Ask Ben

Recent Blog Comments
Nov 21, 2009 at 6:47 PM
Hal Helms - Real World Object Oriented Development, Sarasota - Day Five
@charlie griefer, Thank you.. ... read »
Nov 21, 2009 at 5:15 PM
Using ColdFusion Structures To Remove Duplicate List Values
@Jose Galdamez, Oh heh yeah I didn't paste the whole code. I should have defined the vars -- my bad. It's fixed thou. Thanks. ... read »
Nov 21, 2009 at 4:49 PM
Styling The ColdFusion 8 WriteToBrowser CFImage Output
Great work yet again Ben! Whilst I didn't use this whole code, I copied some of your regex code for a similar problem with the lack of an alt attribute and unescaped ampersands in CFIMAGE for Railo 3 ... read »
Nov 21, 2009 at 1:13 PM
My First ColdFusion Builder Extension - Encrypting And Decrypting CFM / CFC Files
@Ben, Because I am pedantic, I just want to make sure that everyone knows there is absolutely no encryption going on. There is only encoding and obfuscation. The cfencode tool only obfuscates your C ... read »
Nov 21, 2009 at 12:28 PM
Using ColdFusion Structures To Remove Duplicate List Values
@Jody I can't seem to get your code sample to work. If you are still having problems, try this code out and see if it gets you what you wanted. <!--- Comma delimited list with various duplicates ... read »
Nov 21, 2009 at 11:03 AM
Groovy Operator Overloading Does Not Work In The ColdFusion Context
Hi Ben, Thanks for this informative post. Now I am reading ur old posts too ... read »
Nov 21, 2009 at 10:56 AM
HostMySite.com Has The Best ColdFusion Hosting
@Mehul, Yes very nice people, however several downtimes per day which was not acceptable. Hence we had to move out. I am glad you are having good luck with them so far. ... read »