TTMSFNCDataGridExcelIO.XLSImport Method
Imports the first worksheet of an XLS workbook into the grid.
API unit family: TMSFNCDataGridExcelIO
Declaring type: TTMSFNCDataGridExcelIO
Overloads
Overload 1
Imports the first worksheet of an XLS workbook into the grid.
procedure XLSImport(const FileName: TFileName); overload;
void __fastcall XLSImport(const System::Sysutils::TFileName FileName)/* overload */;
Remarks
Equivalent to calling the SheetNumber overload with sheet 1. See that overload for the import sequence.
Parameters
| Name | Description |
|---|---|
FileName |
Path of the .xls workbook to import. |
Exceptions
| Exception | Description |
|---|---|
Exception |
Raised when no grid is assigned. |
Overload 2
Imports one worksheet, selected by number, of an XLS workbook into the grid.
procedure XLSImport(const FileName: TFileName; const SheetNumber: integer); overload;
void __fastcall XLSImport(const System::Sysutils::TFileName FileName, const int SheetNumber)/* overload */;
Remarks
The grid is updated inside BeginUpdate/EndUpdate. Sequence: the grid is cleared (Options.ImportClearCells), resized to the sheet's used range (AutoResizeDataGrid), default and individual sizes are applied (Options.ImportCellSizes), pictures are added (Options.ImportImages), then each cell's merge, read-only state, appearance and value are imported row by row, raising OnProgress after each row.
Worksheet cell (XlsStartCol, XlsStartRow) is placed in grid cell (DataGridStartCol, DataGridStartRow). The names of all sheets are loaded into SheetNames as a side effect.
Parameters
| Name | Description |
|---|---|
FileName |
Path of the .xls workbook to import. |
SheetNumber |
One-based index of the worksheet. Values below 1 import the first sheet. |
Exceptions
| Exception | Description |
|---|---|
Exception |
Raised when no grid is assigned, or when SheetNumber is greater than the number of sheets in the workbook. |
Overload 3
Imports one worksheet, selected by name, of an XLS workbook into the grid.
procedure XLSImport(const FileName: TFileName; const SheetName: UTF16String); overload;
void __fastcall XLSImport(const System::Sysutils::TFileName FileName, const UTF16String SheetName)/* overload */;
Remarks
Use LoadSheetNames first to present the available names. Otherwise identical to the SheetNumber overload.
Parameters
| Name | Description |
|---|---|
FileName |
Path of the .xls workbook to import. |
SheetName |
Name of the worksheet, compared case-insensitively. When no sheet has this name, the first sheet is imported. |
Exceptions
| Exception | Description |
|---|---|
Exception |
Raised when SheetName is empty or no grid is assigned. |