Metodo protect

protect(self, type)

Protegge il foglio di lavoro.


def protect(self, type):
    ...
ParametroTipoDescrizione
typeProtectionTypeTipo di protezione.

Osservazioni

Questo metodo protegge il foglio di lavoro senza password. Può essere utilizzato in tutte le versioni di Excel.

protect(self, type, password, old_password)

Protegge il foglio di lavoro.


def protect(self, type, password, old_password):
    ...
ParametroTipoDescrizione
typeProtectionTypeTipo di protezione.
passwordstrPassword.
old_passwordstrSe il foglio di lavoro è già protetto da password, fornire la vecchia password.
In caso contrario, è possibile impostare un valore nullo o una stringa vuota su questo parametro.

Osservazioni

Questo metodo può essere utilizzato in tutte le versioni del foglio di lavoro Excel.

Esempio

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

Guarda anche