TChart Export to Excel

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
jogi
Newbie
Newbie
Posts: 5
Joined: Tue Aug 16, 2005 4:00 am

TChart Export to Excel

Post by jogi » Thu May 29, 2008 11:08 am

First: D7, XP, TeeChart Pro 7.07.

I use a Tchart to display Measurement Data (each Minute) from different sources using LineSeries.
All series using just one X-Axis displaying data over the time from times between 0:00 to 24:00.

Image

I want to Export this Data to one Excel File.

I've done it using the:
TSeriesDataXLS.Create(Chart1,nil)...
method.

Now the problems:

1. Is it possible only to export the active series or some selected series?
I just found solutions for one or all series. But If I use all - it exports
also the inactive series...

2. the exported file contains allway pairs of X and Y. (X,Y,X,Y,...)
Is it possibe to export only one X (timebase) like X, y1, y2, y3...

3. I managed to export the legends Title using that example - but how do I do it for ONE x-Axis (if possible)?

4. How can I export the X-Axis Data as DateTime and not as real?

Thanks in advance
Jogi

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 29, 2008 12:07 pm

Hi Jogi,

Please find below the answers to your questions:
1. Is it possible only to export the active series or some selected series?
I just found solutions for one or all series. But If I use all - it exports
also the inactive series...
You can create a dummy chart without inactive series like this:

Code: Select all

Uses TeeStore, TeExport;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Chart1.SeriesCount-1 do
  begin
    Chart1[i].FillSampleValues();
    if i mod 2 <> 0 then Chart1[i].Active:=false;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var tmpChart: TChart;
    i: Integer;
begin
  //Create dummy chart without inactive series
  tmpChart := TChart.Create(Self);

  for i:=Chart1.SeriesCount-1 downto 0 do
    if Chart1[i].Active then
      CloneChartSeries(Chart1.Series[i]).ParentChart := tmpChart;

  { nil = all series in Chart1 }
  with TSeriesDataXLS.Create(tmpChart,nil) do
  try
    IncludeIndex:=true;
    IncludeHeader:=true;

    SaveToFile('c:\temp\exceltest.xls');
    ShowSavedFile;
  finally
    Free;
  end;

  tmpChart.Free;
end;

procedure TForm1.ShowSavedFile;
begin
  TeeGotoURL(Handle,'c:\temp\exceltest.xls');
end;
2. the exported file contains allway pairs of X and Y. (X,Y,X,Y,...)
Is it possibe to export only one X (timebase) like X, y1, y2, y3...
Using code example above already does it.
3. I managed to export the legends Title using that example - but how do I do it for ONE x-Axis (if possible)?
You can do something like the example below. I'm afraid it's not possible to only include one single XValues column:

Code: Select all

Uses TeeConst, TeeStore, TeExport;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Chart1.SeriesCount-1 do
  begin
    Chart1[i].XValues.DateTime:=true;
    Chart1[i].FillSampleValues();
    if i mod 2 <> 0 then Chart1[i].Active:=false;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var tmpChart: TChart;
    i: Integer;
begin
  //Create dummy chart without inactive series
  tmpChart := TChart.Create(Self);

  for i:=Chart1.SeriesCount-1 downto 0 do
    if Chart1[i].Active then
    begin
      CloneChartSeries(Chart1[i]).ParentChart := tmpChart;
      tmpChart[tmpChart.SeriesCount-1].XValues.Name:='MyXValues';
      tmpChart[tmpChart.SeriesCount-1].YValues.Name:='MyYValues';
      TeeMsg_Text := 'CustomTextName';
    end;

  { nil = all series in Chart1 }
  with TSeriesDataXLS.Create(tmpChart,nil) do
  try
    IncludeIndex:=true;
    IncludeHeader:=true;
    IncludeLabels:=true;

    SaveToFile('c:\temp\exceltest.xls');
    ShowSavedFile;
  finally
    Free;
  end;

  tmpChart.Free;
end;

procedure TForm1.ShowSavedFile;
begin
  TeeGotoURL(Handle,'c:\temp\exceltest.xls');
end;
4. How can I export the X-Axis Data as DateTime and not as real?
You have to do that in Excel and set the columns format you wish to DateTime.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

jogi
Newbie
Newbie
Posts: 5
Joined: Tue Aug 16, 2005 4:00 am

Post by jogi » Thu May 29, 2008 2:02 pm

Hi Narcís,

thanks for the quick reply - the steema support is always fast and good - a pleasure!

But - one problem ist still there:
narcis wrote:[...]
2. the exported file contains allway pairs of X and Y. (X,Y,X,Y,...)
Is it possibe to export only one X (timebase) like X, y1, y2, y3...
Using code example above already does it.
[...]
If I do a clean project your code (for topic 2) works, but in my program I always get: X,Y,X,Y,...

I figured out, that if I add the:
Chart1.XValues.DateTime:=true;
in the "OnCreate Event" it also happens in the clean program.

So setting the DateTime Property prevents the program to export just a single X-axis.

Any solutions?

Thanks
Jogi

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 29, 2008 2:25 pm

Hi Jogi,

I'm afraid not. Seems XValues are automatically included when they are not automatically sequential generated values (eg.: 0,1,2,3,...). I'll add your request to our wish-list to be considered for inclusion in future releases.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

jogi
Newbie
Newbie
Posts: 5
Joined: Tue Aug 16, 2005 4:00 am

Post by jogi » Thu May 29, 2008 2:45 pm

Hi Narcís,

OK - thank you anyway.

But future releases are no updates to TeeChart7 - or are they?

Best Regards
Jogi

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 29, 2008 2:55 pm

Hi Jogi,

No, there are no plans to implement new features in TeeChart v7. They would be included in v8 or future versions.

TeeChart VCL optionally is also sold with full sourcecode so that clients can customize it to fit their needs.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply