Back to Devexpress

Use the Excel Export API to Show and Hide Gridlines

officefileapi-114474-excel-export-library-worksheets-how-to-show-and-hide-gridlines.md

latest1.4 KB
Original Source

Use the Excel Export API to Show and Hide Gridlines

  • Sep 19, 2023

The example below demonstrates how to control the visibility of worksheet gridlines (the faint lines that separate rows and columns in a worksheet). To do this, use the IXlSheetViewOptions.ShowGridLines property of the IXlSheetViewOptions object that contains worksheet display settings and can be accessed using the IXlSheet.ViewOptions property.

View Example

csharp
// Create a worksheet. 
using (IXlSheet sheet = document.CreateSheet())
{
    // Hide gridlines on the worksheet.
    sheet.ViewOptions.ShowGridLines = false;
}
vb
' Create a worksheet. 
Using sheet As IXlSheet = document.CreateSheet()
    ' Hide gridlines on the worksheet.
    sheet.ViewOptions.ShowGridLines = False
End Using

The image below shows the worksheet when gridlines are displayed, and when gridlines are hidden (the workbook is opened in Microsoft® Excel®).