Adding Date support to POIUtil.cfc (Jakarta POI) when WRITING excel sheets
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.