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]