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

Source for file Style.php

Documentation is available at Style.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_Style
  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.2, 2010-01-11
  26.  */
  27.  
  28.  
  29. /** PHPExcel root directory */
  30. if (!defined('PHPEXCEL_ROOT')) {
  31.     /**
  32.      * @ignore
  33.      */
  34.     define('PHPEXCEL_ROOT'dirname(__FILE__'/../');
  35. }
  36.  
  37. /** PHPExcel_Style_Color */
  38. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Color.php';
  39.  
  40. /** PHPExcel_Style_Font */
  41. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Font.php';
  42.  
  43. /** PHPExcel_Style_Fill */
  44. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Fill.php';
  45.  
  46. /** PHPExcel_Style_Borders */
  47. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Borders.php';
  48.  
  49. /** PHPExcel_Style_Alignment */
  50. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Alignment.php';
  51.  
  52. /** PHPExcel_Style_NumberFormat */
  53. require_once PHPEXCEL_ROOT 'PHPExcel/Style/NumberFormat.php';
  54.  
  55. /** PHPExcel_Style_Conditional */
  56. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Conditional.php';
  57.  
  58. /** PHPExcel_Style_Protection */
  59. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Protection.php';
  60.  
  61. /** PHPExcel_IComparable */
  62. require_once PHPEXCEL_ROOT 'PHPExcel/IComparable.php';
  63.  
  64. /**
  65.  * PHPExcel_Style
  66.  *
  67.  * @category   PHPExcel
  68.  * @package    PHPExcel_Style
  69.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  70.  */
  71. class PHPExcel_Style implements PHPExcel_IComparable
  72. {
  73.     /**
  74.      * Font
  75.      *
  76.      * @var PHPExcel_Style_Font 
  77.      */
  78.     private $_font;
  79.     
  80.     /**
  81.      * Fill
  82.      *
  83.      * @var PHPExcel_Style_Fill 
  84.      */
  85.     private $_fill;
  86.  
  87.     /**
  88.      * Borders
  89.      *
  90.      * @var PHPExcel_Style_Borders 
  91.      */
  92.     private $_borders;
  93.     
  94.     /**
  95.      * Alignment
  96.      *
  97.      * @var PHPExcel_Style_Alignment 
  98.      */
  99.     private $_alignment;
  100.     
  101.     /**
  102.      * Number Format
  103.      *
  104.      * @var PHPExcel_Style_NumberFormat 
  105.      */
  106.     private $_numberFormat;
  107.     
  108.     /**
  109.      * Conditional styles
  110.      *
  111.      * @var PHPExcel_Style_Conditional[] 
  112.      */
  113.     private $_conditionalStyles;
  114.     
  115.     /**
  116.      * Protection
  117.      *
  118.      * @var PHPExcel_Style_Protection 
  119.      */
  120.     private $_protection;
  121.  
  122.     /**
  123.      * Style supervisor?
  124.      *
  125.      * @var boolean 
  126.      */
  127.     private $_isSupervisor;
  128.  
  129.     /**
  130.      * Parent. Only used for style supervisor
  131.      *
  132.      * @var PHPExcel 
  133.      */
  134.     private $_parent;
  135.  
  136.     /**
  137.      * Index of style in collection. Only used for real style.
  138.      *
  139.      * @var int 
  140.      */
  141.     private $_index;
  142.  
  143.     /**
  144.      * Create a new PHPExcel_Style
  145.      *
  146.      * @param boolean $isSupervisor 
  147.      */
  148.     public function __construct($isSupervisor false)
  149.     {
  150.         // Supervisor?
  151.         $this->_isSupervisor = $isSupervisor;
  152.  
  153.         // Initialise values
  154.         $this->_conditionalStyles     = array();
  155.         $this->_font                = new PHPExcel_Style_Font($isSupervisor);
  156.         $this->_fill                = new PHPExcel_Style_Fill($isSupervisor);
  157.         $this->_borders                = new PHPExcel_Style_Borders($isSupervisor);
  158.         $this->_alignment            = new PHPExcel_Style_Alignment($isSupervisor);
  159.         $this->_numberFormat        = new PHPExcel_Style_NumberFormat($isSupervisor);
  160.         $this->_protection            = new PHPExcel_Style_Protection($isSupervisor);
  161.  
  162.         // bind parent if we are a supervisor
  163.         if ($isSupervisor{
  164.             $this->_font->bindParent($this);
  165.             $this->_fill->bindParent($this);
  166.             $this->_borders->bindParent($this);
  167.             $this->_alignment->bindParent($this);
  168.             $this->_numberFormat->bindParent($this);
  169.             $this->_protection->bindParent($this);
  170.         }
  171.     }
  172.  
  173.     /**
  174.      * Bind parent. Only used for supervisor
  175.      *
  176.      * @param PHPExcel $parent 
  177.      * @return PHPExcel_Style 
  178.      */
  179.     public function bindParent($parent)
  180.     {
  181.         $this->_parent = $parent;
  182.         return $this;
  183.     }
  184.     
  185.     /**
  186.      * Is this a supervisor or a real style component?
  187.      *
  188.      * @return boolean 
  189.      */
  190.     public function getIsSupervisor()
  191.     {
  192.         return $this->_isSupervisor;
  193.     }
  194.  
  195.     /**
  196.      * Get the shared style component for the currently active cell in currently active sheet.
  197.      * Only used for style supervisor
  198.      *
  199.      * @return PHPExcel_Style 
  200.      */
  201.     public function getSharedComponent()
  202.     {
  203.         $activeSheet $this->getActiveSheet();
  204.         $selectedCell $this->getActiveCell()// e.g. 'A1'
  205.  
  206.         if ($activeSheet->cellExists($selectedCell)) {
  207.             $cell $activeSheet->getCell($selectedCell);
  208.             $xfIndex $cell->getXfIndex();
  209.         else {
  210.             $xfIndex 0;
  211.         }
  212.  
  213.         $activeStyle $this->_parent->getCellXfByIndex($xfIndex);
  214.         return $activeStyle;
  215.     }
  216.  
  217.     /**
  218.      * Get the currently active sheet. Only used for supervisor
  219.      *
  220.      * @return PHPExcel_Worksheet 
  221.      */
  222.     public function getActiveSheet()
  223.     {
  224.         return $this->_parent->getActiveSheet();
  225.     }
  226.  
  227.     /**
  228.      * Get the currently active cell coordinate in currently active sheet.
  229.      * Only used for supervisor
  230.      *
  231.      * @return string E.g. 'A1'
  232.      */
  233.     public function getSelectedCells()
  234.     {
  235.         return $this->_parent->getActiveSheet()->getSelectedCells();
  236.     }
  237.  
  238.     /**
  239.      * Get the currently active cell coordinate in currently active sheet.
  240.      * Only used for supervisor
  241.      *
  242.      * @return string E.g. 'A1'
  243.      */
  244.     public function getActiveCell()
  245.     {
  246.         return $this->_parent->getActiveSheet()->getActiveCell();
  247.     }
  248.  
  249.     /**
  250.      * Get parent. Only used for style supervisor
  251.      *
  252.      * @return PHPExcel 
  253.      */
  254.     public function getParent()
  255.     {
  256.         return $this->_parent;
  257.     }
  258.  
  259.     /**
  260.      * Apply styles from array
  261.      * 
  262.      * <code>
  263.      * $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray(
  264.      *         array(
  265.      *             'font'    => array(
  266.      *                 'name'      => 'Arial',
  267.      *                 'bold'      => true,
  268.      *                 'italic'    => false,
  269.      *                 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE,
  270.      *                 'strike'    => false,
  271.      *                 'color'     => array(
  272.      *                     'rgb' => '808080'
  273.      *                 )
  274.      *             ),
  275.      *             'borders' => array(
  276.      *                 'bottom'     => array(
  277.      *                     'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
  278.      *                     'color' => array(
  279.      *                         'rgb' => '808080'
  280.      *                     )
  281.      *                 ),
  282.      *                 'top'     => array(
  283.      *                     'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
  284.      *                     'color' => array(
  285.      *                         'rgb' => '808080'
  286.      *                     )
  287.      *                 )
  288.      *             )
  289.      *         )
  290.      * );
  291.      * </code>
  292.      * 
  293.      * @param    array    $pStyles    Array containing style information
  294.      * @param     boolean        $pAdvanced    Advanced mode for setting borders.
  295.      * @throws    Exception
  296.      * @return PHPExcel_Style 
  297.      */
  298.     public function applyFromArray($pStyles null$pAdvanced true{
  299.         if (is_array($pStyles)) {
  300.             if ($this->_isSupervisor{
  301.  
  302.                 $pRange $this->getSelectedCells();
  303.  
  304.                 // Uppercase coordinate
  305.                 $pRange strtoupper($pRange);
  306.  
  307.                 // Is it a cell range or a single cell?
  308.                 $rangeA     '';
  309.                 $rangeB     '';
  310.                 if (strpos($pRange':'=== false{
  311.                     $rangeA $pRange;
  312.                     $rangeB $pRange;
  313.                 else {
  314.                     list($rangeA$rangeBexplode(':'$pRange);
  315.                 }
  316.  
  317.                 // Calculate range outer borders
  318.                 $rangeStart PHPExcel_Cell::coordinateFromString($rangeA);
  319.                 $rangeEnd     PHPExcel_Cell::coordinateFromString($rangeB);
  320.  
  321.                 // Translate column into index
  322.                 $rangeStart[0]    PHPExcel_Cell::columnIndexFromString($rangeStart[0]1;
  323.                 $rangeEnd[0]    PHPExcel_Cell::columnIndexFromString($rangeEnd[0]1;
  324.  
  325.                 // Make sure we can loop upwards on rows and columns
  326.                 if ($rangeStart[0$rangeEnd[0&& $rangeStart[1$rangeEnd[1]{
  327.                     $tmp $rangeStart;
  328.                     $rangeStart $rangeEnd;
  329.                     $rangeEnd $tmp;
  330.                 }
  331.  
  332.                 // ADVANCED MODE:
  333.  
  334.                 if ($pAdvanced && isset($pStyles['borders'])) {
  335.  
  336.                     // 'allborders' is a shorthand property for 'outline' and 'inside' and
  337.                     //        it applies to components that have not been set explicitly
  338.                     if (isset($pStyles['borders']['allborders'])) {
  339.                         foreach (array('outline''inside'as $component{
  340.                             if (!isset($pStyles['borders'][$component])) {
  341.                                 $pStyles['borders'][$component$pStyles['borders']['allborders'];
  342.                             }
  343.                         }
  344.                         unset($pStyles['borders']['allborders'])// not needed any more
  345.                     }
  346.  
  347.                     // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left'
  348.                     //        it applies to components that have not been set explicitly
  349.                     if (isset($pStyles['borders']['outline'])) {
  350.                         foreach (array('top''right''bottom''left'as $component{
  351.                             if (!isset($pStyles['borders'][$component])) {
  352.                                 $pStyles['borders'][$component$pStyles['borders']['outline'];
  353.                             }
  354.                         }
  355.                         unset($pStyles['borders']['outline'])// not needed any more
  356.                     }
  357.  
  358.                     // 'inside' is a shorthand property for 'vertical' and 'horizontal'
  359.                     //        it applies to components that have not been set explicitly
  360.                     if (isset($pStyles['borders']['inside'])) {
  361.                         foreach (array('vertical''horizontal'as $component{
  362.                             if (!isset($pStyles['borders'][$component])) {
  363.                                 $pStyles['borders'][$component$pStyles['borders']['inside'];
  364.                             }
  365.                         }
  366.                         unset($pStyles['borders']['inside'])// not needed any more
  367.                     }
  368.  
  369.                     // width and height characteristics of selection, 1, 2, or 3 (for 3 or more)
  370.                     $xMax min($rangeEnd[0$rangeStart[013);
  371.                     $yMax min($rangeEnd[1$rangeStart[113);
  372.  
  373.                     // loop through up to 3 x 3 = 9 regions
  374.                     for ($x 1$x <= $xMax++$x{
  375.                         // start column index for region
  376.                         $colStart ($x == 3
  377.                             PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0])
  378.                                 : PHPExcel_Cell::stringFromColumnIndex($rangeStart[0$x 1);
  379.  
  380.                         // end column index for region
  381.                         $colEnd ($x == 1?
  382.                             PHPExcel_Cell::stringFromColumnIndex($rangeStart[0])
  383.                                 : PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0$xMax $x);
  384.  
  385.                         for ($y 1$y <= $yMax++$y{
  386.  
  387.                             // which edges are touching the region
  388.                             $edges array();
  389.  
  390.                             // are we at left edge
  391.                             if ($x == 1{
  392.                                 $edges['left';
  393.                             }
  394.  
  395.                             // are we at right edge
  396.                             if ($x == $xMax{
  397.                                 $edges['right';
  398.                             }
  399.  
  400.                             // are we at top edge?
  401.                             if ($y == 1{
  402.                                 $edges['top';
  403.                             }
  404.  
  405.                             // are we at bottom edge?
  406.                             if ($y == $yMax{
  407.                                 $edges['bottom';
  408.                             }
  409.  
  410.                             // start row index for region
  411.                             $rowStart ($y == 3?
  412.                                 $rangeEnd[1$rangeStart[1$y 1;
  413.  
  414.                             // end row index for region
  415.                             $rowEnd ($y == 1?
  416.                                 $rangeStart[1$rangeEnd[1$yMax $y;
  417.  
  418.                             // build range for region
  419.                             $range $colStart $rowStart ':' $colEnd $rowEnd;
  420.                             
  421.                             // retrieve relevant style array for region
  422.                             $regionStyles $pStyles;
  423.                             unset($regionStyles['borders']['inside']);
  424.  
  425.                             // what are the inner edges of the region when looking at the selection
  426.                             $innerEdges array_diffarray('top''right''bottom''left')$edges );
  427.  
  428.                             // inner edges that are not touching the region should take the 'inside' border properties if they have been set
  429.                             foreach ($innerEdges as $innerEdge{
  430.                                 switch ($innerEdge{
  431.                                     case 'top':
  432.                                     case 'bottom':
  433.                                         // should pick up 'horizontal' border property if set
  434.                                         if (isset($pStyles['borders']['horizontal'])) {
  435.                                             $regionStyles['borders'][$innerEdge$pStyles['borders']['horizontal'];
  436.                                         else {
  437.                                             unset($regionStyles['borders'][$innerEdge]);
  438.                                         }
  439.                                         break;
  440.                                     case 'left':
  441.                                     case 'right':
  442.                                         // should pick up 'vertical' border property if set
  443.                                         if (isset($pStyles['borders']['vertical'])) {
  444.                                             $regionStyles['borders'][$innerEdge$pStyles['borders']['vertical'];
  445.                                         else {
  446.                                             unset($regionStyles['borders'][$innerEdge]);
  447.                                         }
  448.                                         break;
  449.                                 }
  450.                             }
  451.  
  452.                             // apply region style to region by calling applyFromArray() in simple mode
  453.                             $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStylesfalse);
  454.                         }
  455.                     }
  456.                     return;
  457.                 }
  458.  
  459.                 // SIMPLE MODE:
  460.  
  461.                 // Selection type, inspect
  462.                 if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/'$pRange)) {
  463.                     $selectionType 'COLUMN';
  464.                 else if (preg_match('/^A[0-9]+:XFD[0-9]+$/'$pRange)) {
  465.                     $selectionType 'ROW';
  466.                 else {
  467.                     $selectionType 'CELL';
  468.                 }
  469.  
  470.                 // First loop through columns, rows, or cells to find out which styles are affected by this operation
  471.                 switch ($selectionType{
  472.                     case 'COLUMN':
  473.                         $oldXfIndexes array();
  474.                         for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  475.                             $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()true;
  476.                         }
  477.                         break;
  478.  
  479.                     case 'ROW':
  480.                         $oldXfIndexes array();
  481.                         for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  482.                             if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex(== null{
  483.                                 $oldXfIndexes[0true// row without explicit style should be formatted based on default style
  484.                             else {
  485.                                 $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()true;
  486.                             }
  487.                         }
  488.                         break;
  489.  
  490.                     case 'CELL':
  491.                         $oldXfIndexes array();
  492.                         for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  493.                             for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  494.                                 $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col$row)->getXfIndex()true;
  495.                             }
  496.                         }
  497.                         break;
  498.                 }
  499.  
  500.                 // clone each of the affected styles, apply the style arrray, and add the new styles to the workbook
  501.                 $workbook $this->getActiveSheet()->getParent();
  502.                 foreach ($oldXfIndexes as $oldXfIndex => $dummy{
  503.                     $style $workbook->getCellXfByIndex($oldXfIndex);
  504.                     $newStyle clone $style;
  505.                     $newStyle->applyFromArray($pStyles);
  506.                     
  507.                     if ($existingStyle $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
  508.                         // there is already such cell Xf in our collection
  509.                         $newXfIndexes[$oldXfIndex$existingStyle->getIndex();
  510.                     else {
  511.                         // we don't have such a cell Xf, need to add
  512.                         $workbook->addCellXf($newStyle);
  513.                         $newXfIndexes[$oldXfIndex$newStyle->getIndex();
  514.                     }
  515.                 }
  516.  
  517.                 // Loop through columns, rows, or cells again and update the XF index
  518.                 switch ($selectionType{
  519.                     case 'COLUMN':
  520.                         for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  521.                             $columnDimension $this->getActiveSheet()->getColumnDimensionByColumn($col);
  522.                             $oldXfIndex $columnDimension->getXfIndex();
  523.                             $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
  524.                         }
  525.                         break;
  526.  
  527.                     case 'ROW':
  528.                         for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  529.                             $rowDimension $this->getActiveSheet()->getRowDimension($row);
  530.                             $oldXfIndex $rowDimension->getXfIndex(=== null ?
  531.                                 $rowDimension->getXfIndex()// row without explicit style should be formatted based on default style
  532.                             $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
  533.                         }
  534.                         break;
  535.  
  536.                     case 'CELL':
  537.                         for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  538.                             for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  539.                                 $cell $this->getActiveSheet()->getCellByColumnAndRow($col$row);
  540.                                 $oldXfIndex $cell->getXfIndex();
  541.                                 $cell->setXfIndex($newXfIndexes[$oldXfIndex]);
  542.                             }
  543.                         }
  544.                         break;
  545.                 }
  546.  
  547.             else {
  548.                 // not a supervisor, just apply the style array directly on style object
  549.                 if (array_key_exists('fill'$pStyles)) {
  550.                     $this->getFill()->applyFromArray($pStyles['fill']);
  551.                 }
  552.                 if (array_key_exists('font'$pStyles)) {
  553.                     $this->getFont()->applyFromArray($pStyles['font']);
  554.                 }
  555.                 if (array_key_exists('borders'$pStyles)) {
  556.                     $this->getBorders()->applyFromArray($pStyles['borders']);
  557.                 }
  558.                 if (array_key_exists('alignment'$pStyles)) {
  559.                     $this->getAlignment()->applyFromArray($pStyles['alignment']);
  560.                 }
  561.                 if (array_key_exists('numberformat'$pStyles)) {
  562.                     $this->getNumberFormat()->applyFromArray($pStyles['numberformat']);
  563.                 }
  564.                 if (array_key_exists('protection'$pStyles)) {
  565.                     $this->getProtection()->applyFromArray($pStyles['protection']);
  566.                 }
  567.             }
  568.         else {
  569.             throw new Exception("Invalid style array passed.");
  570.         }
  571.         return $this;
  572.     }
  573.  
  574.     /**
  575.      * Get Fill
  576.      *
  577.      * @return PHPExcel_Style_Fill 
  578.      */
  579.     public function getFill({
  580.         return $this->_fill;
  581.     }
  582.     
  583.     /**
  584.      * Get Font
  585.      *
  586.      * @return PHPExcel_Style_Font 
  587.      */
  588.     public function getFont({
  589.         return $this->_font;
  590.     }
  591.  
  592.     /**
  593.      * Set font
  594.      *
  595.      * @param PHPExcel_Style_Font $font 
  596.      * @return PHPExcel_Style 
  597.      */
  598.     public function setFont(PHPExcel_Style_Font $font)
  599.     {
  600.         $this->_font = $font;
  601.         return $this;
  602.     }
  603.  
  604.     /**
  605.      * Get Borders
  606.      *
  607.      * @return PHPExcel_Style_Borders 
  608.      */
  609.     public function getBorders({
  610.         return $this->_borders;
  611.     }
  612.     
  613.     /**
  614.      * Get Alignment
  615.      *
  616.      * @return PHPExcel_Style_Alignment 
  617.      */
  618.     public function getAlignment({
  619.         return $this->_alignment;
  620.     }
  621.     
  622.     /**
  623.      * Get Number Format
  624.      *
  625.      * @return PHPExcel_Style_NumberFormat 
  626.      */
  627.     public function getNumberFormat({
  628.         return $this->_numberFormat;
  629.     }
  630.     
  631.     /**
  632.      * Get Conditional Styles. Only used on supervisor.
  633.      *
  634.      * @return PHPExcel_Style_Conditional[] 
  635.      */
  636.     public function getConditionalStyles({
  637.         return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell());
  638.     }
  639.        
  640.     /**
  641.      * Set Conditional Styles. Only used on supervisor.
  642.      *
  643.      * @param PHPExcel_Style_Conditional[]    $pValue    Array of condtional styles
  644.      * @return PHPExcel_Style 
  645.      */
  646.     public function setConditionalStyles($pValue null{
  647.         if (is_array($pValue)) {
  648.             foreach (PHPExcel_Cell::extractAllCellReferencesInRange($this->getSelectedCells()) as $cellReference{
  649.                 $this->getActiveSheet()->setConditionalStyles($cellReference$pValue);
  650.             }
  651.         }
  652.         return $this;
  653.     }
  654.     
  655.     /**
  656.      * Get Protection
  657.      *
  658.      * @return PHPExcel_Style_Protection 
  659.      */
  660.     public function getProtection({
  661.         return $this->_protection;
  662.     }
  663.    
  664.     /**
  665.      * Get hash code
  666.      *
  667.      * @return string    Hash code
  668.      */    
  669.     public function getHashCode({
  670.         $hashConditionals '';
  671.         foreach ($this->_conditionalStyles as $conditional{
  672.             $hashConditionals .= $conditional->getHashCode();
  673.         }
  674.         
  675.         return md5(
  676.               $this->getFill()->getHashCode()
  677.             . $this->getFont()->getHashCode()
  678.             . $this->getBorders()->getHashCode()
  679.             . $this->getAlignment()->getHashCode()
  680.             . $this->getNumberFormat()->getHashCode()
  681.             . $hashConditionals
  682.             . $this->getProtection()->getHashCode()
  683.             . __CLASS__
  684.         );
  685.     }
  686.     
  687.     /**
  688.      * Get own index in style collection
  689.      *
  690.      * @return int 
  691.      */
  692.     public function getIndex()
  693.     {
  694.         return $this->_index;
  695.     }
  696.  
  697.     /**
  698.      * Set own index in style collection
  699.      *
  700.      * @param int $pValue 
  701.      */
  702.     public function setIndex($pValue)
  703.     {
  704.         $this->_index = $pValue;
  705.     }
  706.  
  707.     /**
  708.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  709.      */
  710.     public function __clone({
  711.         $vars get_object_vars($this);
  712.         foreach ($vars as $key => $value{
  713.             if (is_object($value)) {
  714.                 $this->$key clone $value;
  715.             else {
  716.                 $this->$key $value;
  717.             }
  718.         }
  719.     }
  720. }

Documentation generated on Mon, 11 Jan 2010 08:14:21 +0100 by phpDocumentor 1.4.1