This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,420 @@
<?php
/**
* PHPExcel
*
* 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
*
* @category PHPExcel
* @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.6, 2009-03-02
*/
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Alignment
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Alignment implements PHPExcel_IComparable
{
/* Horizontal alignment styles */
const HORIZONTAL_GENERAL = 'general';
const HORIZONTAL_LEFT = 'left';
const HORIZONTAL_RIGHT = 'right';
const HORIZONTAL_CENTER = 'center';
const HORIZONTAL_JUSTIFY = 'justify';
/* Vertical alignment styles */
const VERTICAL_BOTTOM = 'bottom';
const VERTICAL_TOP = 'top';
const VERTICAL_CENTER = 'center';
const VERTICAL_JUSTIFY = 'justify';
/**
* Horizontal
*
* @var string
*/
private $_horizontal;
/**
* Vertical
*
* @var string
*/
private $_vertical;
/**
* Text rotation
*
* @var int
*/
private $_textRotation;
/**
* Wrap text
*
* @var boolean
*/
private $_wrapText;
/**
* Shrink to fit
*
* @var boolean
*/
private $_shrinkToFit;
/**
* Indent - only possible with horizontal alignment left and right
*
* @var int
*/
private $_indent;
/**
* Parent Style
*
* @var PHPExcel_Style
*/
private $_parent;
/**
* Parent Borders
*
* @var _parentPropertyName string
*/
private $_parentPropertyName;
/**
* Create a new PHPExcel_Style_Alignment
*/
public function __construct()
{
// Initialise values
$this->_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
$this->_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
$this->_textRotation = 0;
$this->_wrapText = false;
$this->_shrinkToFit = false;
$this->_indent = 0;
}
/**
* Property Prepare bind
*
* Configures this object for late binding as a property of a parent object
*
* @param $parent
* @param $parentPropertyName
*/
public function propertyPrepareBind($parent, $parentPropertyName)
{
// Initialize parent PHPExcel_Style for late binding. This relationship purposely ends immediately when this object
// is bound to the PHPExcel_Style object pointed to so as to prevent circular references.
$this->_parent = $parent;
$this->_parentPropertyName = $parentPropertyName;
}
/**
* Property Get Bound
*
* Returns the PHPExcel_Style_Alignment that is actual bound to PHPExcel_Style
*
* @return PHPExcel_Style_Alignment
*/
private function propertyGetBound() {
if(!isset($this->_parent))
return $this; // I am bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getAlignment(); // Another one is bound
return $this; // No one is bound yet
}
/**
* Property Begin Bind
*
* If no PHPExcel_Style_Alignment has been bound to PHPExcel_Style then bind this one. Return the actual bound one.
*
* @return PHPExcel_Style_Alignment
*/
private function propertyBeginBind() {
if(!isset($this->_parent))
return $this; // I am already bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getAlignment(); // Another one is already bound
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
$this->_parent = null;
return $this;
}
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray(
* array(
* 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
* 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
* 'rotation' => 0,
* 'wrap' => true
* )
* );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if (array_key_exists('horizontal', $pStyles)) {
$this->setHorizontal($pStyles['horizontal']);
}
if (array_key_exists('vertical', $pStyles)) {
$this->setVertical($pStyles['vertical']);
}
if (array_key_exists('rotation', $pStyles)) {
$this->setTextRotation($pStyles['rotation']);
}
if (array_key_exists('wrap', $pStyles)) {
$this->setWrapText($pStyles['wrap']);
}
if (array_key_exists('shrinkToFit', $pStyles)) {
$this->setShrinkToFit($pStyles['shrinkToFit']);
}
if (array_key_exists('indent', $pStyles)) {
$this->setIndent($pStyles['indent']);
}
} else {
throw new Exception("Invalid style array passed.");
}
}
/**
* Get Horizontal
*
* @return string
*/
public function getHorizontal() {
return $this->propertyGetBound()->_horizontal;
}
/**
* Set Horizontal
*
* @param string $pValue
*/
public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
}
$this->propertyBeginBind()->_horizontal = $pValue;
}
/**
* Get Vertical
*
* @return string
*/
public function getVertical() {
return $this->propertyGetBound()->_vertical;
}
/**
* Set Vertical
*
* @param string $pValue
*/
public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
}
$this->propertyBeginBind()->_vertical = $pValue;
}
/**
* Get TextRotation
*
* @return int
*/
public function getTextRotation() {
return $this->propertyGetBound()->_textRotation;
}
/**
* Set TextRotation
*
* @param int $pValue
* @throws Exception
*/
public function setTextRotation($pValue = 0) {
// Excel2007 value 255 => PHPExcel value -165
if ($pValue == 255) {
$pValue = -165;
}
// Set rotation
if ( ($pValue >= -90 && $pValue <= 90) || $pValue == -165 ) {
$this->propertyBeginBind()->_textRotation = $pValue;
} else {
throw new Exception("Text rotation should be a value between -90 and 90.");
}
}
/**
* Get Wrap Text
*
* @return boolean
*/
public function getWrapText() {
return $this->propertyGetBound()->_wrapText;
}
/**
* Set Wrap Text
*
* @param boolean $pValue
*/
public function setWrapText($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
$this->propertyBeginBind()->_wrapText = $pValue;
}
/**
* Get Shrink to fit
*
* @return boolean
*/
public function getShrinkToFit() {
return $this->propertyGetBound()->_shrinkToFit;
}
/**
* Set Shrink to fit
*
* @param boolean $pValue
*/
public function setShrinkToFit($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
$this->propertyBeginBind()->_shrinkToFit = $pValue;
}
/**
* Get indent
*
* @return int
*/
public function getIndent() {
return $this->propertyGetBound()->_indent;
}
/**
* Set indent
*
* @param int $pValue
*/
public function setIndent($pValue = 0) {
if ($pValue > 0) {
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) {
$pValue = 0; // indent not supported
}
}
$this->propertyBeginBind()->_indent = $pValue;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
$property = $this->propertyGetBound();
return md5(
$property->_horizontal
. $property->_vertical
. $property->_textRotation
. ($property->_wrapText ? 't' : 'f')
. ($property->_shrinkToFit ? 't' : 'f')
. $property->_indent
. __CLASS__
);
}
/**
* Hash index
*
* @var string
*/
private $_hashIndex;
/**
* Get 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.
*
* @return string Hash index
*/
public function getHashIndex() {
return $this->_hashIndex;
}
/**
* Set 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
*/
public function setHashIndex($value) {
$this->_hashIndex = $value;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@@ -0,0 +1,331 @@
<?php
/**
* PHPExcel
*
* 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
*
* @category PHPExcel
* @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.6, 2009-03-02
*/
/** PHPExcel_Style_Color */
require_once 'PHPExcel/Style/Color.php';
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Border
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Border implements PHPExcel_IComparable
{
/* Border style */
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';
/**
* Border style
*
* @var string
*/
private $_borderStyle;
/**
* Border color
*
* @var PHPExcel_Style_Color
*/
private $_borderColor;
/**
* Parent
*
* @var PHPExcel_Style_Borders
*/
private $_parent;
/**
* Parent Property Name
*
* @var string
*/
private $_parentPropertyName;
/**
* Create a new PHPExcel_Style_Border
*/
public function __construct()
{
// Initialise values
$this->_borderStyle = PHPExcel_Style_Border::BORDER_NONE;
$this->_borderColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
}
/**
* Property Prepare bind
*
* Configures this object for late binding as a property of a parent object
*
* @param $parent
* @param $parentPropertyName
*/
public function propertyPrepareBind($parent, $parentPropertyName)
{
// Initialize parent PHPExcel_Style for late binding. This relationship purposely ends immediately when this object
// is bound to the PHPExcel_Style object pointed to so as to prevent circular references.
$this->_parent = $parent;
$this->_parentPropertyName = $parentPropertyName;
}
/**
* Property Get Bound
*
* Returns the PHPExcel_Style_Border that is actual bound to PHPExcel_Style_Borders
*
* @return PHPExcel_Style_Border
*/
private function propertyGetBound() {
if(!isset($this->_parent))
return $this; // I am bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
{
switch($this->_parentPropertyName) // Another one is bound
{
case "_left":
return $this->_parent->getLeft();
case "_right":
return $this->_parent->getRight();
case "_top":
return $this->_parent->getTop();
case "_bottom":
return $this->_parent->getBottom();
case "_diagonal":
return $this->_parent->getDiagonal();
case "_vertical":
return $this->_parent->getVertical();
case "_horizontal":
return $this->_parent->getHorizontal();
}
}
return $this; // No one is bound yet
}
/**
* Property Begin Bind
*
* If no PHPExcel_Style_Border has been bound to PHPExcel_Style_Borders then bind this one. Return the actual bound one.
*
* @return PHPExcel_Style_Border
*/
private function propertyBeginBind() {
if(!isset($this->_parent))
return $this; // I am already bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
{
switch($this->_parentPropertyName) // Another one is already bound
{
case "_left":
return $this->_parent->getLeft();
case "_right":
return $this->_parent->getRight();
case "_top":
return $this->_parent->getTop();
case "_bottom":
return $this->_parent->getBottom();
case "_diagonal":
return $this->_parent->getDiagonal();
case "_vertical":
return $this->_parent->getVertical();
case "_horizontal":
return $this->_parent->getHorizontal();
}
}
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
$this->_parent = null;
return $this;
}
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray(
* array(
* 'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
* 'color' => array(
* 'rgb' => '808080'
* )
* )
* );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if (array_key_exists('style', $pStyles)) {
$this->setBorderStyle($pStyles['style']);
}
if (array_key_exists('color', $pStyles)) {
$this->getColor()->applyFromArray($pStyles['color']);
}
} else {
throw new Exception("Invalid style array passed.");
}
}
/**
* Get Border style
*
* @return string
*/
public function getBorderStyle() {
return $this->propertyGetBound()->_borderStyle;
}
/**
* Set Border style
*
* @param string $pValue
*/
public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Border::BORDER_NONE;
}
$this->propertyBeginBind()->_borderStyle = $pValue;
}
/**
* Get Border Color
*
* @return PHPExcel_Style_Color
*/
public function getColor() {
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
// So bind as an assurance.
return $this->propertyBeginBind()->_borderColor;
}
/**
* Set Border Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
*/
public function setColor(PHPExcel_Style_Color $pValue = null) {
$this->propertyBeginBind()->_borderColor = $pValue;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
$property = $this->propertyGetBound();
return md5(
$property->_borderStyle
. $property->_borderColor->getHashCode()
. __CLASS__
);
}
/**
* Hash index
*
* @var string
*/
private $_hashIndex;
/**
* Get 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.
*
* @return string Hash index
*/
public function getHashIndex() {
return $this->_hashIndex;
}
/**
* Set 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
*/
public function setHashIndex($value) {
$this->_hashIndex = $value;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@@ -0,0 +1,577 @@
<?php
/**
* PHPExcel
*
* 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
*
* @category PHPExcel
* @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.6, 2009-03-02
*/
/** PHPExcel_Style_Border */
require_once 'PHPExcel/Style/Border.php';
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Borders
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Borders implements PHPExcel_IComparable
{
/* Diagonal directions */
const DIAGONAL_NONE = 0;
const DIAGONAL_UP = 1;
const DIAGONAL_DOWN = 2;
/**
* Left
*
* @var PHPExcel_Style_Border
*/
private $_left;
/**
* Right
*
* @var PHPExcel_Style_Border
*/
private $_right;
/**
* Top
*
* @var PHPExcel_Style_Border
*/
private $_top;
/**
* Bottom
*
* @var PHPExcel_Style_Border
*/
private $_bottom;
/**
* Diagonal
*
* @var PHPExcel_Style_Border
*/
private $_diagonal;
/**
* Vertical
*
* @var PHPExcel_Style_Border
*/
private $_vertical;
/**
* Horizontal
*
* @var PHPExcel_Style_Border
*/
private $_horizontal;
/**
* DiagonalDirection
*
* @var int
*/
private $_diagonalDirection;
/**
* Outline, defaults to true
*
* @var boolean
*/
private $_outline;
/**
* Parent
*
* @var PHPExcel_Style
*/
private $_parent;
/**
* Parent Borders
*
* @var _parentPropertyName string
*/
private $_parentPropertyName;
/**
* Create a new PHPExcel_Style_Borders
*/
public function __construct()
{
// Initialise values
/**
* The following properties are late bound. Binding is initiated by property classes when they are modified.
*
* _left
* _right
* _top
* _bottom
* _diagonal
* _vertical
* _horizontal
*
*/
$this->_diagonalDirection = PHPExcel_Style_Borders::DIAGONAL_NONE;
$this->_outline = true;
}
/**
* Property Prepare bind
*
* Configures this object for late binding as a property of a parent object
*
* @param $parent
* @param $parentPropertyName
*/
public function propertyPrepareBind($parent, $parentPropertyName)
{
// Initialize parent PHPExcel_Style for late binding. This relationship purposely ends immediately when this object
// is bound to the PHPExcel_Style object pointed to so as to prevent circular references.
$this->_parent = $parent;
$this->_parentPropertyName = $parentPropertyName;
}
/**
* Property Get Bound
*
* Returns the PHPExcel_Style_Borders that is actual bound to PHPExcel_Style
*
* @return PHPExcel_Style_Borders
*/
private function propertyGetBound() {
if(!isset($this->_parent))
return $this; // I am bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getBorders(); // Another one is bound
return $this; // No one is bound yet
}
/**
* Property Begin Bind
*
* If no PHPExcel_Style_Borders has been bound to PHPExcel_Style then bind this one. Return the actual bound one.
*
* @return PHPExcel_Style_Borders
*/
private function propertyBeginBind() {
if(!isset($this->_parent))
return $this; // I am already bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getBorders(); // Another one is already bound
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
$this->_parent = null;
return $this;
}
/**
* Property Complete Bind
*
* Complete the binding process a child property object started
*
* @param $propertyObject
* @param $propertyName Name of this property in the parent object
*/
public function propertyCompleteBind($propertyObject, $propertyName) {
switch($propertyName) {
case "_left":
$this->propertyBeginBind()->_left = $propertyObject;
break;
case "_right":
$this->propertyBeginBind()->_right = $propertyObject;
break;
case "_top":
$this->propertyBeginBind()->_top = $propertyObject;
break;
case "_bottom":
$this->propertyBeginBind()->_bottom = $propertyObject;
break;
case "_diagonal":
$this->propertyBeginBind()->_diagonal = $propertyObject;
break;
case "_vertical":
$this->propertyBeginBind()->_vertical = $propertyObject;
break;
case "_horizontal":
$this->propertyBeginBind()->_horizontal = $propertyObject;
break;
default:
throw new Exception("Invalid property passed.");
}
}
/**
* Property Is Bound
*
* Determines if a child property is bound to this one
*
* @param $propertyName Name of this property in the parent object
*
* @return boolean
*/
public function propertyIsBound($propertyName) {
switch($propertyName) {
case "_left":
return isset($this->propertyGetBound()->_left);
case "_right":
return isset($this->propertyGetBound()->_right);
case "_top":
return isset($this->propertyGetBound()->_top);
case "_bottom":
return isset($this->propertyGetBound()->_bottom);
case "_diagonal":
return isset($this->propertyGetBound()->_diagonal);
case "_vertical":
return isset($this->propertyGetBound()->_vertical);
case "_horizontal":
return isset($this->propertyGetBound()->_horizontal);
default:
throw new Exception("Invalid property passed.");
}
}
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray(
* array(
* 'bottom' => array(
* 'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
* 'color' => array(
* 'rgb' => '808080'
* )
* ),
* 'top' => array(
* 'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
* 'color' => array(
* 'rgb' => '808080'
* )
* )
* )
* );
* </code>
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray(
* array(
* 'allborders' => array(
* 'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
* 'color' => array(
* 'rgb' => '808080'
* )
* )
* )
* );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if (array_key_exists('allborders', $pStyles)) {
$this->getLeft()->applyFromArray($pStyles['allborders']);
$this->getRight()->applyFromArray($pStyles['allborders']);
$this->getTop()->applyFromArray($pStyles['allborders']);
$this->getBottom()->applyFromArray($pStyles['allborders']);
}
if (array_key_exists('left', $pStyles)) {
$this->getLeft()->applyFromArray($pStyles['left']);
}
if (array_key_exists('right', $pStyles)) {
$this->getRight()->applyFromArray($pStyles['right']);
}
if (array_key_exists('top', $pStyles)) {
$this->getTop()->applyFromArray($pStyles['top']);
}
if (array_key_exists('bottom', $pStyles)) {
$this->getBottom()->applyFromArray($pStyles['bottom']);
}
if (array_key_exists('diagonal', $pStyles)) {
$this->getDiagonal()->applyFromArray($pStyles['diagonal']);
}
if (array_key_exists('vertical', $pStyles)) {
$this->getVertical()->applyFromArray($pStyles['vertical']);
}
if (array_key_exists('horizontal', $pStyles)) {
$this->getHorizontal()->applyFromArray($pStyles['horizontal']);
}
if (array_key_exists('diagonaldirection', $pStyles)) {
$this->setDiagonalDirection($pStyles['diagonaldirection']);
}
if (array_key_exists('outline', $pStyles)) {
$this->setOutline($pStyles['outline']);
}
} else {
throw new Exception("Invalid style array passed.");
}
}
/**
* Get Left
*
* @return PHPExcel_Style_Border
*/
public function getLeft() {
$property = $this->propertyGetBound();
if(isset($property->_left))
return $property->_left;
$property = new PHPExcel_Style_Border();
$property->propertyPrepareBind($this, "_left");
return $property;
}
/**
* Get Right
*
* @return PHPExcel_Style_Border
*/
public function getRight() {
$property = $this->propertyGetBound();
if(isset($property->_right))
return $property->_right;
$property = new PHPExcel_Style_Border();
$property->propertyPrepareBind($this, "_right");
return $property;
}
/**
* Get Top
*
* @return PHPExcel_Style_Border
*/
public function getTop() {
$property = $this->propertyGetBound();
if(isset($property->_top))
return $property->_top;
$property = new PHPExcel_Style_Border();
$property->propertyPrepareBind($this, "_top");
return $property;
}
/**
* Get Bottom
*
* @return PHPExcel_Style_Border
*/
public function getBottom() {
$property = $this->propertyGetBound();
if(isset($property->_bottom))
return $property->_bottom;
$property = new PHPExcel_Style_Border();
$property->propertyPrepareBind($this, "_bottom");
return $property;
}
/**
* Get Diagonal
*
* @return PHPExcel_Style_Border
*/
public function getDiagonal() {
$property = $this->propertyGetBound();
if(isset($property->_diagonal))
return $property->_diagonal;
$property = new PHPExcel_Style_Border();
$property->propertyPrepareBind($this, "_diagonal");
return $property;
}
/**
* Get Vertical
*
* @return PHPExcel_Style_Border
*/
public function getVertical() {
$property = $this->propertyGetBound();
if(isset($property->_vertical))
return $property->_vertical;
$property = new PHPExcel_Style_Border();
$property->propertyPrepareBind($this, "_vertical");
return $property;
}
/**
* Get Horizontal
*
* @return PHPExcel_Style_Border
*/
public function getHorizontal() {
$property = $this->propertyGetBound();
if(isset($property->_horizontal))
return $property->_horizontal;
$property = new PHPExcel_Style_Border();
$property->propertyPrepareBind($this, "_horizontal");
return $property;
}
/**
* Get DiagonalDirection
*
* @return int
*/
public function getDiagonalDirection() {
return $this->propertyGetBound()->_diagonalDirection;
}
/**
* Set DiagonalDirection
*
* @param int $pValue
*/
public function setDiagonalDirection($pValue = PHPExcel_Style_Borders::DIAGONAL_NONE) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Borders::DIAGONAL_NONE;
}
$this->propertyBeginBind()->_diagonalDirection = $pValue;
}
/**
* Get Outline
*
* @return boolean
*/
public function getOutline() {
return $this->propertyGetBound()->_outline;
}
/**
* Set Outline
*
* @param boolean $pValue
*/
public function setOutline($pValue = true) {
if ($pValue == '') {
$pValue = true;
}
$this->propertyBeginBind()->_outline = $pValue;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
$property = $this->propertyGetBound();
return md5(
$property->getLeft()->getHashCode()
. $property->getRight()->getHashCode()
. $property->getTop()->getHashCode()
. $property->getBottom()->getHashCode()
. $property->getDiagonal()->getHashCode()
. $property->getVertical()->getHashCode()
. $property->getHorizontal()->getHashCode()
. $property->getDiagonalDirection()
. ($property->getOutline() ? 't' : 'f')
. __CLASS__
);
}
/**
* Hash index
*
* @var string
*/
private $_hashIndex;
/**
* Get 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.
*
* @return string Hash index
*/
public function getHashIndex() {
return $this->_hashIndex;
}
/**
* Set 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
*/
public function setHashIndex($value) {
$this->_hashIndex = $value;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@@ -0,0 +1,286 @@
<?php
/**
* PHPExcel
*
* 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
*
* @category PHPExcel
* @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.6, 2009-03-02
*/
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Color
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Color implements PHPExcel_IComparable
{
/* Colors */
const COLOR_BLACK = 'FF000000';
const COLOR_WHITE = 'FFFFFFFF';
const COLOR_RED = 'FFFF0000';
const COLOR_DARKRED = 'FF800000';
const COLOR_BLUE = 'FF0000FF';
const COLOR_DARKBLUE = 'FF000080';
const COLOR_GREEN = 'FF00FF00';
const COLOR_DARKGREEN = 'FF008000';
const COLOR_YELLOW = 'FFFFFF00';
const COLOR_DARKYELLOW = 'FF808000';
/**
* Indexed colors array
*
* @var array
*/
private static $_indexedColors;
/**
* ARGB - Alpha RGB
*
* @var string
*/
private $_argb;
/**
* Create a new PHPExcel_Style_Color
*
* @param string $pARGB
*/
public function __construct($pARGB = PHPExcel_Style_Color::COLOR_BLACK)
{
// Initialise values
$this->_argb = $pARGB;
}
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray( array('rgb' => '808080') );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if (array_key_exists('rgb', $pStyles)) {
$this->setRGB($pStyles['rgb']);
}
if (array_key_exists('argb', $pStyles)) {
$this->setARGB($pStyles['argb']);
}
} else {
throw new Exception("Invalid style array passed.");
}
}
/**
* Get ARGB
*
* @return string
*/
public function getARGB() {
return $this->_argb;
}
/**
* Set ARGB
*
* @param string $pValue
*/
public function setARGB($pValue = PHPExcel_Style_Color::COLOR_BLACK) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Color::COLOR_BLACK;
}
$this->_argb = $pValue;
}
/**
* Get RGB
*
* @return string
*/
public function getRGB() {
return substr($this->_argb, 2);
}
/**
* Set RGB
*
* @param string $pValue
*/
public function setRGB($pValue = '000000') {
if ($pValue == '') {
$pValue = '000000';
}
$this->_argb = 'FF' . $pValue;
}
/**
* Get indexed color
*
* @param int $pIndex
* @return PHPExcel_Style_Color
*/
public static function indexedColor($pIndex) {
// Clean parameter
$pIndex = intval($pIndex);
// Indexed colors
if (is_null(self::$_indexedColors)) {
self::$_indexedColors = array();
self::$_indexedColors[] = '00000000';
self::$_indexedColors[] = '00FFFFFF';
self::$_indexedColors[] = '00FF0000';
self::$_indexedColors[] = '0000FF00';
self::$_indexedColors[] = '000000FF';
self::$_indexedColors[] = '00FFFF00';
self::$_indexedColors[] = '00FF00FF';
self::$_indexedColors[] = '0000FFFF';
self::$_indexedColors[] = '00000000';
self::$_indexedColors[] = '00FFFFFF';
self::$_indexedColors[] = '00FF0000';
self::$_indexedColors[] = '0000FF00';
self::$_indexedColors[] = '000000FF';
self::$_indexedColors[] = '00FFFF00';
self::$_indexedColors[] = '00FF00FF';
self::$_indexedColors[] = '0000FFFF';
self::$_indexedColors[] = '00800000';
self::$_indexedColors[] = '00008000';
self::$_indexedColors[] = '00000080';
self::$_indexedColors[] = '00808000';
self::$_indexedColors[] = '00800080';
self::$_indexedColors[] = '00008080';
self::$_indexedColors[] = '00C0C0C0';
self::$_indexedColors[] = '00808080';
self::$_indexedColors[] = '009999FF';
self::$_indexedColors[] = '00993366';
self::$_indexedColors[] = '00FFFFCC';
self::$_indexedColors[] = '00CCFFFF';
self::$_indexedColors[] = '00660066';
self::$_indexedColors[] = '00FF8080';
self::$_indexedColors[] = '000066CC';
self::$_indexedColors[] = '00CCCCFF';
self::$_indexedColors[] = '00000080';
self::$_indexedColors[] = '00FF00FF';
self::$_indexedColors[] = '00FFFF00';
self::$_indexedColors[] = '0000FFFF';
self::$_indexedColors[] = '00800080';
self::$_indexedColors[] = '00800000';
self::$_indexedColors[] = '00008080';
self::$_indexedColors[] = '000000FF';
self::$_indexedColors[] = '0000CCFF';
self::$_indexedColors[] = '00CCFFFF';
self::$_indexedColors[] = '00CCFFCC';
self::$_indexedColors[] = '00FFFF99';
self::$_indexedColors[] = '0099CCFF';
self::$_indexedColors[] = '00FF99CC';
self::$_indexedColors[] = '00CC99FF';
self::$_indexedColors[] = '00FFCC99';
self::$_indexedColors[] = '003366FF';
self::$_indexedColors[] = '0033CCCC';
self::$_indexedColors[] = '0099CC00';
self::$_indexedColors[] = '00FFCC00';
self::$_indexedColors[] = '00FF9900';
self::$_indexedColors[] = '00FF6600';
self::$_indexedColors[] = '00666699';
self::$_indexedColors[] = '00969696';
self::$_indexedColors[] = '00003366';
self::$_indexedColors[] = '00339966';
self::$_indexedColors[] = '00003300';
self::$_indexedColors[] = '00333300';
self::$_indexedColors[] = '00993300';
self::$_indexedColors[] = '00993366';
self::$_indexedColors[] = '00333399';
self::$_indexedColors[] = '00333333';
}
if (array_key_exists($pIndex, self::$_indexedColors)) {
return new PHPExcel_Style_Color(self::$_indexedColors[$pIndex]);
}
return new PHPExcel_Style_Color();
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
return md5(
$this->_argb
. __CLASS__
);
}
/**
* Hash index
*
* @var string
*/
private $_hashIndex;
/**
* Get 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.
*
* @return string Hash index
*/
public function getHashIndex() {
return $this->_hashIndex;
}
/**
* Set 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
*/
public function setHashIndex($value) {
$this->_hashIndex = $value;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@@ -0,0 +1,302 @@
<?php
/**
* PHPExcel
*
* 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
*
* @category PHPExcel
* @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.6, 2009-03-02
*/
/** PHPExcel_Style */
require_once 'PHPExcel/Style.php';
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Conditional
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Conditional implements PHPExcel_IComparable
{
/* Condition types */
const CONDITION_NONE = 'none';
const CONDITION_CELLIS = 'cellIs';
const CONDITION_CONTAINSTEXT = 'containsText';
const CONDITION_EXPRESSION = 'expression';
/* Operator types */
const OPERATOR_NONE = '';
const OPERATOR_BEGINSWITH = 'beginsWith';
const OPERATOR_ENDSWITH = 'endsWith';
const OPERATOR_EQUAL = 'equal';
const OPERATOR_GREATERTHAN = 'greaterThan';
const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
const OPERATOR_LESSTHAN = 'lessThan';
const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
const OPERATOR_NOTEQUAL = 'notEqual';
const OPERATOR_CONTAINSTEXT = 'containsText';
const OPERATOR_NOTCONTAINS = 'notContains';
const OPERATOR_BETWEEN = 'between';
/**
* Condition type
*
* @var int
*/
private $_conditionType;
/**
* Operator type
*
* @var int
*/
private $_operatorType;
/**
* Text
*
* @var string
*/
private $_text;
/**
* Condition
*
* @var string[]
*/
private $_condition = array();
/**
* Style
*
* @var PHPExcel_Style
*/
private $_style;
/**
* Create a new PHPExcel_Style_Conditional
*/
public function __construct()
{
// Initialise values
$this->_conditionType = PHPExcel_Style_Conditional::CONDITION_NONE;
$this->_operatorType = PHPExcel_Style_Conditional::OPERATOR_NONE;
$this->_text = null;
$this->_condition = array();
$this->_style = new PHPExcel_Style();
}
/**
* Get Condition type
*
* @return string
*/
public function getConditionType() {
return $this->_conditionType;
}
/**
* Set Condition type
*
* @param string $pValue PHPExcel_Style_Conditional condition type
*/
public function setConditionType($pValue = PHPExcel_Style_Conditional::CONDITION_NONE) {
$this->_conditionType = $pValue;
}
/**
* Get Operator type
*
* @return string
*/
public function getOperatorType() {
return $this->_operatorType;
}
/**
* Set Operator type
*
* @param string $pValue PHPExcel_Style_Conditional operator type
*/
public function setOperatorType($pValue = PHPExcel_Style_Conditional::OPERATOR_NONE) {
$this->_operatorType = $pValue;
}
/**
* Get text
*
* @return string
*/
public function getText() {
return $this->_text;
}
/**
* Set text
*
* @param string $value
*/
public function setText($value = null) {
$this->_text = $value;
}
/**
* Get Condition
*
* @deprecated Deprecated, use getConditions instead
* @return string
*/
public function getCondition() {
if (isset($this->_condition[0])) {
return $this->_condition[0];
}
return '';
}
/**
* Set Condition
*
* @deprecated Deprecated, use setConditions instead
* @param string $pValue Condition
*/
public function setCondition($pValue = '') {
if (!is_array($pValue))
$pValue = array($pValue);
$this->setConditions($pValue);
}
/**
* Get Conditions
*
* @return string[]
*/
public function getConditions() {
return $this->_condition;
}
/**
* Set Conditions
*
* @param string[] $pValue Condition
*/
public function setConditions($pValue) {
if (!is_array($pValue))
$pValue = array($pValue);
$this->_condition = $pValue;
}
/**
* Add Condition
*
* @param string $pValue Condition
*/
public function addCondition($pValue = '') {
$this->_condition[] = $pValue;
}
/**
* Get Style
*
* @return PHPExcel_Style
*/
public function getStyle() {
return $this->_style;
}
/**
* Set Style
*
* @param PHPExcel_Style $pValue
* @throws Exception
*/
public function setStyle(PHPExcel_Style $pValue = null) {
$this->_style = $pValue;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
return md5(
$this->_conditionType
. $this->_operatorType
. implode(';', $this->_condition)
. $this->_style->getHashCode()
. __CLASS__
);
}
/**
* Hash index
*
* @var string
*/
private $_hashIndex;
/**
* Get 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.
*
* @return string Hash index
*/
public function getHashIndex() {
return $this->_hashIndex;
}
/**
* Set 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
*/
public function setHashIndex($value) {
$this->_hashIndex = $value;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@@ -0,0 +1,362 @@
<?php
/**
* PHPExcel
*
* 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
*
* @category PHPExcel
* @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.6, 2009-03-02
*/
/** PHPExcel_Style_Color */
require_once 'PHPExcel/Style/Color.php';
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Fill
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Fill implements PHPExcel_IComparable
{
/* Fill types */
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';
/**
* Fill type
*
* @var string
*/
private $_fillType;
/**
* Rotation
*
* @var double
*/
private $_rotation;
/**
* Start color
*
* @var PHPExcel_Style_Color
*/
private $_startColor;
/**
* End color
*
* @var PHPExcel_Style_Color
*/
private $_endColor;
/**
* Parent Style
*
* @var PHPExcel_Style
*/
private $_parent;
/**
* Parent Borders
*
* @var _parentPropertyName string
*/
private $_parentPropertyName;
/**
* Create a new PHPExcel_Style_Fill
*/
public function __construct()
{
// Initialise values
$this->_fillType = PHPExcel_Style_Fill::FILL_NONE;
$this->_rotation = 0;
$this->_startColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_WHITE);
$this->_endColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
}
/**
* Property Prepare bind
*
* Configures this object for late binding as a property of a parent object
*
* @param $parent
* @param $parentPropertyName
*/
public function propertyPrepareBind($parent, $parentPropertyName)
{
// Initialize parent PHPExcel_Style for late binding. This relationship purposely ends immediately when this object
// is bound to the PHPExcel_Style object pointed to so as to prevent circular references.
$this->_parent = $parent;
$this->_parentPropertyName = $parentPropertyName;
}
/**
* Property Get Bound
*
* Returns the PHPExcel_Style_Fill that is actual bound to PHPExcel_Style
*
* @return PHPExcel_Style_Fill
*/
private function propertyGetBound() {
if(!isset($this->_parent))
return $this; // I am bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getFill(); // Another one is bound
return $this; // No one is bound yet
}
/**
* Property Begin Bind
*
* If no PHPExcel_Style_Fill has been bound to PHPExcel_Style then bind this one. Return the actual bound one.
*
* @return PHPExcel_Style_Fill
*/
private function propertyBeginBind() {
if(!isset($this->_parent))
return $this; // I am already bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getFill(); // Another one is already bound
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
$this->_parent = null;
return $this;
}
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFill()->applyFromArray(
* array(
* 'type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
* 'rotation' => 0,
* 'startcolor' => array(
* 'rgb' => '000000'
* ),
* 'endcolor' => array(
* 'argb' => 'FFFFFFFF'
* )
* )
* );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if (array_key_exists('type', $pStyles)) {
$this->setFillType($pStyles['type']);
}
if (array_key_exists('rotation', $pStyles)) {
$this->setRotation($pStyles['rotation']);
}
if (array_key_exists('startcolor', $pStyles)) {
$this->getStartColor()->applyFromArray($pStyles['startcolor']);
}
if (array_key_exists('endcolor', $pStyles)) {
$this->getEndColor()->applyFromArray($pStyles['endcolor']);
}
if (array_key_exists('color', $pStyles)) {
$this->getStartColor()->applyFromArray($pStyles['color']);
}
} else {
throw new Exception("Invalid style array passed.");
}
}
/**
* Get Fill Type
*
* @return string
*/
public function getFillType() {
$property = $this->propertyGetBound();
if ($property->_fillType == '') {
$property->_fillType = self::FILL_NONE;
}
return $property->_fillType;
}
/**
* Set Fill Type
*
* @param string $pValue PHPExcel_Style_Fill fill type
*/
public function setFillType($pValue = PHPExcel_Style_Fill::FILL_NONE) {
$this->propertyBeginBind()->_fillType = $pValue;
}
/**
* Get Rotation
*
* @return double
*/
public function getRotation() {
return $this->propertyGetBound()->_rotation;
}
/**
* Set Rotation
*
* @param double $pValue
*/
public function setRotation($pValue = 0) {
$this->propertyBeginBind()->_rotation = $pValue;
}
/**
* Get Start Color
*
* @return PHPExcel_Style_Color
*/
public function getStartColor() {
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
// So bind as an assurance.
return $this->propertyBeginBind()->_startColor;
}
/**
* Set Start Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
*/
public function setStartColor(PHPExcel_Style_Color $pValue = null) {
$this->propertyBeginBind()->_startColor = $pValue;
}
/**
* Get End Color
*
* @return PHPExcel_Style_Color
*/
public function getEndColor() {
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
// So bind as an assurance.
return $this->propertyBeginBind()->_endColor;
}
/**
* Set End Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
*/
public function setEndColor(PHPExcel_Style_Color $pValue = null) {
$this->propertyBeginBind()->_endColor = $pValue;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
$property = $this->propertyGetBound();
return md5(
$property->getFillType()
. $property->getRotation()
. $property->getStartColor()->getHashCode()
. $property->getEndColor()->getHashCode()
. __CLASS__
);
}
/**
* Hash index
*
* @var string
*/
private $_hashIndex;
/**
* Get 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.
*
* @return string Hash index
*/
public function getHashIndex() {
return $this->_hashIndex;
}
/**
* Set 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
*/
public function setHashIndex($value) {
$this->_hashIndex = $value;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@@ -0,0 +1,504 @@
<?php
/**
* PHPExcel
*
* 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
*
* @category PHPExcel
* @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.6, 2009-03-02
*/
/** PHPExcel_Style_Color */
require_once 'PHPExcel/Style/Color.php';
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Font
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Font implements PHPExcel_IComparable
{
/* Underline types */
const UNDERLINE_NONE = 'none';
const UNDERLINE_DOUBLE = 'double';
const UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting';
const UNDERLINE_SINGLE = 'single';
const UNDERLINE_SINGLEACCOUNTING = 'singleAccounting';
/**
* Name
*
* @var string
*/
private $_name;
/**
* Bold
*
* @var boolean
*/
private $_bold;
/**
* Italic
*
* @var boolean
*/
private $_italic;
/**
* Superscript
*
* @var boolean
*/
private $_superScript;
/**
* Subscript
*
* @var boolean
*/
private $_subScript;
/**
* Underline
*
* @var string
*/
private $_underline;
/**
* Striketrough
*
* @var boolean
*/
private $_striketrough;
/**
* Foreground color
*
* @var PHPExcel_Style_Color
*/
private $_color;
/**
* Parent Style
*
* @var PHPExcel_Style
*/
private $_parent;
/**
* Parent Borders
*
* @var _parentPropertyName string
*/
private $_parentPropertyName;
/**
* Create a new PHPExcel_Style_Font
*/
public function __construct()
{
// Initialise values
$this->_name = 'Calibri';
$this->_size = 10;
$this->_bold = false;
$this->_italic = false;
$this->_superScript = false;
$this->_subScript = false;
$this->_underline = PHPExcel_Style_Font::UNDERLINE_NONE;
$this->_striketrough = false;
$this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
}
/**
* Property Prepare bind
*
* Configures this object for late binding as a property of a parent object
*
* @param $parent
* @param $parentPropertyName
*/
public function propertyPrepareBind($parent, $parentPropertyName)
{
// Initialize parent PHPExcel_Style for late binding. This relationship purposely ends immediately when this object
// is bound to the PHPExcel_Style object pointed to so as to prevent circular references.
$this->_parent = $parent;
$this->_parentPropertyName = $parentPropertyName;
}
/**
* Property Get Bound
*
* Returns the PHPExcel_Style_Font that is actual bound to PHPExcel_Style
*
* @return PHPExcel_Style_Font
*/
private function propertyGetBound() {
if(!isset($this->_parent))
return $this; // I am bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getFont(); // Another one is bound
return $this; // No one is bound yet
}
/**
* Property Begin Bind
*
* If no PHPExcel_Style_Font has been bound to PHPExcel_Style then bind this one. Return the actual bound one.
*
* @return PHPExcel_Style_Font
*/
private function propertyBeginBind() {
if(!isset($this->_parent))
return $this; // I am already bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getFont(); // Another one is already bound
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
$this->_parent = null;
return $this;
}
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray(
* array(
* 'name' => 'Arial',
* 'bold' => true,
* 'italic' => false,
* 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE,
* 'strike' => false,
* 'color' => array(
* 'rgb' => '808080'
* )
* )
* );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if (array_key_exists('name', $pStyles)) {
$this->setName($pStyles['name']);
}
if (array_key_exists('bold', $pStyles)) {
$this->setBold($pStyles['bold']);
}
if (array_key_exists('italic', $pStyles)) {
$this->setItalic($pStyles['italic']);
}
if (array_key_exists('superScript', $pStyles)) {
$this->setSuperScript($pStyles['superScript']);
}
if (array_key_exists('subScript', $pStyles)) {
$this->setSubScript($pStyles['subScript']);
}
if (array_key_exists('underline', $pStyles)) {
$this->setUnderline($pStyles['underline']);
}
if (array_key_exists('strike', $pStyles)) {
$this->setStriketrough($pStyles['strike']);
}
if (array_key_exists('color', $pStyles)) {
$this->getColor()->applyFromArray($pStyles['color']);
}
if (array_key_exists('size', $pStyles)) {
$this->setSize($pStyles['size']);
}
} else {
throw new Exception("Invalid style array passed.");
}
}
/**
* Get Name
*
* @return string
*/
public function getName() {
return $this->propertyGetBound()->_name;
}
/**
* Set Name
*
* @param string $pValue
*/
public function setName($pValue = 'Calibri') {
if ($pValue == '') {
$pValue = 'Calibri';
}
$this->propertyBeginBind()->_name = $pValue;
}
/**
* Get Size
*
* @return double
*/
public function getSize() {
return $this->propertyGetBound()->_size;
}
/**
* Set Size
*
* @param double $pValue
*/
public function setSize($pValue = 10) {
if ($pValue == '') {
$pValue = 10;
}
$this->propertyBeginBind()->_size = $pValue;
}
/**
* Get Bold
*
* @return boolean
*/
public function getBold() {
return $this->propertyGetBound()->_bold;
}
/**
* Set Bold
*
* @param boolean $pValue
*/
public function setBold($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
$this->propertyBeginBind()->_bold = $pValue;
}
/**
* Get Italic
*
* @return boolean
*/
public function getItalic() {
return $this->propertyGetBound()->_italic;
}
/**
* Set Italic
*
* @param boolean $pValue
*/
public function setItalic($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
$this->propertyBeginBind()->_italic = $pValue;
}
/**
* Get SuperScript
*
* @return boolean
*/
public function getSuperScript() {
return $this->propertyGetBound()->_superScript;
}
/**
* Set SuperScript
*
* @param boolean $pValue
*/
public function setSuperScript($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
$this->propertyBeginBind()->_superScript = $pValue;
$this->propertyBeginBind()->_subScript = !$pValue;
}
/**
* Get SubScript
*
* @return boolean
*/
public function getSubScript() {
return $this->propertyGetBound()->_subScript;
}
/**
* Set SubScript
*
* @param boolean $pValue
*/
public function setSubScript($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
$this->propertyBeginBind()->_subScript = $pValue;
$this->propertyBeginBind()->_superScript = !$pValue;
}
/**
* Get Underline
*
* @return string
*/
public function getUnderline() {
return $this->propertyGetBound()->_underline;
}
/**
* Set Underline
*
* @param string $pValue PHPExcel_Style_Font underline type
*/
public function setUnderline($pValue = PHPExcel_Style_Font::UNDERLINE_NONE) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Font::UNDERLINE_NONE;
}
$this->propertyBeginBind()->_underline = $pValue;
}
/**
* Get Striketrough
*
* @return boolean
*/
public function getStriketrough() {
return $this->propertyGetBound()->_striketrough;
}
/**
* Set Striketrough
*
* @param boolean $pValue
*/
public function setStriketrough($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
$this->propertyBeginBind()->_striketrough = $pValue;
}
/**
* Get Color
*
* @return PHPExcel_Style_Color
*/
public function getColor() {
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
// So bind as an assurance.
return $this->propertyBeginBind()->_color;
}
/**
* Set Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
*/
public function setColor(PHPExcel_Style_Color $pValue = null) {
$this->propertyBeginBind()->_color = $pValue;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
$property = $this->propertyGetBound();
return md5(
$property->_name
. $property->_size
. ($property->_bold ? 't' : 'f')
. ($property->_italic ? 't' : 'f')
. ($property->_superScript ? 't' : 'f')
. ($property->_subScript ? 't' : 'f')
. $property->_underline
. ($property->_striketrough ? 't' : 'f')
. $property->_color->getHashCode()
. __CLASS__
);
}
/**
* Hash index
*
* @var string
*/
private $_hashIndex;
/**
* Get 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.
*
* @return string Hash index
*/
public function getHashIndex() {
return $this->_hashIndex;
}
/**
* Set 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
*/
public function setHashIndex($value) {
$this->_hashIndex = $value;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@@ -0,0 +1,468 @@
<?php
/**
* PHPExcel
*
* 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
*
* @category PHPExcel
* @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.6, 2009-03-02
*/
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
/** PHPExcel_Shared_Date */
require_once 'PHPExcel/Shared/Date.php';
/**
* PHPExcel_Style_NumberFormat
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
{
/* Pre-defined formats */
const FORMAT_GENERAL = 'General';
const FORMAT_TEXT = '@';
const FORMAT_NUMBER = '0';
const FORMAT_NUMBER_00 = '0.00';
const FORMAT_NUMBER_COMMA_SEPARATED1 = '#,##0.00';
const FORMAT_NUMBER_COMMA_SEPARATED2 = '#,##0.00_-';
const FORMAT_PERCENTAGE = '0%';
const FORMAT_PERCENTAGE_00 = '0.00%';
const FORMAT_DATE_YYYYMMDD2 = 'yyyy-mm-dd';
const FORMAT_DATE_YYYYMMDD = 'yy-mm-dd';
const FORMAT_DATE_DDMMYYYY = 'dd/mm/yy';
const FORMAT_DATE_DMYSLASH = 'd/m/y';
const FORMAT_DATE_DMYMINUS = 'd-m-y';
const FORMAT_DATE_DMMINUS = 'd-m';
const FORMAT_DATE_MYMINUS = 'm-y';
const FORMAT_DATE_XLSX14 = 'mm-dd-yy';
const FORMAT_DATE_XLSX15 = 'd-mmm-yy';
const FORMAT_DATE_XLSX16 = 'd-mmm';
const FORMAT_DATE_XLSX17 = 'mmm-yy';
const FORMAT_DATE_XLSX22 = 'm/d/yy h:mm';
const FORMAT_DATE_DATETIME = 'd/m/y h:mm';
const FORMAT_DATE_TIME1 = 'h:mm AM/PM';
const FORMAT_DATE_TIME2 = 'h:mm:ss AM/PM';
const FORMAT_DATE_TIME3 = 'h:mm';
const FORMAT_DATE_TIME4 = 'h:mm:ss';
const FORMAT_DATE_TIME5 = 'mm:ss';
const FORMAT_DATE_TIME6 = 'h:mm:ss';
const FORMAT_DATE_TIME7 = 'i:s.S';
const FORMAT_DATE_TIME8 = 'h:mm:ss;@';
const FORMAT_DATE_YYYYMMDDSLASH = 'yy/mm/dd;@';
const FORMAT_CURRENCY_USD_SIMPLE = '"$"#,##0.00_-';
const FORMAT_CURRENCY_USD = '$#,##0_-';
const FORMAT_CURRENCY_EUR_SIMPLE = '[$EUR ]#,##0.00_-';
/**
* Excel built-in number formats
*
* @var array
*/
private static $_builtInFormats;
/**
* Format Code
*
* @var string
*/
private $_formatCode;
/**
* Parent Style
*
* @var PHPExcel_Style
*/
private $_parent;
/**
* Parent Borders
*
* @var _parentPropertyName string
*/
private $_parentPropertyName;
/**
* Create a new PHPExcel_Style_NumberFormat
*/
public function __construct()
{
// Initialise values
$this->_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
}
/**
* Property Prepare bind
*
* Configures this object for late binding as a property of a parent object
*
* @param $parent
* @param $parentPropertyName
*/
public function propertyPrepareBind($parent, $parentPropertyName)
{
// Initialize parent PHPExcel_Style for late binding. This relationship purposely ends immediately when this object
// is bound to the PHPExcel_Style object pointed to so as to prevent circular references.
$this->_parent = $parent;
$this->_parentPropertyName = $parentPropertyName;
}
/**
* Property Get Bound
*
* Returns the PHPExcel_Style_NumberFormat that is actual bound to PHPExcel_Style
*
* @return PHPExcel_Style_NumberFormat
*/
private function propertyGetBound() {
if(!isset($this->_parent))
return $this; // I am bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getNumberFormat(); // Another one is bound
return $this; // No one is bound yet
}
/**
* Property Begin Bind
*
* If no PHPExcel_Style_NumberFormat has been bound to PHPExcel_Style then bind this one. Return the actual bound one.
*
* @return PHPExcel_Style_NumberFormat
*/
private function propertyBeginBind() {
if(!isset($this->_parent))
return $this; // I am already bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getNumberFormat(); // Another one is already bound
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
$this->_parent = null;
return $this;
}
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray(
* array(
* 'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
* )
* );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if (array_key_exists('code', $pStyles)) {
$this->setFormatCode($pStyles['code']);
}
} else {
throw new Exception("Invalid style array passed.");
}
}
/**
* Get Format Code
*
* @return string
*/
public function getFormatCode() {
return $this->propertyGetBound()->_formatCode;
}
/**
* Set Format Code
*
* @param string $pValue
*/
public function setFormatCode($pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL) {
if ($pValue == '') {
$pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
}
$this->propertyBeginBind()->_formatCode = $pValue;
}
/**
* Get built-in format code
*
* @param int $pIndex
* @return string
*/
public static function builtInFormatCode($pIndex) {
// Clean parameter
$pIndex = intval($pIndex);
// Built-in format codes
if (is_null(self::$_builtInFormats)) {
self::$_builtInFormats = array();
// General
self::$_builtInFormats[0] = 'General';
self::$_builtInFormats[1] = '0';
self::$_builtInFormats[2] = '0.00';
self::$_builtInFormats[3] = '#,##0';
self::$_builtInFormats[4] = '#,##0.00';
self::$_builtInFormats[9] = '0%';
self::$_builtInFormats[10] = '0.00%';
self::$_builtInFormats[11] = '0.00E+00';
self::$_builtInFormats[12] = '# ?/?';
self::$_builtInFormats[13] = '# ??/??';
self::$_builtInFormats[14] = 'mm-dd-yy';
self::$_builtInFormats[15] = 'd-mmm-yy';
self::$_builtInFormats[16] = 'd-mmm';
self::$_builtInFormats[17] = 'mmm-yy';
self::$_builtInFormats[18] = 'h:mm AM/PM';
self::$_builtInFormats[19] = 'h:mm:ss AM/PM';
self::$_builtInFormats[20] = 'h:mm';
self::$_builtInFormats[21] = 'h:mm:ss';
self::$_builtInFormats[22] = 'm/d/yy h:mm';
self::$_builtInFormats[37] = '#,##0 ;(#,##0)';
self::$_builtInFormats[38] = '#,##0 ;[Red](#,##0)';
self::$_builtInFormats[39] = '#,##0.00;(#,##0.00)';
self::$_builtInFormats[40] = '#,##0.00;[Red](#,##0.00)';
self::$_builtInFormats[45] = 'mm:ss';
self::$_builtInFormats[46] = '[h]:mm:ss';
self::$_builtInFormats[47] = 'mmss.0';
self::$_builtInFormats[48] = '##0.0E+0';
self::$_builtInFormats[49] = '@';
// CHT
self::$_builtInFormats[27] = '[$-404]e/m/d';
self::$_builtInFormats[30] = 'm/d/yy';
self::$_builtInFormats[36] = '[$-404]e/m/d';
self::$_builtInFormats[50] = '[$-404]e/m/d';
self::$_builtInFormats[57] = '[$-404]e/m/d';
// THA
self::$_builtInFormats[59] = 't0';
self::$_builtInFormats[60] = 't0.00';
self::$_builtInFormats[61] = 't#,##0';
self::$_builtInFormats[62] = 't#,##0.00';
self::$_builtInFormats[67] = 't0%';
self::$_builtInFormats[68] = 't0.00%';
self::$_builtInFormats[69] = 't# ?/?';
self::$_builtInFormats[70] = 't# ??/??';
}
if (array_key_exists($pIndex, self::$_builtInFormats)) {
return self::$_builtInFormats[$pIndex];
}
return '';
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
$property = $this->propertyGetBound();
return md5(
$property->_formatCode
. __CLASS__
);
}
/**
* Hash index
*
* @var string
*/
private $_hashIndex;
/**
* Get 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.
*
* @return string Hash index
*/
public function getHashIndex() {
return $this->_hashIndex;
}
/**
* Set 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
*/
public function setHashIndex($value) {
$this->_hashIndex = $value;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Convert a value in a pre-defined format to a PHP string
*
* @param mixed $value Value to format
* @param string $format Format code
* @return string Formatted string
*/
public static function toFormattedString($value = '', $format = '') {
if (!is_numeric($value)) return $value;
if (preg_match("/^[hmsdy]/i", $format)) { // custom datetime format
// dvc: convert Excel formats to PHP date formats
// first remove escapes related to non-format characters
// OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case
$format = strtolower($format);
$format = str_replace('\\', '', $format);
// 4-digit year
$format = str_replace('yyyy', 'Y', $format);
// 2-digit year
$format = str_replace('yy', 'y', $format);
// first letter of month - no php equivalent
$format = str_replace('mmmmm', 'M', $format);
// full month name
$format = str_replace('mmmm', 'F', $format);
// short month name
$format = str_replace('mmm', 'M', $format);
// mm is minutes if time or month w/leading zero
$format = str_replace(':mm', ':i', $format);
// tmp place holder
$format = str_replace('mm', 'x', $format);
// month no leading zero
$format = str_replace('m', 'n', $format);
// month leading zero
$format = str_replace('x', 'm', $format);
// 12-hour suffix
$format = str_replace('am/pm', 'A', $format);
// tmp place holder
$format = str_replace('dd', 'x', $format);
// days no leading zero
$format = str_replace('d', 'j', $format);
// days leading zero
$format = str_replace('x', 'd', $format);
// seconds
$format = str_replace('ss', 's', $format);
// fractional seconds - no php equivalent
$format = str_replace('.s', '', $format);
if (!strpos($format,'A')) { // 24-hour format
$format = str_replace('h', 'H', $format);
}
// user defined flag symbol????
$format = str_replace(';@', '', $format);
if (is_float($value)) {
return date($format, PHPExcel_Shared_Date::ExceltoPHP($value));
}
return date($format, $value);
} else if (preg_match('/%$/', $format)) { // % number format
if (preg_match('/\.[#0]+/i',$format,$m)) {
$s = substr($m[0],0,1).(strlen($m[0])-1);
$format = str_replace($m[0],$s,$format);
}
if (preg_match('/^[#0]+/',$format,$m)) {
$format = str_replace($m[0],strlen($m[0]),$format);
}
$format = '%' . str_replace('%',"f%%",$format);
return sprintf($format, $value);
} else {
if (preg_match ("/^([0-9.,-]+)$/", $value)) {
if ($format === self::FORMAT_NUMBER)
return sprintf('%1.0f', $value);
else if ($format === self::FORMAT_NUMBER_00)
return sprintf('%1.2f', $value);
else if ($format === self::FORMAT_NUMBER_COMMA_SEPARATED1 || $format === self::FORMAT_NUMBER_COMMA_SEPARATED2)
return number_format($value, 2, ',', '.');
else if ($format === self::FORMAT_PERCENTAGE)
return round( (100 * $value), 0) . '%';
else if ($format === self::FORMAT_PERCENTAGE_00)
return round( (100 * $value), 2) . '%';
else if ($format === self::FORMAT_DATE_YYYYMMDD || $format === self::FORMAT_DATE_YYYYMMDD2)
return date('Y-m-d', (1 * $value));
else if ($format === self::FORMAT_DATE_DDMMYYYY)
return date('d/m/Y', (1 * $value));
else if ($format === 'yyyy/mm/dd;@')
return date('Y/m/d', (1 * $value));
else if ($format === self::FORMAT_CURRENCY_USD_SIMPLE)
return '$' . number_format($value, 2);
else if ($format === self::FORMAT_CURRENCY_USD)
return '$' . number_format($value);
else if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE)
return 'EUR ' . sprintf('%1.2f', $value);
}
return $value;
}
}
}

