Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to use a variant array to write data to Excel in one go Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
19-Dec-03
Category
OLE
Language
Delphi 5.x
Views
236
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to use a variant array to write data to Excel in one go 

Answer:

Here are a couple of examples of using a variant array to write data to Excel in 
one go:

1   { ... }
2   var
3     ArrV: OleVariant;
4     i: integer;
5     StartCell: OleVariant;
6     { ... }
7   
8   {Create a variant array with 5 rows (0 to 4) and 125 columns (0 to 124)}
9   ArrV := VarArrayCreate([0, 4, 0, 124], varVariant);
10  { ... }
11  for i := 0 to 124 do
12  begin
13    ArrV[0, i] := i;
14    ArrV[1, i] := '2';
15    ArrV[2, i] := 3;
16    ArrV[3, i] := 4;
17    ArrV[4, i] := 5;
18  end;
19  StartCell := WS.Cells.Item[8, 3];
20  WS.Range[StartCell, StartCell.Offset[4, 125]].Value2 := ArrV;
21  
22  {Create a variant array with 4 rows (0 to 3) and 2 columns (0 to 1)}
23  ArrV := VarArrayCreate([0, 3, 0, 1], varOleStr);
24  ArrV[0, 0] := 'First Column';
25  ArrV[0, 1] := 'Second Column';
26  ArrV[1, 0] := 'Second Row';
27  ArrV[2, 0] := 'Third Row';
28  ArrV[3, 0] := 'Fourth row';
29  ArrV[3, 1] := 'Fourth row, second column';
30  
31  {Write the array to a worksheet}
32  WS.Range['A1', 'B4'].Value := ArrV;
33  { ... }


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC