Überprüfen Sie das zu ändernde Passwort mit Aspose.Cells

Aktivieren Sie das zu ändernde Passwort in Microsoft Excel

Sie können zuweisenPasswort zum öffnen undZu änderndes Passwort beim Erstellen Ihrer Arbeitsmappen in Microsoft Excel. Bitte sehen Sie sich diesen Screenshot an, der die Schnittstelle Microsoft zeigt, die Excel bereitstellt, um diese Passwörter anzugeben.

todo: Bild_alt_Text

Überprüfen Sie das zu ändernde Passwort mit Aspose.Cells

Die folgenden Beispielcodes laden dieQuelle Excel Datei. Es hat ein Passwort zum Öffnen als 1234 und ein Passwort zum Ändern als 5678. Der Code prüft zuerst, ob 567 das richtige Passwort zum Ändern ist, und gibt falsch zurück, und dann prüft er, ob 5678 das zu ändernde Passwort ist, und es gibt wahr zurück.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Specify password to open inside the load options
LoadOptions opts = new LoadOptions();
opts.Password = "1234";
// Open the source Excel file with load options
Workbook workbook = new Workbook(dataDir + "sampleBook.xlsx", opts);
// Check if 567 is Password to modify
bool ret = workbook.Settings.WriteProtection.ValidatePassword("567");
Console.WriteLine("Is 567 correct Password to modify: " + ret);
// Check if 5679 is Password to modify
ret = workbook.Settings.WriteProtection.ValidatePassword("5678");
Console.WriteLine("Is 5678 correct Password to modify: " + ret);

Konsolenausgabe

Hier ist die Konsolenausgabe des obigen Beispielcodes nach dem Laden derQuelle Excel Datei.

Is 567 correct Password to modify: False

Is 5678 correct Password to modify: True