セルの保護
Contents
[
Hide
]
このトピックでは、セルを保護するためのいくつかのテクニックについて説明します。これらのテクニックを使用することで、ワークシート内のすべてまたは選択したセル範囲の編集をユーザーに制限することができます。
セルの保護
Aspose.Cells.GridWeb は、コントロールが 編集モード (デフォルトモード) にある場合に、セルの保護レベルを制御するためのいくつかの異なる技術を提供しています。これにより、エンドユーザーによるセルの変更を防ぐことができます。
すべてのセルを読み取り専用にする
ワークシートのすべてのセルを読み取り専用に設定するには、ワークシートの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(); |
すべてのセルを編集可能にする
すべてのセルの保護を解除するには、ワークシートの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(); |
選択したセルを読み取り専用にする
特定のセル範囲のみを保護するには:
- 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); |
選択したセルを編集可能にする
特定のセル範囲の保護を解除するには:
- 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); |