Get specific images from XLS file

Topics: User Forum
May 11, 2011 at 4:47 PM
Edited May 11, 2011 at 4:50 PM

Hi all,

Just wondering if it is possible to return individual images when reading an XLS file?  So in the same way as you can retrieve a specific cell value, can you retrieve a specific image?

I know that my image names will always be "Image1" & "Image2" within the XLS file.

Many thanks for any help offered - I've been pulling my hair out trying to do this! :)

PHPExcel 1.7.6
PHP 5.2.17
Linux Server

May 15, 2011 at 9:58 AM

If someone can help me with this I would be very grateful.  Even if someone just lets me know that it is/isn't possible.

Thank you

May 16, 2011 at 2:14 PM

Sorry to keep bumping this - please can anyone say if this is possible or not?  Can you read images from an xls file and use it in PHP to save onto the server etc?

Please please please can someone help...

May 25, 2011 at 12:40 AM

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 fro the image object.

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


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.

May 31, 2011 at 5:11 PM

Hi Mark,

I was the one who asked this on StackOverflow too.  Thank you very much for replying to me.

A couple of related questions if you don't mind:

  1. What determines if an image will be a PHPExcel_Worksheet_Drawing object or a PHPExcel_Worksheet_MemoryDrawing object?  Is it how to create it in Excel?
  2. Can you adjust the quality of the image returned from the Excel file?


For anyone else, I have it working with the following code:


$objPHPExcel = PHPExcel_IOFactory::load("MyExcelFile.xls");

foreach ($objPHPExcel->getSheetByName("My Sheet")->getDrawingCollection() as $drawing) {
	if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
		$imageContents = ob_get_contents();

Then $imageContents will contain the image data that you can output or save as a file etc.

Great library by the way!


Aug 28, 2013 at 2:51 PM
Hi ,

I ll be so happy if it is possible to read embedded object ( ) like image from excel using PHP .

Can any one help me