Exporting selected series to Excel

TeeChart for ActiveX, COM and ASP
Post Reply
nbp
Newbie
Newbie
Posts: 15
Joined: Fri Apr 01, 2016 12:00 am

Exporting selected series to Excel

Post by nbp » Thu Oct 27, 2016 8:19 pm

I'm using TChart2015.ocx with C++ interface.

I want to export only a few of the line series on my chart to excel, not all of them. Is that possible? Also, I want to have just 1 column for X and multiple columns for my Y values. Is there an example that I can see to do this?

Regards
nbp.

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exporting selected series to Excel

Post by Yeray » Fri Oct 28, 2016 3:29 pm

Hello,

There was a VCL ticket reporting the xls generated from TeeChart couldn't be open with Excel >= 2013 (note TeeChart ActiveX is a wrapper from TeeChart VCL).
http://bugs.teechart.net/show_bug.cgi?id=1257

We fixed it for the TeeChart VCL v2016.19 recently published, adding the option to export to .xlsx. In Delphi:

Code: Select all

  with TSeriesDataXLSObject.Create(Chart1,nil) do
  try
    //IncludeIndex:=true;
    //IncludeHeader:=true;
    //IncludeColors:=true;
    //IncludeLabels:=true;
    SaveToFile('C:\tmp\exported.xlsx');

  finally
    Free;
  end;
For Excel < 2013 (and current LibreOffice, OpenOffice,...), the .xls still works fine in both TeeChart ActiveX and VCL/FMX.

Also note we expect to improve the new .xlsx option in a future:
http://bugs.teechart.net/show_bug.cgi?id=1669

This would allow you to call the export as many times as series you'd like to export, and all the data would be in the same .xlsx.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

nbp
Newbie
Newbie
Posts: 15
Joined: Fri Apr 01, 2016 12:00 am

Re: Exporting selected series to Excel

Post by nbp » Thu Feb 23, 2017 9:47 pm

I have several series on a chart. They all share the same X values, only differ in their Y values. Can I export them to Excel so that I only have a single column for the X values and multiple columns for the Y values? I'm using TChart ActiveX 2015 ocx component.

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exporting selected series to Excel

Post by Yeray » Fri Feb 24, 2017 8:52 am

Hello,

You can't choose which series to export. Instead, you could save your chart to a stream, remove the series you don't want in the xls, export the chart to an xls and reload the stream into your chart. Ie:

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False

  For i = 0 To 4
    TChart1.AddSeries scBar
    TChart1.Series(i).FillSampleValues
  Next i  
End Sub

Private Sub Command1_Click()
  Dim MyStream As Variant
  MyStream = TChart1.Export.asNative.SaveToStream(True)
  
  TChart1.RemoveSeries 2
  TChart1.RemoveSeries 1
  
  TChart1.Export.asXLS.IncludeHeader = True
  TChart1.Export.asXLS.IncludeIndex = True
  TChart1.Export.asXLS.SaveToFile "mytest.xls"
  
  TChart1.ClearChart
  TChart1.Import.LoadFromStream MyStream
End Sub
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

nbp
Newbie
Newbie
Posts: 15
Joined: Fri Apr 01, 2016 12:00 am

Re: Exporting selected series to Excel

Post by nbp » Wed Mar 08, 2017 10:52 pm

Has the above bug been fixed? The link above says it has been fixed on 10-28? If so, what release contains the fix?

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exporting selected series to Excel

Post by Yeray » Thu Mar 09, 2017 11:27 am

Hello,

I see the ticket #1257 was closed the 28th October 2016, but it was reopened the 7th December 2016. I'm reviewing what happened.
And the ticket #1669 hasn't been closed.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exporting selected series to Excel

Post by Yeray » Thu Mar 09, 2017 3:01 pm

Hello,
Yeray wrote:I see the ticket #1257 was closed the 28th October 2016, but it was reopened the 7th December 2016. I'm reviewing what happened.
The new feature allowing to export to xlsx was introduced in v2016.19. However, this option was refined adding support straight from the editor after v2016.19.That's why it was reopened.
Since the upcoming v2017.20 will include both changes, we are closing the ticket.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

nbp
Newbie
Newbie
Posts: 15
Joined: Fri Apr 01, 2016 12:00 am

Re: Exporting selected series to Excel

Post by nbp » Thu Mar 09, 2017 4:49 pm

Thanks for the reply.

So I just want to confirm that the 2017.20 build will include the feature to export only selected series to Excel?

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exporting selected series to Excel

Post by Yeray » Fri Mar 10, 2017 7:35 am

Hello,
nbp wrote:So I just want to confirm that the 2017.20 build will include the feature to export only selected series to Excel?
We are mixing TeeChart VCL and ActiveX here. Let me try to clarify:

You can already export a subset of series to .xls using the solution suggested above in current TeeChart ActiveX versions.
The only problem with that option is that the .xls won't open in Excel >= 2013 (you can open it in LibreOffice/OpenOffice instead).

With the current TeeChart VCL v2016.19 you are able to do the same with .xlsx and it will open in Excel >= 2013.
However, this runtime option still has to be ported to TeeChart ActiveX: #1670.
Will it fit your needs?

Finally, worth to mention here, with the coming TeeChart VCL v2017.20, and with the recently published TeeChart ActiveX v2017.0.0.0, the export to .xlsx is available through the editor:
VB6_2017-03-10_09-14-50.png
VB6_2017-03-10_09-14-50.png (15.02 KiB) Viewed 29152 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply