PHPExcel_Worksheet
[ class tree: PHPExcel_Worksheet ] [ index: PHPExcel_Worksheet ] [ all elements ]

Source for file PageSetup.php

Documentation is available at PageSetup.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2010 PHPExcel
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPExcel
  22.  * @package    PHPExcel_Worksheet
  23.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.4, 2010-08-26
  26.  */
  27.  
  28.  
  29. /**
  30.  * PHPExcel_Worksheet_PageSetup
  31.  *
  32.  * <code>
  33.  * Paper size taken from Office Open XML Part 4 - Markup Language Reference, page 1988:
  34.  *
  35.  * 1 = Letter paper (8.5 in. by 11 in.)
  36.  * 2 = Letter small paper (8.5 in. by 11 in.)
  37.  * 3 = Tabloid paper (11 in. by 17 in.)
  38.  * 4 = Ledger paper (17 in. by 11 in.)
  39.  * 5 = Legal paper (8.5 in. by 14 in.)
  40.  * 6 = Statement paper (5.5 in. by 8.5 in.)
  41.  * 7 = Executive paper (7.25 in. by 10.5 in.)
  42.  * 8 = A3 paper (297 mm by 420 mm)
  43.  * 9 = A4 paper (210 mm by 297 mm)
  44.  * 10 = A4 small paper (210 mm by 297 mm)
  45.  * 11 = A5 paper (148 mm by 210 mm)
  46.  * 12 = B4 paper (250 mm by 353 mm)
  47.  * 13 = B5 paper (176 mm by 250 mm)
  48.  * 14 = Folio paper (8.5 in. by 13 in.)
  49.  * 15 = Quarto paper (215 mm by 275 mm)
  50.  * 16 = Standard paper (10 in. by 14 in.)
  51.  * 17 = Standard paper (11 in. by 17 in.)
  52.  * 18 = Note paper (8.5 in. by 11 in.)
  53.  * 19 = #9 envelope (3.875 in. by 8.875 in.)
  54.  * 20 = #10 envelope (4.125 in. by 9.5 in.)
  55.  * 21 = #11 envelope (4.5 in. by 10.375 in.)
  56.  * 22 = #12 envelope (4.75 in. by 11 in.)
  57.  * 23 = #14 envelope (5 in. by 11.5 in.)
  58.  * 24 = C paper (17 in. by 22 in.)
  59.  * 25 = D paper (22 in. by 34 in.)
  60.  * 26 = E paper (34 in. by 44 in.)
  61.  * 27 = DL envelope (110 mm by 220 mm)
  62.  * 28 = C5 envelope (162 mm by 229 mm)
  63.  * 29 = C3 envelope (324 mm by 458 mm)
  64.  * 30 = C4 envelope (229 mm by 324 mm)
  65.  * 31 = C6 envelope (114 mm by 162 mm)
  66.  * 32 = C65 envelope (114 mm by 229 mm)
  67.  * 33 = B4 envelope (250 mm by 353 mm)
  68.  * 34 = B5 envelope (176 mm by 250 mm)
  69.  * 35 = B6 envelope (176 mm by 125 mm)
  70.  * 36 = Italy envelope (110 mm by 230 mm)
  71.  * 37 = Monarch envelope (3.875 in. by 7.5 in.).
  72.  * 38 = 6 3/4 envelope (3.625 in. by 6.5 in.)
  73.  * 39 = US standard fanfold (14.875 in. by 11 in.)
  74.  * 40 = German standard fanfold (8.5 in. by 12 in.)
  75.  * 41 = German legal fanfold (8.5 in. by 13 in.)
  76.  * 42 = ISO B4 (250 mm by 353 mm)
  77.  * 43 = Japanese double postcard (200 mm by 148 mm)
  78.  * 44 = Standard paper (9 in. by 11 in.)
  79.  * 45 = Standard paper (10 in. by 11 in.)
  80.  * 46 = Standard paper (15 in. by 11 in.)
  81.  * 47 = Invite envelope (220 mm by 220 mm)
  82.  * 50 = Letter extra paper (9.275 in. by 12 in.)
  83.  * 51 = Legal extra paper (9.275 in. by 15 in.)
  84.  * 52 = Tabloid extra paper (11.69 in. by 18 in.)
  85.  * 53 = A4 extra paper (236 mm by 322 mm)
  86.  * 54 = Letter transverse paper (8.275 in. by 11 in.)
  87.  * 55 = A4 transverse paper (210 mm by 297 mm)
  88.  * 56 = Letter extra transverse paper (9.275 in. by 12 in.)
  89.  * 57 = SuperA/SuperA/A4 paper (227 mm by 356 mm)
  90.  * 58 = SuperB/SuperB/A3 paper (305 mm by 487 mm)
  91.  * 59 = Letter plus paper (8.5 in. by 12.69 in.)
  92.  * 60 = A4 plus paper (210 mm by 330 mm)
  93.  * 61 = A5 transverse paper (148 mm by 210 mm)
  94.  * 62 = JIS B5 transverse paper (182 mm by 257 mm)
  95.  * 63 = A3 extra paper (322 mm by 445 mm)
  96.  * 64 = A5 extra paper (174 mm by 235 mm)
  97.  * 65 = ISO B5 extra paper (201 mm by 276 mm)
  98.  * 66 = A2 paper (420 mm by 594 mm)
  99.  * 67 = A3 transverse paper (297 mm by 420 mm)
  100.  * 68 = A3 extra transverse paper (322 mm by 445 mm)
  101.  * </code>
  102.  *
  103.  * @category   PHPExcel
  104.  * @package    PHPExcel_Worksheet
  105.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  106.  */
  107. {
  108.     /* Paper size */
  109.     const PAPERSIZE_LETTER                            1;
  110.     const PAPERSIZE_LETTER_SMALL                    2;
  111.     const PAPERSIZE_TABLOID                            3;
  112.     const PAPERSIZE_LEDGER                            4;
  113.     const PAPERSIZE_LEGAL                            5;
  114.     const PAPERSIZE_STATEMENT                        6;
  115.     const PAPERSIZE_EXECUTIVE                        7;
  116.     const PAPERSIZE_A3                                8;
  117.     const PAPERSIZE_A4                                9;
  118.     const PAPERSIZE_A4_SMALL                        10;
  119.     const PAPERSIZE_A5                                11;
  120.     const PAPERSIZE_B4                                12;
  121.     const PAPERSIZE_B5                                13;
  122.     const PAPERSIZE_FOLIO                            14;
  123.     const PAPERSIZE_QUARTO                            15;
  124.     const PAPERSIZE_STANDARD_1                        16;
  125.     const PAPERSIZE_STANDARD_2                        17;
  126.     const PAPERSIZE_NOTE                            18;
  127.     const PAPERSIZE_NO9_ENVELOPE                    19;
  128.     const PAPERSIZE_NO10_ENVELOPE                    20;
  129.     const PAPERSIZE_NO11_ENVELOPE                    21;
  130.     const PAPERSIZE_NO12_ENVELOPE                    22;
  131.     const PAPERSIZE_NO14_ENVELOPE                    23;
  132.     const PAPERSIZE_C                                24;
  133.     const PAPERSIZE_D                                25;
  134.     const PAPERSIZE_E                                26;
  135.     const PAPERSIZE_DL_ENVELOPE                        27;
  136.     const PAPERSIZE_C5_ENVELOPE                        28;
  137.     const PAPERSIZE_C3_ENVELOPE                        29;
  138.     const PAPERSIZE_C4_ENVELOPE                        30;
  139.     const PAPERSIZE_C6_ENVELOPE                        31;
  140.     const PAPERSIZE_C65_ENVELOPE                    32;
  141.     const PAPERSIZE_B4_ENVELOPE                        33;
  142.     const PAPERSIZE_B5_ENVELOPE                        34;
  143.     const PAPERSIZE_B6_ENVELOPE                        35;
  144.     const PAPERSIZE_ITALY_ENVELOPE                    36;
  145.     const PAPERSIZE_MONARCH_ENVELOPE                37;
  146.     const PAPERSIZE_6_3_4_ENVELOPE                    38;
  147.     const PAPERSIZE_US_STANDARD_FANFOLD                39;
  148.     const PAPERSIZE_GERMAN_STANDARD_FANFOLD            40;
  149.     const PAPERSIZE_GERMAN_LEGAL_FANFOLD            41;
  150.     const PAPERSIZE_ISO_B4                            42;
  151.     const PAPERSIZE_JAPANESE_DOUBLE_POSTCARD        43;
  152.     const PAPERSIZE_STANDARD_PAPER_1                44;
  153.     const PAPERSIZE_STANDARD_PAPER_2                45;
  154.     const PAPERSIZE_STANDARD_PAPER_3                46;
  155.     const PAPERSIZE_INVITE_ENVELOPE                    47;
  156.     const PAPERSIZE_LETTER_EXTRA_PAPER                48;
  157.     const PAPERSIZE_LEGAL_EXTRA_PAPER                49;
  158.     const PAPERSIZE_TABLOID_EXTRA_PAPER                50;
  159.     const PAPERSIZE_A4_EXTRA_PAPER                    51;
  160.     const PAPERSIZE_LETTER_TRANSVERSE_PAPER            52;
  161.     const PAPERSIZE_A4_TRANSVERSE_PAPER                53;
  162.     const PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER    54;
  163.     const PAPERSIZE_SUPERA_SUPERA_A4_PAPER            55;
  164.     const PAPERSIZE_SUPERB_SUPERB_A3_PAPER            56;
  165.     const PAPERSIZE_LETTER_PLUS_PAPER                57;
  166.     const PAPERSIZE_A4_PLUS_PAPER                    58;
  167.     const PAPERSIZE_A5_TRANSVERSE_PAPER                59;
  168.     const PAPERSIZE_JIS_B5_TRANSVERSE_PAPER            60;
  169.     const PAPERSIZE_A3_EXTRA_PAPER                    61;
  170.     const PAPERSIZE_A5_EXTRA_PAPER                    62;
  171.     const PAPERSIZE_ISO_B5_EXTRA_PAPER                63;
  172.     const PAPERSIZE_A2_PAPER                        64;
  173.     const PAPERSIZE_A3_TRANSVERSE_PAPER                65;
  174.     const PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER        66;
  175.  
  176.     /* Page orientation */
  177.     const ORIENTATION_DEFAULT    'default';
  178.     const ORIENTATION_LANDSCAPE    'landscape';
  179.     const ORIENTATION_PORTRAIT    'portrait';
  180.  
  181.     /* Print Range Set Method */
  182.     const SETPRINTRANGE_OVERWRITE    'O';
  183.     const SETPRINTRANGE_INSERT        'I';
  184.  
  185.  
  186.     /**
  187.      * Paper size
  188.      *
  189.      * @var int 
  190.      */
  191.     private $_paperSize;
  192.  
  193.     /**
  194.      * Orientation
  195.      *
  196.      * @var string 
  197.      */
  198.     private $_orientation;
  199.  
  200.     /**
  201.      * Scale (Print Scale)
  202.      *
  203.      * Print scaling. Valid values range from 10 to 400
  204.      * This setting is overridden when fitToWidth and/or fitToHeight are in use
  205.      *
  206.      * @var int? 
  207.      */
  208.     private $_scale;
  209.  
  210.     /**
  211.       * Fit To Page
  212.       * Whether scale or fitToWith / fitToHeight applies
  213.       *
  214.       * @var boolean 
  215.       */
  216.     private $_fitToPage;
  217.  
  218.     /**
  219.       * Fit To Height
  220.       * Number of vertical pages to fit on
  221.       *
  222.       * @var int? 
  223.       */
  224.     private $_fitToHeight;
  225.  
  226.     /**
  227.       * Fit To Width
  228.       * Number of horizontal pages to fit on
  229.       *
  230.       * @var int? 
  231.       */
  232.     private $_fitToWidth;
  233.  
  234.     /**
  235.      * Columns to repeat at left
  236.      *
  237.      * @var array Containing start column and end column, empty array if option unset
  238.      */
  239.     private $_columnsToRepeatAtLeft array('''');
  240.  
  241.     /**
  242.      * Rows to repeat at top
  243.      *
  244.      * @var array Containing start row number and end row number, empty array if option unset
  245.      */
  246.     private $_rowsToRepeatAtTop array(00);
  247.  
  248.     /**
  249.      * Center page horizontally
  250.      *
  251.      * @var boolean 
  252.      */
  253.     private $_horizontalCentered false;
  254.  
  255.     /**
  256.      * Center page vertically
  257.      *
  258.      * @var boolean 
  259.      */
  260.     private $_verticalCentered false;
  261.  
  262.     /**
  263.      * Print area
  264.      *
  265.      * @var string 
  266.      */
  267.     private $_printArea null;
  268.  
  269.     /**
  270.      * First page number
  271.      *
  272.      * @var int 
  273.      */
  274.     private $_firstPageNumber null;
  275.  
  276.     /**
  277.      * Create a new PHPExcel_Worksheet_PageSetup
  278.      */
  279.     public function __construct()
  280.     {
  281.         // Initialise values
  282.         $this->_paperSize                 PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER;
  283.         $this->_orientation                PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT;
  284.         $this->_scale                    100;
  285.         $this->_fitToPage                false;
  286.         $this->_fitToHeight                1;
  287.         $this->_fitToWidth                1;
  288.         $this->_columnsToRepeatAtLeft     array('''');
  289.         $this->_rowsToRepeatAtTop        array(00);
  290.         $this->_horizontalCentered        false;
  291.         $this->_verticalCentered        false;
  292.         $this->_printArea                null;
  293.         $this->_firstPageNumber         null;
  294.     }
  295.  
  296.     /**
  297.      * Get Paper Size
  298.      *
  299.      * @return int 
  300.      */
  301.     public function getPaperSize({
  302.         return $this->_paperSize;
  303.     }
  304.  
  305.     /**
  306.      * Set Paper Size
  307.      *
  308.      * @param int $pValue 
  309.      * @return PHPExcel_Worksheet_PageSetup 
  310.      */
  311.     public function setPaperSize($pValue PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER{
  312.         $this->_paperSize $pValue;
  313.         return $this;
  314.     }
  315.  
  316.     /**
  317.      * Get Orientation
  318.      *
  319.      * @return string 
  320.      */
  321.     public function getOrientation({
  322.         return $this->_orientation;
  323.     }
  324.  
  325.     /**
  326.      * Set Orientation
  327.      *
  328.      * @param string $pValue 
  329.      * @return PHPExcel_Worksheet_PageSetup 
  330.      */
  331.     public function setOrientation($pValue PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT{
  332.         $this->_orientation $pValue;
  333.         return $this;
  334.     }
  335.  
  336.     /**
  337.      * Get Scale
  338.      *
  339.      * @return int? 
  340.      */
  341.     public function getScale({
  342.         return $this->_scale;
  343.     }
  344.  
  345.     /**
  346.      * Set Scale
  347.      *
  348.      * Print scaling. Valid values range from 10 to 400
  349.      * This setting is overridden when fitToWidth and/or fitToHeight are in use
  350.      *
  351.      * @param     int?     $pValue 
  352.      * @param boolean $pUpdate Update fitToPage so scaling applies rather than fitToHeight / fitToWidth
  353.      * @throws     Exception
  354.      * @return PHPExcel_Worksheet_PageSetup 
  355.      */
  356.     public function setScale($pValue 100$pUpdate true{
  357.         // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
  358.         // but it is apparently still able to handle any scale >= 0, where 0 results in 100
  359.         if (($pValue >= 0|| is_null($pValue)) {
  360.             $this->_scale $pValue;
  361.             if ($pUpdate{
  362.                 $this->_fitToPage false;
  363.             }
  364.         else {
  365.             throw new Exception("Scale must not be negative");
  366.         }
  367.         return $this;
  368.     }
  369.  
  370.     /**
  371.      * Get Fit To Page
  372.      *
  373.      * @return boolean 
  374.      */
  375.     public function getFitToPage({
  376.         return $this->_fitToPage;
  377.     }
  378.  
  379.     /**
  380.      * Set Fit To Page
  381.      *
  382.      * @param boolean $pValue 
  383.      * @return PHPExcel_Worksheet_PageSetup 
  384.      */
  385.     public function setFitToPage($pValue true{
  386.         $this->_fitToPage $pValue;
  387.         return $this;
  388.     }
  389.  
  390.     /**
  391.      * Get Fit To Height
  392.      *
  393.      * @return int? 
  394.      */
  395.     public function getFitToHeight({
  396.         return $this->_fitToHeight;
  397.     }
  398.  
  399.     /**
  400.      * Set Fit To Height
  401.      *
  402.      * @param int? $pValue 
  403.      * @param boolean $pUpdate Update fitToPage so it applies rather than scaling
  404.      * @return PHPExcel_Worksheet_PageSetup 
  405.      */
  406.     public function setFitToHeight($pValue 1$pUpdate true{
  407.         $this->_fitToHeight $pValue;
  408.         if ($pUpdate{
  409.             $this->_fitToPage true;
  410.         }
  411.         return $this;
  412.     }
  413.  
  414.     /**
  415.      * Get Fit To Width
  416.      *
  417.      * @return int? 
  418.      */
  419.     public function getFitToWidth({
  420.         return $this->_fitToWidth;
  421.     }
  422.  
  423.     /**
  424.      * Set Fit To Width
  425.      *
  426.      * @param int? $pValue 
  427.      * @param boolean $pUpdate Update fitToPage so it applies rather than scaling
  428.      * @return PHPExcel_Worksheet_PageSetup 
  429.      */
  430.     public function setFitToWidth($pValue 1$pUpdate true{
  431.         $this->_fitToWidth $pValue;
  432.         if ($pUpdate{
  433.             $this->_fitToPage true;
  434.         }
  435.         return $this;
  436.     }
  437.  
  438.     /**
  439.      * Is Columns to repeat at left set?
  440.      *
  441.      * @return boolean 
  442.      */
  443.     public function isColumnsToRepeatAtLeftSet({
  444.         if (is_array($this->_columnsToRepeatAtLeft)) {
  445.             if ($this->_columnsToRepeatAtLeft[0!= '' && $this->_columnsToRepeatAtLeft[1!= ''{
  446.                 return true;
  447.             }
  448.         }
  449.  
  450.         return false;
  451.     }
  452.  
  453.     /**
  454.      * Get Columns to repeat at left
  455.      *
  456.      * @return array Containing start column and end column, empty array if option unset
  457.      */
  458.     public function getColumnsToRepeatAtLeft({
  459.         return $this->_columnsToRepeatAtLeft;
  460.     }
  461.  
  462.     /**
  463.      * Set Columns to repeat at left
  464.      *
  465.      * @param array $pValue Containing start column and end column, empty array if option unset
  466.      * @return PHPExcel_Worksheet_PageSetup 
  467.      */
  468.     public function setColumnsToRepeatAtLeft($pValue null{
  469.         if (is_array($pValue)) {
  470.             $this->_columnsToRepeatAtLeft $pValue;
  471.         }
  472.         return $this;
  473.     }
  474.  
  475.     /**
  476.      * Set Columns to repeat at left by start and end
  477.      *
  478.      * @param string $pStart 
  479.      * @param string $pEnd 
  480.      * @return PHPExcel_Worksheet_PageSetup 
  481.      */
  482.     public function setColumnsToRepeatAtLeftByStartAndEnd($pStart 'A'$pEnd 'A'{
  483.         $this->_columnsToRepeatAtLeft array($pStart$pEnd);
  484.         return $this;
  485.     }
  486.  
  487.     /**
  488.      * Is Rows to repeat at top set?
  489.      *
  490.      * @return boolean 
  491.      */
  492.     public function isRowsToRepeatAtTopSet({
  493.         if (is_array($this->_rowsToRepeatAtTop)) {
  494.             if ($this->_rowsToRepeatAtTop[0!= && $this->_rowsToRepeatAtTop[1!= 0{
  495.                 return true;
  496.             }
  497.         }
  498.  
  499.         return false;
  500.     }
  501.  
  502.     /**
  503.      * Get Rows to repeat at top
  504.      *
  505.      * @return array Containing start column and end column, empty array if option unset
  506.      */
  507.     public function getRowsToRepeatAtTop({
  508.         return $this->_rowsToRepeatAtTop;
  509.     }
  510.  
  511.     /**
  512.      * Set Rows to repeat at top
  513.      *
  514.      * @param array $pValue Containing start column and end column, empty array if option unset
  515.      * @return PHPExcel_Worksheet_PageSetup 
  516.      */
  517.     public function setRowsToRepeatAtTop($pValue null{
  518.         if (is_array($pValue)) {
  519.             $this->_rowsToRepeatAtTop $pValue;
  520.         }
  521.         return $this;
  522.     }
  523.  
  524.     /**
  525.      * Set Rows to repeat at top by start and end
  526.      *
  527.      * @param int $pStart 
  528.      * @param int $pEnd 
  529.      * @return PHPExcel_Worksheet_PageSetup 
  530.      */
  531.     public function setRowsToRepeatAtTopByStartAndEnd($pStart 1$pEnd 1{
  532.         $this->_rowsToRepeatAtTop array($pStart$pEnd);
  533.         return $this;
  534.     }
  535.  
  536.     /**
  537.      * Get center page horizontally
  538.      *
  539.      * @return bool 
  540.      */
  541.     public function getHorizontalCentered({
  542.         return $this->_horizontalCentered;
  543.     }
  544.  
  545.     /**
  546.      * Set center page horizontally
  547.      *
  548.      * @param bool $value 
  549.      * @return PHPExcel_Worksheet_PageSetup 
  550.      */
  551.     public function setHorizontalCentered($value false{
  552.         $this->_horizontalCentered $value;
  553.         return $this;
  554.     }
  555.  
  556.     /**
  557.      * Get center page vertically
  558.      *
  559.      * @return bool 
  560.      */
  561.     public function getVerticalCentered({
  562.         return $this->_verticalCentered;
  563.     }
  564.  
  565.     /**
  566.      * Set center page vertically
  567.      *
  568.      * @param bool $value 
  569.      * @return PHPExcel_Worksheet_PageSetup 
  570.      */
  571.     public function setVerticalCentered($value false{
  572.         $this->_verticalCentered $value;
  573.         return $this;
  574.     }
  575.  
  576.     /**
  577.      *    Get print area
  578.      *
  579.      *    @param    int        $index    Identifier for a specific print area range if several ranges have been set
  580.      *                             Default behaviour, or a index value of 0, will return all ranges as a comma-separated string
  581.      *                             Otherwise, the specific range identified by the value of $index will be returned
  582.      *                             Print areas are numbered from 1
  583.      *    @throws    Exception
  584.      *    @return    string 
  585.      */
  586.     public function getPrintArea($index 0{
  587.         if ($index == 0{
  588.             return $this->_printArea;
  589.         }
  590.         $printAreas explode(',',$this->_printArea);
  591.         if (isset($printAreas[$index-1])) {
  592.             return $printAreas[$index-1];
  593.         }
  594.         throw new Exception("Requested Print Area does not exist");
  595.     }
  596.  
  597.     /**
  598.      *    Is print area set?
  599.      *
  600.      *    @param    int        $index    Identifier for a specific print area range if several ranges have been set
  601.      *                             Default behaviour, or an index value of 0, will identify whether any print range is set
  602.      *                             Otherwise, existence of the range identified by the value of $index will be returned
  603.      *                             Print areas are numbered from 1
  604.      *    @return    boolean 
  605.      */
  606.     public function isPrintAreaSet($index 0{
  607.         if ($index == 0{
  608.             return !is_null($this->_printArea);
  609.         }
  610.         $printAreas explode(',',$this->_printArea);
  611.         return isset($printAreas[$index-1]);
  612.     }
  613.  
  614.     /**
  615.      *    Clear a print area
  616.      *
  617.      *    @param    int        $index    Identifier for a specific print area range if several ranges have been set
  618.      *                             Default behaviour, or an index value of 0, will clear all print ranges that are set
  619.      *                             Otherwise, the range identified by the value of $index will be removed from the series
  620.      *                             Print areas are numbered from 1
  621.      *    @return    PHPExcel_Worksheet_PageSetup 
  622.      */
  623.     public function clearPrintArea($index 0{
  624.         if ($index == 0{
  625.             $this->_printArea NULL;
  626.         else {
  627.             $printAreas explode(',',$this->_printArea);
  628.             if (isset($printAreas[$index-1])) {
  629.                 unset($printAreas[$index-1]);
  630.                 $this->_printArea implode(',',$printAreas);
  631.             }
  632.         }
  633.  
  634.         return $this;
  635.     }
  636.  
  637.     /**
  638.      *    Set print area. e.g. 'A1:D10' or 'A1:D10,G5:M20'
  639.      *
  640.      *    @param    string    $value 
  641.      *    @param    int        $index    Identifier for a specific print area range allowing several ranges to be set
  642.      *                             When the method is "O"verwrite, then a positive integer index will overwrite that indexed
  643.      *                                 entry in the print areas list; a negative index value will identify which entry to
  644.      *                                 overwrite working bacward through the print area to the list, with the last entry as -1.
  645.      *                                 Specifying an index value of 0, will overwrite <b>all</b> existing print ranges.
  646.      *                             When the method is "I"nsert, then a positive index will insert after that indexed entry in
  647.      *                                 the print areas list, while a negative index will insert before the indexed entry.
  648.      *                                 Specifying an index value of 0, will always append the new print range at the end of the
  649.      *                                 list.
  650.      *                             Print areas are numbered from 1
  651.      *    @param    string    $method    Determines the method used when setting multiple print areas
  652.      *                             Default behaviour, or the "O" method, overwrites existing print area
  653.      *                             The "I" method, inserts the new print area before any specified index, or at the end of the list
  654.      *    @throws    Exception
  655.      *    @return    PHPExcel_Worksheet_PageSetup 
  656.      */
  657.     public function setPrintArea($value$index 0$method self::SETPRINTRANGE_OVERWRITE{
  658.         if (strpos($value,'!'!== false{
  659.             throw new Exception('Cell coordinate must not specify a worksheet.');
  660.         elseif (strpos($value,':'=== false{
  661.             throw new Exception('Cell coordinate must be a range of cells.');
  662.         elseif (strpos($value,'$'!== false{
  663.             throw new Exception('Cell coordinate must not be absolute.');
  664.         }
  665.         $value strtoupper($value);
  666.  
  667.         if ($method == self::SETPRINTRANGE_OVERWRITE{
  668.             if ($index == 0{
  669.                 $this->_printArea $value;
  670.             else {
  671.                 $printAreas explode(',',$this->_printArea);
  672.                 if($index 0{
  673.                     $index count($printAreasabs($index1;
  674.                 }
  675.                 if (($index <= 0|| ($index count($printAreas))) {
  676.                     throw new Exception('Invalid index for setting print range.');
  677.                 }
  678.                 $printAreas[$index-1$value;
  679.                 $this->_printArea implode(',',$printAreas);
  680.             }
  681.         elseif($method == self::SETPRINTRANGE_INSERT{
  682.             if ($index == 0{
  683.                 $this->_printArea .= ($this->_printArea == ''$value ','.$value;
  684.             else {
  685.                 $printAreas explode(',',$this->_printArea);
  686.                 if($index 0{
  687.                     $index abs($index1;
  688.                 }
  689.                 if ($index count($printAreas)) {
  690.                     throw new Exception('Invalid index for setting print range.');
  691.                 }
  692.                 $printAreas array_merge(array_slice($printAreas,0,$index),array($value),array_slice($printAreas,$index));
  693.                 $this->_printArea implode(',',$printAreas);
  694.             }
  695.         else {
  696.             throw new Exception('Invalid method for setting print range.');
  697.         }
  698.  
  699.         return $this;
  700.     }
  701.  
  702.     /**
  703.      *    Add a new print area (e.g. 'A1:D10' or 'A1:D10,G5:M20') to the list of print areas
  704.      *
  705.      *    @param    string    $value 
  706.      *    @param    int        $index    Identifier for a specific print area range allowing several ranges to be set
  707.      *                             A positive index will insert after that indexed entry in the print areas list, while a
  708.      *                                 negative index will insert before the indexed entry.
  709.      *                                 Specifying an index value of 0, will always append the new print range at the end of the
  710.      *                                 list.
  711.      *                             Print areas are numbered from 1
  712.      *    @throws    Exception
  713.      *    @return    PHPExcel_Worksheet_PageSetup 
  714.      */
  715.     public function addPrintArea($value$index = -1{
  716.         return $this->setPrintArea($value$indexself::SETPRINTRANGE_INSERT);
  717.     }
  718.  
  719.     /**
  720.      *    Set print area
  721.      *
  722.      *    @param    int        $column1    Column 1
  723.      *    @param    int        $row1        Row 1
  724.      *    @param    int        $column2    Column 2
  725.      *    @param    int        $row2        Row 2
  726.      *    @param    int        $index    Identifier for a specific print area range allowing several ranges to be set
  727.      *                             When the method is "O"verwrite, then a positive integer index will overwrite that indexed
  728.      *                                 entry in the print areas list; a negative index value will identify which entry to
  729.      *                                 overwrite working bacward through the print area to the list, with the last entry as -1.
  730.      *                                 Specifying an index value of 0, will overwrite <b>all</b> existing print ranges.
  731.      *                             When the method is "I"nsert, then a positive index will insert after that indexed entry in
  732.      *                                 the print areas list, while a negative index will insert before the indexed entry.
  733.      *                                 Specifying an index value of 0, will always append the new print range at the end of the
  734.      *                                 list.
  735.      *                             Print areas are numbered from 1
  736.      *    @param    string    $method    Determines the method used when setting multiple print areas
  737.      *                             Default behaviour, or the "O" method, overwrites existing print area
  738.      *                             The "I" method, inserts the new print area before any specified index, or at the end of the list
  739.      *    @throws    Exception
  740.      *    @return    PHPExcel_Worksheet_PageSetup 
  741.      */
  742.     public function setPrintAreaByColumnAndRow($column1$row1$column2$row2$index 0$method self::SETPRINTRANGE_OVERWRITE)
  743.     {
  744.         return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1$row1 ':' PHPExcel_Cell::stringFromColumnIndex($column2$row2$index$method);
  745.     }
  746.  
  747.     /**
  748.      *    Add a new print area to the list of print areas
  749.      *
  750.      *    @param    int        $column1    Column 1
  751.      *    @param    int        $row1        Row 1
  752.      *    @param    int        $column2    Column 2
  753.      *    @param    int        $row2        Row 2
  754.      *    @param    int        $index        Identifier for a specific print area range allowing several ranges to be set
  755.      *                                 A positive index will insert after that indexed entry in the print areas list, while a
  756.      *                                     negative index will insert before the indexed entry.
  757.      *                                     Specifying an index value of 0, will always append the new print range at the end of the
  758.      *                                     list.
  759.      *                                 Print areas are numbered from 1
  760.      *    @throws    Exception
  761.      *    @return    PHPExcel_Worksheet_PageSetup 
  762.      */
  763.     public function addPrintAreaByColumnAndRow($column1$row1$column2$row2$index = -1)
  764.     {
  765.         return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1$row1 ':' PHPExcel_Cell::stringFromColumnIndex($column2$row2$indexself::SETPRINTRANGE_INSERT);
  766.     }
  767.  
  768.     /**
  769.      * Get first page number
  770.      *
  771.      * @return int 
  772.      */
  773.     public function getFirstPageNumber({
  774.         return $this->_firstPageNumber;
  775.     }
  776.  
  777.     /**
  778.      * Set first page number
  779.      *
  780.      * @param int $value 
  781.      * @return PHPExcel_Worksheet_HeaderFooter 
  782.      */
  783.     public function setFirstPageNumber($value null{
  784.         $this->_firstPageNumber $value;
  785.         return $this;
  786.     }
  787.  
  788.     /**
  789.      * Reset first page number
  790.      *
  791.      * @return PHPExcel_Worksheet_HeaderFooter 
  792.      */
  793.     public function resetFirstPageNumber({
  794.         return $this->setFirstPageNumber(null);
  795.     }
  796.  
  797.     /**
  798.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  799.      */
  800.     public function __clone({
  801.         $vars get_object_vars($this);
  802.         foreach ($vars as $key => $value{
  803.             if (is_object($value)) {
  804.                 $this->$key clone $value;
  805.             else {
  806.                 $this->$key $value;
  807.             }
  808.         }
  809.     }
  810. }

Documentation generated on Thu, 26 Aug 2010 17:43:49 +0200 by phpDocumentor 1.4.3