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 Example1.html with two Worksheets which contain data from Table1 e Table2 datasets

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

  //First dataset
  DataToXLS1.WorksheetName := 'Table1 sheet'; //Specifica the name for first Worksheet
  DataToXLS1.Dataset := Table1; //Specifica the dataset for export
  DataToXLS1.ExportDataset;

  //Second dataset
  DataToXLS1.WorksheetName := 'Table2 sheet'; //Specifica the name for second Worksheet
  DataToXLS1.Dataset := Table2; //Specifica the dataset for export
  DataToXLS1.ExportDataset;

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