Page 1 of 2

Export excel file with header

Posted: Mon Jun 05, 2006 3:51 am
by 9529132
Hi,

I would like to export a chart as a xls file with headers like "xTime","yPosition" instead of X and Y only. I searched the functions and found only
m_chart1.Series(0).GetYValue.GetName()
no function like
m_chart1.Series(0).GetYValue.SetName().

How can I use headers other than the default X and Y when exporting xls file?

Thank you.
David

Posted: Wed Jun 07, 2006 2:12 am
by 9529132
And what is the purpose of giving a chart name as m_chart1.Series(0).SetName("CH1")? Will the name be displayed somewhere or can it be saved when exporting data?

David

Posted: Fri Jun 09, 2006 8:08 am
by Pep
Hi David,

which TeeChart Version are you using ?
Using the latest v7.07 you should be able to set the Header for X and YValues using the following code (vb code) :

Code: Select all

With TChart1
    .Series(0).FillSampleValues (10)
    .Export.asXLS.IncludeHeader = True
    .Series(0).YValues.Name = "YVals"
    .Export.asXLS.SaveToFile "c:\a.xls"
End With

Posted: Fri Jun 09, 2006 8:12 am
by Pep
Hi David,

about the Name, it will not be displayed nowhere. It's just to be able to assign a custom name to identificate.

From the Help :
You may change the name of a Series with this property. Use is optional, It is not necessary to name Series for them to function correctly. Use the Series.Title property to give Series titles to display in Legends and the Chart Editor.

Posted: Fri Jun 09, 2006 8:41 am
by 9529132
Pep wrote:

Code: Select all

With TChart1
    .Series(0).FillSampleValues (10)
    .Export.asXLS.IncludeHeader = True
    .Series(0).YValues.Name = "YVals"
    .Export.asXLS.SaveToFile "c:\a.xls"
End With
Hi, Pep,

I am using the latest v7.07 version. Would you please transfer this segment of code into VC++ code? I couldn't find a suitable function in VC++ for "Series(0).YValues.Name = "YVals"".

Thank you very much!
David

Posted: Fri Jun 09, 2006 12:47 pm
by Pep
Hi David,

yes, of course :

Code: Select all

	m_chart.AddSeries(0);
	m_chart.Series(0).FillSampleValues(10);
	m_chart.GetExport().GetAsXLS().SetIncludeHeader(true);
	m_chart.Series(0).GetYValues().SetName("MyYHeader");
	m_chart.GetExport().GetAsXLS().SaveToFile("myfile.xls");

Posted: Mon Jun 12, 2006 1:02 am
by 9529132
Hi, Pep,

How come I couldn't find the function SetName() and the auto-completion in VC++.NET doesn't have this function listed either. After I manually typed it and compiled it, there is an error saying
error C2039: 'SetName' : is not a member of 'CValueList'
Any suggestions? (I am using the lastest version)

David

Posted: Mon Jun 12, 2006 11:07 am
by narcis
Hi David,

It works fine for me here using v7.0.0.7 and including CValueList class in the project ClassView. Can you please check that?

Also notice that we have just posted 7.0.0.8 at our Customer Download Area.

Posted: Tue Jun 13, 2006 1:27 am
by 9529132
Hi, Pep,

It is so strange. I read the source code of valuelist.h and valuelist.cpp and there is no function named SetName(). Am I right to use the files under the folder \TeeChart Pro v7 ActiveX Control\Utilities\New VC Classes? Even after I installed the latest 7.0.0.8, I still can't found the function SetName(). I also tried the example projects for VC6, SetName() didn't work either.

So any idea what's wrong here?

David

PS: I included the CValuelist class in the valuelist.h

class CValueList : public COleDispatchDriver
{
public:
CValueList() {} // Calls COleDispatchDriver default constructor
CValueList(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
CValueList(const CValueList& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}

// Attributes
public:

// Operations
public:
long GetCount();
BOOL GetDateTime();
void SetDateTime(BOOL bNewValue);
double GetFirst();
double GetLast();
double GetMaximum();
double GetMinimum();
long GetOrder();
void SetOrder(long nNewValue);
double GetTotal();
double GetTotalABS();
double GetValue(long Index);
void SetValue(long Index, double newValue);
CString GetValueSource();
void SetValueSource(LPCTSTR lpszNewValue);
void Delete(long Index);
void FillSequence();
long Locate(double SomeValue);
void Sort();
BOOL GetModified();
void SetModified(BOOL bNewValue);
double GetTempValue();
void SetTempValue(double newValue);
CString GetName();
};

Posted: Tue Jun 13, 2006 8:17 am
by narcis
Hi David,

It works fine for me here having the CValueList class in the ClassView tab in Visual C++. If you wnat I'll send you the project I'm using.

Posted: Tue Jun 13, 2006 9:10 am
by 9529132
Hi, Narcís,

Please send me your project so that I could check if there is anything wrong with my development environment.

Thank you very much!
David

Posted: Tue Jun 13, 2006 9:21 am
by narcis
Hi David,

Ok, I've just sent a project using SetName to your forums contact e-mail address.

Posted: Tue Jun 13, 2006 10:31 am
by 9529132
Hi, Narcís,

I got the project file and I checked the valuelist.h file you included. The reason why it works fine in your project is because there is a function void SetName(LPCTSTR lpszNewValue); in your valuelist.h file. How come we have different files? Even the files in the lastes 7.0.0.8 doesn't have this function. Would you please check if the files released are the correct ones? I think it could be a serious issue if the released files are not the correct ones. As I attached in my last post, the content of my valuelist.h is different from yours at the last line. Below is the comparision.

The content of my valuelist.h (the last few lines only)
.....
void Sort();
BOOL GetModified();
void SetModified(BOOL bNewValue);
double GetTempValue();
void SetTempValue(double newValue);
CString GetName();
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

The content of the valuelist.h in the zipped file you emailed:
.........
void Sort();
BOOL GetModified();
void SetModified(BOOL bNewValue);
double GetTempValue();
void SetTempValue(double newValue);
CString GetName();
void SetName(LPCTSTR lpszNewValue); //Here is the difference :idea:
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

Would you please check why there is a difference?

Thank you very much!
David

Posted: Wed Jun 14, 2006 4:00 am
by 9529132
Hi, Narcís,

I also noticed that several other files are also different in size between those in your project and those in the folder \TeeChart Pro v7 ActiveX Control\Utilities\New VC Classes\, such as areaseries.h and cpp, annotationtool.h and cpp, etc. In your files there are some new functions. May I know why there is the difference?

Thank you very much!
David

Posted: Fri Jun 16, 2006 1:35 am
by 9529132
Any suggestions?