943,097 Members | Top Members by Rank

Ad:
Jan 15th, 2010
0

delphi export excel!

Expand Post »
hi I want my delphi DB that I made to export to excel file how it is possible?and the most important thing is delphi reports that I made I want them to export as excel files ,plz help me !!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
seto.girl is offline Offline
5 posts
since Dec 2009
Jan 16th, 2010
0
Re: delphi export excel!
Hi
I Send you an example that will be useful for you.
note that I use access database. you can use any kind of database instead.
Attached Files
File Type: zip ExportToExcerl.zip (311.0 KB, 2326 views)
Reputation Points: 12
Solved Threads: 10
Junior Poster in Training
fayyaz is offline Offline
66 posts
since Jun 2007
Jan 16th, 2010
0

explain plz

Hi i could not log in with my pre user ,,,thx for the example programm plz can you explain more how did you export access db to excel with delphi programm? and the sec question is if I wanted to export my report in delphi that I wrote with sql builder to excel what should I do? the third question is how did u convert ur delphi programm to an exe file? thx for the quick reply
Reputation Points: 10
Solved Threads: 0
Newbie Poster
setogirl is offline Offline
2 posts
since Jan 2010
Jan 16th, 2010
0
Re: delphi export excel!
Dear setogirl
I'm Sorry I don't know what is your mine about
Quote ...
i could not log in with my pre user
But about your Questions :
1- you can Export any kind of Data Base Table to Excel Sheet (not only Access Tables) by Flowing Code

procedure TForm1.Button1Click(Sender: TObject);
var
    XApp:Variant;
    sheet:Variant;
    r,c:Integer;
    row,col:Integer;
    filName:Integer;
    q:Integer;
begin
    XApp:=CreateOleObject('Excel.Application');
    XApp.Visible:=true;
    XApp.WorkBooks.Add(-4167);
    XApp.WorkBooks[1].WorkSheets[1].Name:='Sheet1';
    sheet:=XApp.WorkBooks[1].WorkSheets['Sheet1'];
    for filName:=0 to AdoQuery1.FieldCount-1 do
    begin
        q:=filName+1;
        sheet.Cells[1,q]:=AdoQuery1.Fields[filName].FieldName;
    end;
    for r:=0 to AdoQuery1.RecordCount-1 do
    begin
        for c:=0 to AdoQuery1.FieldCount-1 do
        begin
            row:=r+2;
            col:=c+1;
            sheet.Cells[row,col]:=AdoQuery1.Fields[c].AsString;
        end;
        AdoQuery1.Next;
    end;
    XApp.WorkSheets['Sheet1'].Range['A1:AA1'].Font.Bold:=True;
    XApp.WorkSheets['Sheet1'].Range['A1:K1'].Borders.LineStyle :=13;
    XApp.WorkSheets['Sheet1'].Range['A2:K'+inttostr(AdoQuery1.RecordCount-1)].Borders.LineStyle :=1;
    XApp.WorkSheets['Sheet1'].Columns[1].ColumnWidth:=16;
    XApp.WorkSheets['Sheet1'].Columns[2].ColumnWidth:=7;
    XApp.WorkSheets['Sheet1'].Columns[3].ColumnWidth:=19;
    XApp.WorkSheets['Sheet1'].Columns[4].ColumnWidth:=9;
    XApp.WorkSheets['Sheet1'].Columns[5].ColumnWidth:=9;
    XApp.WorkSheets['Sheet1'].Columns[6].ColumnWidth:=9;
    XApp.WorkSheets['Sheet1'].Columns[7].ColumnWidth:=46;
    XApp.WorkSheets['Sheet1'].Columns[8].ColumnWidth:=9;
    XApp.WorkSheets['Sheet1'].Columns[9].ColumnWidth:=7;
    XApp.WorkSheets['Sheet1'].Columns[10].ColumnWidth:=6;
    XApp.WorkSheets['Sheet1'].Columns[11].ColumnWidth:=13;
end;

ADOQuery1 Is a SQL Query that can connect to many kind of Data Base such as SQLServer,Oracle,Access,etc
2- as I explained you can export any Query Result to Excel sheet .
consider that your report is the result of a SQL Statement that wrote in a Query Object. and by above Code you can export it to Excel Sheet.
3-If you compile your code , delphi compiler make an exe file for your Project automaticly
I hope that my explanation be useful for you.
Reputation Points: 12
Solved Threads: 10
Junior Poster in Training
fayyaz is offline Offline
66 posts
since Jun 2007
Jan 18th, 2010
0

Exporting to Excel

