Если кратко:
uses
ComObj;
const
xlCellTypeLastCell = $0000000B;
var
ExcelApp, ExcelSheet: OLEVariant;
MyMass: Variant;
x, y: Integer;
begin
ExcelApp := CreateOleObject();
ExcelApp.Workbooks.Open();
ExcelSheet := ExcelApp.Workbooks[1].WorkSheets[1];
ExcelSheet.Cells.SpecialCells(xlCellTypeLastCell).Activate;
x := ExcelApp.ActiveCell.Row;
y := ExcelApp.ActiveCell.Column;
MyMass := ExcelApp.Range['A1', ExcelApp.Cells.Item[X, Y]].Value;
ExcelApp.Quit;
ExcelApp := Unassigned;
ExcelSheet := Unassigned;
end;
MyStringGrid.RowCount := x;
MyStringGrid.ColCount := y;
for x := 1 to MyStringGrid.ColCount do
for y := 1 to MyStringGrid.RowCount do
MyStringGrid.Cells[x-1, y-1] := MyMass[y, x];
Если с описанием:
https://space-base.ru/library/?book=8
|