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?