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

is it possible?

How to do ?

thanks
LVL 1
hidrauAsked:
Who is Participating?
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.