Überprüfung des Passworts zum Ändern mithilfe von Aspose.Cells für Python via .NET
Passwort zum Ändern in Microsoft Excel überprüfen
Sie können beim Erstellen Ihrer Arbeitsbücher in Microsoft Excel Passwort zum Öffnen und Passwort zum Ändern zuweisen. Bitte sehen Sie sich diesen Screenshot an, der die Benutzeroberfläche zeigt, die Microsoft Excel zum Angeben dieser Passwörter bereitstellt.
![]() |
---|
Überprüfung des Passworts zum Ändern mithilfe von Aspose.Cells für Python via .NET
Die folgenden Beispielscodes laden die Quell-Excel-Datei. Sie hat ein Passwort zum Öffnen als 1234 und ein Passwort zum Ändern als 5678. Der Code überprüft zunächst, ob 567 das richtige Passwort zum Ändern ist, und gibt false zurück, und dann überprüft er, ob 5678 das Passwort zum Ändern ist, und gibt true zurück.
from aspose.cells import LoadOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Specify password to open inside the load options | |
opts = LoadOptions() | |
opts.password = "1234" | |
# Open the source Excel file with load options | |
workbook = Workbook(dataDir + "sampleBook.xlsx", opts) | |
# Check if 567 is Password to modify | |
ret = workbook.settings.write_protection.validate_password("567") | |
print("Is 567 correct Password to modify: " + str(ret)) | |
# Check if 5679 is Password to modify | |
ret = workbook.settings.write_protection.validate_password("5678") | |
print("Is 5678 correct Password to modify: " + str(ret)) |
Konsolenausgabe
Hier ist die Konsolenausgabe des obigen Beispielscodes nach dem Laden der Quell-Excel-Datei.
Is 567 correct Password to modify: False
Is 5678 correct Password to modify: True