I have one query regarding column charts in Excel.

How do I set gap width property in column clustered charts in Excel using C#

Following is my code snippet

Code Snippet

xlSeries4 = (Excel.Series)xlChart.SeriesCollection(4);

xlSeries4.AxisGroup = Excel.XlAxisGroup.xlSecondary;

xlSeries4.ChartType = Excel.XlChartType.xlColumnClustered;

I want to decrease the gap width of xlSeries4 to minimum value. I am using Excel 2007.

Please help me out of this.


Re: Visual Studio Tools for Office Gap width property in column clustered charts in Excel 2007 using C#


The solution for above problem is below

Code Snippet

Excel.Workbook xlBookScript = null;

Excel.Series xlSeriesVol = null;

xlSeriesVol = (Excel.Series)xlChart.SeriesCollection(4);

xlSeriesVol.AxisGroup = Excel.XlAxisGroup.xlSecondary;

xlSeriesVol.ChartType = Excel.XlChartType.xlColumnClustered;

Excel.ChartGroup cc = xlBookScript.ActiveChart.ChartGroups(1) as Excel.ChartGroup;

cc.GapWidth = 10;