I'm having trouble creating charts in Excel using C #. I managed to get a chart of any kind, working with the following code:
Excel.Range chartRange;
Excel.ChartObjects xlCharts = (Excel.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing);
Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 250);
Excel.Chart chartPage = myChart.Chart;
chartRange = xlWorkSheet.get_Range("A2", "Y2");
chartPage.SetSourceData(chartRange, misValue);
chartPage.ChartType = Excel.XlChartType.xlColumnClustered;
Unfortunately, I'm not quite sure what to do next. Here is what I want to do:
1) It is assumed that these are several rows of data, but they are not next to each other (for example, A2: Y2; A4: Y4; A6: Y6;). How to add each of them to the chart?
2) A1: Y1 has all the meanings for my legend, how would I add this to the legend?
3) How can I change it so that each chart is created in a new tab?
Thanks!
source
share