Click to Expand / Collapse  Quote originally posted by seto.girl ...
hi I want my delphi DB that I made to export to excel file how it is possible?and the most important thing is delphi reports that I made I want them to export as excel files ,plz help me !!
This is very simple actually ...I have also written some software that you can export your data to several formats..
for example
Aceess DB,
Excel
PDF
XML
MS Word Doc.
I have some of my software for sale for as little as $29.95 checkout my web site as well to see just a list of what we do. http://presoftsol.com
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wylddev is offline Offline
9 posts
since Jan 2010
Mar 30th, 2010
0
Re: delphi export excel!
thank you.very very much!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
traixubac is offline Offline
1 posts
since Mar 2010
Mar 30th, 2010
0
Re: delphi export excel!
Click to Expand / Collapse  Quote originally posted by traixubac ...
thank you.very very much!
Did my code help out...?
I hope it did..
you're welcome.
I would appreciate some comments on my code in positive fashion
thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wylddev is offline Offline
9 posts
since Jan 2010
Mar 30th, 2010
0
Re: delphi export excel!
I really need to know what it is exactly you are trying to do..
if you could write or send me a spec of what it is exactly you are trying to do I could help you code this with no problem.
in order to get my code to work you need to drop a TButton on to a TForm.
replace my procedure call name with what ever name you named your button..
I am giving you the simplest example believe it or not..
let me know what it is you want to do..

Thanks

Click to Expand / Collapse  Quote originally posted by fayyaz ...
Dear setogirl
I'm Sorry I don't know what is your mine about

But about your Questions :
1- you can Export any kind of Data Base Table to Excel Sheet (not only Access Tables) by Flowing Code

procedure TForm1.Button1Click(Sender: TObject);
var
    XApp:Variant;
    sheet:Variant;
    r,c:Integer;
    row,col:Integer;
    filName:Integer;
    q:Integer;
begin
    XApp:=CreateOleObject('Excel.Application');
    XApp.Visible:=true;
    XApp.WorkBooks.Add(-4167);
    XApp.WorkBooks[1].WorkSheets[1].Name:='Sheet1';
    sheet:=XApp.WorkBooks[1].WorkSheets['Sheet1'];
    for filName:=0 to AdoQuery1.FieldCount-1 do
    begin
        q:=filName+1;
        sheet.Cells[1,q]:=AdoQuery1.Fields[filName].FieldName;
    end;
    for r:=0 to AdoQuery1.RecordCount-1 do
    begin
        for c:=0 to AdoQuery1.FieldCount-1 do
        begin
            row:=r+2;
            col:=c+1;
            sheet.Cells[row,col]:=AdoQuery1.Fields[c].AsString;
        end;
        AdoQuery1.Next;
    end;
    XApp.WorkSheets['Sheet1'].Range['A1:AA1'].Font.Bold:=True;
    XApp.WorkSheets['Sheet1'].Range['A1:K1'].Borders.LineStyle :=13;
    XApp.WorkSheets['Sheet1'].Range['A2:K'+inttostr(AdoQuery1.RecordCount-1)].Borders.LineStyle :=1;
    XApp.WorkSheets['Sheet1'].Columns[1].ColumnWidth:=16;
    XApp.WorkSheets['Sheet1'].Columns[2].ColumnWidth:=7;
    XApp.WorkSheets['Sheet1'].Columns[3].ColumnWidth:=19;
    XApp.WorkSheets['Sheet1'].Columns[4].ColumnWidth:=9;
    XApp.WorkSheets['Sheet1'].Columns[5].ColumnWidth:=9;
    XApp.WorkSheets['Sheet1'].Columns[6].ColumnWidth:=9;
    XApp.WorkSheets['Sheet1'].Columns[7].ColumnWidth:=46;
    XApp.WorkSheets['Sheet1'].Columns[8].ColumnWidth:=9;
    XApp.WorkSheets['Sheet1'].Columns[9].ColumnWidth:=7;
    XApp.WorkSheets['Sheet1'].Columns[10].ColumnWidth:=6;
    XApp.WorkSheets['Sheet1'].Columns[11].ColumnWidth:=13;
end;

ADOQuery1 Is a SQL Query that can connect to many kind of Data Base such as SQLServer,Oracle,Access,etc
2- as I explained you can export any Query Result to Excel sheet .
consider that your report is the result of a SQL Statement that wrote in a Query Object. and by above Code you can export it to Excel Sheet.
3-If you compile your code , delphi compiler make an exe file for your Project automaticly
I hope that my explanation be useful for you.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wylddev is offline Offline
9 posts
since Jan 2010
Dec 3rd, 2011
0
Re: delphi export excel!
what about intraweb and export to excel?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tco9998 is offline Offline
1 posts
since Dec 2011
Dec 4th, 2011
0
Re: delphi export excel!
Maybe I am missing something, but it is easy enough to have Delphi to write to a text file.
Put a comma or semicolon between all columns on each row.
Add a #13 (Carrier return) at end of row.
Then start next row.

Excel can easily import a comma or semicolon delimited textfile, and everything is ok.

It does not actually make an Excel file, but it is readable and importable by Excel.
Best regards.
Reputation Points: 37
Solved Threads: 1
Light Poster
Morten Brendefu is offline Offline
44 posts
since Mar 2011
Message:
Previous Thread in Pascal and Delphi Forum Timeline: pascal:increasing the array
Next Thread in Pascal and Delphi Forum Timeline: Direct arranging of an array





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC