C# - Excel 2013 how to change chart style

老子叫甜甜 提交于 2019-12-11 03:03:47

问题


I'm trying to chnage style for a chart in excel 2013 but it only changes color:

Range chartRange;
ChartObjects wsCharts = (ChartObjects)workSheet.ChartObjects(Type.Missing);
ChartObject myChart = (ChartObject)wsCharts.Add(0, 0, 900, 500);
Chart workChart = myChart.Chart;

chartRange = workSheet.get_Range("A1", "D12");
workChart.SetSourceData(chartRange, Type.Missing);
workChart.ChartType = XlChartType.xlColumnClustered;

now the chart looks like this:

and then workChart.ChartStyle = 8; changes the bar's color to:

instead of the chart's style to:

I also tried playing with the ChartWizard method and other properties of Chart but with no luck so far.


回答1:


Try

workChart.ChartStyle = 209;


来源:https://stackoverflow.com/questions/15504337/c-sharp-excel-2013-how-to-change-chart-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!