Free Support Forum - aspose.com

Decrypt of a password protected file corrupts file

We are currently using Aspose Cells (version 7.3.0.0) to extract data from Excel files sent out to clients. The files are often returned password protected. Normally, this works fine. However, we had a client file that ends up becoming corrupted after being decrypted.

When you try to open the decrypted file with Excel 2003, you get a message about "Excel found unreadable content" and asks if you want to recove the file. If you recover the file, it will open but all formatting has been lost and Excel prompts you that "Damage to the file was so extensive that repairs were not possible. Excel attempted to recover your formulas and values, but some data may have been lost or corrupted".

This only effects the file that has been saved with an external password. The same file without a password can be open and saved without corruption using the same code.

I have included the sample code I used to reproduce as well as the files used to test this.

string excelFileNameAndPath = "C:\\no macros plus ext password.xls";

string decryptedFileNameAndPath = "C:\\no macros plus ext password_PasswordRemoved.xls";

string password = "dubai543";

Aspose.Cells.LoadOptions loadOptions = new Aspose.Cells.LoadOptions();

loadOptions.Password = password;

Aspose.Cells.Workbook excelFile = new Aspose.Cells.Workbook(excelFileNameAndPath, loadOptions);

excelFile.Decrypt(password);

Aspose.Cells.SaveFormat saveFormat = Aspose.Cells.SaveFormat.Excel97To2003;

excelFile.Save(decryptedFileNameAndPath, saveFormat);

The other thing to note is that using Excel 2003 to removed the password and save the file doesn't result in the file having any problems.

What is decrypt doing that is corrupting the file?

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We were able to replicate this issue using the latest version: Aspose.Cells
for .NET v7.3.5.1
with the given sample code.

We have logged this issue in our database. We will look into this issue and fix it. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-41320.

C#


string excelFileNameAndPath = @“F:\Shak-Data-RW\Downloads\no+macros+plus+ext+password.xls”;

string password = “dubai543”;

Aspose.Cells.LoadOptions loadOptions = new Aspose.Cells.LoadOptions();

loadOptions.Password = password;

Aspose.Cells.Workbook excelFile = new Aspose.Cells.Workbook(excelFileNameAndPath, loadOptions);

excelFile.Decrypt(password);

Aspose.Cells.SaveFormat saveFormat = Aspose.Cells.SaveFormat.Excel97To2003;

excelFile.Save(excelFileNameAndPath + “.decrypted.xls”, saveFormat);

Do you see what about the file is causing the problem? Is there something in the file (such as named range or external link) that is causing the problem? If there is something we can change about the file or workaround in the mean time (until a fix is produced) that would be very helpful.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

I will recommend you to create a totally new file like this from scratch in MS-Excel and see if it then works fine with the Aspose.Cells.

Mostly, such issues occur because of some internal broken/corrupt records, which Ms-Excel can fix on the fly but Aspose.Cells cannot.

We will look into your issue and let you know what could be done with your existing file.

I have also logged your comments against the issue id: CELLSNET-41320.

Once, there is some update for you, we will share it with you asap.

Also, we wish you a happy new year 2013. May this year bring prosperity for all. Keep us in your good wishes.

FYI - I tested the same sample code using Aspose.Cells 7.0.2.0 (the version we were using prior to upgrading to 7.3.0.0). Running the same code using 7.0.2.0 does not end up corrupting the decrypted file. So it looks like this problem was introduced between those two versions.

Hi,


Thanks for providing us further details.

We are working over your issue and we will try to provide you a fix in the next week that figures out your issue. Hopefully, it will not be too late for you and you don’t need any workaround any more now.

Thank you.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We have fixed this issue.

Please download and try this fix: Aspose.Cells for .NET v7.3.5.3 and let us know your feedback.

The version you provided (7.3.5.3) fixes the corruption issue when decrypting/removing the external password. Thanks for the quick turnaround.

Hi,


Thanks for your feedback,

Good to know that your issue is resolved now.

Thank you.

The issues you have found earlier (filed as CELLSNET-41320) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.