Check Workbook is password protected

Hi,


Right now in our application we do not want to deal with password protected spreadsheets. At the moment, we have to include bouncycastle libraries.

Otherwise, if I do not have bouncycastle, Aspose 8.4.1 throws:

java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider
at com.aspose.cells.zqe.a(Unknown Source) ~[cells-8.4.1.jar:8.4.1.0]
at com.aspose.cells.zqe.a(Unknown Source) ~[cells-8.4.1.jar:8.4.1.0]

Is there a way I can check if an excel file is protected BEFORE aspose throws an Error? I don’t want to have to wrap a try/catch statement to catch FileNotFound/ClassNotFound exception - if anything, it would be more helpful if Aspose threw a custom exception. I’d rather gracefully exit than have to catch an exception.

But ideally, I’d like to be able to NOT include bouncycastle. Right now I am including it for the possibility of dealing with password protected spreadsheets to avoid this exception which seems a bit silly.

Thanks!

Hi,


Thanks for your query.

Well, we do provide an API for checking whether a file has been protected by a password, see the document for your reference here:

However, for workbooks that are protected by default password, MS Excel does not take it as encrypted file, so for such kind of workbooks we have to use encryption related APIs (e.g org/bouncycastle/jce/provider/BouncyCastleProvider) to check whether the password is the default one. So, this API still requires the classes, such as, org/bouncycastle/jce/provider/BouncyCastleProvider. We are afraid there is no better solution to cope with your requirements.

Thank you.