How to test for password protected Excel files?

Hi,


I’m converting Excels to PDFs doing the following:

com.aspose.cells.Workbook bookd = new com.aspose.cells.Workbook(fileLoc);

bookd.save(pdf);


However if the file is password protected I get the following exception:

java.lang.ArrayIndexOutOfBoundsException

at java.lang.System.arraycopy(Native Method)

at com.aspose.cells.zsv.a(Unknown Source)

at com.aspose.cells.zsv.a(Unknown Source)

at com.aspose.cells.zsh.a(Unknown Source)

at com.aspose.cells.Workbook.a(Unknown Source)

at com.aspose.cells.Workbook.(Unknown Source)


Is there a way to test to see if the file is password protected ??

thanks

Hi,


Thanks for your query.

Yes, you can determine whether the file is encrypted (password protected), see the document for your reference:
How to Detect a File Format and Check if the File is Encrypted

Hope, this helps a bit.

Thank you.