View File

@@ -0,0 +1,256 @@
<?php
/**
* PHPExcel
*
* 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
*
* @category PHPExcel
* @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.4.5, 2007-08-23
*/
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Protection
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Protection implements PHPExcel_IComparable
{
/** Protection styles */
const PROTECTION_INHERIT = 'inherit';
const PROTECTION_PROTECTED = 'protected';
const PROTECTION_UNPROTECTED = 'unprotected';
/**
* Locked
*
* @var string
*/
private $_locked;
/**
* Hidden
*
* @var string
*/
private $_hidden;
/**
* Parent Style
*
* @var PHPExcel_Style
*/
private $_parent;
/**
* Parent Borders
*
* @var _parentPropertyName string
*/
private $_parentPropertyName;
/**
* Create a new PHPExcel_Style_Protection
*/
public function __construct()
{
// Initialise values
$this->_locked = self::PROTECTION_INHERIT;
$this->_hidden = self::PROTECTION_INHERIT;
}
/**
* Property Prepare bind
*
* Configures this object for late binding as a property of a parent object
*
* @param $parent
* @param $parentPropertyName
*/
public function propertyPrepareBind($parent, $parentPropertyName)
{
// Initialize parent PHPExcel_Style for late binding. This relationship purposely ends immediately when this object
// is bound to the PHPExcel_Style object pointed to so as to prevent circular references.
$this->_parent = $parent;
$this->_parentPropertyName = $parentPropertyName;
}
/**
* Property Get Bound
*
* Returns the PHPExcel_Style_Protection that is actual bound to PHPExcel_Style
*
* @return PHPExcel_Style_Protection
*/
private function propertyGetBound() {
if(!isset($this->_parent))
return $this; // I am bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getProtection(); // Another one is bound
return $this; // No one is bound yet
}
/**
* Property Begin Bind
*
* If no PHPExcel_Style_Protection has been bound to PHPExcel_Style then bind this one. Return the actual bound one.
*
* @return PHPExcel_Style_Protection
*/
private function propertyBeginBind() {
if(!isset($this->_parent))
return $this; // I am already bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getProtection(); // Another one is already bound
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
$this->_parent = null;
return $this;
}
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray( array('locked' => true, 'hidden' => false) );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if (array_key_exists('locked', $pStyles)) {
$this->setLocked($pStyles['locked']);
}
if (array_key_exists('hidden', $pStyles)) {
$this->setHidden($pStyles['hidden']);
}
} else {
throw new Exception("Invalid style array passed.");
}
}
/**
* Get locked
*
* @return string
*/
public function getLocked() {
return $this->propertyGetBound()->_locked;
}
/**
* Set locked
*
* @param string $pValue
*/
public function setLocked($pValue = self::PROTECTION_INHERIT) {
$this->propertyBeginBind()->_locked = $pValue;
}
/**
* Get hidden
*
* @return string
*/
public function getHidden() {
return $this->propertyGetBound()->_hidden;
}
/**
* Set hidden
*
* @param string $pValue
*/
public function setHidden($pValue = self::PROTECTION_INHERIT) {
$this->propertyBeginBind()->_hidden = $pValue;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
$property = $this->propertyGetBound();
return md5(
$property->_locked
. $property->_hidden
. __CLASS__
);
}
/**
* Hash index
*
* @var string
*/
private $_hashIndex;
/**
* Get 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.
*
* @return string Hash index
*/
public function getHashIndex() {
return $this->_hashIndex;
}
/**
* Set 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
*/
public function setHashIndex($value) {
$this->_hashIndex = $value;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}