Skip to content
本页内容

AllowSorting (属性)

如果允许在受保护的工作表上使用排序选项,则返回 Truebool 类型,只读。

说明

在受保护的工作表中,只能对未锁定或未保护的单元格进行排序。

可以使用 Protect 方法参数设置 AllowSorting 属性。

示例

python
#本示例允许用户对受保护的工作表上未锁定或未保护的单元格进行排序,并通知用户
def test():
    Application.ActiveSheet.Unprotect()
    # Unlock cells A1 through B5.
    Range("A1:B5").Locked = False
    # Allow sorting to be performed on the protected worksheet.
    if Application.ActiveSheet.Protection.AllowSorting == False:
        Application.ActiveSheet.Protect(None, None, None, None, None, None, None, None, None, None, None, None, None, True)
   
    print("For cells A1 through B5, sorting can be performed on the protected worksheet.")
python
#本示例显示是否允许在受保护的第二张工作表上使用排序选项
def test():
    print(Worksheets.Item(2).Protection.AllowSorting)