0

I'm able to read excel files from a folder using PHPExcel_IOFactory, but I'm not able to open and read Excel files from Zip.

Below is the code snippet

$inputFileType = \PHPExcel_IOFactory::identify("data\file.zip\\"."excel1.xlsx");

Getting below error

Exception 'PHPExcel_Reader_Exception' with message 'Could not open data\file.zip\excel1.xlsx for reading! File does not exist.'

Rohit Nimmala
  • 1,459
  • 10
  • 28
Rajani
  • 25
  • 6
  • 1
    You need to unzip excel first. [ZipArchive::open](https://www.php.net/manual/en/ziparchive.open.php) – Insane Skull Nov 25 '19 at 10:35
  • I have used like below $zip = new \ZipArchive(); if($zip->open('data\file.zip') == TrUE){ //here my code to read $inputFileType }. Still getting Exception – Rajani Nov 25 '19 at 10:47
  • [How to open and read from zip?](https://stackoverflow.com/questions/10420112/how-to-read-a-single-file-inside-a-zip-archive) – Insane Skull Nov 25 '19 at 12:29
  • Add what you have tried – Insane Skull Nov 25 '19 at 12:29
  • Thank you for your help. But it will not work for me. In my case, PHPExcel_IOFactory::identify() must idenfy the files from zip. Because I have to read each sheet from excel file. – Rajani Nov 25 '19 at 12:49
  • I understand that, But first you have to get file from zip file in order to read it. Add what you tried so far. – Insane Skull Nov 25 '19 at 13:00

0 Answers0