How to use print-ready features in the PHPExcel library

I use the PHPExcel library for working with spreadsheets. I use print functionality. Does this functionality exist?

+6
source share
1 answer

If you read the documentation , in particular the section " Configuring printer settings for Excel files ), there is a lot of information about setting up a page for printing: -

Orientation and paper size:

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

Page Fields:

 $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 ); 

Display 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 documentation so you don’t have to ask such questions

+24
source

Source: https://habr.com/ru/post/983732/


All Articles