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

标签 c# .net asp.net-mvc excel linechart

我在使用 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;

我的问题是网格线,请引用图片。

如有任何帮助,我们将不胜感激。

谢谢!

最佳答案

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

希望对遇到同样问题的小伙伴有所帮助。

Sample 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();

干杯!

关于c# - 使用 C#.net (Microsoft.Office.Interop.Excel) 在 Excel 中删除折线图中的网格线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41609230/

相关文章:

c# - 检查时间范围是否在 C# 中相交

ASP.Net MVC – 找不到资源错误

c# - 使用 SimpleMembership (MySQL) 将用户添加到角色时出现外键问题

c# - Asp.Net ViewState 性能

c# - vsto 加载项中的本地化

.net - 如何创建 Azure 数字孪生备份并将其恢复到空 ADT 帐户中?

asp.net - 来自数据库的 Entity Framework 更新模型不为 tt 类中新添加的表生成 cs 类

asp.net - ASP .NET MVC2 中的 Web 服务

c# - 一旦知道字典的大小是固定的,有没有办法削减它的容量?

c# - .Net 中的大容量、高速文本框