Bug 60347 - Reading password protected worksheet (version - excel 95,97-2003)
Summary: Reading password protected worksheet (version - excel 95,97-2003)
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.13-FINAL
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-06 15:33 UTC by Barak
Modified: 2016-11-06 16:41 UTC (History)
0 users



Attachments
Excel file with password (34.50 KB, application/vnd.ms-excel)
2016-11-06 16:26 UTC, Barak
Details
Excel file 95 with password (26.00 KB, application/vnd.ms-excel)
2016-11-06 16:27 UTC, Barak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Barak 2016-11-06 15:33:57 UTC
I have a password protected worksheet create with excel 95,97-2003

i have the password and i was trying to read this file in different ways

Method 1:

WorkbookFactory.create(inputStream, "password");
throws:  org.apache.poi.EncryptedDocumentException: HSSF does not currently support CryptoAPI encryption
Method 2:

    protected InputStream WorkbookProtectionUnlocker(NPOIFSFileSystem fs, String password) throws AAAAException {

    EncryptionInfo info;
    try {
        info = new EncryptionInfo(fs.getRoot());
    } catch (IOException e) {
        throw new AAAException(e.getCause());
    }

    Decryptor d = Decryptor.getInstance(info);
org.apache.poi.EncryptedDocumentException: HSSF does not currently support CryptoAPI encryption

also throw the same exception

Method 3:

org.apache.poi.hssf.record.crypto.Biff8EncryptionKey.setCurrentUserPassword("password");

Workbook wb = new HSSFWorkbook(new FileInputStream(file);
same exception .

Method 4:

read about jxl.Workbook.getWorkbook but in this object the password is only allowed setting it to the sheet not the entire worksheet .

throw this error: jxl.read.biff.PasswordException

since its not possible setting the password to the worksheet .

method 5

org.apache.poi.hssf.record.crypto.Biff8EncryptionKey.setCurrentUserPassword(fileInfo.getFileOptions().xlsWorkbookPasswordExpression);
                            WorkbookFactory.create(new FileInputStream(fileInfo.getInputFile()));
the same exception:

    org.apache.poi.EncryptedDocumentException: HSSF does not currently support CryptoAPI encryption
what is the correct way of Opening HSSF workbook which is password protected ?
Comment 1 Andreas Beeker 2016-11-06 16:11:54 UTC
Can you try with a nightly? ... I have added CryptoAPI support just recently.
If this fails, could you send me the file on my apache email?
Comment 2 Barak 2016-11-06 16:26:47 UTC
Created attachment 34424 [details]
Excel file with password

password is 12345
Comment 3 Barak 2016-11-06 16:27:27 UTC
Created attachment 34425 [details]
Excel file 95 with password

password is 12345
Comment 4 Andreas Beeker 2016-11-06 16:41:24 UTC
The "Excel file 95" is in Biff5 format, which is not supported by the HSSF classes - although there's an OldExcelExtractor class, I haven't implemented the crypto logic there.
The other excel file opens just fine:

Biff8EncryptionKey.setCurrentUserPassword("12345");
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream("Canada - 97-2003 Pass.xls"));


With "nightly" I meant a development build:
https://builds.apache.org/job/POI/lastSuccessfulBuild/artifact/build/dist/