Title:
cfspreadsheet with header=1 doesn't throw error if spreadsheet is empty but was created with spreadsheetNew
| View in TrackerStatus/Resolution/Reason: Closed/Withdrawn/NotABug
Reporter/Name(from Bugbase): colin macallister / colin macallister (colin macallister)
Created: 03/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: Normal / Few users will encounter
Locale/System: English / Win 2008 Server x64
Vote Count: 0
Problem Description:
If you read in a spreadsheet via cfspreadsheet with header=1, it should throw an error if there is no data in the header. It does this for pristine spreadsheets created in Excel or Libre Office. However, for spreadsheets that are empty were created with spreadsheetNew, spreadsheetAddRow, spreadsheetFormatRow, and output with spreadsheetReadBinary, no error is thrown and an empty query object is returned. Any subsequent attempt to access data by the header indices throws the error that the table is not indexable by that header value.
Steps to Reproduce:
Create two empty spreadsheets, one from Excel and one generated by the commands listed above. To output the spreadsheet use
<cfset local.s = spreadsheetNew( "My Worksheet" ) />
<cfset spreadsheetAddRow( local.s, "ColumnA,ColumnB,ColumnC") />
<cfset spreadsheetFormatRow( local.s, { bold=true }, 1 ) />
<cfheader name="Pragma" value="" />
<cfheader name="Cache-control" value="" />
<cfheader name="Content-Disposition" value="inline; filename=myspreadsheet.xls" charset="utf-8" />
<cfcontent type="application/vnd.msexcel; charset=utf-8" variable="#spreadSheetReadBinary( local.s )#" />
<cfabort/>
Read both in with cfspreadsheet, with header=1.
Actual Result:
The generated spreadsheet returns an empty query object for the spreadsheet, and doesn't throw an error that there is no data for a header row. Weirder, even though it reports that recordCount = 0, <cfif spreadsheet.recordCount eq 0> does not evaluate to true and looping over the query object seems to reflect the presence of two rows. For each row, every header (column) index returns an error because it doesn't exist.
Expected Result:
If the spreadsheet is empty, regardless of the source of the xls file, cfspreadsheet header=1 should throw an error.
Any Workarounds:
I am experimenting with this to see if other ways of generating a spreadsheet cause the same problem.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3952934
External Customer Info:
External Company:
External Customer Name: colin
External Customer Email:
External Test Config: My Hardware and Environment details:
Server: Windows 2008, Coldfusion 11 Developer behind IIS.
Client: Windows 7, Firefox 36.01, blank spreadsheets generated by either Microsoft Office Standard 2010 (Excel version 14.0.7143.5000 (64-bit) or LibreOffice version 4.2.8.2.
Attachments:
Comments: