Adds multiple rows from a query or array to an Excel spreadsheet object.
spreadsheetAddRows(spreadsheetObj, data,[ row, column , insert, datatype, includeColumnNames])
→ returns void
true
data
to the spreadsheetObj
. When false
attempts to update the spreadsheet object rows.
true
false
STRING
NUMERIC
or DATE
. For example use `DATE:1;NUMERIC:2-2;STRING
false
true
writes column names as headers in the spreadsheet.
<cfset q = queryNew("name,beers",
"varchar,integer",
[ {"name":"John","beers":2}, {"name":"Pete","beers":1} ])>
<!--- Make a spreadsheet object --->
<cfset s = spreadsheetNew()>
<!--- Add header row --->
<cfset spreadsheetAddRow(s, "Name,Beers")>
<!--- Add query --->
<cfset spreadsheetAddRows(s, q)>
<cfdump var="#s#" />
You need to state the row, column, insert and datatype arguments before you can change includeColumnNames to true as ACF internal functions don't allow named arguments.
<cfset q = queryNew("name,beers",
"varchar,integer",
[ {"name":"John","beers":2}, {"name":"Pete","beers":1} ])>
<!--- Make a spreadsheet object --->
<cfset s = spreadsheetNew()>
<!--- Add query and preserve column names --->
<cfset spreadsheetAddrows(s,q,1,1,true,[""],true)>
<cfdump var="#s#" />
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.