SpreadsheetWrite

Description

Writes single sheet to a new XLS file from a ColdFusion spreadsheet object.

Category

Microsoft Office Integration

Function syntax

SpreadSheetWrite(SpreadsheetObj, fileName) 
SpreadSheetWrite(SpreadsheetObj, fileName [,overwrite]) 
SpreadSheetWrite(SpreadsheetObj, fileName [, password]) 
SpreadSheetWrite(SpreadsheetObj, fileName [, password,overwrite])

History

ColdFusion 9: Added the function.

Parameters

Parameter

Description

spreadSheetObj

The Excel spreadsheet object to which to write.

fileName

The pathname of the file that is written.

overwrite

A Boolean value specifying whether to overwrite an existing file. Specify yes to overwrite.

password

Password to protect the active sheet. Password is applicable only for Excel 97 - 2003 file formats. It will be ignored for XML file format (Excel 2007).

Usage

Use this function to:

  • Write multiple sheets to a single file.

  • Update an existing file, read all sheets in the file, modify one or more sheets, and to rewrite the entire file.

Example

<cfscript>     
    spreadsheet = SpreadSheetRead("C:\Files\Report.xls","Annual Report"); 
    SpreadSheetWrite(spreadsheet,"C:\Files\Report.xls","P@ssword","yes"); 
</cfscript>

Example 2

<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>