Back to Devexpress

Use the Excel Export API to Show and Hide Row and Column Headers

officefileapi-114469-excel-export-library-worksheets-how-to-show-and-hide-row-and-column-headers.md

latest2.0 KB
Original Source

Use the Excel Export API to Show and Hide Row and Column Headers

  • Sep 19, 2023

Each worksheet (IXlSheet) consists of cells (IXlCell) that are arranged in rows (IXlRow) and columns (IXlColumn). Each row and column has its own unique name (numbers “1”, “2”, “3”, etc. are used for rows and letters A”, “B”, “C”, etc. are used for columns). These unique names for rows and columns are displayed as headers at the left and at the top of a worksheet, respectively. To specify the visibility of row and column headers on a worksheet, use the IXlSheetViewOptions.ShowRowColumnHeaders property of the IXlSheetViewOptions object that controls worksheet display settings. It can be accessed using the IXlSheet.ViewOptions property.

View Example

csharp
// Create a worksheet. 
using (IXlSheet sheet = document.CreateSheet())
{
    // Hide row and column headers in the worksheet.
    sheet.ViewOptions.ShowRowColumnHeaders = false;
}
vb
' Create a worksheet. 
Using sheet As IXlSheet = document.CreateSheet()
    ' Hide row and column headers in the worksheet.
    sheet.ViewOptions.ShowRowColumnHeaders = False
End Using

The image below shows the appearance of the worksheet when row and column headers are shown, and when row and column headers are hidden (the workbook is opened in Microsoft® Excel®).