Metodo protect

protect

Protegge il foglio di lavoro.

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

Osservazioni

Questo metodo protegge il foglio di lavoro senza password. Può contenere il foglio di lavoro protect in tutte le versioni del file Excel.

protect

Protegge il foglio di lavoro.

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

Osservazioni

Questo metodo può essere utilizzato nel foglio di lavoro protect in tutte le versioni del file 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