Source for file Border.php
Documentation is available at Border.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 BORDER_NONE = 'none';
const BORDER_DASHDOT = 'dashDot';
const BORDER_DASHDOTDOT = 'dashDotDot';
const BORDER_DASHED = 'dashed';
const BORDER_DOTTED = 'dotted';
const BORDER_DOUBLE = 'double';
const BORDER_HAIR = 'hair';
const BORDER_MEDIUM = 'medium';
const BORDER_MEDIUMDASHDOT = 'mediumDashDot';
const BORDER_MEDIUMDASHDOTDOT = 'mediumDashDotDot';
const BORDER_MEDIUMDASHED = 'mediumDashed';
const BORDER_SLANTDASHDOT = 'slantDashDot';
const BORDER_THICK = 'thick';
const BORDER_THIN = 'thin';
private $_borderStyle = PHPExcel_Style_Border::BORDER_NONE;
* @var PHPExcel_Style_Color
* Parent. Only used for supervisor
* @var PHPExcel_Style_Borders
private $_parentPropertyName;
* Create a new PHPExcel_Style_Border
$this->_isSupervisor = $isSupervisor;
// bind parent if we are a supervisor
* Bind parent. Only used for supervisor
* @param PHPExcel_Style_Borders $parent
* @param string $parentPropertyName
* @return PHPExcel_Style_Border
public function bindParent($parent, $parentPropertyName)
$this->_parent = $parent;
$this->_parentPropertyName = $parentPropertyName;
* 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_Border
switch ($this->_parentPropertyName) {
throw new Exception('Cannot get shared component for a pseudo-border.');
* 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
switch ($this->_parentPropertyName) {
* Apply styles from array
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray(
* 'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
* @param array $pStyles Array containing style information
* @return PHPExcel_Style_Border
if ($this->_isSupervisor) {
$this->getColor()->applyFromArray($pStyles['color']);
throw new Exception("Invalid style array passed.");
if ($this->_isSupervisor) {
return $this->_borderStyle;
* @return PHPExcel_Style_Border
public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
if ($this->_isSupervisor) {
$this->_borderStyle = $pValue;
* @return PHPExcel_Style_Color
* @param PHPExcel_Style_Color $pValue
* @return PHPExcel_Style_Border
public function setColor(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->getColor()->getStyleArray(array('argb' => $color->getARGB()));
* @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;
|