EDN Admin
Well-known member
Basically Im trying to create an excel graph in c# with 4 series. The series come from 4 different columns in my data table. My problem is figuring out how to make a fifth column be the x values for each of the 4 series. Ive tried many different ways and
I been left very confused.
Here was my last attempt:
<div style="color:black; background-color:white
<pre>Excel.Range chartRange;
Excel.ChartObjects xlCharts = (Excel.ChartObjects)oSheet.ChartObjects(Type.Missing);
Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 250);
Excel.Chart chartPage = myChart.Chart;
<span style="color:green //creates a range for the y values
chartRange = oSheet.get_Range(<span style="color:#a31515 "E2:E131, F2:E131, G2:E131, I2:I131", Missing.Value);
<span style="color:green //sets the y values
chartPage.SetSourceData(chartRange, missing);
chartPage.ChartType = Excel.XlChartType.xlXYScatter;
<span style="color:green //sets the x values to the range A2 through A131
Excel.Series oSeries = (Excel.Series)chartPage.SeriesCollection(1);
oSeries.XValues = oSheet.get_Range(<span style="color:#a31515 "A2", <span style="color:#a31515 "A131");
[/code]
My graph has 7 series listed on the side, which I dont understand because there should only be 4.<br/>
Can anyone enlighten me on this?<br/>
<br/>
Thanks<br/>
<br/>
<br/>
View the full article
I been left very confused.
Here was my last attempt:
<div style="color:black; background-color:white
<pre>Excel.Range chartRange;
Excel.ChartObjects xlCharts = (Excel.ChartObjects)oSheet.ChartObjects(Type.Missing);
Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 250);
Excel.Chart chartPage = myChart.Chart;
<span style="color:green //creates a range for the y values
chartRange = oSheet.get_Range(<span style="color:#a31515 "E2:E131, F2:E131, G2:E131, I2:I131", Missing.Value);
<span style="color:green //sets the y values
chartPage.SetSourceData(chartRange, missing);
chartPage.ChartType = Excel.XlChartType.xlXYScatter;
<span style="color:green //sets the x values to the range A2 through A131
Excel.Series oSeries = (Excel.Series)chartPage.SeriesCollection(1);
oSeries.XValues = oSheet.get_Range(<span style="color:#a31515 "A2", <span style="color:#a31515 "A131");
[/code]
My graph has 7 series listed on the side, which I dont understand because there should only be 4.<br/>
Can anyone enlighten me on this?<br/>
<br/>
Thanks<br/>
<br/>
<br/>
View the full article