Nick

Just getting back to this after some other work...

I can't find a constructor for HSSFWorkbook that accepts a NPOIFSFileSystem, 
only POIFSFileSystem.


Tom

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

On Wed, 7 Sep 2011, Simmons, Tom (GE Oil & Gas, VG) wrote:
> For checking XLS files I have been using...
>
> System.out.println(new Date());
> InputStream is = new FileInputStream("d:\\big n p.xls"); 
> System.out.println(new Date());
>
> Workbook wb = new HSSFWorkbook(is);

HSSFWorkbook will take a NPOIFSFileSystem. If you pass in a NPOIFS opened from 
a file, you'll significantly cut down on the memory needed

> System.out.println(new Date());
> Boolean check = ((HSSFWorkbook)wb).isWriteProtected();
> System.out.println(check);

That isn't the only kind of protection though.

Admitedly, most of the other kinds will throw a EncryptedDocumentException 
earlier in the process, so that's probably the slowest one to find :)

One other option is to do event model processing of your xls file. Wait until 
you hit the record with the write protection on it, and bail out either way at 
that point

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