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 - 2011 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 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.6, 2011-02-27
  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 - 2011 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        PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER;
  192.  
  193.     /**
  194.      * Orientation
  195.      *
  196.      * @var string 
  197.      */
  198.     private $_orientation    PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT;
  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            100;
  209.  
  210.     /**
  211.       * Fit To Page
  212.       * Whether scale or fitToWith / fitToHeight applies
  213.       *
  214.       * @var boolean 
  215.       */
  216.     private $_fitToPage        false;
  217.  
  218.     /**
  219.       * Fit To Height
  220.       * Number of vertical pages to fit on
  221.       *
  222.       * @var int? 
  223.       */
  224.     private $_fitToHeight    1;
  225.  
  226.     /**
  227.       * Fit To Width
  228.       * Number of horizontal pages to fit on
  229.       *
  230.       * @var int? 
  231.       */
  232.     private $_fitToWidth    1;
  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.     }
  282.  
  283.     /**
  284.      * Get Paper Size
  285.      *
  286.      * @return int 
  287.      */
  288.     public function getPaperSize({
  289.         return $this->_paperSize;
  290.     }
  291.  
  292.     /**
  293.      * Set Paper Size
  294.      *
  295.      * @param int $pValue 
  296.      * @return PHPExcel_Worksheet_PageSetup 
  297.      */
  298.     public function setPaperSize($pValue PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER{
  299.         $this->_paperSize $pValue;
  300.         return $this;
  301.     }
  302.  
  303.     /**
  304.      * Get Orientation
  305.      *
  306.      * @return string 
  307.      */
  308.     public function getOrientation({
  309.         return $this->_orientation;
  310.     }
  311.  
  312.     /**
  313.      * Set Orientation
  314.      *
  315.      * @param string $pValue 
  316.      * @return PHPExcel_Worksheet_PageSetup 
  317.      */
  318.     public function setOrientation($pValue PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT{
  319.         $this->_orientation $pValue;
  320.         return $this;
  321.     }
  322.  
  323.     /**
  324.      * Get Scale
  325.      *
  326.      * @return int? 
  327.      */
  328.     public function getScale({
  329.         return $this->_scale;
  330.     }
  331.  
  332.     /**
  333.      * Set Scale
  334.      *
  335.      * Print scaling. Valid values range from 10 to 400
  336.      * This setting is overridden when fitToWidth and/or fitToHeight are in use
  337.      *
  338.      * @param     int?     $pValue 
  339.      * @param boolean $pUpdate Update fitToPage so scaling applies rather than fitToHeight / fitToWidth
  340.      * @throws     Exception
  341.      * @return PHPExcel_Worksheet_PageSetup 
  342.      */
  343.     public function setScale($pValue 100$pUpdate true{
  344.         // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
  345.         // but it is apparently still able to handle any scale >= 0, where 0 results in 100
  346.         if (($pValue >= 0|| is_null($pValue)) {
  347.             $this->_scale $pValue;
  348.             if ($pUpdate{
  349.                 $this->_fitToPage false;
  350.             }
  351.         else {
  352.             throw new Exception("Scale must not be negative");
  353.         }
  354.         return $this;
  355.     }
  356.  
  357.     /**
  358.      * Get Fit To Page
  359.      *
  360.      * @return boolean 
  361.      */
  362.     public function getFitToPage({
  363.         return $this->_fitToPage;
  364.     }
  365.  
  366.     /**
  367.      * Set Fit To Page
  368.      *
  369.      * @param boolean $pValue 
  370.      * @return PHPExcel_Worksheet_PageSetup 
  371.      */
  372.     public function setFitToPage($pValue true{
  373.         $this->_fitToPage $pValue;
  374.         return $this;
  375.     }
  376.  
  377.     /**
  378.      * Get Fit To Height
  379.      *
  380.      * @return int? 
  381.      */
  382.     public function getFitToHeight({
  383.         return $this->_fitToHeight;
  384.     }
  385.  
  386.     /**
  387.      * Set Fit To Height
  388.      *
  389.      * @param int? $pValue 
  390.      * @param boolean $pUpdate Update fitToPage so it applies rather than scaling
  391.      * @return PHPExcel_Worksheet_PageSetup 
  392.      */
  393.     public function setFitToHeight($pValue 1$pUpdate true{
  394.         $this->_fitToHeight $pValue;
  395.         if ($pUpdate{
  396.             $this->_fitToPage true;
  397.         }
  398.         return $this;
  399.     }
  400.  
  401.     /**
  402.      * Get Fit To Width
  403.      *
  404.      * @return int? 
  405.      */
  406.     public function getFitToWidth({
  407.         return $this->_fitToWidth;
  408.     }
  409.  
  410.     /**
  411.      * Set Fit To Width
  412.      *
  413.      * @param int? $pValue 
  414.      * @param boolean $pUpdate Update fitToPage so it applies rather than scaling
  415.      * @return PHPExcel_Worksheet_PageSetup 
  416.      */
  417.     public function setFitToWidth($pValue 1$pUpdate true{
  418.         $this->_fitToWidth $pValue;
  419.         if ($pUpdate{
  420.             $this->_fitToPage true;
  421.         }
  422.         return $this;
  423.     }
  424.  
  425.     /**
  426.      * Is Columns to repeat at left set?
  427.      *
  428.      * @return boolean 
  429.      */
  430.     public function isColumnsToRepeatAtLeftSet({
  431.         if (is_array($this->_columnsToRepeatAtLeft)) {
  432.             if ($this->_columnsToRepeatAtLeft[0!= '' && $this->_columnsToRepeatAtLeft[1!= ''{
  433.                 return true;
  434.             }
  435.         }
  436.  
  437.         return false;
  438.     }
  439.  
  440.     /**
  441.      * Get Columns to repeat at left
  442.      *
  443.      * @return array Containing start column and end column, empty array if option unset
  444.      */
  445.     public function getColumnsToRepeatAtLeft({
  446.         return $this->_columnsToRepeatAtLeft;
  447.     }
  448.  
  449.     /**
  450.      * Set Columns to repeat at left
  451.      *
  452.      * @param array $pValue Containing start column and end column, empty array if option unset
  453.      * @return PHPExcel_Worksheet_PageSetup 
  454.      */
  455.     public function setColumnsToRepeatAtLeft($pValue null{
  456.         if (is_array($pValue)) {
  457.             $this->_columnsToRepeatAtLeft $pValue;
  458.         }
  459.         return $this;
  460.     }
  461.  
  462.     /**
  463.      * Set Columns to repeat at left by start and end
  464.      *
  465.      * @param string $pStart 
  466.      * @param string $pEnd 
  467.      * @return PHPExcel_Worksheet_PageSetup 
  468.      */
  469.     public function setColumnsToRepeatAtLeftByStartAndEnd($pStart 'A'$pEnd 'A'{
  470.         $this->_columnsToRepeatAtLeft array($pStart$pEnd);
  471.         return $this;
  472.     }
  473.  
  474.     /**
  475.      * Is Rows to repeat at top set?
  476.      *
  477.      * @return boolean 
  478.      */
  479.     public function isRowsToRepeatAtTopSet({
  480.         if (is_array($this->_rowsToRepeatAtTop)) {
  481.             if ($this->_rowsToRepeatAtTop[0!= && $this->_rowsToRepeatAtTop[1!= 0{
  482.                 return true;
  483.             }
  484.         }
  485.  
  486.         return false;
  487.     }
  488.  
  489.     /**
  490.      * Get Rows to repeat at top
  491.      *
  492.      * @return array Containing start column and end column, empty array if option unset
  493.      */
  494.     public function getRowsToRepeatAtTop({
  495.         return $this->_rowsToRepeatAtTop;
  496.     }
  497.  
  498.     /**
  499.      * Set Rows to repeat at top
  500.      *
  501.      * @param array $pValue Containing start column and end column, empty array if option unset
  502.      * @return PHPExcel_Worksheet_PageSetup 
  503.      */
  504.     public function setRowsToRepeatAtTop($pValue null{
  505.         if (is_array($pValue)) {
  506.             $this->_rowsToRepeatAtTop $pValue;
  507.         }
  508.         return $this;
  509.     }
  510.  
  511.     /**
  512.      * Set Rows to repeat at top by start and end
  513.      *
  514.      * @param int $pStart 
  515.      * @param int $pEnd 
  516.      * @return PHPExcel_Worksheet_PageSetup 
  517.      */
  518.     public function setRowsToRepeatAtTopByStartAndEnd($pStart 1$pEnd 1{
  519.         $this->_rowsToRepeatAtTop array($pStart$pEnd);
  520.         return $this;
  521.     }
  522.  
  523.     /**
  524.      * Get center page horizontally
  525.      *
  526.      * @return bool 
  527.      */
  528.     public function getHorizontalCentered({
  529.         return $this->_horizontalCentered;
  530.     }
  531.  
  532.     /**
  533.      * Set center page horizontally
  534.      *
  535.      * @param bool $value 
  536.      * @return PHPExcel_Worksheet_PageSetup 
  537.      */
  538.     public function setHorizontalCentered($value false{
  539.         $this->_horizontalCentered $value;
  540.         return $this;
  541.     }
  542.  
  543.     /**
  544.      * Get center page vertically
  545.      *
  546.      * @return bool 
  547.      */
  548.     public function getVerticalCentered({
  549.         return $this->_verticalCentered;
  550.     }
  551.  
  552.     /**
  553.      * Set center page vertically
  554.      *
  555.      * @param bool $value 
  556.      * @return PHPExcel_Worksheet_PageSetup 
  557.      */
  558.     public function setVerticalCentered($value false{
  559.         $this->_verticalCentered $value;
  560.         return $this;
  561.     }
  562.  
  563.     /**
  564.      *    Get print area
  565.      *
  566.      *    @param    int        $index    Identifier for a specific print area range if several ranges have been set
  567.      *                             Default behaviour, or a index value of 0, will return all ranges as a comma-separated string
  568.      *                             Otherwise, the specific range identified by the value of $index will be returned
  569.      *                             Print areas are numbered from 1
  570.      *    @throws    Exception
  571.      *    @return    string 
  572.      */
  573.     public function getPrintArea($index 0{
  574.         if ($index == 0{
  575.             return $this->_printArea;
  576.         }
  577.         $printAreas explode(',',$this->_printArea);
  578.         if (isset($printAreas[$index-1])) {
  579.             return $printAreas[$index-1];
  580.         }
  581.         throw new Exception("Requested Print Area does not exist");
  582.     }
  583.  
  584.     /**
  585.      *    Is print area set?
  586.      *
  587.      *    @param    int        $index    Identifier for a specific print area range if several ranges have been set
  588.      *                             Default behaviour, or an index value of 0, will identify whether any print range is set
  589.      *                             Otherwise, existence of the range identified by the value of $index will be returned
  590.      *                             Print areas are numbered from 1
  591.      *    @return    boolean 
  592.      */
  593.     public function isPrintAreaSet($index 0{
  594.         if ($index == 0{
  595.             return !is_null($this->_printArea);
  596.         }
  597.         $printAreas explode(',',$this->_printArea);
  598.         return isset($printAreas[$index-1]);
  599.     }
  600.  
  601.     /**
  602.      *    Clear a print area
  603.      *
  604.      *    @param    int        $index    Identifier for a specific print area range if several ranges have been set
  605.      *                             Default behaviour, or an index value of 0, will clear all print ranges that are set
  606.      *                             Otherwise, the range identified by the value of $index will be removed from the series
  607.      *                             Print areas are numbered from 1
  608.      *    @return    PHPExcel_Worksheet_PageSetup 
  609.      */
  610.     public function clearPrintArea($index 0{
  611.         if ($index == 0{
  612.             $this->_printArea NULL;
  613.         else {
  614.             $printAreas explode(',',$this->_printArea);
  615.             if (isset($printAreas[$index-1])) {
  616.                 unset($printAreas[$index-1]);
  617.                 $this->_printArea implode(',',$printAreas);
  618.             }
  619.         }
  620.  
  621.         return $this;
  622.     }
  623.  
  624.     /**
  625.      *    Set print area. e.g. 'A1:D10' or 'A1:D10,G5:M20'
  626.      *
  627.      *    @param    string    $value 
  628.      *    @param    int        $index    Identifier for a specific print area range allowing several ranges to be set
  629.      *                             When the method is "O"verwrite, then a positive integer index will overwrite that indexed
  630.      *                                 entry in the print areas list; a negative index value will identify which entry to
  631.      *                                 overwrite working bacward through the print area to the list, with the last entry as -1.
  632.      *                                 Specifying an index value of 0, will overwrite <b>all</b> existing print ranges.
  633.      *                             When the method is "I"nsert, then a positive index will insert after that indexed entry in
  634.      *                                 the print areas list, while a negative index will insert before the indexed entry.
  635.      *                                 Specifying an index value of 0, will always append the new print range at the end of the
  636.      *                                 list.
  637.      *                             Print areas are numbered from 1
  638.      *    @param    string    $method    Determines the method used when setting multiple print areas
  639.      *                             Default behaviour, or the "O" method, overwrites existing print area
  640.      *                             The "I" method, inserts the new print area before any specified index, or at the end of the list
  641.      *    @throws    Exception
  642.      *    @return    PHPExcel_Worksheet_PageSetup 
  643.      */
  644.     public function setPrintArea($value$index 0$method self::SETPRINTRANGE_OVERWRITE{
  645.         if (strpos($value,'!'!== false{
  646.             throw new Exception('Cell coordinate must not specify a worksheet.');
  647.         elseif (strpos($value,':'=== false{
  648.             throw new Exception('Cell coordinate must be a range of cells.');
  649.         elseif (strpos($value,'$'!== false{
  650.             throw new Exception('Cell coordinate must not be absolute.');
  651.         }
  652.         $value strtoupper($value);
  653.  
  654.         if ($method == self::SETPRINTRANGE_OVERWRITE{
  655.             if ($index == 0{
  656.                 $this->_printArea $value;
  657.             else {
  658.                 $printAreas explode(',',$this->_printArea);
  659.                 if($index 0{
  660.                     $index count($printAreasabs($index1;
  661.                 }
  662.                 if (($index <= 0|| ($index count($printAreas))) {
  663.                     throw new Exception('Invalid index for setting print range.');
  664.                 }
  665.                 $printAreas[$index-1$value;
  666.                 $this->_printArea implode(',',$printAreas);
  667.             }
  668.         elseif($method == self::SETPRINTRANGE_INSERT{
  669.             if ($index == 0{
  670.                 $this->_printArea .= ($this->_printArea == ''$value ','.$value;
  671.             else {
  672.                 $printAreas explode(',',$this->_printArea);
  673.                 if($index 0{
  674.                     $index abs($index1;
  675.                 }
  676.                 if ($index count($printAreas)) {
  677.                     throw new Exception('Invalid index for setting print range.');
  678.                 }
  679.                 $printAreas array_merge(array_slice($printAreas,0,$index),array($value),array_slice($printAreas,$index));
  680.                 $this->_printArea implode(',',$printAreas);
  681.             }
  682.         else {
  683.             throw new Exception('Invalid method for setting print range.');
  684.         }
  685.  
  686.         return $this;
  687.     }
  688.  
  689.     /**
  690.      *    Add a new print area (e.g. 'A1:D10' or 'A1:D10,G5:M20') to the list of print areas
  691.      *
  692.      *    @param    string    $value 
  693.      *    @param    int        $index    Identifier for a specific print area range allowing several ranges to be set
  694.      *                             A positive index will insert after that indexed entry in the print areas list, while a
  695.      *                                 negative index will insert before the indexed entry.
  696.      *                                 Specifying an index value of 0, will always append the new print range at the end of the
  697.      *                                 list.
  698.      *                             Print areas are numbered from 1
  699.      *    @throws    Exception
  700.      *    @return    PHPExcel_Worksheet_PageSetup 
  701.      */
  702.     public function addPrintArea($value$index = -1{
  703.         return $this->setPrintArea($value$indexself::SETPRINTRANGE_INSERT);
  704.     }
  705.  
  706.     /**
  707.      *    Set print area
  708.      *
  709.      *    @param    int        $column1    Column 1
  710.      *    @param    int        $row1        Row 1
  711.      *    @param    int        $column2    Column 2
  712.      *    @param    int        $row2        Row 2
  713.      *    @param    int        $index    Identifier for a specific print area range allowing several ranges to be set
  714.      *                             When the method is "O"verwrite, then a positive integer index will overwrite that indexed
  715.      *                                 entry in the print areas list; a negative index value will identify which entry to
  716.      *                                 overwrite working bacward through the print area to the list, with the last entry as -1.
  717.      *                                 Specifying an index value of 0, will overwrite <b>all</b> existing print ranges.
  718.      *                             When the method is "I"nsert, then a positive index will insert after that indexed entry in
  719.      *                                 the print areas list, while a negative index will insert before the indexed entry.
  720.      *                                 Specifying an index value of 0, will always append the new print range at the end of the
  721.      *                                 list.
  722.      *                             Print areas are numbered from 1
  723.      *    @param    string    $method    Determines the method used when setting multiple print areas
  724.      *                             Default behaviour, or the "O" method, overwrites existing print area
  725.      *                             The "I" method, inserts the new print area before any specified index, or at the end of the list
  726.      *    @throws    Exception
  727.      *    @return    PHPExcel_Worksheet_PageSetup 
  728.      */
  729.     public function setPrintAreaByColumnAndRow($column1$row1$column2$row2$index 0$method self::SETPRINTRANGE_OVERWRITE)
  730.     {
  731.         return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1$row1 ':' PHPExcel_Cell::stringFromColumnIndex($column2$row2$index$method);
  732.     }
  733.  
  734.     /**
  735.      *    Add a new print area to the list of print areas
  736.      *
  737.      *    @param    int        $column1    Column 1
  738.      *    @param    int        $row1        Row 1
  739.      *    @param    int        $column2    Column 2
  740.      *    @param    int        $row2        Row 2
  741.      *    @param    int        $index        Identifier for a specific print area range allowing several ranges to be set
  742.      *                                 A positive index will insert after that indexed entry in the print areas list, while a
  743.      *                                     negative index will insert before the indexed entry.
  744.      *                                     Specifying an index value of 0, will always append the new print range at the end of the
  745.      *                                     list.
  746.      *                                 Print areas are numbered from 1
  747.      *    @throws    Exception
  748.      *    @return    PHPExcel_Worksheet_PageSetup 
  749.      */
  750.     public function addPrintAreaByColumnAndRow($column1$row1$column2$row2$index = -1)
  751.     {
  752.         return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1$row1 ':' PHPExcel_Cell::stringFromColumnIndex($column2$row2$indexself::SETPRINTRANGE_INSERT);
  753.     }
  754.  
  755.     /**
  756.      * Get first page number
  757.      *
  758.      * @return int 
  759.      */
  760.     public function getFirstPageNumber({
  761.         return $this->_firstPageNumber;
  762.     }
  763.  
  764.     /**
  765.      * Set first page number
  766.      *
  767.      * @param int $value 
  768.      * @return PHPExcel_Worksheet_HeaderFooter 
  769.      */
  770.     public function setFirstPageNumber($value null{
  771.         $this->_firstPageNumber $value;
  772.         return $this;
  773.     }
  774.  
  775.     /**
  776.      * Reset first page number
  777.      *
  778.      * @return PHPExcel_Worksheet_HeaderFooter 
  779.      */
  780.     public function resetFirstPageNumber({
  781.         return $this->setFirstPageNumber(null);
  782.     }
  783.  
  784.     /**
  785.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  786.      */
  787.     public function __clone({
  788.         $vars get_object_vars($this);
  789.         foreach ($vars as $key => $value{
  790.             if (is_object($value)) {
  791.                 $this->$key clone $value;
  792.             else {
  793.                 $this->$key $value;
  794.             }
  795.         }
  796.     }
  797. }

Documentation generated on Sun, 27 Feb 2011 16:33:01 -0800 by phpDocumentor 1.4.3