write - cfsimplicity/spreadsheet-cfml GitHub Wiki
Write a spreadsheet object to a file.
write( workbook, filepath [, overwrite [, password [, algorithm ] ] ] )
Required arguments
workbook
spreadsheet objectfilepath
string: the absolute path of the file to be written.
Optional arguments
overwrite
boolean default=false: whether to overwrite an existing filepassword
string: if supplied the file will be encrypted and require the password to be opened.- Password-protection only works with XML format (.xlsx) spreadsheets, and is not available in Adobe ColdFusion
algorithm
string default="agile": algorithm/mode to use when encrypting a file. Possible values are agile, standard or binaryRC4- The available algorithms are not universally supported by spreadsheet software. You may find encrypted files cannot be opened depending on which algorithm you use to encrypt and which program you use to open the file.
- Note that binaryRC4 is apparently regarded as not very secure.
Chainable? Yes.
Examples
data = QueryNew( "First,Last", "VarChar,VarChar", [ [ "Susi","Sorglos" ], [ "Frumpo","McNugget" ] ] );
spreadsheet = New spreadsheet();
workbook = spreadsheet.workbookFromQuery( data );
path = "C:/temp/test.xls";
spreadsheet.write( workbook, path );
Write a password protected file
data = QueryNew( "First,Last", "VarChar,VarChar", [ [ "Susi","Sorglos" ], [ "Frumpo","McNugget" ] ] );
spreadsheet = New spreadsheet();
workbook = spreadsheet.workbookFromQuery( data=data, xmlFormat=true);
path = "C:/temp/test.xlsx";
spreadsheet.write( workbook, path, "secret" );