unable to get any of the getPageSetup functions to work

Topics: User Forum
Apr 22, 2010 at 7:08 PM

version :: PHPExcel 1.7.2

I am passing the excel sheet to the client through the browser

The following piece of code works fine, until I uncomment any of the getPageSetup functions.

Then the webpage just goes blank on me.

Is there anything else I need to 'require' to get the page_setup functions to work ?

(I am almost sure its something very basic, but I would appreciate it if someone would point it out! :( Thanks)

require_once 'PHPExcel.php'

    private function BoE_header($excel, $worksheet_no) {
         /*
 
        //Set the Page Size and Orientation
        $excel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_WorksheetPageSetup::ORIENTATION_LANDSCAPE);
        $excel->getActiveSheet()->getPageSetup()->setPagerSize(PHPExcel_WorksheetPageSetup::PAPERSIZE_A4);
        //Ensure that the worksheet is printed in 1 page
        $excel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
        $excel->getActiveSheet()->getPageSetup()->setFitToHeight(1);
        //Center the page Horizontally and Vertically
        $excel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
        $excel->getActiveSheet()->getPageSetup()->setVerticalCentered(true);
        
        // Show gridlines when printing
        $excel->getActiveSheet()->getPageSetup()->setShowGridlines(true);
*/



        $excel->getActiveSheet()->insertNewRowBefore(1,2);
        $excel->getActiveSheet()->SetCellValue('J2', 'FORM V');

        $excel->getActiveSheet()->SetCellValue('I3', '(SEE REGULATION 7)');
                $excel->getActiveSheet()->mergeCells('I3:K3');
                $excel->getActiveSheet()->getStyle('I3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

        $excel->getActiveSheet()->SetCellValue('O3', 'BE No.:');
        $excel->getActiveSheet()->SetCellValue('H4', 'Bill to Be provided for entry');
        $excel->getActiveSheet()->SetCellValue('O4', 'DATE');
        $excel->getActiveSheet()->SetCellValue('C5', 'NAME & ADDRESS OF THE');
        $excel->getActiveSheet()->SetCellValue('C6', 'authorized consignee');
}

Jul 5, 2010 at 5:14 AM

$excel->getActiveSheet()->getPageSetup()->setShowGridlines(true);

====> $excel->getActiveSheet()->setShowGridlines(true);

 

$excel->getActiveSheet()->getPageSetup()->setPagerSize(PHPExcel_WorksheetPageSetup::PAPERSIZE_A4);

====> $excel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);

and other Error was also cause of incorrect function call

Jul 7, 2010 at 8:54 PM

I dunno about bhave13, but while the proper call may in fact be $excel->getActiveSheet()->setShowGridlines(true);

It does diddly, no lines, no nothing, at least for me. For the most part things work beautifully, except for a few page settings.

I couldn't get $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 2); to work either, and in the case of a multi-sheet document in bombed (nothing legible in the resulting file). Odd, though, the example runs fine, maybe I'm running it at the wrong spot (despite similar settings working)?

Jul 8, 2010 at 4:50 PM

Looks like my issue with gridlines was I was using the wrong setting, now I have no idea what setShowGridlines() does... what I wanted was:

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

Still no luck with my repeating rows issue.

 

Jul 8, 2010 at 5:13 PM

Ok..now I'm redfaced...

After expecting setShowGridlines to only show in printing, for some reason I expected the repeating rows function to show up in regular view (and I failed to check printing, doh).

It works just fine :-[

Jul 26, 2010 at 5:08 PM
tracerofwind wrote:

$excel->getActiveSheet()->getPageSetup()->setShowGridlines(true);

====> $excel->getActiveSheet()->setShowGridlines(true);

 

$excel->getActiveSheet()->getPageSetup()->setPagerSize(PHPExcel_WorksheetPageSetup::PAPERSIZE_A4);

====> $excel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);

and other Error was also cause of incorrect function call

Thank you, was away from this project for while, usually it does not take me so long to appreciate timely help. Appreciate the corrections.