Background image in header/footer

Topics: Developer Forum, User Forum
Jan 12, 2009 at 10:13 AM

According to the phpExcel documentation it should be possible to add a background image in the header/footer, but I can't make it working.

My code:

$objDrawing = new PHPExcel_Worksheet_HeaderFooterDrawing();
$this->getActiveSheet()->getHeaderFooter()->addImage($objDrawing, PHPExcel_Worksheet_HeaderFooter::IMAGE_HEADER_LEFT);


Can someone point me out what I do wrong ?

Thx in advance

Jan 13, 2009 at 12:36 AM
Are you using Excel2007 or Excel5 writer?

Jan 13, 2009 at 8:57 AM
I'm using Excel2007. I did try in Excel5 which doesn't either.
Jan 13, 2009 at 10:59 AM
You need a section code, such as for left, center, right

This would be for left section:


Tip: When in doubt what values to use, create in MS Office Excel 2007 the spreadsheet the way you want it to look. Then use PHPExcel_Reader_Excel2007 to read off the correct values as they should be set.
Jan 13, 2009 at 12:34 PM
OOOOOH that was it :D :D :D

I tried everything except that :$

Thx koyama !!! Als thx for the tip !
Jan 13, 2009 at 12:53 PM
I do have another issue ..

I need to do the same code but for another sheet in the same workbook ... but this don't work he only puts the background on the first sheet. Each time it repairs the file and removes the drawings ("Removed Part: Drawing shape.")

is there a limitation ?
Jan 13, 2009 at 1:08 PM
Thanks, I verified the bug. Will post this in the issue tracker!

Jan 13, 2009 at 1:33 PM
Work item created in the issue tracker:

Mar 23, 2009 at 10:40 AM
I have a similar problem with image in header but I'm using excel5.
All is fine but there is no background image.
please What can I do to have a image header on an excel5 file ?

my code :

    require_once 'PHPExcel.php';
    require_once 'PHPExcel/IOFactory.php';
    require_once 'PHPExcel/Writer/Excel5.php';
    require_once 'PHPExcel/Worksheet/Drawing.php';

    $objPHPExcel = new PHPExcel();
    $sheet = $objPHPExcel->getActiveSheet();

    $objDrawing = new PHPExcel_Worksheet_HeaderFooterDrawing();

    $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
Mar 24, 2009 at 8:04 PM
@clionhearts: Excel5 reader/writer does unfortunately not support header/footer images. I think it may be hard to implement, but it might come in the future.

Mar 25, 2009 at 12:09 PM
ok thanks for your answer