ワークシートを削除
Contents
[
Hide
]
このトピックでは、Aspose.Cells.GridWeb API を使用して Microsoft Excel ファイルからワークシートを削除する方法について説明します。シート インデックスまたは名前を指定して、ワークシートを削除することができます。
ワークシートの削除
シート インデックスの使用
次のコードは、GridWorksheetCollection の RemoveAt メソッドでシート インデックスを指定して、ワークシートを削除する方法を示しています。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 メソッドでシート名を指定してワークシートを削除する方法を示しています。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); | |
} |
参照またはインスタンスを使用してワークシートを削除することもできます。これを行うには、GridWorksheetCollection の Remove メソッドを使用します。このアプローチは一般的に使用されます。