The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.

How to: Delete a Worksheet

Important

You require a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.

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.

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

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

You can also hide a worksheet. See the How to: Show and Hide a Worksheet topic for details.

Note

A workbook must always contain at least one visible worksheet.

See Also