Aspose fails to open proteced Workbooks

Hi Laurence,

Contrary to what you have posted, we have found that Aspose fails to read an Excel file if the Workbook and the first worksheet in the workbook are protected.

If the Workbook is protected, the error message thrown is:

"Currently, Worksheets protected by password is not supported."

If the workbook is unprotected but the first worksheet is protected we get this:

"Erros in Excel Open method."

We have cross-checked the issue with all the releases of Aspose.Excel starting from 1.7.3.2 to 1.7.7.0 and this disgusting bug exists.

Can you please do something quickly. We are scheduled to go for a production deployment next week.

Thanks & Regards,

Partha

Dear Partha,

Sorry for the problem. Please send me your design Excel file and I will fix it ASAP.

Hi Laurence,

Thanks for your prompt response.

We have checked out the fix 1.7.8. If the Workbook is unprotected and the sheets are protected it works fine now. But the issue of opening protected Workbook remains.

The excel workbooks we use are sent to users who should not be able to modify the workbook structure and hence needs to be protected.

Can you please do something?

Thanks & Regards,

Partha

Dear Partha,

Unfortunately I cannot provide a quick fix to solve this Workbook protection issue.
When the workbook is protected, the excel file is internally encrypted. So there are some jobs to do to find the encryption/decryption method. I will work on this issue.

Maybe you can try this approach. Since you embedded VBA in your file, could you use VBA to protect your workbook when the file is opened?

I tried the following method and it worked fine.

I created a file and didn’t protect the workbook with password. In VBA project, I added the following code.

Private Sub Workbook_Open()
ActiveWorkbook.Protect Password:="abcdef"
End Sub

If needed, you can also protect VBA project with password.

Thanks for you help Laurence. I think that is a workable solution.

While this workaround may suffice for some scenarios, it does not address scenarios where the workbook must be locked down. The workaround provided allows the user opening the workbook to choose to disable the macro, thus leaving the workbook unprotected.

Unfortunately, my use of the Aspose.Excel product currently depends on being able to open protected workbooks. I cannot allow the worokbooks to be unprotected when opened by editors

I am evaluating the product and I consider this to be a showstopper.Crying


There are two level of protection for an Excel file:

1. File protection
In this mode, if you don't have a password, you cannot open this file. In this thread before, I talked with Partha about this issue.

2. Workbook/Worksheet protection
In this mode, you don't need a password to open a file. But if you want to change the content or structure of this file, you should provide a password.
Aspose.Excel supports to import a file with such protection. And the created file cannot be unprotected when opened by users. Aspose.Excel also supports to protect worksheet at run time.

Please write a simple case to test it:

Excel excel = new Excel();
excel.Open(myFile); //File with protection
excel.Save("C:\\book1.xls");

Then you can open and check the result file.

@jsytniak,
Aspose.Excel is discontinued and no more under active development now. It is replaced by Aspose.Cells that is much more advanced and contains all the latest features provided by different versions of MS Excel. Using the latest version you can generate protected files and then open the protected file.

//Instantiate a Workbook object.
Workbook workbook = new Workbook();

//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("encryptedBook1.xls");

Workbook workbook2 = new Workbook("encryptedBook1.xls", new LoadOptions() { Password = "1234" });

Here are the links to different documents that can be referred to for protecting/un-protecting workbooks and worksheets:
Security Features
Encrypting Excel files

Here is the latest free trial version of this new product that can be downloaded here:
Aspose.Cells for .NET (Latest Version)

Here is the link to a runnable solution that can be used to test different features of this new product.