保护行和列
Contents
[
Hide
]
此主题讨论了保护行和列中单元格不受最终用户执行的任何操作的几种技术。开发人员可以使用两种技术来实现此保护:通过使行和列中的单元格只读,或者通过限制Aspose.Cells.GridWeb的上下文菜单选项。下面将通过示例讨论这两种技术。
保护行和列中的单元格
使行和列只读
保护工作表中行和列的一种方法是使单元格只读。然后最终用户无法删除它们。
使行和列只读:
- 将 Aspose.Cells.GridWeb 控件添加到 Web 表单中。
- 访问集合中的GridWorksheet。
- 设置你所需要的行或列中的单元格为只读。
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 first worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Set the 1st cell (A1) read only | |
sheet.SetIsReadonly(sheet.Cells["A1"], true); |
限制上下文菜单选项
Aspose.Cells.GridWeb提供了一个上下文菜单,最终用户可以使用它对控件执行操作。菜单提供了许多用于操作单元格、行和列的选项。
完整的上下文选项
可以通过限制上下文菜单中的可用选项来限制行和列上的任何一种客户端操作。可以通过将GridWeb控件的EnableClientColumnOperations和EnableClientRowOperations属性设置为false来实现。还可以通过将GridWeb控件的EnableClientFreeze属性设置为false来限制用户冻结行和列。
限制行和列选项后的上下文菜单