ワークシートの削除
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メソッドを使用します。このアプローチは一般的に使用されます。