Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Delete a Row or Column from a Worksheet

  • 3 minutes to read
In This Article

#Row

This example demonstrates how to remove rows from a worksheet.

When you delete rows from a worksheet, other rows are automatically shifted up.

Enclose your code in the Workbook.BeginUpdate - Workbook.EndUpdate method calls to improve performance when you remove multiple rows from a document.

View Example

// Delete the 2nd row from the worksheet.
worksheet.Rows[1].Delete();

// Delete the 3rd row from the worksheet.
worksheet.Rows.Remove(2);

// Delete three rows from the worksheet starting from the 10th row.
worksheet.Rows.Remove(9, 3);

// Delete a row that contains the "B2"cell.
worksheet.DeleteCells(worksheet.Cells["B2"], DeleteMode.EntireRow);

You can also hide worksheet rows. See the How to: Hide a Row or a Column topic for details.

Note

The number of rows in a worksheet is permanently fixed - 1048576.

#Column

This example demonstrates how to remove columns from a worksheet.

When you delete columns from a worksheet, other columns are automatically shifted to the left.

Enclose your code in the Workbook.BeginUpdate - Workbook.EndUpdate method calls to improve performance when you remove multiple columns from a document.

View Example

// Delete the 2nd column from the worksheet.
worksheet.Columns[1].Delete();

// Delete the 3rd column from the worksheet.
worksheet.Columns.Remove(2);

// Delete three columns from the worksheet starting from the 10th column.
worksheet.Columns.Remove(9, 3);

// Delete a column that contains the "B2"cell.
worksheet.DeleteCells(worksheet.Cells["B2"], DeleteMode.EntireColumn);

You can also hide worksheet columns. See the How to: Hide a Row or a Column topic for details.

Note

The number of columns in a worksheet is permanently fixed - 16384.

See Also