gpt4 book ai didi

php - 在 PHPExcel 中检索图像

转载 作者:可可西里 更新时间:2023-11-01 13:10:32 24 4
gpt4 key购买 nike


我想使用 PHPExcel 从 excel 文件读取/检索图像到 PHP。此代码用于从特定单元格中检索值。

    $objPHPExcel->getActiveSheet()->getCell('B5')->getValue();

这仅检索单元格值,但我无法检索图像。有办法吗?

最佳答案

Googling phpexcel read image产生了 this page作为第二个结果。它会告诉您如何执行此操作。

直接引用相关信息:

$objPHPExcel->getActiveSheet()->getDrawingCollection() will return an ArrayObject of all the image objects in the active worksheet.

These objects will be either PHPExcel_Worksheet_Drawing or PHPExcel_Worksheet_MemoryDrawing objects: you can identify which using is_a(). You can then use the methods appropriate to that class (as described in the API) either to read the image data from file (for PHPExcel_Worksheet_Drawing objects) or directly from the PHPExcel_Worksheet_MemoryDrawing object itself. The getName() and getDescription() methods can be used to retrieve the relevant values from the image object.

Note that it's also possible to have image objects associated with print headers:

$objPHPExcel->getActiveSheet()->getHeaderFooter()->getImages() can be used to retrieve images from the header/footer. This is an array of PHPExcel_Worksheet_HeaderFooterDrawing objects. All the PHPExcel_Worksheet_Drawing methods can be used to extract the image file from these objects.

关于php - 在 PHPExcel 中检索图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7887332/

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