Verschlüsseln von Excel-Dateien mit Aspose.Cells

Mit Microsoft Excel

So legen Sie die Dateiverschlüsselungseinstellungen in Microsoft Excel fest (hier Microsoft Excel 2003):

  1. Von demWerkzeug Menü, auswählenOptionen. Ein Dialogfeld wird angezeigt.
  2. Wähle ausSicherheit Tab.
  3. Geben Sie ein Passwort ein und klicken Sie aufFortschrittlich Dialogfeld „Optionen“.

todo: Bild_alt_Text

  1. Wählen Sie den Verschlüsselungstyp und bestätigen Sie das Passwort.

Dialogfeld „Verschlüsselungstyp“.

todo: Bild_alt_Text

Verschlüsselung mit Aspose.Cells

Das folgende Beispiel zeigt, wie eine Excel-Datei mit Aspose.Cells API verschlüsselt und mit einem Kennwort geschützt wird.

C#

 string FilePath = @"..\..\..\Sample Files\";

string srcFileName = FilePath + "Encrypting Excel Files.xlsx";

string destFileName = FilePath + "Result Encrypting Excel Files.xlsx";

//Open an excel file.

Workbook workbook = new Workbook(srcFileName);

//Specify XOR encryption type.

workbook.SetEncryptionOptions(EncryptionType.XOR, 40);

//Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).

workbook.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);

//Password protect the file.

workbook.Settings.Password = "1234";

//Save the excel file.

workbook.Save(destFileName);

Laufcode herunterladen

Beispielcode herunterladen