Skip to content
本页内容

Protection (属性)

返回一个 Protection 对象,该对象表示工作表的保护选项。

示例

python
#本示例对活动工作表进行保护,并判断是否能在受保护的工作表中插入列,然后将此状态通知用户
def test():
    Application.ActiveSheet.Protect()
    # Check the ability to insert columns on a protected sheet.
    # Notify the user of this status.
    if Application.ActiveSheet.Protection.AllowInsertingColumns == True:
        print("The insertion of columns is allowed on this protected worksheet.")
    else:
        print("The insertion of columns is not allowed on this protected worksheet.")
python
#本示例允许用户对受保护的工作表 Sheet1 上的单元格进行格式设置,并通知用户
def test():
    Worksheets.Item("Sheet1").Protect(None, None, None, None, None, True)
    if Worksheets.Item("Sheet1").Protection.AllowFormattingCells:
        print("可以在此受保护的工作表 Sheet1 上设置单元格的格式。")
    else:
        print("不能在此受保护的工作表 Sheet1 上设置单元格的格式。")