Dokumentacija HotXLS

SaveAs metoda

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

Sintaksa

function SaveAs( Filename: WideString): Integer;
FileName WideString. A string that indicates the name of the file to be saved. You can include a full path; if you don't, component saves the file in the current folder

Primjer

This example creates Example1.xls Workbook and Example1.html with two Worksheets which contain data from Table1 and Table2 datasets

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

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

  //Second dataset
  DataToXLS1.WorksheetName := 'Table2 sheet'; //Specifies the name for second Worksheet
  DataToXLS1.Dataset := Table2; //Specifies 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;