Skip to main content

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

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

// Create a worksheet. 
using (IXlSheet sheet = document.CreateSheet())
{
    // Hide row and column headers in the worksheet.
    sheet.ViewOptions.ShowRowColumnHeaders = false;
}

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®).

XLExport_ViewOptions_ShowHeaders