tracker issue : CF-3043981

select a category, or use search below
(searches all categories and all time range)
Title:

Bug 87056:(Watson Migration Closure)Summary: spreadsheetSetCellValue() and other cell-value setting functions should be data-type awareThe datatype of the data being put in the spreadsheet should be respected

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 08/21/2011

Components: Document Management, Office Integration

Versions: 9.0.1

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 /

Priority/Frequency: Minor / Unknown

Locale/System: English / Platforms All

Vote Count: 2

Problem:

Summary: spreadsheetSetCellValue() and other cell-value setting functions should be data-type awareThe datatype of the data being put in the spreadsheet should be respected.  If it's a date I am putting in, then it should be put in as a date.  Date data is currently just being cast to a string and inserted as a string (eg: {ts '2011-08-21 12:41:43'}, which is not a date as far as Excel is concerned).Just casting everything as a string has a knock-on effect, as detailed in bug 86948.  I think the expectations described in that issue are valid, if not how it's been reported.-- Adam
Method:

<cfscript>ts = now();stFormat = {dataformat="yyy-mm-dd hh:mm:ss"};oSpreadsheet = spreadsheetNew();spreadsheetSetCellValue(oSpreadsheet, ts, 1, 1);spreadsheetSetCellValue(oSpreadsheet, date2Excel(ts), 1, 2);spreadsheetFormatCell(oSpreadsheet, stFormat, 1, 1);spreadsheetFormatCell(oSpreadsheet, stFormat, 1, 2);spreadsheetSetColumnWidth(oSpreadsheet, 2, 20);numeric function date2Excel(date d){var iDayPart = dateDiff("d", createDate(1899, 12, 30), arguments.d);var fTimePart = (hour(arguments.d) / 24) + (minute(arguments.d) / (24*60)) + (second(arguments.d) / (24*60*60));return iDayPart + fTimePart; }</cfscript><cfheader name="Content-Disposition" value="attachment; filename=dateTest_#timeFormat(now(), "HHMMSS")#.xls"><cfcontent type="application/vnd-ms.excel" variable="#spreadsheetReadBinary(oSpreadsheet)#" reset="true">
Result:

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3043981

External Customer Info:
External Company:  
External Customer Name: Adam Cameron
External Customer Email: 17EB1A7649DA54C7992015A9
External Test Config: 08/21/2011

Attachments:

Comments:

+1, spreadsheet functions should respect data type when writing to a spreadsheet. The date2Excel() function, in the "Steps to Reproduce", illustrates how to pass a date correctly.
Vote by External U.
21002 | November 11, 2011 07:30:58 AM GMT
I too have experienced this bug when creating Excel spreadsheets.
Vote by External U.
21003 | November 19, 2012 03:39:23 PM GMT
implemented in CF11. We now have a new 'datatype' parameter for the method. Ref. https://wikidocs.adobe.com/wiki/display/coldfusionen/SpreadsheetSetCellValue
Comment by Piyush K.
21000 | December 05, 2014 01:49:36 AM GMT
Cheers, Piyush.
Comment by External U.
21001 | December 05, 2014 01:51:42 AM GMT