Delphi ActiveX
Delphi ActiveX
XLSX Get Sheet Names
Open an Excel spreadsheet (.xlsx) and get the names of the sheets.Chilkat Delphi ActiveX Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
zip: TChilkatZip;
csv: TChilkatCsv;
sheetNames: TChilkatStringTable;
i: Integer;
begin
success := 0;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// .xlsx files are Zip archives
zip := TChilkatZip.Create(Self);
success := zip.OpenZip('qa_data/excel/fakeCompanies.xlsx');
if (success = 0) then
begin
Memo1.Lines.Add(zip.LastErrorText);
Exit;
end;
csv := TChilkatCsv.Create(Self);
sheetNames := TChilkatStringTable.Create(Self);
success := csv.XlsxGetSheets(zip.ControlInterface,sheetNames.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(csv.LastErrorText);
Exit;
end;
i := 0;
while i < sheetNames.Count do
begin
Memo1.Lines.Add(sheetNames.StringAt(i));
i := i + 1;
end;
end;