Problem saving .xlsx with image already present

Topics: Developer Forum
Dec 10, 2012 at 3:57 AM

PHPExcel 1.7.8

PHP536 on Windows7

Hi there,

I am hoping that this is a small oversight on my part :-)

I load a template with a .png already embedded, but when I save with ExcelWriter 2007, i get an error

PHP Fatal error:  Uncaught exception 'Exception' with message 'File zip://custom/excel/results/E1355108068.xlsx#xl/media/image1.png does not exist' in C:\inetpub\wwwroot\mmsales\custom\excel\phpExcel_1.7.8\Classes\PHPExcel\Writer\Excel2007\ContentTypes.php:216

The code saving is simply:

$this->objWriter = PHPExcel_IOFactory::createWriter($this->objPHPexcel, 'Excel2007');


And I get the error regarless of whether I modify the .xlxs.

Any help would be appreciated!

Many thanks





Dec 13, 2012 at 12:02 PM


Dec 20, 2012 at 5:27 PM

I am having this same issue and have been pulling my hair trying to figure this out. 

I am actually running this on a CentOS box.

I created a spreadsheet with text in one cell, loaded the file into a "reader" and "saved it" with a "writer" and it worked fine.

Modified the spreadsheet (in Excel) and added an image, saved the spreadsheet to the same name.  Ran through the same test, and I got the same type error that you did and it actually "deleted" my spreadsheet. (Luckily, I maintained a copy for further testing).

Modified the spreadsheet (in Excel) again and removed the image, save the spreadsheet to the same name.  Ran through the same test and it worked fine.

In playing around I noticed that with or without the image the value of $writer->getDrawingHashTable()->count() is 0.  Not sure if that means anything.

I am not sure where to go from here.