C# - Excel 2013 how to change chart style

2019-07-18 01:03发布

问题:

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;