Reputation: 455
I have an excel document with multiple records which contains both the text content and images. I have to save the images according to the record basis. A record has either an image or multiple images or no image. So If I retrieve an image means then I have to name it.
Therefore, I need to find the image's cell name. So that I can easily name it and save it. But I have no solution to do this. Can we retrieve the cell information using
$worksheet->getDrawingCollection()
Please suggest me how to do this.
Upvotes: 1
Views: 5310
Reputation: 212412
$objPHPExcel = PHPExcel_IOFactory::load("MyExcelFile.xls");
foreach ($objPHPExcel->getSheetByName("My Sheet")->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();
$cellID = $drawing->getCoordinates();
// .... do your save here
}
}
Upvotes: 6