I need to read the images present in the cell, I know how to read the drawing present the sheet but the getDrawingCollection() only works on sheet. is there any function that will give the images present in the cell while getting the data. The below code is used to fetch the data of the sheet.
$spreadsheet = IOFactory::load($inputFileName);
$worksheet = $spreadsheet->setActiveSheetIndex(2);
foreach ($worksheet->getRowIterator() as $row) {
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(FALSE);
foreach ($cellIterator as $cell) {
echo $cell->getValue();
}
}
If the question is duplicate I am happy to remove it.
I don't think it has any function for that, but you can do something like this:
foreach ($worksheet->getDrawingCollection() as $drawing) {
$drawings[$drawing->getCoordinates()] = $drawing;
}
// then find your image using your cell coordinates
$image = $drawings[$cell->getCoordinates()];
// or
foreach ($worksheet->getDrawingCollection() as $drawing) {
if($drawing->getCoordinates() == $cell->getCoordinates()){
// or do your stuff here
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With