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

Source for file Cell.php

Documentation is available at Cell.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_Cell
  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_Cell
  31.  *
  32.  * @category   PHPExcel
  33.  * @package    PHPExcel_Cell
  34.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  35.  */
  36. {
  37.     /**
  38.      * Value binder to use
  39.      *
  40.      * @var PHPExcel_Cell_IValueBinder 
  41.      */
  42.     private static $_valueBinder null;
  43.  
  44.     /**
  45.      * Column of the cell
  46.      *
  47.      * @var string 
  48.      */
  49.     private $_column;
  50.  
  51.     /**
  52.      * Row of the cell
  53.      *
  54.      * @var int 
  55.      */
  56.     private $_row;
  57.  
  58.     /**
  59.      * Value of the cell
  60.      *
  61.      * @var mixed 
  62.      */
  63.     private $_value;
  64.  
  65.     /**
  66.      * Calculated value of the cell (used for caching)
  67.      *
  68.      * @var mixed 
  69.      */
  70.     private $_calculatedValue null;
  71.  
  72.     /**
  73.      * Type of the cell data
  74.      *
  75.      * @var string 
  76.      */
  77.     private $_dataType;
  78.  
  79.     /**
  80.      * Parent worksheet
  81.      *
  82.      * @var PHPExcel_Worksheet 
  83.      */
  84.     private $_parent;
  85.  
  86.     /**
  87.      * Index to cellXf
  88.      *
  89.      * @var int 
  90.      */
  91.     private $_xfIndex;
  92.  
  93.     /**
  94.      * Attributes of the formula
  95.      *
  96.      *
  97.      */
  98.     private $_formulaAttributes;
  99.  
  100.  
  101.     /**
  102.      * Send notification to the cache controller
  103.      * @return void 
  104.      ***/
  105.     public function notifyCacheController({
  106.         $this->_parent->getCellCacheController()->updateCacheData($this);
  107.         return $this;
  108.     }
  109.  
  110.     public function detach({
  111.         $this->_parent null;
  112.     }
  113.  
  114.     public function attach($parent{
  115.         $this->_parent $parent;
  116.     }
  117.  
  118.  
  119.     /**
  120.      * Create a new Cell
  121.      *
  122.      * @param    string                $pColumn 
  123.      * @param    int                $pRow 
  124.      * @param    mixed                $pValue 
  125.      * @param    string                $pDataType 
  126.      * @param    PHPExcel_Worksheet    $pSheet 
  127.      * @throws    Exception
  128.      */
  129.     public function __construct($pColumn 'A'$pRow 1$pValue null$pDataType nullPHPExcel_Worksheet $pSheet null)
  130.     {
  131.         // Initialise cell coordinate
  132.         $this->_column strtoupper($pColumn);
  133.         $this->_row $pRow;
  134.  
  135.         // Initialise cell value
  136.         $this->_value $pValue;
  137.  
  138.         // Set worksheet
  139.         $this->_parent $pSheet;
  140.  
  141.         // Set datatype?
  142.         if (!is_null($pDataType)) {
  143.             $this->_dataType $pDataType;
  144.         else {
  145.             if (!self::getValueBinder()->bindValue($this$pValue)) {
  146.                 throw new Exception("Value could not be bound to cell.");
  147.             }
  148.         }
  149.  
  150.         // set default index to cellXf
  151.         $this->_xfIndex 0;
  152.     }
  153.  
  154.     /**
  155.      * Get cell coordinate column
  156.      *
  157.      * @return string 
  158.      */
  159.     public function getColumn()
  160.     {
  161.         return $this->_column;
  162.     }
  163.  
  164.     /**
  165.      * Get cell coordinate row
  166.      *
  167.      * @return int 
  168.      */
  169.     public function getRow()
  170.     {
  171.         return $this->_row;
  172.     }
  173.  
  174.     /**
  175.      * Get cell coordinate
  176.      *
  177.      * @return string 
  178.      */
  179.     public function getCoordinate()
  180.     {
  181.         return $this->_column $this->_row;
  182.     }
  183.  
  184.     /**
  185.      * Get cell value
  186.      *
  187.      * @return mixed 
  188.      */
  189.     public function getValue()
  190.     {
  191.         return $this->_value;
  192.     }
  193.  
  194.     /**
  195.      * Set cell value
  196.      *
  197.      * This clears the cell formula.
  198.      *
  199.      * @param mixed    $pValue                    Value
  200.      * @return PHPExcel_Cell 
  201.      */
  202.     public function setValue($pValue null)
  203.     {
  204.         if (!self::getValueBinder()->bindValue($this$pValue)) {
  205.             throw new Exception("Value could not be bound to cell.");
  206.         }
  207.         return $this;
  208.     }
  209.  
  210.     /**
  211.      * Set cell value (with explicit data type given)
  212.      *
  213.      * @param mixed    $pValue            Value
  214.      * @param string    $pDataType        Explicit data type
  215.      * @return PHPExcel_Cell 
  216.      * @throws Exception
  217.      */
  218.     public function setValueExplicit($pValue null$pDataType PHPExcel_Cell_DataType::TYPE_STRING)
  219.     {
  220.         // set the value according to data type
  221.         switch ($pDataType{
  222.             case PHPExcel_Cell_DataType::TYPE_STRING:
  223.             case PHPExcel_Cell_DataType::TYPE_NULL:
  224.             case PHPExcel_Cell_DataType::TYPE_INLINE:
  225.                 $this->_value PHPExcel_Cell_DataType::checkString($pValue);
  226.                 break;
  227.  
  228.             case PHPExcel_Cell_DataType::TYPE_NUMERIC:
  229.                 $this->_value = (float)$pValue;
  230.                 break;
  231.  
  232.             case PHPExcel_Cell_DataType::TYPE_FORMULA:
  233.                 $this->_value = (string)$pValue;
  234.                 break;
  235.  
  236.             case PHPExcel_Cell_DataType::TYPE_BOOL:
  237.                 $this->_value = (bool)$pValue;
  238.                 break;
  239.  
  240.             case PHPExcel_Cell_DataType::TYPE_ERROR:
  241.                 $this->_value PHPExcel_Cell_DataType::checkErrorCode($pValue);
  242.                 break;
  243.  
  244.             default:
  245.                 throw new Exception('Invalid datatype: ' $pDataType);
  246.                 break;
  247.         }
  248.  
  249.         // set the datatype
  250.         $this->_dataType $pDataType;
  251.  
  252.         return $this->notifyCacheController();
  253.     }
  254.  
  255.     /**
  256.      * Get calculated cell value
  257.      *
  258.      * @return mixed 
  259.      */
  260.     public function getCalculatedValue($resetLog=true)
  261.     {
  262. //        echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().'<br />';
  263.         if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA{
  264.             try {
  265. //                echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value<br />';
  266.                 $result PHPExcel_Calculation::getInstance()->calculateCellValue($this,$resetLog);
  267. //                echo $this->getCoordinate().' calculation result is '.$result.'<br />';
  268.             catch Exception $ex {
  269. //                echo 'Calculation Exception: '.$ex->getMessage().'<br />';
  270.                 $result '#N/A';
  271.                 throw(new Exception($this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()));
  272.             }
  273.  
  274.             if ($result === '#Not Yet Implemented'{
  275. //                echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'<br />';
  276.                 return $this->_calculatedValue// Fallback if calculation engine does not support the formula.
  277.             }
  278. //            echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().'<br />';
  279.             return $result;
  280.         }
  281.  
  282.         if (is_null($this->_value)) {
  283. //            echo 'Cell '.$this->getCoordinate().' has no value, formula or otherwise<br />';
  284.             return null;
  285.         }
  286. //        echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
  287.         return $this->_value;
  288.     }
  289.  
  290.     /**
  291.      * Set calculated value (used for caching)
  292.      *
  293.      * @param mixed $pValue    Value
  294.      * @return PHPExcel_Cell 
  295.      */
  296.     public function setCalculatedValue($pValue null)
  297.     {
  298.         if (!is_null($pValue)) {
  299.             $this->_calculatedValue $pValue;
  300.         }
  301.  
  302.         return $this->notifyCacheController();
  303.     }
  304.  
  305.     /**
  306.      * Get old calculated value (cached)
  307.      *
  308.      * @return mixed 
  309.      */
  310.     public function getOldCalculatedValue()
  311.     {
  312.         return $this->_calculatedValue;
  313.     }
  314.  
  315.     /**
  316.      * Get cell data type
  317.      *
  318.      * @return string 
  319.      */
  320.     public function getDataType()
  321.     {
  322.         return $this->_dataType;
  323.     }
  324.  
  325.     /**
  326.      * Set cell data type
  327.      *
  328.      * @param string $pDataType 
  329.      * @return PHPExcel_Cell 
  330.      */
  331.     public function setDataType($pDataType PHPExcel_Cell_DataType::TYPE_STRING)
  332.     {
  333.         $this->_dataType $pDataType;
  334.  
  335.         return $this->notifyCacheController();
  336.     }
  337.  
  338.     /**
  339.      * Has Data validation?
  340.      *
  341.      * @return boolean 
  342.      */
  343.     public function hasDataValidation()
  344.     {
  345.         if (!isset($this->_parent)) {
  346.             throw new Exception('Cannot check for data validation when cell is not bound to a worksheet');
  347.         }
  348.  
  349.         return $this->_parent->dataValidationExists($this->getCoordinate());
  350.     }
  351.  
  352.     /**
  353.      * Get Data validation
  354.      *
  355.      * @return PHPExcel_Cell_DataValidation 
  356.      */
  357.     public function getDataValidation()
  358.     {
  359.         if (!isset($this->_parent)) {
  360.             throw new Exception('Cannot get data validation for cell that is not bound to a worksheet');
  361.         }
  362.  
  363.         return $this->_parent->getDataValidation($this->getCoordinate());
  364.     }
  365.  
  366.     /**
  367.      * Set Data validation
  368.      *
  369.      * @param    PHPExcel_Cell_DataValidation    $pDataValidation 
  370.      * @throws    Exception
  371.      * @return PHPExcel_Cell 
  372.      */
  373.     public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation null)
  374.     {
  375.         if (!isset($this->_parent)) {
  376.             throw new Exception('Cannot set data validation for cell that is not bound to a worksheet');
  377.         }
  378.  
  379.         $this->_parent->setDataValidation($this->getCoordinate()$pDataValidation);
  380.  
  381.         return $this->notifyCacheController();
  382.     }
  383.  
  384.     /**
  385.      * Has Hyperlink
  386.      *
  387.      * @return boolean 
  388.      */
  389.     public function hasHyperlink()
  390.     {
  391.         if (!isset($this->_parent)) {
  392.             throw new Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
  393.         }
  394.  
  395.         return $this->_parent->hyperlinkExists($this->getCoordinate());
  396.     }
  397.  
  398.     /**
  399.      * Get Hyperlink
  400.      *
  401.      * @throws Exception
  402.      * @return PHPExcel_Cell_Hyperlink 
  403.      */
  404.     public function getHyperlink()
  405.     {
  406.         if (!isset($this->_parent)) {
  407.             throw new Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
  408.         }
  409.  
  410.         return $this->_parent->getHyperlink($this->getCoordinate());
  411.     }
  412.  
  413.     /**
  414.      * Set Hyperlink
  415.      *
  416.      * @param    PHPExcel_Cell_Hyperlink    $pHyperlink 
  417.      * @throws    Exception
  418.      * @return PHPExcel_Cell 
  419.      */
  420.     public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink null)
  421.     {
  422.         if (!isset($this->_parent)) {
  423.             throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
  424.         }
  425.  
  426.         $this->_parent->setHyperlink($this->getCoordinate()$pHyperlink);
  427.  
  428.         return $this->notifyCacheController();
  429.     }
  430.  
  431.     /**
  432.      * Get parent
  433.      *
  434.      * @return PHPExcel_Worksheet 
  435.      */
  436.     public function getParent({
  437.         return $this->_parent;
  438.     }
  439.  
  440.     /**
  441.      * Re-bind parent
  442.      *
  443.      * @param PHPExcel_Worksheet $parent 
  444.      * @return PHPExcel_Cell 
  445.      */
  446.     public function rebindParent(PHPExcel_Worksheet $parent{
  447.         $this->_parent $parent;
  448.  
  449.         return $this->notifyCacheController();
  450.     }
  451.  
  452.     /**
  453.      * Is cell in a specific range?
  454.      *
  455.      * @param    string    $pRange        Cell range (e.g. A1:A1)
  456.      * @return    boolean 
  457.      */
  458.     public function isInRange($pRange 'A1:A1')
  459.     {
  460.         list($rangeStart,$rangeEndPHPExcel_Cell::rangeBoundaries($pRange);
  461.  
  462.         // Translate properties
  463.         $myColumn    PHPExcel_Cell::columnIndexFromString($this->getColumn()) 1;
  464.         $myRow        $this->getRow();
  465.  
  466.         // Verify if cell is in range
  467.         return (($rangeStart[0<= $myColumn&& ($rangeEnd[0>= $myColumn&&
  468.                 ($rangeStart[1<= $myRow&& ($rangeEnd[1>= $myRow)
  469.                );
  470.     }
  471.  
  472.     /**
  473.      * Coordinate from string
  474.      *
  475.      * @param    string    $pCoordinateString 
  476.      * @return    array    Array containing column and row (indexes 0 and 1)
  477.      * @throws    Exception
  478.      */
  479.     public static function coordinateFromString($pCoordinateString 'A1')
  480.     {
  481.         if (strpos($pCoordinateString,':'!== false{
  482.             throw new Exception('Cell coordinate string can not be a range of cells.');
  483.         else if ($pCoordinateString == ''{
  484.             throw new Exception('Cell coordinate can not be zero-length string.');
  485.         else if (preg_match("/([$]?[A-Z]+)([$]?\d+)/"$pCoordinateString$matches)) {
  486.             list($column$row$matches;
  487.             return array($column$row);
  488.         else {
  489.             throw new Exception('Invalid cell coordinate.');
  490.         }
  491.     }
  492.  
  493.     /**
  494.      * Make string coordinate absolute
  495.      *
  496.      * @param    string    $pCoordinateString 
  497.      * @return    string    Absolute coordinate
  498.      * @throws    Exception
  499.      */
  500.     public static function absoluteCoordinate($pCoordinateString 'A1')
  501.     {
  502.         if (strpos($pCoordinateString,':'=== false && strpos($pCoordinateString,','=== false{
  503.             // Create absolute coordinate
  504.             list($column$rowPHPExcel_Cell::coordinateFromString($pCoordinateString);
  505.             return '$' $column '$' $row;
  506.         else {
  507.             throw new Exception("Coordinate string should not be a cell range.");
  508.         }
  509.     }
  510.  
  511.     /**
  512.      * Split range into coordinate strings
  513.      *
  514.      * @param    string    $pRange 
  515.      * @return    array    Array containg one or more arrays containing one or two coordinate strings
  516.      */
  517.     public static function splitRange($pRange 'A1:A1')
  518.     {
  519.         $exploded explode(','$pRange);
  520.         for ($i 0$i count($exploded)++$i{
  521.             $exploded[$iexplode(':'$exploded[$i]);
  522.         }
  523.         return $exploded;
  524.     }
  525.  
  526.     /**
  527.      * Build range from coordinate strings
  528.      *
  529.      * @param    array    $pRange    Array containg one or more arrays containing one or two coordinate strings
  530.      * @return  string    String representation of $pRange
  531.      * @throws    Exception
  532.      */
  533.     public static function buildRange($pRange)
  534.     {
  535.         // Verify range
  536.         if (!is_array($pRange|| count($pRange== || !is_array($pRange[0])) {
  537.             throw new Exception('Range does not contain any information.');
  538.         }
  539.  
  540.         // Build range
  541.         $imploded array();
  542.         for ($i 0$i count($pRange)++$i{
  543.             $pRange[$iimplode(':'$pRange[$i]);
  544.         }
  545.         $imploded implode(','$pRange);
  546.  
  547.         return $imploded;
  548.     }
  549.  
  550.     /**
  551.      * Calculate range boundaries
  552.      *
  553.      * @param    string    $pRange        Cell range (e.g. A1:A1)
  554.      * @return    array    Range coordinates (Start Cell, End Cell) where Start Cell and End Cell are arrays (Column Number, Row Number)
  555.      */
  556.     public static function rangeBoundaries($pRange 'A1:A1')
  557.     {
  558.         // Uppercase coordinate
  559.         $pRange strtoupper($pRange);
  560.  
  561.         // Extract range
  562.         if (strpos($pRange':'=== false{
  563.             $rangeA $rangeB $pRange;
  564.         else {
  565.             list($rangeA$rangeBexplode(':'$pRange);
  566.         }
  567.  
  568.         // Calculate range outer borders
  569.         $rangeStart PHPExcel_Cell::coordinateFromString($rangeA);
  570.         $rangeEnd    PHPExcel_Cell::coordinateFromString($rangeB);
  571.  
  572.         // Translate column into index
  573.         $rangeStart[0]    PHPExcel_Cell::columnIndexFromString($rangeStart[0]);
  574.         $rangeEnd[0]    PHPExcel_Cell::columnIndexFromString($rangeEnd[0]);
  575.  
  576.         return array($rangeStart$rangeEnd);
  577.     }
  578.  
  579.     /**
  580.      * Calculate range dimension
  581.      *
  582.      * @param    string    $pRange        Cell range (e.g. A1:A1)
  583.      * @return    array    Range dimension (width, height)
  584.      */
  585.     public static function rangeDimension($pRange 'A1:A1')
  586.     {
  587.         // Calculate range outer borders
  588.         list($rangeStart,$rangeEndPHPExcel_Cell::rangeBoundaries($pRange);
  589.  
  590.         return array( ($rangeEnd[0$rangeStart[01)($rangeEnd[1$rangeStart[11) );
  591.     }
  592.  
  593.     /**
  594.      * Calculate range boundaries
  595.      *
  596.      * @param    string    $pRange        Cell range (e.g. A1:A1)
  597.      * @return    array    Range boundaries (staring Column, starting Row, Final Column, Final Row)
  598.      */
  599.     public static function getRangeBoundaries($pRange 'A1:A1')
  600.     {
  601.         // Uppercase coordinate
  602.         $pRange strtoupper($pRange);
  603.  
  604.         // Extract range
  605.         if (strpos($pRange':'=== false{
  606.             $rangeA $pRange;
  607.             $rangeB $pRange;
  608.         else {
  609.             list($rangeA$rangeBexplode(':'$pRange);
  610.         }
  611.  
  612.         return arrayself::coordinateFromString($rangeA)self::coordinateFromString($rangeB));
  613.     }
  614.  
  615.     /**
  616.      * Column index from string
  617.      *
  618.      * @param    string $pString 
  619.      * @return    int Column index (base 1 !!!)
  620.      * @throws    Exception
  621.      */
  622.     public static function columnIndexFromString($pString 'A')
  623.     {
  624.         static $lookup array(
  625.             'A' => 1'B' => 2'C' => 3'D' => 4'E' => 5'F' => 6'G' => 7'H' => 8'I' => 9'J' => 10'K' => 11'L' => 12'M' => 13,
  626.             'N' => 14'O' => 15'P' => 16'Q' => 17'R' => 18'S' => 19'T' => 20'U' => 21'V' => 22'W' => 23'X' => 24'Y' => 25'Z' => 26
  627.         );
  628.  
  629.         if (isset($lookup[$pString]))
  630.             return $lookup[$pString];
  631.  
  632.         // Convert to uppercase
  633.         $pString strtoupper($pString);
  634.  
  635.         $strLen strlen($pString);
  636.         // Convert column to integer
  637.         if ($strLen == 1{
  638.             return (ord($pString{0}64);
  639.         elseif ($strLen == 2{
  640.             return $result (((ord($pString{0}65)) 26(ord($pString{1}64);
  641.         elseif ($strLen == 3{
  642.             return (((ord($pString{0}65)) 676(((ord($pString{1}65)) 26(ord($pString{2}64);
  643.         else {
  644.             throw new Exception("Column string index can not be " ($strLen != "longer than 3 characters" "empty"".");
  645.         }
  646.     }
  647.  
  648.     /**
  649.      * String from columnindex
  650.      *
  651.      * @param int $pColumnIndex Column index (base 0 !!!)
  652.      * @return string 
  653.      */
  654.     public static function stringFromColumnIndex($pColumnIndex 0)
  655.     {
  656.         // Determine column string
  657.         if ($pColumnIndex 26{
  658.             return chr(65 $pColumnIndex);
  659.         }
  660.         return PHPExcel_Cell::stringFromColumnIndex((int)($pColumnIndex 26-1).chr(65 $pColumnIndex%26;
  661.     }
  662.  
  663.     /**
  664.      * Extract all cell references in range
  665.      *
  666.      * @param    string    $pRange        Range (e.g. A1 or A1:A10 or A1:A10 A100:A1000)
  667.      * @return    array    Array containing single cell references
  668.      */
  669.     public static function extractAllCellReferencesInRange($pRange 'A1'{
  670.         // Returnvalue
  671.         $returnValue array();
  672.  
  673.         // Explode spaces
  674.         $aExplodeSpaces explode(' 'str_replace('$'''strtoupper($pRange)));
  675.         foreach ($aExplodeSpaces as $explodedSpaces{
  676.             // Single cell?
  677.             if (strpos($explodedSpaces,':'=== false && strpos($explodedSpaces,','=== false{
  678.                 $col 'A';
  679.                 $row 1;
  680.                 list($col$rowPHPExcel_Cell::coordinateFromString($explodedSpaces);
  681.  
  682.                 if (strlen($col<= 2{
  683.                     $returnValue[$explodedSpaces;
  684.                 }
  685.  
  686.                 continue;
  687.             }
  688.  
  689.             // Range...
  690.             $range PHPExcel_Cell::splitRange($explodedSpaces);
  691.             for ($i 0$i count($range)++$i{
  692.                 // Single cell?
  693.                 if (count($range[$i]== 1{
  694.                     $col 'A';
  695.                     $row 1;
  696.                     list($col$rowPHPExcel_Cell::coordinateFromString($range[$i]);
  697.  
  698.                     if (strlen($col<= 2{
  699.                         $returnValue[$explodedSpaces;
  700.                     }
  701.                 }
  702.  
  703.                 // Range...
  704.                 $rangeStart        $rangeEnd        '';
  705.                 $startingCol    $startingRow    $endingCol    $endingRow    0;
  706.  
  707.                 list($rangeStart$rangeEnd)        $range[$i];
  708.                 list($startingCol$startingRow)    PHPExcel_Cell::coordinateFromString($rangeStart);
  709.                 list($endingCol$endingRow)        PHPExcel_Cell::coordinateFromString($rangeEnd);
  710.  
  711.                 // Conversions...
  712.                 $startingCol    PHPExcel_Cell::columnIndexFromString($startingCol);
  713.                 $endingCol        PHPExcel_Cell::columnIndexFromString($endingCol);
  714.  
  715.                 // Current data
  716.                 $currentCol    = --$startingCol;
  717.                 $currentRow    $startingRow;
  718.  
  719.                 // Loop cells
  720.                 while ($currentCol $endingCol{
  721.                     $loopColumn PHPExcel_Cell::stringFromColumnIndex($currentCol);
  722.                     while ($currentRow <= $endingRow{
  723.                         $returnValue[$loopColumn.$currentRow;
  724.                         ++$currentRow;
  725.                     }
  726.                     ++$currentCol;
  727.                     $currentRow $startingRow;
  728.                 }
  729.             }
  730.         }
  731.  
  732.         // Return value
  733.         return $returnValue;
  734.     }
  735.  
  736.     /**
  737.      * Compare 2 cells
  738.      *
  739.      * @param    PHPExcel_Cell    $a    Cell a
  740.      * @param    PHPExcel_Cell    $a    Cell b
  741.      * @return    int        Result of comparison (always -1 or 1, never zero!)
  742.      */
  743.     public static function compareCells(PHPExcel_Cell $aPHPExcel_Cell $b)
  744.     {
  745.         if ($a->_row $b->_row{
  746.             return -1;
  747.         elseif ($a->_row $b->_row{
  748.             return 1;
  749.         elseif (PHPExcel_Cell::columnIndexFromString($a->_columnPHPExcel_Cell::columnIndexFromString($b->_column)) {
  750.             return -1;
  751.         else {
  752.             return 1;
  753.         }
  754.     }
  755.  
  756.     /**
  757.      * Get value binder to use
  758.      *
  759.      * @return PHPExcel_Cell_IValueBinder 
  760.      */
  761.     public static function getValueBinder({
  762.         if (is_null(self::$_valueBinder)) {
  763.             self::$_valueBinder new PHPExcel_Cell_DefaultValueBinder();
  764.         }
  765.  
  766.         return self::$_valueBinder;
  767.     }
  768.  
  769.     /**
  770.      * Set value binder to use
  771.      *
  772.      * @param PHPExcel_Cell_IValueBinder $binder 
  773.      * @throws Exception
  774.      */
  775.     public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder null{
  776.         if (is_null($binder)) {
  777.             throw new Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
  778.         }
  779.  
  780.         self::$_valueBinder $binder;
  781.     }
  782.  
  783.     /**
  784.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  785.      */
  786.     public function __clone({
  787.         $vars get_object_vars($this);
  788.         foreach ($vars as $key => $value{
  789.             if ((is_object($value)) && ($key != '_parent')) {
  790.                 $this->$key clone $value;
  791.             else {
  792.                 $this->$key $value;
  793.             }
  794.         }
  795.     }
  796.  
  797.     /**
  798.      * Get index to cellXf
  799.      *
  800.      * @return int 
  801.      */
  802.     public function getXfIndex()
  803.     {
  804.         return $this->_xfIndex;
  805.     }
  806.  
  807.     /**
  808.      * Set index to cellXf
  809.      *
  810.      * @param int $pValue 
  811.      * @return PHPExcel_Cell 
  812.      */
  813.     public function setXfIndex($pValue 0)
  814.     {
  815.         $this->_xfIndex $pValue;
  816.  
  817.         return $this->notifyCacheController();
  818.     }
  819.  
  820.  
  821.     public function setFormulaAttributes($pAttributes)
  822.     {
  823.         $this->_formulaAttributes $pAttributes;
  824.         return $this;
  825.     }
  826.  
  827.     public function getFormulaAttributes()
  828.     {
  829.         return $this->_formulaAttributes;
  830.     }
  831.  
  832. }

Documentation generated on Thu, 26 Aug 2010 17:40:54 +0200 by phpDocumentor 1.4.3