Documentazione HotXLS

Metodo SaveAs

Salva le modifiche alla cartella di lavoro in un file o stream diverso. Restituisce 1 in caso di successo

Sintassi

function SaveAs(FileName: WideString): Integer;
function SaveAs(FileName: WideString; FileFormat: TXLSFileFormat): Integer;
function SaveAs(Stream: TStream);
function SaveAs(Stream: TStream; FileFormat: TXLSFileFormat): Integer;
FileName WideString. Stringa che indica il nome del file da salvare. Puoi includere un percorso completo; in caso contrario, Workbook salva il file nella cartella corrente
FileFormat TXLSFileFormat facoltativo. Un valore che indica il formato del file da salvare. Il valore predefinito è xlExcel97
Stream TStream. Saves cartella di lavoro stream specificato nell'intervallo Stream parameter

Descrizione

FileFormat can be one of these TXLSFileFormat constants
xlExcel97 MS Excel 97,2000,XP,2003 file format
xlExcel5 MS Excel 5,95 file format
xlHTML HTML file format
xlRTF Rich Text Format (RTF)
xlCSV Comma separated values file format (CSV)
xlText Tab separated values file format (TSV)
xlUnicodeCSV Comma separated unicode values file format (CSV)
xlUnicodeText Tab separated unicode values file format (TSV)

Esempio

This example creates a new Workbook with one Worksheet and then saves the Workbook

Var
  Workbook: IXLSWorkbook;
begin
  Workbook := TXLSWorkbook.Create; {create new Workbook}
  Workbook.Worksheets.Add;
  {...}
  //Save cartella di lavoro as Excel 97 file formato 
  Workbook.SaveAs('C:\book.xls');
  //Save cartella di lavoro as Excel 5-95 file formato 
  Workbook.SaveAs('C:\book5.xls', xlExcel5);
  //Save cartella di lavoro as HTML 
  Workbook.SaveAs('C:\book.html', xlHTML);
  //Save cartella di lavoro as RTF file 
  Workbook.SaveAs('C:\book.rtf', xlRTF);
  //Save active foglio di lavoro as comma separated valori (CSV)
  Workbook.SaveAs('C:\book.csv', xlCSV);
  //Save active foglio di lavoro as tab separated valori (TSV)
  Workbook.SaveAs('C:\book.tsv', xlText);
  //Save active foglio di lavoro as comma separated unicode valori (CSV)
  Workbook.SaveAs('C:\book.csv', xlUnicodeCSV);
  //Save active foglio di lavoro as tab separated unicode valori (TSV)
  Workbook.SaveAs('C:\book.tsv', xlUnicodeText);
end;
This example saves Workbook into the BLOB field

var
  MS: TMemoryStream;
begin
  if not (ClientDataSet1.State in [dsInsert, dsEdit]) then
    ClientDataSet1.Insert;
  MS := TMemoryStream.Create();
  try
    FWorkbook.SaveAs(MS);
    ClientDataSet1Documents.LoadFromStream(MS);
  finally
    MS.Free;
  end;
  ClientDataSet1.Post;
end;