Hi

I am trying to check whether XLSX files that are being uploaded have a 
password.  I won't know the password, I simply want to prevent any password 
protected files being uploaded.

I've done a lot of search on Google and of the Apache POI site, but I'm afraid 
failed to find an answer, or at least one that works.

What I think I have gleaned so far is I should open the file...

POIFSFileSystem pfs = new POIFSFileSystem(new File("d:\\file.xlsx"));

And the do something like this...

EncryptionInfo e = new EncryptionInfo(pfs);
Decryptor d = Decryptor.getInstance(e);
d.verifyPassword(Decryptor.DEFAULT_PASSWORD);


However, every time the POIFSFileSystem line is executed I get an 
OfficeXmlFileException, the message is...

The supplied data appears to be in the Office 2007+ XML. You are calling the 
part of POI that deals with OLE2 Office Documents. You need to call a different 
part of POI to process this data (eg XSSF instead of HSSF)

The file I'm using is most certainly a valid xlsx file generated in Excel 2010, 
with nothing more complicated that a single cell with two words in it.  At this 
stage it's not even password protected!


Thanks for any help offered.

Tom

Reply via email to