bonjour,
je désire piloter Excel depuis une application Delphi.
j'ai fait une partie du code qui ouvre un fichier excel, récupère dans le fichier excel le nombre de valeurs par données et le nombre de données à récupérer.
Ensuite, je désire lire en une seule fois la plage de valeurs comprise entre 2 cellules.
Cela marche parfaitement avec la notation suivante :
cellDebut := 'D12';
cellFin := 'CT545';
mais j'aimerais le faire fonctionner avec la notation L12C4 eà L545C98
Comment faire ?
Ci-joint le code :
ExcelApplication1.Connect;
ExcelApplication1.ReferenceStyle[xlR1C1];
MonClasseur := ExcelApplication1.Workbooks.Open('l:\bremen_trial3_5-6_5coils_normalized_EMO.xls', False, False,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0);
ExcelApplication1.Visible[0] := true;
MaFeuille := MonClasseur.Worksheets[1] AS _worksheet;
cellDebut := 'L'+ IntToStr(PremiereLigne) + 'C' + IntToStr(ColonneTemps);
colFin := nbDataReal +ColonneTemps;
ligneFin := PremiereLigne +nbColonnesTotal;
cellFin := 'L'+ IntToStr(ligneFin-1) + 'C' + IntToStr(colFin);
//cellDebut := 'D12';
//cellFin := 'CT545';
Resultat := MaFeuille.Range[cellDebut, cellFin].Value;
FOR comptLig := 1 TO VarArrayHighBound(Resultat, 1) DO
FOR comptCol := 1 TO VarArrayHighBound(Resultat, 2) DO
begin
mesValeurs[comptlig,comptcol] := Resultat[comptlig, comptcol];
Resultat[comptlig, comptcol] := Resultat[comptlig, comptcol] * 3 + 2;
StatusBar1.SimpleText := IntToStr(Resultat[comptlig, comptcol]) + ' valeurs pour ' + IntToStr(comptLig) + ' ligne' + IntToStr(comptCol) + ' colonnes';
end;
MaFeuille.Range[cellDebut, cellFin].Value := Resultat;
ExcelApplication1.disConnect;
merci pour votre aide