Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack - special offer!

Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

WinAPI Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
cdtrrracks.com new!

Blogspot  greatis.blogspot.com

Get data from excel file - Others - Tips & Tricks - Greatis Delphi Pages

This example shows, how to run Excel, open *.xls file and get data of this file into StringGrid component.
Don't forget add ComObj in uses chapter.


procedure TForm1.Button1Click(Sender: TObject);
begin
  Excel:=CreateOleObject('Excel.Application');
  Excel.Visible:=True;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Excel.Workbooks.Open(GetCurrentDir+'\book1.xls');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Excel.Workbooks.Close;
end;

procedure TForm1.Button4Click(Sender: TObject);
var
  i, j: Integer;
begin
  for i:=1 to 4 do
    for j:=1 to 2 do
      StringGrid1.Cells[j,i]:=
        Excel.ActiveSheet.Cells[i,j].Value;
end;
Related topics
Work with word document

For more
Delphi Help

Download source