exporting to excel

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Patrik
Newbie
Newbie
Posts: 4
Joined: Tue Jun 15, 2004 4:00 am
Location: Stockholm, Sweden

exporting to excel

Post by Patrik » Tue Nov 02, 2004 11:43 am

Hi!

I want to export the data in a chart to excel. I use this code:

with TSeriesDataXLS.Create(chart1,nil) do
try
includeindex:=true;
IncludeHeader := True;
IncludeLabels := True;
CopyToClipboard;
finally
Free;
end;

but it doesn't work. When I paste in Excel I get empty cells. The number of empty cells differs so it does something. If my piechart for instance has 4 pieces I get 4 empty cells and so on.

If I change "CopyToClipboard;" to "SaveToFile('c:\test.xls');" it works but
I would like to avoid the actual excel-file. The users of my application have to be able to copy the chart-data into an existing excel document.

What do I do wrong?

/Patrik

Pep
Site Admin
Site Admin
Posts: 3298
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Nov 02, 2004 4:02 pm

Hi Patrik,

to do a copy/paste of the data to Excel file you must export the data as text to a ClipBoard and then you will be able to paste it on excel sheet.

Patrik
Newbie
Newbie
Posts: 4
Joined: Tue Jun 15, 2004 4:00 am
Location: Stockholm, Sweden

Post by Patrik » Wed Nov 03, 2004 8:55 am

Thanks for ur answer, but how do I do that? I thought the CopyToClipboard command did exactly that.

Some example code or a link do some other help would be much appreciated.

Thanks in advance.

Pep
Site Admin
Site Admin
Posts: 3298
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Nov 03, 2004 11:22 am

Hi Patrik,

you can use the following code :

Code: Select all

     with TSeriesDataText.Create(Chart1,nil) do
     try
       TextDelimiter:=',' ;  { try also: TeeTabDelimiter }
       IncludeIndex:=true;
       CopyToClipBoard;
     finally
       Free;
     end;

Post Reply