Back to Devexpress

How to: Delete a Worksheet

wpf-16315-controls-and-libraries-spreadsheet-examples-worksheets-how-to-delete-a-worksheet.md

latest1.2 KB
Original Source

How to: Delete a Worksheet

  • Jun 07, 2019

This example demonstrates how to remove a worksheet from a workbook by calling the WorksheetCollection.Remove or WorksheetCollection.RemoveAt method of the WorksheetCollection object that is accessed via the Workbook.Worksheets property.

View Example

csharp
// Delete the "Sheet2" worksheet from the workbook.
workbook.Worksheets.Remove(workbook.Worksheets["Sheet2"]);

// Delete the first worksheet from the workbook.
workbook.Worksheets.RemoveAt(0);
vb
' Delete the "Sheet2" worksheet from the workbook.
workbook.Worksheets.Remove(workbook.Worksheets("Sheet2"))

' Delete the first worksheet from the workbook.
workbook.Worksheets.RemoveAt(0)