Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






Change a cell into a clickable URL

You can make a cell a clickable URL by setting its hyperlink property:

$objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');

$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net');

 

If you want to make a hyperlink to another worksheet/cell, use the following code:

$objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');

$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl(“sheet://'Sheetname'!A1”);

4.6.9. Setting a worksheet’s page orientation and size

Setting a worksheet’s page orientation and size can be done using the following lines of code:

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

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

 

Note that there are additional page settings available. Please refer to the API documentation for all possible options.

4.6.10. Page Setup: Scaling options

The page setup scaling options in PHPExcel relate directly to the scaling options in the "Page Setup" dialog as shown in the illustration.

 

Default values in PHPExcel correspond to default values in MS Office Excel as shown in illustration

 

 

 

method initial value calling method will trigger Note
setFitToPage(...) false -  
setScale(...) setFitToPage(false)  
setFitToWidth(...) setFitToPage(true) value 0 means do-not-fit-to-width
setFitToHeight(...) setFitToPage(true) value 0 means do-not-fit-to-height

 

Example

Here is how to fit to 1 page wide by infinite pages tall:

 

$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);

$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);

 

As you can see, it is not necessary to call setFitToPage(true) since setFitToWidth(…) and setFitToHeight(…) triggers this.

 

i If you use setFitToWidth() you should in general also specify setFitToHeight() explicitly like in the example. Be careful relying on the initial values. This is especially true if you are upgrading from PHPExcel 1.7.0 to 1.7.1 where the default values for fit-to-height and fit-to-width changed from 0 to 1.

Page margins

To set page margins for a worksheet, use this code:

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

$objPHPExcel->getActiveSheet()->getPageMargins()->setBottom(1);

 

Note that the margin values are specified in inches.

 

4.6.12. Center a page horizontally/vertically

To center a page horizontally/vertically, you can use the following code:



$objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
$objPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);


Date: 2016-03-03; view: 1319


<== previous page | next page ==>
Locale Settings for Formulae | Setting the print header and footer of a worksheet
doclecture.net - lectures - 2014-2024 year. Copyright infringement or personal data (0.012 sec.)