Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read password protected Excel files using PHPExcel?

Tags:

php

xls

phpexcel

When Tried to read a password protected file using PHPExcel,I got this error.I tried pasting the password in different function of PHPExcel,but didn't work.Please tell me how to open password protected Excel file via PHPExcel.

There was a problem handling your file. Technical details: Cannot read encrypted file

My Code

    $inputFileType = PHPExcel_IOFactory::identify(dirname(__FILE__) . '/../uploads/' . $model->report);
    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
    if ($inputFileType != 'CSV') {
         $objReader->setReadDataOnly(true);
    }
    $objPHPExcel = $objReader->load(dirname(__FILE__) . '/../uploads/' . $model->report);
    $objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
like image 979
Harikrishnan Avatar asked Nov 02 '22 11:11

Harikrishnan


1 Answers

At this point, PHPExcel still can't read files that have been password protected, but somebody actually posted a PR yesterday that should allow this, based on the Perl encrypted file reader. I've yet to look at it, and doubt if I'll get much chance today due to real-world pressures of work; but I should get an opportunity to test it over the coming week... so there's real hope that the next release will allow reading of password protected xls files.

like image 70
Mark Baker Avatar answered Nov 14 '22 15:11

Mark Baker