Problem on setting SpreadSheet object as the DataSource of ChartSpace.

C

cindy liu

Hi,

I just tried to plot some data via OWC11 Chart object.
Since I cannot use array of int to plot a chart directly,
so I created OWC11 SpreadSheet object and populated some
data for it. So far so good! Now I have problem to assign
it to ChartSpace.DataSource. Here is my code...

private AxMicrosoft.Office.Interop.Owc11.AxSpreadsheet
axSpreadsheet1;
Range oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[2,1];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,5);
oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[2,2];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,5);

oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[3,1];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,1);
oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[3,2];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,1);

oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[4,1];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,9);
oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[4,2];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,5);

oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[5,1];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,12);
oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[5,2];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,0);

axChartSpace1.DataSource=(msdatasrc.DataSource)
axSpreadsheet1; // Error occurred here.

oSeries.SetData(ChartDimensionsEnum.chDimXValues,(int)
(ChartSpecialDataSourcesEnum.chDataBound),"A2:A5");
oSeries.SetData(ChartDimensionsEnum.chDimYValues,(int)
(ChartSpecialDataSourcesEnum.chDataBound),"B2:B5");

Can anyone help me out? Why setting a chart data is so
difficult?

Thanks in advance!
Cindy
 
T

Thao Moua [ms]

Your code looks right. Try this

-----------------------
axChartSpace1.DataSource=(msdatasrc.DataSource) (object)
axSpreadsheet1;
-----------------------

Thao Moua
OWC Webchart Support
-----Original Message-----
Hi,

I just tried to plot some data via OWC11 Chart object.
Since I cannot use array of int to plot a chart directly,
so I created OWC11 SpreadSheet object and populated some
data for it. So far so good! Now I have problem to assign
it to ChartSpace.DataSource. Here is my code...

private AxMicrosoft.Office.Interop.Owc11.AxSpreadsheet
axSpreadsheet1;
Range oRange=(Range)axSpreadsheet1.ActiveSheet.Cells [2,1];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,5);
oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[2,2];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,5);

oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[3,1];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,1);
oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[3,2];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,1);

oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[4,1];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,9);
oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[4,2];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,5);

oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[5,1];
oRange.set_Value
(XlRangeValueType.xlRangeValueDefault,12);
oRange=(Range)axSpreadsheet1.ActiveSheet.Cells[5,2];
oRange.set_Value(XlRangeValueType.xlRangeValueDefault,0);

axChartSpace1.DataSource=(msdatasrc.DataSource)
axSpreadsheet1; // Error occurred here.

oSeries.SetData(ChartDimensionsEnum.chDimXValues,(int)
(ChartSpecialDataSourcesEnum.chDataBound),"A2:A5");
oSeries.SetData(ChartDimensionsEnum.chDimYValues,(int)
(ChartSpecialDataSourcesEnum.chDataBound),"B2:B5");

Can anyone help me out? Why setting a chart data is so
difficult?

Thanks in advance!
Cindy
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top