How to bind spreadsheet data to OWCChart in C#

F

Fu Ruijin

Hi,

I am using OWC10 to plot a chart from data in spreadsheet. Strangely, I
could not see any data displayed in my chart. Would anybody help me on this
issue? Thanks millions! Following is my code:

OWC10.ChartSpace cs = BuildChartSpace(GetViewLevel(doc), defectCount);
OWC10.ChChart pChart = cs.Charts[0];

OWC10.Spreadsheet spSheet = new OWC10.SpreadsheetClass();
cs.DataSource = (msdatasrc.DataSource)spSheet;

pChart.SeriesCollection.Add(0);
pChart.SeriesCollection[0].Caption = "R1"
pChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimCategories, (int)OWC10.ChartSpecialDataSourcesEnum.chDataBound, "$A$1:$A$3");
pChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimValues,
(int)OWC10.ChartSpecialDataSourcesEnum.chDataBound, "$B$1:$B$3");

pChart.SeriesCollection.Add(1);
pChart.SeriesCollection[1].Caption = "R2"
pChart.SeriesCollection[1].SetData(OWC10.ChartDimensionsEnum.chDimCategories,(int)OWC10.ChartSpecialDataSourcesEnum.chDataBound, "$A$1:$A$3");
pChart.SeriesCollection[1].SetData(OWC10.ChartDimensionsEnum.chDimValues,
(int)OWC10.ChartSpecialDataSourcesEnum.chDataBound, "$C$1:$C$3");
 
G

Guest

you need to drag a field into the chart.

i dont know why; it sure looks like this is broken-- (it seems like it
shoudl display multiple fields for example)

what version of office are you using??


Fu Ruijin said:
Hi,

I am using OWC10 to plot a chart from data in spreadsheet. Strangely, I
could not see any data displayed in my chart. Would anybody help me on this
issue? Thanks millions! Following is my code:

OWC10.ChartSpace cs = BuildChartSpace(GetViewLevel(doc), defectCount);
OWC10.ChChart pChart = cs.Charts[0];

OWC10.Spreadsheet spSheet = new OWC10.SpreadsheetClass();
cs.DataSource = (msdatasrc.DataSource)spSheet;

pChart.SeriesCollection.Add(0);
pChart.SeriesCollection[0].Caption = "R1";
pChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimCategories
, (int)OWC10.ChartSpecialDataSourcesEnum.chDataBound, "$A$1:$A$3");
pChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimValues,
(int)OWC10.ChartSpecialDataSourcesEnum.chDataBound, "$B$1:$B$3");

pChart.SeriesCollection.Add(1);
pChart.SeriesCollection[1].Caption = "R2";
pChart.SeriesCollection[1].SetData(OWC10.ChartDimensionsEnum.chDimCategories
,(int)OWC10.ChartSpecialDataSourcesEnum.chDataBound, "$A$1:$A$3");
pChart.SeriesCollection[1].SetData(OWC10.ChartDimensionsEnum.chDimValues,
(int)OWC10.ChartSpecialDataSourcesEnum.chDataBound, "$C$1:$C$3");
 

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