使用带有DLL的 C#.Net MVC ( 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;
我的问题是网格线,请参考图片。
任何帮助都将不胜感激。
谢谢!
答案 0 :(得分:0)
我已经找到了解决这个问题的方法。
我希望这会对所有遇到同样问题的人有所帮助。
//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();
干杯!