Author: Deborah Pate
How to copy an Excel range into a two-dimensional array
Answer:
Copy it to a variant, then read the resulting variant array. This will be much
faster than reading from each Excel cell individually, and it will avoid an Excel
resource leak that can be critical on Win9x systems.
1 { ... }2 var3 ArrV: OleVariant;
4 { ... }5 6 ArrV := WS.UsedRange[LCID].Value2;
7 for Row := 1 to VarArrayHighBound(ArrV, 1) - 1 do8 for Col := 1 to VarArrayHighBound(ArrV, 2) - 1 do9 Memo1.Lines.Add(Format('Row: %d Col: %d %s', [Row, Col, VarToStr(ArrV[Row,
10 Col])]));
11 end;
12 { ... }