Adding Date support to POIUtil.cfc (Jakarta POI) when WRITING excel sheets


Adding Date support to POIUtil.cfc (Jakarta POI) when WRITING excel sheets

Posted by Luis Majano
Oct 08, 2007 00:00:00 UTC
The POIUtil.cfc by Ben Nadel is a great wrapper to the Apache POI project. I am using it in a current project and have come to certain caveats that I needed to extend the library. I did a post regarding how to read excel dates, this is the second part, how to write dates. This can apply to various types of formatting that could be done on an excel sheet. To come up with all the variations would take a very big big POI coldfusion wrapper. So I am coding to my needs.

Anyways, to sum up the problem

Excel stores dates as numbers therefore the only way to determine if a cell is actually stored as a date is to look at the formatting.

Enter a little digging in the docs and the API and you find the famous HSSFDataFormat class.

This class will help you get the correct formatting for any kind of date, datetime, etc.

 


Terry Schmitt

Thanks much for the tip. This is a nice quick fix for formatting dates. I did have to comment out some alt row code in the latest version of poiutil.cfc though. The alt row code was overriding the cellStyle.

Fernando

Hi Luis,

I'm trying to patch the cfc but it's not working, my query comes from a mysql select, i tried formating the date field but i couldn't get it work.

Do you know in which format the date must be in the select?

Tks,

Fernando

Luis Majano

I believe mine was as a datetime field

Fernando

tks, now it's working

Site Updates

Entry Comments

Archives

Entries Search