本文介绍了PHPexcel:图像提取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个具有多个记录的excel文档,其中包含文本内容和图像.我必须根据记录保存图像.一条记录包含一个图像或多个图像,或者没有图像.因此,如果我检索图像意味着必须命名.
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()
请建议我该怎么做.
推荐答案
$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
}
}
这篇关于PHPexcel:图像提取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!