1

Closed

Extracting images with Excel file (xlsx) using PHP

description

How can I read images from excel file using PHPExcel and save the images in the server and display them? the extension of the file is .xlsx
Closed Jun 6, 2012 at 12:08 PM by MarkBaker
This is not an Issue. It should be on the discussion board, not in the issue tracker.$objPHPExcel = PHPExcel_IOFactory::load("00Test.xlsx");$i = 0;foreach ($objPHPExcel->getActiveSheet()->getDrawingCollection() as $drawing) { if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) { ob_start(); call_user_func( $drawing->getRenderingFunction(), $drawing->getImageResource() ); $imageContents = ob_get_contents(); ob_end_clean(); $extension = 'png'; } else { $zipReader = fopen($drawing->getPath(),'r'); $imageContents = ''; while (!feof($zipReader)) { $imageContents .= fread($zipReader,1024); } fclose($zipReader); $extension = $drawing->getExtension(); } $myFileName = '00_Image_'.++$i.'.'.$extension; file_put_contents($myFileName,$imageContents);}

comments

rSara wrote Jun 6, 2012 at 7:49 AM

m