How can I set the font size for the Footer of sheet?

Topics: User Forum
Apr 26, 2009 at 7:21 PM
I've try below code:

$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&16&CSet the Font to 16px');
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&font size16&CSet the Font to 16px');

But the font size of footer isn't changed...What's the matter? Please help me, thanks!
Apr 26, 2009 at 7:51 PM
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&16Set the Font to 16px');

1. Create the workbook like you want it to be in MS Office Excel.
2. Read the file using PHPExcel_Reader_Excel2007

$reader = PHPExcel_IOFactory::createReader('Excel2007');
$excel = $reader->load('template.xlsx');

$sheet = $excel->getActiveSheet();

This will give you how to write the header or footer.

3. Alternatively, rename template.xlsx to, unzip it, and inspect file:


Look towards the end for something like this:

<headerFooter><oddHeader>&amp;16&amp;CSet the Font to 16px</oddHeader></headerFooter>

This will also give you how to write the header or footer.

Just keep in mind that &amp; should be written as & when you write the string in PHPExcel.

Apr 27, 2009 at 2:09 AM
Edited Apr 27, 2009 at 2:11 AM
Sorry,I can not catch your meaning, the start section of my code is as:

$objPHPExcel = new PHPExcel();

//Set default font & size of Excel File

//Set Header

Can you please show me how to setup it?
I just can found it out from the Developer documentation:


Code for "total pages"<o:p></o:p>

&font size

Code for "text font size", where font size is a font size in points.<o:p></o:p>

but it doesn't work when I do by following it.

Apr 27, 2009 at 12:23 PM
Try to run this:

$objPHPExcel = new PHPExcel();

$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->getHeaderFooter()->setOddHeader('&C&16Set the Font to 16px');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

Apr 28, 2009 at 5:52 AM

I have made it by run as:

$objWorksheet->getHeaderFooter()->setOddHeader('&C&16Set the Font to 16px');   //okay!

However, the differnce with my wrote code is the order sequence of "&C" and "&16":

$objWorksheet->getHeaderFooter()->setOddHeader('&16&CSet the Font to 16px');  //don't work

I just don't know why.

thanks so much koyama!