Autor Beitrag
Almidagu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Di 04.11.03 23:31 
Guten Abend,

ich suche die Möglichkeit, die Daten aus einem Bereich in Excel 2000 nach Delphi 3 zu übertragen. Aber nicht zellenweiße, sondern als ein Array.

Danke im Voraus
Almidagu
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Mi 05.11.03 08:31 
Hi!

Du kannst so

ausblenden Quelltext
1:
ExcelInstanz.Range['Zell1', 'Zell2'].Value;					


auf einen Zellbereich zugreifen und dann einer Variable vom Typ OLEVariant zuweisen.

Hab hier mal ein Beispiel gemacht:

www.swissdelphicente...showcode.php?id=1728
Almidagu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Mi 05.11.03 13:25 
Guten Tag Toms!

Vielen Dank für Deine Antwort. Dein Beispiel (www.swissdelphicente...howcode.php?id=1728) ist hilfreich

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
RangeMatrix := XLApp.Range['A1', XLApp.Cells.Item[X, Y]].Value; 
//  Define the loop for filling in the TStringGrid 
k := 1
repeat 
  for r := 1 to y do 
    AGrid.Cells[(r - 1), (k - 1)] := RangeMatrix[K, R]; 
  Inc(k, 1); 
  AGrid.RowCount := k + 1
until k > x; 
// Unassign the Delphi Variant Matrix 
RangeMatrix := Unassigned;


Ich dachte, dass ich ein Variant-Array definieren sollte.
Nächste Frage: Wo ist der Unterschied zwischen oberem und folgendem Code (z.B. nur eine Zeile)?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
k := 1
for r := 1 to y do 
begin
  RangeMatrix := XLApp.Range['A' + IntToStr(R)].Value; 
  AGrid.Cells[(r - 1), (k - 1)] := RangeMatrix; 
end;
AGrid.RowCount := k; 
// Unassign the Delphi Variant Matrix 
RangeMatrix := Unassigned;


Wie unterscheidet sich die Übertragungsgeschwindigkeit?

Mit freundlichen Grüssen
Almidagu