在工作表中添加保护
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); |