Page 1 of 1

Exporting selected series to Excel

Posted: Thu Oct 27, 2016 8:19 pm
by 16677938
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.

Re: Exporting selected series to Excel

Posted: Fri Oct 28, 2016 3:29 pm
by yeray
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.

Re: Exporting selected series to Excel

Posted: Thu Feb 23, 2017 9:47 pm
by 16677938
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.

Re: Exporting selected series to Excel

Posted: Fri Feb 24, 2017 8:52 am
by yeray
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

Re: Exporting selected series to Excel

Posted: Wed Mar 08, 2017 10:52 pm
by 16677938
Has the above bug been fixed? The link above says it has been fixed on 10-28? If so, what release contains the fix?

Re: Exporting selected series to Excel

Posted: Thu Mar 09, 2017 11:27 am
by yeray
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.

Re: Exporting selected series to Excel

Posted: Thu Mar 09, 2017 3:01 pm
by yeray
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.

Re: Exporting selected series to Excel

Posted: Thu Mar 09, 2017 4:49 pm
by 16677938
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?

Re: Exporting selected series to Excel

Posted: Fri Mar 10, 2017 7:35 am
by yeray
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 27226 times