ワークシートに保護を追加
Contents
[
Hide
]
Aspose.Cells for GridDesktopを使用すると、ワークシートのセルを保護できます。 まず、ワークシートを保護し、次にワークシート内の特定のセルを保護できます。 ワークシートを保護するには、Worksheet.Protectedプロパティをtrueに設定し、その後に**Worksheet.SetProtected()**メソッドを使用してセルの範囲を保護します。
Aspose.Cells.GridDesktopを使用してセルを保護
以下のサンプルコードでは、GridDesktopのアクティブなワークシートの範囲A1:B1のすべてのセルを保護しています。 この範囲のセルをダブルクリックすると、編集ができなくなります。 これにより、これらのセルは読み取り専用になります。
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 worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Make sure sheet has been protected | |
sheet.Protected = true; | |
// Choose a cell range | |
CellRange range = sheet.CreateRange("A1", "B1"); | |
// Set protected range area on Worksheet | |
sheet.SetProtected(range, true); |