glant glant - 1 month ago 14
Vb.net Question

Hide the gridlines in Excel Chart winforms vb.net

My winforms application creates an excel spreadsheet with a column chart. I am trying to hide the gridlines in the Chart. Appreciate the help Thanks

'Create a Chart
Dim ChartPage As Excel.Chart
Dim xlCharts As Excel.ChartObjects
Dim myChart As Excel.ChartObject
Dim chartRange As Excel.Range

xlCharts = xlWorkSheet.ChartObjects
myChart = xlCharts.Add(10, 80, 700, 450)
ChartPage = myChart.Chart
chartRange = xlWorkSheet.Range("A10", "K13")
ChartPage.SetSourceData(Source:=chartRange)
ChartPage.ChartType = Excel.XlChartType.xlColumnStacked

Answer

I regret I am not conversant in VB.net, but I'll bet you can quickly convert this C# interop code that will remove the gridlines:

myChart.Chart.Axes(Excel.XlAxisType.xlValue).MajorGridLines.Delete();
Comments