Remove Worksheets

Removing a Worksheet

Using Sheet Index

The code below shows how to remove a worksheet by specifying its sheet index in the GridWorksheetCollection’s RemoveAt method.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
if (GridWeb1.WorkSheets.Count > 2)
{
// Removing a worksheet using its index
GridWeb1.WorkSheets.RemoveAt(1);
}

Using Sheet Name

The code below shows how to remove a worksheet by specifying its sheet name in the GridWorksheetCollection’s RemoveAt method.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Removing a worksheet using its name
if (GridWeb1.WorkSheets["Teachers"] != null)
{
GridWeb1.WorkSheets.RemoveAt("Teachers");
}