Reputation: 1172
I have a query object which contains 5 columns, but I only need to add 4 columns to the spreadsheet. When I am using <cfset spreadSheetAddRows(spreadSheetObj,qryObj)>
it is adding all the columns to the spreadsheet. I cannot remove the 5th column from the query as it is required for some other purpose.
So How can I add only 4 columns from the query to spreadsheet?
Ex: My query contains 4 columns like "Id,Name,Roll,CGPA"
But my Excel sheet should contain only "Id,Name,Roll".
How to do this?
Upvotes: 2
Views: 1316
Reputation: 1090
Just add each row individually with SpreadsheetAddRow(spreadsheetObj, data [,row, column, insert]);
And for columns use SpreadsheetAddColumn(SpreadsheetObj, data[, startRow, startColumn, insert]);
Upvotes: 0
Reputation: 1271
You could do a Query-of-Query to create a temporary query that you can then use to pump into your spreadSheetAddRows()
.
<cfquery name="local.spreadsheetQuery" dbtype="query">
SELECT Id,Name,Roll
FROM variables.originalQuery
</cfquery>
Then use <cfset spreadSheetAddRows(spreadSheetObj,local.spreadsheetQuery)>
instead of <cfset spreadSheetAddRows(spreadSheetObj,variables.originalQuery)>
.
Upvotes: 0