Back to Devexpress

How to: Hide a Row or a Column

officefileapi-12090-spreadsheet-document-api-examples-rows-and-columns-how-to-hide-a-row-or-a-column.md

latest2.5 KB
Original Source

How to: Hide a Row or a Column

  • Sep 19, 2023
  • 2 minutes to read

This example demonstrates how to hide rows and columns in a worksheet using different properties and methods:

View Example

csharp
Worksheet worksheet = workbook.Worksheets[0];

// Hide the 8th row of the worksheet.
worksheet.Rows[7].Visible = false;            
// Hide the 4th column of the worksheet.
worksheet.Columns[3].Visible = false;

// Hide columns from 5 to 7.
worksheet.Columns.Hide(5, 7);
// Hide rows from 6 to 8.
worksheet.Rows.Hide(5, 7);

// Hide the 10th row of the worksheet.
worksheet.Rows[9].Height = 0;
// Hide the 10th column of the worksheet.
worksheet.Columns[9].Width = 0;
vb
Dim worksheet As Worksheet = workbook.Worksheets(0)

' Hide the 8th row of the worksheet.
worksheet.Rows(7).Visible = False
' Hide the 4th column of the worksheet.
worksheet.Columns(3).Visible = False

' Hide columns from 5 to 7.
worksheet.Columns.Hide(5, 7)
' Hide rows from 6 to 8.
worksheet.Rows.Hide(5, 7)

' Hide the 10th row of the worksheet.
worksheet.Rows(9).Height = 0
' Hide the 10th column of the worksheet.
worksheet.Columns(9).Width = 0

See Also

How to: Specify Row Height or Column Width