如果您阅读文档,特别是标题为" 为Excel文件设置打印机选项 "的部分,那么有很多关于打印页面设置的信息: -

方向和纸张尺寸:

$objPHPExcel->getActiveSheet()
    ->getPageSetup()
    ->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()
    ->getPageSetup()
    ->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);

页边距:

$objPHPExcel->getActiveSheet()
    ->getPageMargins()->setTop(1);
$objPHPExcel->getActiveSheet()
    ->getPageMargins()->setRight(0.75);
$objPHPExcel->getActiveSheet()
    ->getPageMargins()->setLeft(0.75);
$objPHPExcel->getActiveSheet()
    ->getPageMargins()->setBottom(1);

页眉和页脚:

$objPHPExcel->getActiveSheet()
    ->getHeaderFooter()
    ->setOddHeader('&C&HPlease treat this document as confidential!');
$objPHPExcel->getActiveSheet()
    ->getHeaderFooter()
    ->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . 

 打印机分页符:

$objPHPExcel->getActiveSheet()
    ->setBreak( 'A10' , PHPExcel_Worksheet::BREAK_ROW );

显示网格线:

$objPHPExcel->getActiveSheet()
    ->setShowGridlines(true);

 将行/列设置为在每页的顶部/左侧重复

$objPHPExcel->getActiveSheet()
    ->getPageSetup()
    ->setRowsToRepeatAtTopByStartAndEnd(1, 5);

设置打印区域:

$objPHPExcel->getActiveSheet()
    ->getPageSetup()
    ->setPrintArea('A1:E5,G4:M20');

 我们编写文档,以便您不必提出这样的问题

posted on 2022-09-23 16:57  Beautytoloveme  阅读(286)  评论(0编辑  收藏  举报