كود :
implementation
{$R *.dfm}
uses comobj;
procedure TForm2.Button1Click(Sender: TObject);
var
xlApp,xlSheet,xlFile:Variant;
line:integer;
S1,S2,S3:string;
begin
xlApp:= CreateOleObject('Excel.Application');
try
xlApp.Visible := False;
xlApp.DisplayAlerts := False;
xlFile := xlApp.Workbooks.Open('C:\Users\user33\Documents\test.xlsx');
xlSheet:=xlFile.Sheets['Feuil1'];
for line := 1 to 10 do
begin
S1:=VarToStr(xlSheet.Cells[1].Item[line].value);
S2:=VarToStr(xlSheet.Cells[2].Item[line].value);
S3:=VarToStr(xlSheet.Cells[3].Item[line].value);
ShowmessageFmt('%s ; %s ; %s',[S1,S2,S3]);
end;
finally
xlApp.Quit;
end;
end;
