I am using PHPExcel library for spreadsheet operations. I am to apply print ready functionality. Does this functionality exist?
1 Answer
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:-
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
-
Sorry if a little OOT. But is there a function to print the excel file? I mean, send it to serverside printer? Dec 7, 2015 at 6:15
-
1@FandiSusanto - No there isn't, that would be outside the scope of PHPExcel which is simply a library for manipulating spreadsheet files Dec 7, 2015 at 7:53
-
@Mark Baker Maybe you can help me. Look at this : stackoverflow.com/questions/56681038/… Jun 20, 2019 at 10:30