How to access a query column with multiple words?

I am using cfspreadsheet reading to read a sheet in a query object.

<cfspreadsheet action="read" src="TestExcel.xls" sheet="1" query="spreadsheetData" headerrow="1" excludeHeaderRow="true"> 

The problem is that some headings contain more than one word. So I get the request something like this:

ID  Name    Start Date  End Date
3   Test    1/1/2009    1/1/2013
17  Test 2  11/11/2010  11/11/2012

If I try to access one of the columns that have a space in the column name, I get an error.

<cfoutput query="spreadsheetData">
   #start date#
</cfoutput>

I tried too #[start date]#, but it didn’t work. I can not control the excel sheet format that I get. Is there a way to access columns with multiple headers?

+5
source share
1 answer

When using musical notation in parentheses, the contents should end as a string, therefore:

<cfoutput query="spreadsheetData">
    #spreadsheetData['start date'][CurrentRow]#
</cfoutput>


, , :

<cfset ColumnName = 'start date' />

<cfoutput query="spreadsheetData">
    #spreadsheetData[ColumnName][CurrentRow]#
</cfoutput>


, - [ColumnName], , .

, (.. cfoutput/cfloop ), CurrentRow, ..

spreadsheetData[ColumnName][spreadsheetData.CurrentRow]

( /).


, cfspreadsheet columnnames, , .

<cfspreadsheet query=".." columnNames="Foo,Bar,StartDate,Etcetera" ..>
+13

All Articles