PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 5, 2022

[FIXED] How to read password protected Excel files using PHPExcel?

 October 05, 2022     php, phpexcel, xls     No comments   

Issue

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);

Solution

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.



Answered By - Mark Baker
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing