I'm using C# to create an Excel sheet with a chart on it. I'm using a pie of pie chart because some of the data are very small and won't be visible in a normal pie chart. Everything works fine, but I need some help with formatting. I'll give you some code and hopefully you can help:
我正在使用C#创建一个带有图表的Excel工作表。我正在使用饼图,因为有些数据非常小,在普通饼图中不可见。一切正常,但我需要一些格式化方面的帮助。我会给你一些代码,希望你能提供帮助:
Excel.ChartObjects xlChart = (Excel.ChartObjects)xlWorksheet.ChartObjects(Type.Missing);
Excel.ChartObject myChart = (Excel.ChartObject)xlChart.Add(350, 30, 300, 250);
Excel.Chart chartPage = myChart.Chart;
range = xlWorksheet.get_Range("a3", "b6");
chartPage.SetSourceData(range, Excel.XlRowCol.xlColumns);
chartPage.ChartType = Excel.XlChartType.xlPieOfPie;
How can I specify which data I want to have in the secondary chart of the pie of pie chart?
如何在饼图饼图的辅助图表中指定我想要的数据?
1 个解决方案
#1
0
I finally found a solution:
我终于找到了解决方案:
myChart.Activate();
Excel.ChartGroup group = chartPage.ChartGroups(1);
//put the last 3 values in the second pie
group.SplitValue = 3;
#1
0
I finally found a solution:
我终于找到了解决方案:
myChart.Activate();
Excel.ChartGroup group = chartPage.ChartGroups(1);
//put the last 3 values in the second pie
group.SplitValue = 3;