VCL2010 LoadChartFromStream Issue: "Wrong *.tee file format"

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
sajtab
Newbie
Newbie
Posts: 6
Joined: Thu Aug 26, 2010 12:00 am

VCL2010 LoadChartFromStream Issue: "Wrong *.tee file format"

Post by sajtab » Mon Sep 20, 2010 5:29 pm

Hi,

I am using TeeChart Standard 9 and facing an issue with saving and loading charts from a TStream object. Upon loading from a TStream object using the LoadChartFromStream I get a runtime ChartException indicating "Wrong *.tee file format". Can someone help me figure out what's wrong in the code below?

Code: Select all

#include "export_chart_sample.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Chart"
#pragma link "Series"
#pragma link "TeEngine"
#pragma link "TeeProcs"
#pragma link "TeeStore"
#pragma link "TeeEdiSeri"
#pragma link "TeExport"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
   TStringStream * myStream = new TStringStream();
   SaveChartToStream(Chart1, myStream);
   LoadChartFromStream(static_cast<Chart::TCustomChart*>(Chart1), myStream);
}
Thanks,

Sajjad

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: VCL2010 LoadChartFromStream Issue: "Wrong *.tee file format"

Post by Sandra » Tue Sep 21, 2010 2:02 pm

Hello sajtab,

I think that you need to set myStream.Position := 0 before reading from it . Next lines of code explains exactly, how you do to load stream:

Code: Select all

 1) Save the template into a Stream...
  TMemoryStream *tmp = new TMemoryStream();
 
    // save only Chart and Series formatting, not data
    SaveChartToStream(TemplateChart,tmp,false);

    // 2) Load the template...

    // Reset stream position to begin:
    tmp->Position=0;

    // Load chart reference from stream:
    LoadChartFromStream(dynamic_cast<TCustomChart*>(Chart1),tmp);
Could you please, say us if previous code solve your problem?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

sajtab
Newbie
Newbie
Posts: 6
Joined: Thu Aug 26, 2010 12:00 am

Re: VCL2010 LoadChartFromStream Issue: "Wrong *.tee file format"

Post by sajtab » Tue Sep 21, 2010 9:48 pm

Thank you very much for your help. Not resetting the TStream objects Position field to 0 was the problem.

Sajjad

Post Reply