The only protection I'm really worried about is the password protection of the file. If it can be opened, then without needing a password they're happy.
To check every other form would be a killer, some of these spread sheets at 80+ MB, checking every row, column, cell would be a killer. 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]
