• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

How can I export Adoquery result to excel in delph D5i?

is it possible?

How to do ?

thanks
0
hidrau
Asked:
hidrau
  • 3
  • 2
2 Solutions
 
ThommyCommented:

This is how you can do it...
MyExcel:=CreateOleObject('Excel.Application');
 MyXlBook:=MyExcel.Workbooks.Add();
 For i:=0 to AdoQuery.FieldCount-1 do
     MyExcel.WorkBooks[1].Sheets[1].Cells[1,i+1]:=AdoQuery.Fields[i].FieldName;
 j:=2;
 AdoQuery.First;
 while not AdoQuery.Eof do begin
     For i:=0 to AdoQuery.FieldCount-1 do
        MyExcel.WorkBooks[1].Sheets[1].Cells[j,i+1]:=AdoQuery.Fields[i].AsString;
     inc(j);
     AdoQuery.Next;
 end;
 MyExcel.Visible:=True;

Open in new window

0
 
hidrauAuthor Commented:
thommy

that's great.

How can I paint a cell? do you know?
0
 
ThommyCommented:
Should work somehow like that...

Paint a cell
MyExcel.WorkBooks[1].Sheets[1].Cells[aRow, aCol].Interior.Color := ColorToRGB(yourColor);

Paint a column
MyExcel.WorkBooks[1].Sheets[1].Columns[aCol].Interior.Color := ColorToRGB(yourColor);

Paint a row
MyExcel.WorkBooks[1].Sheets[1].Rows[aRow].Interior.Color := ColorToRGB(yourColor);
0
 
hidrauAuthor Commented:
thanks very much
0
 
ThommyCommented:
Thank you for the points!!!!
:o)))
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now