getDrawingCollection() won't work (1.7.0)

Topics: Developer Forum, User Forum
Sep 28, 2009 at 6:32 PM

I'm using version 1.6.6 and everything is cool :-)

Today I've updated to the latest version of PHPExcel and found that this construction doesn't work:


foreach ($worksheet->getDrawingCollection() as $i => $drawing) {




Point me pls what I've got to do to use the new version of PHPExcel?

Sep 29, 2009 at 3:45 AM

This is strange, to my knowledge it should still be working in PHPExcel 1.7.0. Are you getting any error messages?

Can you provide some information about the situation you are using the code in, e.g. are you reading xls/xlsx file ?

Sep 29, 2009 at 6:54 AM

I'm reading Excel 2007 (.xlsx) file, no error messages (set error_reporting(6143)), just $worksheet->getDrawingCollection is empty.

Sep 29, 2009 at 4:11 PM

Do you have several sheets in the workbook? There was a bug in PHPExcel 1.6.6 where it was not reading the active sheet index. The active sheet was always the first sheet.

When you open the xlsx file in Microsoft Office Excel, what sheet do you see? This is the active sheet.

My guess is that the active sheet is something else that you expect.


$objPHPExcel->setActiveSheetIndex(0); <--- insert this line

$worksheet = $objPHPExcel->getActiveSheet(); foreach ($worksheet->getDrawingCollection() as $i => $drawing) { }
Sep 29, 2009 at 4:29 PM

No no no! When I'm using a 1.6.6 version - everything works perfect, I know about this bug.

But when I'm using version 1.7.0 - my script doesn't see any images in .xlsx file.

Sep 29, 2009 at 4:37 PM


// Here is the part of my code.

// with 1.6.6 it works, with 1.7.0 - doesn't (((


ini_set('include_path', './Classes/');

include ("PHPExcel/Reader/Excel2007.php");

$reader = new PHPExcel_Reader_Excel2007();

$PHPExcel = $reader->load(@$excel);//открываем экселевский файл

$worksheet = $PHPExcel->getActiveSheet();

foreach ($worksheet->getDrawingCollection() as $i => $drawing) {

    echo "Bingo!";



Sep 29, 2009 at 4:39 PM

P.S. The problem happens only with images, with cell values etc. it works great!

Sep 29, 2009 at 4:49 PM

But you have this line?


It makes the reader skip images. Can you try to take that line out?

Sep 29, 2009 at 7:16 PM

But it works in 1.6.6.

Is this a new feature of 1.7.0 or bug of 1.6.6 ?

There are too much memory usage without this line :-( But it works! Thanks!

Sep 29, 2009 at 7:23 PM

>> There are too much memory usage without this line

Starting with PHPExcel 1.7.0 memory usage from styles have been practically eliminated. Therefore setReadDataOnly(true) should no longer be necessary for saving memory.