Home » excel » Gridlines in excel through interop

Gridlines in excel through interop

Posted by: admin March 9, 2020 Leave a comment

Questions:

Any idea where the setting is hiding for turning gridlines off while using excel 2003 from interop?

How to&Answers:

DisplayGridlines is a method on an Excel Window object.
For example:

ActiveWindow.DisplayGridlines = true

Answer:

using Excel = Microsoft.Office.Interop.Excel;
Excel.Application oXL;
oXL.Windows.get_Item(1).DisplayGridlines = false;

Answer:

oXL.Windows.Application.ActiveWindow.DisplayGridlines = false;

write the code just before save excel code line.

Answer:

Currently, using VS2012 and I did it as follows:

Excel.Application oXl = new Excel.Application();

oXl.Visible = false; // true for debug

Excel.Workbook wb = oXl.Workbooks.Add();
Excel.Worksheet ws = wb.Worksheets[1];

oXL.ActiveWindow.DisplayGridlines = false; //true is the default in Excel

Answer:

ActiveWorkbook.Windows(1).DisplayGridlines = True 'OR False