Page 1 of 1

SetName() works differently for GetXValues and GetYValues?

Posted: Mon Jun 19, 2006 10:51 am
by 9529132
Hi,

I would like to export a chart to a xls file with x and y have their own headers instead of just X and Y. So I tried this way

m_chart1.GetExport().GetAsXLS().SetIncludeHeader(TRUE);
m_chart1.GetExport().GetAsXLS().SetIncludeIndex(TRUE);
m_chart1.GetExport().GetAsXLS().SetIncludeLabels(FALSE);
m_chart1.Series(0).GetXValues().SetName("Degree");
m_chart1.Series(0).GetYValues().SetName("CH0");

However, in the xls file, I can only see two columns, one with a header "Index" and the other "CH0". It seems the SetName() works differently for GetXValues and GetYValues.

Any suggestions?

David

Posted: Mon Jun 19, 2006 11:20 am
by narcis
Hi David,

Are you using Add or AddXY method to populate your series? Using AddXY may solve this issue.

Posted: Mon Jun 19, 2006 2:03 pm
by 9529132
Hi, NarcĂ­s,

Actually I use AddRealTime since the series is defined as FastLine. Is it possible to realize it with AddRealTime?

Thanks
David

Posted: Tue Jun 20, 2006 12:41 pm
by narcis
Hi David,

It's quite weird as it works perfectly using VB6 but doesn't using Visual C++. I've added the issue (TA05011505) to our defect list to be investigated and, if necessary, fixed for future releases.

Posted: Tue Jun 27, 2006 8:49 am
by narcis
Hi David,

After more investigation we have found that if XValues are the same as the index the XValues column is not shown. This would happen when the for populating the series starts at 0, i.e.:

Code: Select all

	for (int i=0; i<100; i++) 
	{
		m_Chart1.Series(0).GetAsFastLine().AddRealTime(i,i*i,"",clTeeColor);
	}
According to this, the following code works fine:

Code: Select all

void CExcelExportDlg::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
	m_Chart1.AddSeries(scFastLine);

	for (int i=1; i<100; i++) 
	{
		m_Chart1.Series(0).GetAsFastLine().AddRealTime(i,i*i,"",clTeeColor);
	}

	m_Chart1.Series(0).GetXValues().SetName("Degree");
	m_Chart1.Series(0).GetYValues().SetName("CHO");	
}

void CExcelExportDlg::OnButton1() 
{
	VARIANT varX, varY;

	VariantInit(&varX);
	varX.vt = VT_BSTR;
	varX.bstrVal = m_Chart1.Series(0).GetXValues().GetName().AllocSysString();

	
	VariantInit(&varY);	
	varY.vt = VT_BSTR;
	varY.bstrVal = m_Chart1.Series(0).GetYValues().GetName().AllocSysString();


	m_Chart1.GetHeader().GetText().Add(varX);
	m_Chart1.GetHeader().GetText().Add(varY);

	m_Chart1.GetExport().GetAsXLS().SetIncludeHeader(true);
	m_Chart1.GetExport().GetAsXLS().SetIncludeIndex(true);
	m_Chart1.GetExport().GetAsXLS().SetIncludeLabels(false);
	
	m_Chart1.GetExport().GetAsXLS().SetSeries(COleVariant("0"));	
	m_Chart1.GetExport().GetAsXLS().SaveToFile("e:\\Temp\\MyTeeChart.xls");	
		
}
I've added an item to our wish-list to add a property to change the Index column header.