Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories


I want to read/retrieve an Image from excel file to PHP using PHPExcel. This code is used to retrieve a value from a particular cell.

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

This retrieves only the cell value, But i cant retrieve a image. Is there a way to do that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
901 views
Welcome To Ask or Share your Answers For Others

1 Answer

Googling phpexcel read image yielded this page as the second result. It tells you how to do this.

To quote the relevant info directly:

$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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...