Free Support Forum - aspose.com

Checking for Encryption

Hi,

I have most of the excel files encrypted, but there are a few that are not encrpypted. Is there a check feature to check to see if there is encryption and if there is none than do not open with the supplied password.

Currently, I am doing something like this to remove an encryption:

//Creating a Workbook object

Workbook workbook = new Workbook();

//Setting the password for the encrypted Excel file

String filePass = "password1";

//Calling open method of Workbook object to open an encrypted file

workbook.open("c:\\EncryptedFile.xls", FileFormatType.DEFAULT, filePass);

workbook.protectFile(ProtectionType.OPEN_FILE, null);

workbook2.copy(workbook);

Some file are not encrypted so they failed at the workbook.open when trying to supply a password.

Is there a check for this first to either supply the password or don't supply it.

Thanks.

Hi,

Well, I am afraid, there is no such api to check whether a file is encrypted(password protected) or not before opening/loading the file. But after analyzing your issue, I think we change the logic of checking password. So, if the file is not protected by a password, it will be ignored. I think this way it will suit your need too. And, in any case, (if the file is encrypted or not) your code will work:
//Calling open method of Workbook object to open an encrypted file
workbook.open(“c:\EncryptedFile.xls”, FileFormatType.DEFAULT, filePass);

Your issue(feature enhancement) is registered into our issue tracking system with an issue id: CELLSJAVA-11371.

We will provide the supported version soon.

Thank you.

Hi,

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. We have enhanced the feature for opening the encrypted files (as mentioned above in Amjad’s post). Please check it and let us know if it fits your needs.

Thank You & Best Regards,

Hi

Thank you very much, Amjad and Nausherwan. The new api (2.1.0.29) works as you have said. I am still using the same approach to open a file:

workbook.open("c:\\EncryptedFile.xls", FileFormatType.DEFAULT, filePass), but with the older api: 2.0.1.11 had given an com.aspose.exception invalid password where the file is not encrypted at all.

Thanks.

Hi,

Please use new jar Aspose.Cells for Java v2.1.0.29 (provided by Nausherwan) as we have tested with it, it works fine using your line of code with non encrypted files too. If you still find any issue with it, kindly post your template file here, we will check it soon.

Thank you…

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.