tags:

views:

677

answers:

2

Hello everyone.

I've just learned POI and find the HSSF is very simple to read and create excel file (.xls). However, I found some problem when want to read excel protected with password. It took me an hour to find this solution on internet.

Please could you help me to solve this problem. I'm very glad if you could give me a code snippet.

Thank you.

A: 

POI will not be able to read encrypted workbooks - that means that if you have protected the entire workbook (and not just a sheet), then it won't be able to read it. Otherwise, it should work.

Ravi Wallau
Thank Ravi Wallau :)
embarus
A: 

Ravi is right. It seems you can read password protected, but not encrypted files with POI. See http://osdir.com/ml/user-poi.apache.org/2010-05/msg00118.html. The following code prints out a trace of the file

POIFSLister lister = new POIFSLister();
lister.viewFile(spreadsheetPath, true);

If you get an output mentioning encryption then you cannot open the file with POI.

Tarski
Thank Tarski :)
embarus