how to read and copy images in excel with php

Subject:

ref: http://www.walkswithme.net/reading-images-from-excel-sheet-using-phpexcel

 

 

2016-06-28 20:59:26gstlouis

$xlsFile = 'sample.xlsx';

require_once 'PHPExcel/Reader/Excel2007.php';

$objReader = new PHPExcel_Reader_Excel2007();

//$objReader->setReadDataOnly(true);

$data = $objReader->load($xlsFile);

$objWorksheet = $data->getActiveSheet();

foreach ($objWorksheet->getDrawingCollection() as $drawing) {

//for XLSX format

$string = $drawing->getCoordinates();

$coordinate = PHPExcel_Cell::coordinateFromString($string);

if ($drawing instanceof PHPExcel_Worksheet_Drawing){

$filename = $drawing->getPath();

$drawing->getDescription();

copy($filename, 'uploads/' . $drawing->getDescription());

}}

 

the above didn't work because getDescription had an emtpy string.  I changed it with $drawing->getIndexedFilename()

gstlouis
vote
2016-06-28 21:00:28