The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

Column.Delete() Method

Deletes a column from a worksheet.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.2.Core.dll

Declaration

void Delete()
Sub Delete
void Delete()
Sub Delete
void Delete()
Sub Delete

Remarks

The Delete method removes the current Column from the Worksheet.Columns collection. Other columns in the worksheet are shifted to the left. To delete more than one column, use the ColumnCollection.Remove method.

Note

The number of columns in a worksheet is unchanged - 16,384. When you delete columns, the equivalent number of new columns is automatically added to the end of the worksheet's column collection.

If you need to delete only the cell content or formatting from columns without removing entire columns from the worksheet, use the Clear* methods of the Worksheet object (see the How to: Clear Cells of Content, Formatting, Hyperlinks and Comments example).

You can also hide unnecessary columns without deleting them from the worksheet. To do this, use the Column.Visible property (see the How to: Hide a Row or a Column example).

Examples

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.

// 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);
See Also