我在使用 C#.Net MVC 和 DLL (Microsoft.Office.Interop.Excel) 在 excel 中删除/隐藏 LINE CHART 中的网格线时遇到问题我想删除它或只是隐藏它,因为这是客户的需要。我看过很多文章,但它仍然不适合我。
Please click here for my sample excel
图像中的 3 个数字是我要删除或隐藏的东西。
这是我的 Border、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;
我的问题是网格线,请引用图片。
如有任何帮助,我们将不胜感激。
谢谢!
最佳答案
我已经找到了解决这个问题的方法。
希望对遇到同样问题的小伙伴有所帮助。
//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();
干杯!
关于c# - 使用 C#.net (Microsoft.Office.Interop.Excel) 在 Excel 中删除折线图中的网格线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41609230/