We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Password protected xls file that contains macro is corrupted

book.SetEncryptionOptions(EncryptionType.XOR, 40);
book.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);
book.Settings.Password = “test123”;

We use the above code to create password protected file. When we create “xls” file without macro it works. But when we create file that contains macro it says the file is corrupted.

Aspose.cells version 18.4.5

@ksnaspose

Thanks for using Aspose APIs.

We tested this issue with the most recent version and it works fine. Please see the following code. It loads the Book1.xls which has macros and after executing your code, it saves it as output.xls which opens fine in Microsoft Excel.

Download Link:
Sample Input and Output Excel Files.zip (26.4 KB)

C#

Workbook book = new Workbook("Book1.xls");
book.SetEncryptionOptions(EncryptionType.XOR, 40);
book.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);
book.Settings.Password = "test123";
book.Save("output.xls");