Kim Stacks Kim Stacks - 4 months ago 51
PHP Question

set footer in all printed pages using phpexcel

What I want to achieve:

I am currently using PHPExcel and I want to display the filename and the page numbers in all the right hand side footer of all the printed pages.

Basically the format should be

filename.xlsx Page 1 / 2

is the file name

and 1 is the current page number

and 2 is the total page number

What I have tried:

I have tried the following code:


On the print preview we saw there are 5 sheets

When we press print, the printer printed out 4 only.

  • First page we only see the filename

  • Second page we only see the number 4

  • Third page we only see the number 5

  • Fourth page we only see the number 4

The position is correct in all the pages, ie the right hand side footer.

The value is not.

Please advise.


If you need the footer displayed on all pages, then you need to save the value for odd and for even footers

    ->getHeaderFooter()->setOddFooter('&R&F Page &P / &N');
    ->getHeaderFooter()->setEvenFooter('&R&F Page &P / &N');