spreadsheetwrite

Writes Spreadsheet object into file

spreadsheetwrite(spreadsheetObj, fileName [, password] [, overwrite]) → returns void

Argument Reference for the spreadsheetwrite function

spreadsheetObj

Required: Yes
No Help Available

fileName

Required: Yes
No Help Available

password

Required: No
No Help Available

overwrite

Required: No
No Help Available

Examples sample code invoking the spreadsheetwrite function


Script Example

<cfscript> 
         spObj = spreadsheetread("#dirname#SingleSheet.xls","Sheet2"); 
         spreadsheetCreateSheet(spObj,"A"); 
         spreadsheetaddrow(spObj,"x,x,x,x,x",3,1); 
         spreadsheetsetActiveSheet(spObj,"A"); 
         spreadsheetaddrow(spObj,"z,z,z,z,z",3,1); 
         spreadsheetsetActiveSheetNumber(spObj,1); 
         spreadsheetaddrow(spObj,"a,b,c,d,e",3,1); 
         SpreadsheetWrite(spObj,"#dirname#SingleSheet1.xls","yes"); 
 </cfscript>  

Script Example

This will work if there was a place to store the xls file.

<cfset filename = 'pathToFile.xls' /> 
<cfset q = queryNew("Name,Beers,Vegetables,Fruits,Meats", "cf_sql_varchar,cf_sql_integer,cf_sql_integer,cf_sql_integer,cf_sql_integer")> 
  <cfset queryAddRow(q)> 
  <cfset querySetCell(q, "Name", "John")> 
  <cfset querySetCell(q, "Beers", "1")> 
  <cfset querySetCell(q, "Vegetables", "1")> 
  <cfset querySetCell(q, "Fruits", "1")> 
  <cfset querySetCell(q, "Meats", "1")> 
  <cfset mySheet =   SpreadsheetNew( "Test"  ) /> 
  <!--- Make a spreadsheet object ---> 
  <cfset s = spreadsheetNew()> 
  <!--- Add header row ---> 
  <cfset spreadsheetAddRow(s, "Name,Beers,Vegetables,Fruits,Meats")> 
 <cfset spreadsheetAddRow(s, "Name1,Beers1,Vegetables1,Fruits1,Meats1")>
  <cfset spreadsheetWrite(s, filename, true) /> 
  

Fork me on GitHub