When creating a spreadsheet from a query, the spreadsheet that is produced will not allow a column of a datetime datatype to be formatted.
The spreadsheet creation is:
<cfset filenametouse = 'AllCaseData' />
<!---Set directory and full file path--->
<cfset theDir = GetDirectoryFromPath(GetCurrentTemplatePath()) />
<!---Attach file extension to full file path and file name--->
<cfset theFile = theDir & filenametouse & ".xls" />
<cflock name="fileActionSentItems" type="exclusive" timeout="30" throwontimeout="true">
<cfset SpreadsheetObj = spreadsheetNew()>
<!---<cfset fcol = {}>
<cfset fcol.dataformat = "@">--->
<!---Create the column headings--->
<cfset SpreadsheetAddRow(SpreadsheetObj, "Case_Number,Ship_Start,Projected_$,VA_$,Customer_ID,Customer,Project_Description,Stage,Sales,PM,J_Count,O_Count,S2_Count,S_Count,I_Count")>
<!---add the column data to the spreadsheet--->
<cfset SpreadsheetAddRows(SpreadsheetObj, caseData) />
<cfset SpreadsheetFormatColumn(SpreadsheetObj, {dataformat="m/d/yyyy"}, 2)>
<!---Generate the spreadsheet--->
<cfspreadsheet action="write" filename="#theFile#" name="SpreadsheetObj" sheetname="Sheet1" overwrite="true" />
</cflock>
<cftry>
<cflock name="fileActionSentItems" type="exclusive" timeout="30" throwontimeout="true">
<cfmail to="#session.authUser.getEmail()#" from="noreply@pratt.com" subject="All Case Data" type="html" >
<cfmailparam file="#theFile#" remove="true" />
<p>The requested data is attached.</p>
</cfmail>
</cflock>
<cfcatch type="any" >
<cffile action="delete" file="#theFile#" />
</cfcatch>
</cftry>
<cfoutput><h3 style="margin-top: 1em;">Email sent to <cfoutput>#session.authUser.getEmail()#</cfoutput></h3></cfoutput>
All the data is correct and in the correct columns, however the "Ship_Start" column comes formatted similar to 2012-11-27 00:00:00.000 and cannot be changed to any other format in Excel.
If I run the query manually in SQL Server Management Studio then copy the results with headers into Excel, the data can be formatted. I have also created an Excel template with the column headers formatted and populated the template with the data, but the column cannot be formatted even though it is formatted with "date."
What could I be missing?