移除工作表

删除工作表

使用工作表索引

下面的代码显示了如何通过在GridWorksheetCollection的RemoveAt方法中指定工作表索引来删除工作表。

// 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);
}

使用工作表名称

下面的代码显示了如何通过在GridWorksheetCollection的RemoveAt方法中指定工作表名称来删除工作表。

// 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");
}