Source for file Fill.php
Documentation is available at Fill.php
* Copyright (c) 2006 - 2011 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 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
const FILL_NONE = 'none';
const FILL_SOLID = 'solid';
const FILL_GRADIENT_LINEAR = 'linear';
const FILL_GRADIENT_PATH = 'path';
const FILL_PATTERN_DARKDOWN = 'darkDown';
const FILL_PATTERN_DARKGRAY = 'darkGray';
const FILL_PATTERN_DARKGRID = 'darkGrid';
const FILL_PATTERN_DARKHORIZONTAL = 'darkHorizontal';
const FILL_PATTERN_DARKTRELLIS = 'darkTrellis';
const FILL_PATTERN_DARKUP = 'darkUp';
const FILL_PATTERN_DARKVERTICAL = 'darkVertical';
const FILL_PATTERN_GRAY0625 = 'gray0625';
const FILL_PATTERN_GRAY125 = 'gray125';
const FILL_PATTERN_LIGHTDOWN = 'lightDown';
const FILL_PATTERN_LIGHTGRAY = 'lightGray';
const FILL_PATTERN_LIGHTGRID = 'lightGrid';
const FILL_PATTERN_LIGHTHORIZONTAL = 'lightHorizontal';
const FILL_PATTERN_LIGHTTRELLIS = 'lightTrellis';
const FILL_PATTERN_LIGHTUP = 'lightUp';
const FILL_PATTERN_LIGHTVERTICAL = 'lightVertical';
const FILL_PATTERN_MEDIUMGRAY = 'mediumGray';
private $_fillType = PHPExcel_Style_Fill::FILL_NONE;
* @var PHPExcel_Style_Color
* @var PHPExcel_Style_Color
* @var _parentPropertyName string
private $_parentPropertyName;
* Parent. Only used for supervisor
* Create a new PHPExcel_Style_Fill
$this->_isSupervisor = $isSupervisor;
// bind parent if we are a supervisor
$this->_startColor->bindParent($this, '_startColor');
* Bind parent. Only used for supervisor
* @param PHPExcel_Style $parent
* @return PHPExcel_Style_Fill
$this->_parent = $parent;
* Is this a supervisor or a real style component?
return $this->_isSupervisor;
* Get the shared style component for the currently active cell in currently active sheet.
* Only used for style supervisor
* @return PHPExcel_Style_Fill
* Get the currently active sheet. Only used for supervisor
* @return PHPExcel_Worksheet
* Get the currently active cell coordinate in currently active sheet.
* Only used for supervisor
* @return string E.g. 'A1'
* Get the currently active cell coordinate in currently active sheet.
* Only used for supervisor
* @return string E.g. 'A1'
* Build style array from subcomponents
return array('fill' => $array);
* Apply styles from array
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFill()->applyFromArray(
* 'type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
* @param array $pStyles Array containing style information
* @return PHPExcel_Style_Fill
if ($this->_isSupervisor) {
$this->getEndColor()->applyFromArray($pStyles['endcolor']);
throw new Exception("Invalid style array passed.");
if ($this->_isSupervisor) {
* @param string $pValue PHPExcel_Style_Fill fill type
* @return PHPExcel_Style_Fill
public function setFillType($pValue = PHPExcel_Style_Fill::FILL_NONE) {
if ($this->_isSupervisor) {
$this->_fillType = $pValue;
if ($this->_isSupervisor) {
* @return PHPExcel_Style_Fill
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('rotation' => $pValue));
$this->_rotation = $pValue;
* @return PHPExcel_Style_Color
return $this->_startColor;
* @param PHPExcel_Style_Color $pValue
* @return PHPExcel_Style_Fill
public function setStartColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) {
$styleArray = $this->getStartColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->_startColor = $color;
* @return PHPExcel_Style_Color
* @param PHPExcel_Style_Color $pValue
* @return PHPExcel_Style_Fill
public function setEndColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) {
$styleArray = $this->getEndColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->_endColor = $color;
* @return string Hash code
if ($this->_isSupervisor) {
* Implement PHP __clone to create a deep clone, not just a shallow copy.
foreach ($vars as $key => $value) {
if ((is_object($value)) && ($key != '_parent')) {
$this->$key = clone $value;
|