Source for file Style.php
Documentation is available at Style.php
* Copyright (c) 2006 - 2009 PHPExcel
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.6.5, 2009-01-05
/** PHPExcel_Style_Color */
require_once 'PHPExcel/Style/Color.php';
/** PHPExcel_Style_Font */
require_once 'PHPExcel/Style/Font.php';
/** PHPExcel_Style_Fill */
require_once 'PHPExcel/Style/Fill.php';
/** PHPExcel_Style_Borders */
require_once 'PHPExcel/Style/Borders.php';
/** PHPExcel_Style_Alignment */
require_once 'PHPExcel/Style/Alignment.php';
/** PHPExcel_Style_NumberFormat */
require_once 'PHPExcel/Style/NumberFormat.php';
/** PHPExcel_Style_Conditional */
require_once 'PHPExcel/Style/Conditional.php';
/** PHPExcel_Style_Protection */
require_once 'PHPExcel/Style/Protection.php';
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
private static $_defaultStyle;
* @var PHPExcel_Style_Font
* @var PHPExcel_Style_Fill
* @var PHPExcel_Style_Borders
* @var PHPExcel_Style_Alignment
* @var PHPExcel_Style_NumberFormat
* @var PHPExcel_Style_Conditional[]
* @var PHPExcel_Style_Protection
* Create a new PHPExcel_Style
* The following properties are late bound. Binding is initiated by property classes when they are modified.
if (is_null(self::$_defaultStyle)) {
self::$_defaultStyle = $this;
* Complete the binding process a child property object started
* @param $propertyName Name of this property in the parent object
$this->_font = $propertyObject;
$this->_fill = $propertyObject;
throw new Exception("Invalid property passed.");
* Determines if a child property is bound to this one
* @param $propertyName Name of this property in the parent object
return isset ($this->_font);
return isset ($this->_fill);
throw new Exception("Invalid property passed.");
* Apply styles from array
* $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray(
* 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE,
* 'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
* 'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
* @param array $pStyles Array containing style information
$this->getFill()->applyFromArray($pStyles['fill']);
$this->getFont()->applyFromArray($pStyles['font']);
$this->getBorders()->applyFromArray($pStyles['borders']);
$this->getAlignment()->applyFromArray($pStyles['alignment']);
throw new Exception("Invalid style array passed.");
return self::$_defaultStyle;
* Set default style - should only be used by PHPExcel_IReader implementations!
* @param PHPExcel_Style $value
self::$_defaultStyle = $value;
* @return PHPExcel_Style_Fill
$property = new PHPExcel_Style_Fill();
$property->propertyPrepareBind($this, "_fill");
* @return PHPExcel_Style_Font
$property->propertyPrepareBind($this, "_font");
* @return PHPExcel_Style_Borders
$property->propertyPrepareBind($this, "_borders");
* @return PHPExcel_Style_Alignment
$property->propertyPrepareBind($this, "_alignment");
* @return PHPExcel_Style_NumberFormat
$property->propertyPrepareBind($this, "_numberFormat");
* @return PHPExcel_Style_Conditional[]
* @param PHPExcel_Style_Conditional[] $pValue Array of condtional styles
* @return PHPExcel_Style_Protection
$property->propertyPrepareBind($this, "_protection");
* @return string Hash code
$hashConditionals .= $conditional->getHashCode();
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
* @return string Hash index
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
* @param string $value Hash index
* Implement PHP __clone to create a deep clone, not just a shallow copy.
foreach ($vars as $key => $value) {
$this->$key = clone $value;
|