1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
   | var
  Excel : TExcelApplication;
  Page  : TExcelWorkbook;
  ID, i : integer;
begin
  Excel := TExcelApplication.Create(nil);
  Page := TExcelWorkbook.Create(nil);
 
  try
    ID := GetUserDefaultLCID;
    Excel.Visible[ID] := False;
 
    Page.ConnectTo(Excel.Workbooks.Open('mon_fichier.xls',
                   emptyparam, emptyparam, emptyparam, emptyparam,
                   emptyparam, emptyparam, emptyparam, emptyparam,
                   emptyparam, emptyparam, emptyparam, emptyparam, ID));
 
    // récupération de la valeur des cellules
    for i := 1 to 500 do // si fichier de 500 lignes
    begin
      ShowMessage(Page.Worksheets[1] as _Worksheet).Cells.Item[i, 2]); // pour la 2eme colonne
    end;
 
    Excel.Visible[lcId] := true;
    Page.Close;
    Page.Disconnect;
    Excel.Quit;
    Excel.Disconnect;
  finally
    Page.Free;
    Excel.Free;
  end;
end; | 
Partager