使用C#.net(Microsoft.Office.Interop.Excel)在Excel中删除LineChart中的网格线

我在使用C#.Net MVC与DLL( Microsoft.Office.Interop.Excel )删除/隐藏在Excel表格中的网格线的问题我想删除它或只是隐藏,因为这是客户端的需要。 我见过很多文章,但仍然不适合我。

请点击这里查看我的示例excel

图像中的3个数字是我想要移除或隐藏的东西。

这里是我的代码边框,ChartArea和PlotArea透明度。

//Plot Area chartPage.PlotArea.Format.Fill.Solid(); chartPage.PlotArea.Format.Fill.ForeColor.RGB = (int)XlRgbColor.rgbWhite; chartPage.PlotArea.Format.Fill.Transparency = (float)1; //Chart Area chartPage.ChartArea.Format.Fill.Solid(); chartPage.ChartArea.Format.Fill.ForeColor.RGB = (int)XlRgbColor.rgbWhite; chartPage.ChartArea.Format.Fill.Transparency = (float)1; //Border chartPage.ChartArea.Format.Line.ForeColor.RGB = (int)XlRgbColor.rgbWhite; chartPage.ChartArea.Format.Line.Transparency = (float)1; 

我的问题是网格线,请参考图像。

任何帮助,将不胜感激。

谢谢!

我已经find了解决这个问题的方法。

我希望这将有助于所有有同样问题的人。

示例Excel

 //This will get the X-Axis (#3 in the image) Axis xAxis = (Axis)chartPage.Axes(XlAxisType.xlValue, XlAxisGroup.xlPrimary); //This will get the Y-Axis (#2 in the image) Axis yAxis = (Axis)chartPage.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); //This will delete the Grid Lines (#1 in the image) xAxis.MajorGridlines.Delete(); //This will delete the X-Axis (#3 in the image) xAxis.Delete(); //This will delete the Y-Axis (#2 in the image) yAxis.Delete(); 

干杯!