プロテクト Cells

保護中 Cells

Aspose.Cells.GridWeb は、コントロールがセルにあるときにセルの保護レベルを制御するためのいくつかの異なる手法を提供します。編集モード(デフォルトモード)。これにより、セルがエンド ユーザーによって変更されないように保護されます。

Cells をすべて読み取り専用にする

ワークシート内のすべてのセルを読み取り専用に設定するには、ワークシートの SetAllCellsReadonly メソッドを呼び出します。

// 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 メソッドとは逆の効果があります。

// 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 を読み取り専用にする

セルの範囲のみを保護するには:

  1. まず、SetAllCellsEditable メソッドを呼び出して、すべてのセルを編集可能にします。
  2. ワークシートの SetReadonlyRange メソッドを呼び出して、保護するセルの範囲を指定します。このメソッドは、セルの範囲を指定するために行と列の数を取ります。
// 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 を編集可能にする

セル範囲の保護を解除するには:

  1. SetAllCellsReadonly メソッドを呼び出して、すべてのセルを読み取り専用にします。
  2. ワークシートの SetEditableRange メソッドを呼び出して、編集可能にするセルの範囲を指定します。このメソッドは、セルの範囲を指定するために行と列の数を取ります。
// 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);