Documentazione HotXLS

SaveAs metodo

Saves the Workbook to the specified file. Restituisce 1 if it succeeds File names ending in .xlsx are written through the XLSX export bridge; .xls, .html, e .rtf continue to use the classic exporters

Sintassi

funzione SaveAs(Filename: WideString): Integer;
FileName WideString. Una stringa che indica il nome del file da salvare. È possibile includere un percorso completo; in caso contrario, il componente salva il file nella cartella corrente

Esempio

This example creates Example1.xls Workbook e Examle1.html file with two Worksheets which contain data from DBGrid1 e DBGrid2

begin
  GridToXLS1.Workbook := nil; //Clears Workbook

  //First dbgrid
  GridToXLS1.WorksheetName := 'DBGrid1 sheet'; //Specifica the name for first Worksheet
  GridToXLS1.DBGrid := DBGrid1; //Specifica the dbgrid for export
  GridToXLS1.ExportDBGrid;

  //Second dbgrid
  GridToXLS1.WorksheetName := 'DBGrid2 sheet'; //Specifica the name for second Worksheet
  GridToXLS1.DBGrid := DBGrid2; //Specifica the dbgrid for export
  GridToXLS1.ExportDBGrid;

  GridToXLS1.SaveAs('Example1.xls'); //Saves the created Workbook into Example1.xls file
  GridToXLS1.SaveAs('Example1.xlsx'); //Saves the created Workbook into Example1.xlsx file
  GridToXLS1.SaveAs('Example1.html'); //Saves the created Workbook into Example1.html file
  GridToXLS1.SaveAs('Example1.rtf'); //Saves the created Workbook into Example1.rtf file
end;