Skip to content
Julian Halliwell edited this page Dec 23, 2015 · 16 revisions

Write a spreadsheet object to a file.

write( workbook, filepath[, overwrite, password, algorithm ] )

##Required arguments

  • workbook spreadsheet object
  • filepath string: the absolute path of the file to be written.

##Optional arguments

  • overwrite boolean default=false: whether to overwrite an existing file
  • password string: if supplied the file will be encrypted and require the password to be opened.
  • Password-protection only works with XML format (.xlsx) spreadsheets.
  • algorithm string default="agile": algorithm/mode to use when encrypting a file. Possible values are agile, standard or binaryRC4
  • The available algorithms are not universially supported by spreadsheet software. You may find some programs cannot open the files depending on which algorithm you use.
  • Note that binaryRC4 is apparently regarded as not very secure.

##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" );

Clone this wiki locally