Page 1 of 1

Exporting all series to xls

Posted: Mon Jan 25, 2010 9:50 am
by 9233301
Hi,

I'm using TeeChart V. 7.07 with BCB 6 and I want to export all series of a chart into an XLS file at runtime. How can I do that without executing the ChartEditor? (I'm unable to run the ChartEditor at runtime due to some really strange linker errors ("Unable to open file 'PENDLG.DFM'"); I'm pretty sure they just appear because I'm very moronic.)

Regards,

Susi

Re: Exporting all series to xls

Posted: Mon Jan 25, 2010 3:27 pm
by yeray
Hi Susi,

The following seems to work fine here in C++Builder 2010 and TeeChart Pro v8. Could you please try it?

Code: Select all

#include "TeeStore.hpp"
#include "TeExport.hpp"
//...
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TSeriesDataXML *tmpXML = new TSeriesDataXML(Chart1, NULL);

  tmpXML->IncludeIndex=true;
  tmpXML->SaveToFile("C:\\tmp\\test.xml");
}

Re: Exporting all series to xls

Posted: Tue Jan 26, 2010 10:35 am
by 9233301
Hi,

it worked like a charm. But for some reason, I can't manage to export the labels of the series into an xls file; you know, the labels from the legend. It's simply "Index", "X", "Y", "X", "Y" in the first row. IncludeLabels does nothing.

Regards,
S.

Re: Exporting all series to xls

Posted: Tue Jan 26, 2010 11:46 am
by yeray
Hi Susi,

The following code seems to export the labels fine for me here with TeeChart VCL 8.06. Isn't it working with the latest TeeChart VCL 7?

Code: Select all

#include "Series.hpp"
#include "TeeStore.hpp"
#include "TeeExport.hpp"
//...
void __fastcall TForm1::FormCreate(TObject *Sender)
{
	TBarSeries *bar1 = new TBarSeries(this);
	Chart1->AddSeries(bar1);

	for (int i = 0; i < 6; i++) {
		bar1->AddBar(random(100),"label nº" + IntToStr(i+1), clTeeColor);
	}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	TSeriesDataXML *tmpXML = new TSeriesDataXML(Chart1, NULL);

	tmpXML->IncludeIndex=true;
	tmpXML->IncludeLabels=true;
	tmpXML->SaveToFile("C:\\tmp\\test.xml");
}

Re: Exporting all series to xls

Posted: Tue Jan 26, 2010 4:37 pm
by 9233301
It works for all formats but XLS.

Re: Exporting all series to xls

Posted: Wed Jan 27, 2010 8:48 am
by yeray
Hi Susi,

Excuse me, I was reading XML where XLS was written. But I still have correct results here with v8.06 with the following code:

Code: Select all

#include "TeeStore.hpp"
#include "Series.hpp"
//...
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   TSeriesDataXLS *tmpXLS = new TSeriesDataXLS(Chart1, NULL);

   tmpXLS->IncludeIndex=true;
   tmpXLS->IncludeLabels=true;
   tmpXLS->SaveToFile("C:\\tmp\\test.xls");

}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
   TBarSeries *bar1 = new TBarSeries(this);
   Chart1->AddSeries(bar1);

   for (int i = 0; i < 6; i++) {
	  bar1->AddBar(random(100),"label nº" + IntToStr(i+1), clTeeColor);
   }
}
So I recommend you to try the TeeChart v8 eval version (or the v9 beta released yesterday)
http://www.steema.com/evaluation/vcl