Excel-Dateien verschlüsseln und entschlüsseln

Mit MS-Excel

In MS Excel (z. B. MS Excel 2003) können Sie zum Implementieren von Dateiverschlüsselungseinstellungen Folgendes versuchen:

  • Von demWerkzeug Menü, auswählenOptionen , und wählen Sie dann die ausSicherheit Tab.
  • EingangPasswort zum öffnen und klicken Sie auf dieFortschrittlich Knopf.
  • Wählen Sie den Verschlüsselungstyp und bestätigen Sie das Passwort.

todo: Bild_alt_Text

Abbildung: Dialog Optionen

todo: Bild_alt_Text

Abbildung: Dialog Verschlüsselungstyp

Excel-Datei verschlüsseln

Das folgende Beispiel zeigt, wie Sie eine Excel-Datei mit der Aspose.Cells API verschlüsseln / mit einem Passwort schützen können.

Beispielcode:

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(EncryptingFiles.class) + "loading_saving/";
// Instantiate a Workbook object by excel file path
Workbook workbook = new Workbook(dataDir + "Book1.xls");
// Password protect the file.
workbook.getSettings().setPassword("1234");
// Specify XOR encrption type.
workbook.setEncryptionOptions(EncryptionType.XOR, 40);
// Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic
// Provider).
workbook.setEncryptionOptions(EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 128);
// Save the excel file.
workbook.save(dataDir + "EncryptingFiles_out.xls");
// Print message
System.out.println("Encryption applied successfully on output file.");

Excel-Datei mit Aspose.Cells entschlüsseln

Es ist sehr wichtig, eine passwortgeschützte Excel-Datei zu öffnen und mit den folgenden Codes Aspose.Cells API zu entschlüsseln:

//Open encrypted file with password.
LoadOptions loadOptions = new LoadOptions();
loadOptions.setPassword("password");
Workbook workbook = new Workbook("Book1.xlsx", loadOptions);
//Remove password.
workbook.getSettings().setPassword(null);
//Save the file.
workbook.save("Book1.xlsx");