プロテクト Cells
Contents
[
Hide
]
このトピックでは、セルを保護するためのいくつかの手法について説明します。これらの手法を使用すると、開発者は、ユーザーがワークシート内のすべてのセルまたは選択したセル範囲を編集することを制限できます。
保護中 Cells
Aspose.Cells.GridWeb は、コントロールがセルにあるときにセルの保護レベルを制御するためのいくつかの異なる手法を提供します。編集モード(デフォルトモード)。これにより、セルがエンド ユーザーによって変更されないように保護されます。
Cells をすべて読み取り専用にする
ワークシート内のすべてのセルを読み取り専用に設定するには、ワークシートの SetAllCellsReadonly メソッドを呼び出します。
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 | |
// Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Setting all cells of the worksheet to Readonly | |
sheet.SetAllCellsReadonly(); |
すべての Cells を編集可能にする
すべてのセルの保護を解除するには、ワークシートの SetAllCellsEditable メソッドを呼び出します。このメソッドは、SetAllCellsReadonly メソッドとは逆の効果があります。
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 | |
// Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Setting all cells of the worksheet to Editable | |
sheet.SetAllCellsEditable(); |
選択した Cells を読み取り専用にする
セルの範囲のみを保護するには:
- まず、SetAllCellsEditable メソッドを呼び出して、すべてのセルを編集可能にします。
- ワークシートの SetReadonlyRange メソッドを呼び出して、保護するセルの範囲を指定します。このメソッドは、セルの範囲を指定するために行と列の数を取ります。
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 | |
// Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Setting all cells of the worksheet to Editable first | |
sheet.SetAllCellsEditable(); | |
// Finally, Setting selected cells of the worksheet to Readonly | |
sheet.SetReadonlyRange(3, 2, 4, 1); |
選択した Cells を編集可能にする
セル範囲の保護を解除するには:
- SetAllCellsReadonly メソッドを呼び出して、すべてのセルを読み取り専用にします。
- ワークシートの SetEditableRange メソッドを呼び出して、編集可能にするセルの範囲を指定します。このメソッドは、セルの範囲を指定するために行と列の数を取ります。
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 | |
// Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Setting all cells of the worksheet to Readonly first | |
sheet.SetAllCellsReadonly(); | |
// Finally, Setting selected cells of the worksheet to Editable | |
sheet.SetEditableRange(3, 2, 4, 1); |