使用phpexcel在所有打印页面中设置页脚 [英] set footer in all printed pages using phpexcel

查看:119
本文介绍了使用phpexcel在所有打印页面中设置页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现的目标:

我当前正在使用PHPExcel,并且我想在所有打印页面的 右侧页脚中显示文件名和页码 .

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.

基本上格式应该是

filename.xlsx Page 1 / 2

其中filename.xlsx是文件名

并且1是当前页码

总页数为2

我尝试过的事情:

我尝试了以下代码:

$this->objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&R&F');
$this->objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&R&P');
$this->objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&R&N');

在打印预览中,我们看到有5张纸

On the print preview we saw there are 5 sheets

当我们按打印时,打印机仅打印出4张.

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

  • 我们只在第一页看到文件名
  • 第二页我们只看到数字4
  • 第三页我们只看到数字5
  • 第四页我们只看到数字4

在所有页面(即右侧页脚)中的位置都是正确的.

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

该值不是.

请告知.

推荐答案

如果需要在所有页面上显示页脚,则需要保存奇数和偶数页脚的值

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

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

这篇关于使用phpexcel在所有打印页面中设置页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