gpt4 book ai didi

php - 如何获取 excel 单元格中存在的图像?

转载 作者:行者123 更新时间:2023-12-05 07:02:47 25 4
gpt4 key购买 nike

我需要读取单元格中的图像,我知道如何读取工作表中的绘图,但 getDrawingCollection() 仅适用于工作表。是否有任何功能可以在获取数据时提供单元格中存在的图像。以下代码用于获取工作表的数据。

$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();
}
}

如果问题重复,我很乐意将其删除。

最佳答案

我不认为它有任何功能,但你可以这样做:

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
}
}

关于php - 如何获取 excel 单元格中存在的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63441036/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com