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

Documentation generated on Tue, 01 Jun 2010 17:02:30 +0200 by phpDocumentor 1.4.3