php 如何在 PHPExcel 库中使用打印就绪功能
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29026645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use print ready functionality in PHPExcel library
提问by Vaishnavesh
I am using PHPExcel library for spreadsheet operations. I am to apply print ready functionality. Does this functionality exist?
我正在使用 PHPExcel 库进行电子表格操作。我要应用打印就绪功能。有这个功能吗?
回答by Mark Baker
If you read the documentation, particularly the section entitled "Setting printer options for Excel files", there's a lot of information about page setup for printing:-
如果您阅读文档,特别是标题为“为 Excel 文件设置打印机选项”的部分,则有很多关于打印页面设置的信息:-
Orientation and Paper Size:
方向和纸张尺寸:
$objPHPExcel->getActiveSheet()
->getPageSetup()
->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()
->getPageSetup()
->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
Page margins:
页边距:
$objPHPExcel->getActiveSheet()
->getPageMargins()->setTop(1);
$objPHPExcel->getActiveSheet()
->getPageMargins()->setRight(0.75);
$objPHPExcel->getActiveSheet()
->getPageMargins()->setLeft(0.75);
$objPHPExcel->getActiveSheet()
->getPageMargins()->setBottom(1);
Headers and Footers:
页眉和页脚:
$objPHPExcel->getActiveSheet()
->getHeaderFooter()
->setOddHeader('&C&HPlease treat this document as confidential!');
$objPHPExcel->getActiveSheet()
->getHeaderFooter()
->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() .
Printer page breaks:
打印机分页符:
$objPHPExcel->getActiveSheet()
->setBreak( 'A10' , PHPExcel_Worksheet::BREAK_ROW );
Showing grid lines:
显示网格线:
$objPHPExcel->getActiveSheet()
->setShowGridlines(true);
Setting rows/columns to repeat at the top/left of each page
将行/列设置为在每页的顶部/左侧重复
$objPHPExcel->getActiveSheet()
->getPageSetup()
->setRowsToRepeatAtTopByStartAndEnd(1, 5);
Setting the print area:
设置打印区域:
$objPHPExcel->getActiveSheet()
->getPageSetup()
->setPrintArea('A1:E5,G4:M20');
We write the documentation so that you don't have to ask questions like this
我们编写文档是为了让您不必问这样的问题