Add a newline in header [solved]

Topics: Developer Forum, User Forum
Dec 7, 2010 at 2:46 PM


I'm newbie on PHPExcel but I'd quickly set-up a routine for generate am Excel file from PHP database, primary for have a well controlled layout "from" a web page.

A problem that I don't resolve is the way to insert a newline in header (or footer): I try with \n "\n" \n\r, tryed to read a header formed with Excel, but without results.

Have I lost some manual entry or blog discussion that solve the problem?

If actualy isn't a solution, will be introduce in the next version?

Thanks in advance.

Dec 8, 2010 at 2:39 PM
Edited Dec 8, 2010 at 2:40 PM

\n should work. (normal PHP rules for \n in single and double quotes apply)

$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&HPlease treat this document as confidential!');
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&"Arial,Bold"Test for line feed in header or footer&CAuthor: Mark Baker'."\n".'Test Worksheet'."\n".'Page &P of &N');

Dec 9, 2010 at 1:00 PM

Yes! I had lost the single/double quote rules! Now it works.

Thanks very much.


Mar 2, 2012 at 9:00 PM

thanks, that response was ussefull for me. Hello from Mexico City.