Phpspreadsheet: Reading XLS with password protection

Created on 5 Apr 2018  路  12Comments  路  Source: PHPOffice/PhpSpreadsheet

This is:

- [ ] a bug report
- [x] a feature request

What is the expected behavior?

XLS with file password protection should be readable.

What is the current behavior?

Only default password ( VelvetSweatshop ) is used

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

    $filename = './data/Reader/XLS/with_password.xls';
    $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
    $reader->setWorkbookPassword('secret');  // or other method for set password 

    $sheet = $reader->load($filename);
         // sheet should be loaded   

Which versions of PhpSpreadsheet and PHP are affected?

1.2.0 - master

stale

Most helpful comment

+1 for workbook password, this would really help with GDPR. Been doing some research, perhaps password protected .ods would be easier as this is more documented than excel approach to password protection?

All 12 comments

Has this been included in the current version?
This would solve a problem I am having.
Thanks.

+1 for workbook password, this would really help with GDPR. Been doing some research, perhaps password protected .ods would be easier as this is more documented than excel approach to password protection?

+1 for workbook protection with password for gdpr

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

+1 This will help sending out GDPR complient email attachments!

+1, no news on this ?

still waiting for this to get fixed.

+1 mark. zip can do this, not expect

Can anyone please help me, I'm trying to unlock a password protected file with PHP. Can't find any library

You can try msoffcrypto-tool is a Python tool and library for decrypting encrypted MS Office files with a password. And use PhpSpreadsheet to read the unencrypted file in a temporary folder.
I used it in some projects, work great.

It would be great if PhpSpreadsheet has functionality to read password protected file with password specified..

I welcome you to check out my PHPDecryptXLSXWithPassword repo. It can decrypt an XLSX file with given password and generate an unprotected (open) XLSX file. Then you can use it with PHPSpreadsheet.
Edit: it also works on DOCX and PPTX files.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garnold picture garnold  路  5Comments

smartlara picture smartlara  路  5Comments

leandrogm picture leandrogm  路  5Comments

cheinle picture cheinle  路  3Comments

ionesculiviucristian picture ionesculiviucristian  路  4Comments