dton37910 2015-02-26 08:54
浏览 28

PHPExcel如何定义新客户PAPERSIZE(不是fontsize)

i need some help about papersize in PHPEXCEL

im using PHPExcel 1.8

and i wonder how to do this

if i redirect to printBigPaper.php , it will render excel file with 20inch x 25inch print area (Let's Name it : MY_CUSTOM_BIG_PAPER)

and

if i redirect to printSmallPaper.php , it will render excel file with 3inch vs 3inch print area (MY_CUSTOM_SMALL_PAPER)**.

That is all the list what i need to do.

If i manually use Excel, i can just simply Define new Paper Size once in a lifetime and then after i generate the excel file, i open it, and simply choose that paper size.

but i want do it automatically using PHPExcel.

What i've found out is :

I looked the code at "Classes/PHPExcel/Worksheet/PageSetup.php" and i found 66 DEFINED PAPER SIZE by PHPExcel

which i thing most of them has not defined yet in my Excel.

I tried to print using number 37 which is PAPERSIZE_MONARCH_ENVELOPE and it works eventhough i dont have that paper size in my Excel.

It makes me think, if PHPExcel can make 66 CONST PAPER SIZE and my excel understand that, i also can DEFINE new PAPER SIZE. So i make CONST MY_CUSTOM_BIG_PAPER as number 67.

then i tried to setPaperSize(PHPExcel_Worksheet_PageSetup::MY_CUSTOM_BIG_PAPER) and it does not give any errors.

but i dont know where to override the code so that PHPEXCEL can understand that if i choose MY_CUSTOM_BIG_PAPER , it will produce 20inch vs 25inch print area

thanks guys, i really hope you guys can help me with this problems.

  • 写回答

1条回答 默认 最新

  • douliaopan1419 2015-02-26 09:31
    关注

    There is no built-in mechanism that allows you to define new paper sizes from within your own code.... if you want to add new paper sizes, then you need to change the relevant sections of PHPExcel code (PageSetup.php); but you'll also need to modify the underlying Reader/Writer code to handle custom paper sizes.

    Note that many of those 66 different paper sizes that are already defined in PHPExcel will not be defined in your version of MS Excel, because many are locale-specific

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