NativeExcel suite v2.x

Open method

Opens an existing workbook

Syntax

function Open(FileName: WideString):integer;
function Open(Stream: TStream):integer;
function Open(FileName: WideString; Password: WideString):integer;
function Open(Stream: TStream; Password: WideString):integer;
FileNameWideString. A string that indicates the name of the file to be opened. You can include a full path; if you don't, workbook opens the file in the current folder.
StreamTStream. A stream object that can be used to read the workbook.
PasswordWideString. A string that contains the password required to open a protected workbook.

Example

This example opens excel file book1.xls from the current folder.
Workbook.Open('book.xls');
This example opens password protected excel workbook book2.xls with the password 'pass2008'.
Workbook.Open('book2.xls', 'pass2008');
This example changes the name of the first worksheet in book1.xls.
Var book: IXLSWorkbook;
begin
  book := TXLSWorkbook.Create();
  book.Open('book1.xls');
  book.Sheets[1].Name := 'New name';
  book.SaveAs('book1.xls');
end;
This example loads workbook from a BLOB field.
var
  MS: TMemoryStream;
begin
  MS := TMemoryStream.Create;
  try
    SQLDataSet1Documents.SaveToStream(MS);
    FWorkbook.Open(MS);
  finally
    MS.Free;
  end;
end;
Copyright © NikaSoft 2004-2010