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.


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.
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
I believe mine was as a datetime field
tks, now it’s working