طريقة protect

protect(self, type)

يحمي ورقة العمل.


def protect(self, type):
    ...
معامليكتبوصف
typeProtectionTypeنوع الحماية.

ملاحظات

هذه الطريقة تحمي أوراق العمل دون كلمة مرور. تتوافق مع جميع إصدارات ملفات إكسل.

protect(self, type, password, old_password)

يحمي ورقة العمل.


def protect(self, type, password, old_password):
    ...
معامليكتبوصف
typeProtectionTypeنوع الحماية.
passwordstrكلمة المرور.
old_passwordstrإذا كانت ورقة العمل محمية بالفعل بكلمة مرور، فيرجى تقديم كلمة المرور القديمة.
يمكنك أيضًا تعيين قيمة فارغة أو سلسلة فارغة لهذه المعلمة.

ملاحظات

يمكن لهذه الطريقة protect ورقة عمل في جميع إصدارات ملف Excel.

مثال

from aspose.cells import ProtectionType, Workbook

# Instantiating a Workbook object
excel = Workbook("template.xlsx")
# Accessing the first worksheet in the Excel file
worksheet = excel.worksheets[0]
# Protecting the worksheet with a password
worksheet.protect(ProtectionType.ALL, "aspose", None)
# Saving the modified Excel file in default (that is Excel 20003) format
excel.save("output.xls")

أنظر أيضا