Back to Devexpress

Use the Excel Export API to Hide a Row or Column

officefileapi-114080-excel-export-library-rows-and-columns-how-to-hide-a-row-or-column.md

latest1.9 KB
Original Source

Use the Excel Export API to Hide a Row or Column

  • Sep 19, 2023

The example below demonstrates how to control the visibility of rows and columns in a worksheet using the IXlRow.IsHidden and IXlColumn.IsHidden properties.

Note

You can also hide a row or column in a worksheet by setting the row height (IXlRow.HeightInPixels) or column width (IXlColumn.WidthInCharacters or IXlColumn.WidthInPixels) to 0, respectively (see the How to: Specify Row Height and Column Width document).

View Example: Excel Export API

csharp
// Create a new worksheet.
using (IXlSheet sheet = document.CreateSheet()) 
{
    // Hide the column B in the worksheet.
    using (IXlColumn column = sheet.CreateColumn(1))
    {
        column.IsHidden = true;
    }

    // Hide the third row in the worksheet.
    using (IXlRow row = sheet.CreateRow(2))
    {
        row.IsHidden = true;
    }
}
vb
' Create a new worksheet.
Using sheet As IXlSheet = document.CreateSheet()
    ' Hide the column B in the worksheet.
    Using column As IXlColumn = sheet.CreateColumn(1)
        column.IsHidden = True
    End Using

    ' Hide the third row in the worksheet.
    Using row As IXlRow = sheet.CreateRow(2)
        row.IsHidden = True
    End Using
End Using

See Also

Use the Excel Export API to Specify Row Height and Column Width