tracker issue : CF-3987544

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

Excel spreadsheet generation and formating issue, value are not returned correctly

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Greg Heh / Greg Heh (Greg Heh)

Created: 05/13/2015

Components: Document Management, Office Integration

Versions: 11.0

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / Few users will encounter

Locale/System: English / Win 2012 Server x64

Vote Count: 0

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on May 18, 2018 using build 2016.0.01.298513
Problem Description:

When generating an excel document that includes numeric value strings, including hyphens (-), formatting those values to 'General' or 'Text' causes all digits before the hyphen to be dropped from the value.

Steps to Reproduce:  When running the following code, a value such as 224-1 gets incorrectly rendered as -1

<cfquery name="getrpt" datasource="#request.db.dsn#">        
                SELECT  
                                                '224-1' as shipment_name
                FROM   dual
</cfquery>

<cfset sObj = SpreadsheetNew("true")>
<cfset SpreadsheetAddRows(sObj, Evaluate("getrpt"))>
<cfset SpreadsheetFormatCellRange(sObj, {dataformat="General"}, 1, 1, Evaluate("getrpt.recordcount + 2"), 1)>

<cfset DateNum = Int((NOW() - DateFormat(NOW(), "yyyy-mm-dd")) * 999999)>
<cfset filename = "Export_#DateNum#">
<cfset fullfilepath = "#GetDirectoryFromPath(GetCurrentTemplatePath())#/#filename#.xlsx">
<cfspreadsheet action="write" filename="#fullfilepath#" name="sObj" sheetname="Exported Data">

<cffile action="readbinary" file="#fullfilepath#" variable="export_file">
<cffile action="delete" file="#fullfilepath#">
<cfheader name="Content-Disposition" value="inline; filename=#filename#.xlsx">
<cfcontent type="application/vnd.msexcel" reset="true" variable="#toBinary(export_file)#">

If you do not specify any formatting, the value will display as #####.  The number of hash's will fill any width you resize the cell to.

Actual Result: cell value of:  -1 or ######## depending on format applied to cell.

Expected Result:  cell value of 224-1

Any Workarounds:

None

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

Watson Bug ID:	3987544

External Customer Info:
External Company:  
External Customer Name: Greg
External Customer Email:  
External Test Config: My Hardware and Environment details:

CF version 11.0.05.293506

Edition:  Enterprise

OS: Windows Server 2012

OS Version:  6.2

Update level /C:/Coldfusion11/cfusion/lib/updates/hf1100-3971083.jar

Adobe Driver Version:  5.1.3 (Build 000094)



Generating an .xlsx spreadsheet to an Excel 2013 application.

Attachments:

Comments:

Opened case# 186625846 will Adobe support. They have been able to reproduce issue.
Comment by External U.
7457 | May 13, 2015 03:52:02 PM GMT
Greg, To avoid this, you can use the datatype parameter of the addrows method like so: <cfset SpreadsheetAddRows(sObj, Evaluate("getrpt"), 1, 1, true, ["string"])> For usage refer https://wikidocs.adobe.com/wiki/display/coldfusionen/SpreadsheetAddRows
Comment by Piyush K.
7458 | June 07, 2015 10:31:47 AM GMT
Hi Piyush, The datatype parameter's description should be more detailed. User's shouldn't have to read thru the example code to figure out all the ways in which the parameter can be used. And the example code doesn't even show that it can accept a range. Thanks!, -Aaron
Comment by External U.
7459 | September 23, 2015 02:02:06 AM GMT
This is fixed for cases where the datatype is specified in the query. For other cases user can specify the new datatype parameter to enforce the desired format. eg. datatype used: q = QueryNew( col_lst, dt_lst, [ {col_chr1:"11-1111", col_int:12}, {col_chr1:"21-2222", col_int:22}, ]); datatype NOT used: q = QueryNew("col_chr1, col_int"); QueryAddRow( q, [{col_chr1:"11-1111", col_int:12}]); QueryAddRow( q, [{col_chr1:"11-1111", col_int:12}]); Thanks Aaron, for pointing out the shortcomings in the documentation. Incidentally, I noticed that too. I'll raise a documentation bug for that.
Comment by Piyush K.
7460 | September 23, 2015 10:10:39 AM GMT
Adobe issued a hotfix for this.
Comment by External U.
7461 | September 23, 2015 10:21:31 AM GMT
Thanks Greg for noting that (very good on Adobe's part there). And thanks Piyush for clarifying and then logging a doc bug - you're very welcome! -Aaron
Comment by External U.
7462 | September 23, 2015 12:45:11 PM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513). Thanks!, -Aaron
Comment by Aaron N.
27853 | May 18, 2018 01:04:43 AM GMT