I'll give the event a try then.

I've been working with two files, and it appeared to be working, but to be 
honest I find (and I think many other do judging by the quantity of questions 
on the same topic) that things a pretty vague and poorly explained in the 
documentation.

I was happy that the isWriteProtected was correct, then you see 
question/answers talking about with or without encryption and it gets you to 
wondering if you've really got the correct solution.


Tom

-----Original Message-----
From: Nick Burch [mailto:[email protected]] 
Sent: 12 September 2011 14:17
To: POI Users List
Subject: RE: How to check whether an XLSX has a read password

On Mon, 12 Sep 2011, Simmons, Tom (GE Oil & Gas, VG) wrote:
> I've now got...
>
>       System.out.println(new Date());
>       NPOIFSFileSystem npoiFS = new NPOIFSFileSystem( new File("d:\\big n 
> p.xls"));
>       System.out.println(new Date());
>       HSSFWorkbook wb = new HSSFWorkbook(npoiFS.getRoot(), true);
>       System.out.println(new Date());
>       Boolean check = wb. isWriteProtected();
>       System.out.println(check);

You could try with the event usermodel, and bail out once you hit a point where 
it has worked.

> I'm also no longer sure I'm using the correct test (isWiteProtected). 
> All I am looking for is to check that the workbook hasn't had a 
> password added that prevents it being loaded/opened.

I'd suggest you create two files, one which isn't protected and one that is (in 
the way you want to check for). Try with them and use that to verify!

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional 
commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to