protect Methode

protect(self, type)

Schützt das Arbeitsblatt.


def protect(self, type):
    ...
ParameterTypBeschreibung
typeProtectionTypeSchutzart.

Bemerkungen

Diese Methode schützt das Arbeitsblatt ohne Kennwort. Sie kann das Arbeitsblatt protect in allen Versionen der Excel-Datei schützen.

protect(self, type, password, old_password)

Schützt das Arbeitsblatt.


def protect(self, type, password, old_password):
    ...
ParameterTypBeschreibung
typeProtectionTypeSchutzart.
passwordstrPasswort.
old_passwordstrWenn das Arbeitsblatt bereits durch ein Passwort geschützt ist, geben Sie bitte das alte Passwort ein.
Andernfalls können Sie diesem Parameter einen Nullwert oder eine leere Zeichenfolge zuweisen.

Bemerkungen

Mit dieser Methode können Sie das Arbeitsblatt protect in allen Versionen von Excel-Dateien verwenden.

Beispiel

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")

Siehe auch