使用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了解决这个问题的方法。
我希望这将有助于所有有同样问题的人。
//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();
干杯!
- TreeNode导出为Excel
- EPPlus不能正确调用不同工作表上的公式
- .NET导出为excel – 子行不显示
- 来自HRESULT的exception:0x8002000B(DISP_E_BADINDEX)for System.Runtime.InteropServices.COMException
- 如何将程序状态信息从应用程序级加载项存储在已保存的excel文件中?
- 无法使用openxml在Excel中设置所需的背景颜色
- VB.netexception德HRESULT:0x800A03EC(Excel)
- 使用c#从excel文件中删除行
- Excel API错误 – System.AccessViolationException:试图读取或写入受保护的内存