Search code examples
c#excelautomationoffice-interop

C# - Excel 2013 how to change chart style


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: original

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

instead of the chart's style to: enter image description here

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


Solution

  • Try

    workChart.ChartStyle = 209;