Discussion:
Excel 2007+ with password protection
Matt Rogghe
2012-03-15 16:16:18 UTC
Permalink
I've been experimenting with opening password protected (not encrypted) workbooks. The HSSF (2003 and lower) versions seem to work fine when using the org.apache.poi.hssf.record.crypto.Biff8EncryptionKey methods. The XSSF methods seem to be problematic.

poi-3.8-beta5

Using the following methods to determine workbook version and get an object to work with: POIFSFileSystem.hasPOIFSHeader(inputStream), POIXMLDocument.hasOOXMLHeader(inputStream) as well as the generic WorkbookFactory.create(inputStream).

When I come across a 2007+ workbook that has been saved as password protected POI determines that the file is in HSSF/BIFF format.

Error generated:
The supplied POIFSFileSystem does not contain a BIFF8 'Workbook' entry. Is it really an excel file?

Has anyone had success opening password protected 2007+ files?

Steps to reproduce:
1. Create a new Excel file using Excel 2007+.
2. Save As ->
3. Click Tools -> General Options
4. Enter a password in both or either fields.
5. OK and save.
6. Attempt to read the file using POI.
Nick Burch
2012-03-15 16:21:20 UTC
Permalink
Post by Matt Rogghe
I've been experimenting with opening password protected (not encrypted)
workbooks. The HSSF (2003 and lower) versions seem to work fine when
using the org.apache.poi.hssf.record.crypto.Biff8EncryptionKey methods.
The XSSF methods seem to be problematic.
See http://poi.apache.org/encryption.html for details on how to read .xlsx
password protected files
Post by Matt Rogghe
When I come across a 2007+ workbook that has been saved as password
protected POI determines that the file is in HSSF/BIFF format.
Password protected .xlsx files are slightly confusingly wrapped in an OLE2
container

Nick

Loading...