General performance improvements, and specific improvements in the CSV Reader

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@65064 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2010-12-09 12:07:50 +00:00
parent 500a8e763e
commit 1fad8bd2dd
23 changed files with 800 additions and 902 deletions

View File

@ -49,7 +49,7 @@ class PHPExcel_DocumentProperties
*
* @var string
*/
private $_creator;
private $_creator = 'Unknown Creator';
/**
* LastModifiedBy
@ -77,42 +77,49 @@ class PHPExcel_DocumentProperties
*
* @var string
*/
private $_title;
private $_title = 'Untitled Spreadsheet';
/**
* Description
*
* @var string
*/
private $_description;
private $_description = '';
/**
* Subject
*
* @var string
*/
private $_subject;
private $_subject = '';
/**
* Keywords
*
* @var string
*/
private $_keywords;
private $_keywords = '';
/**
* Category
*
* @var string
*/
private $_category;
private $_category = '';
/**
* Manager
*
* @var string
*/
private $_manager = '';
/**
* Company
*
* @var string
*/
private $_company;
private $_company = 'Microsoft Corporation';
/**
* Custom Properties
@ -128,17 +135,9 @@ class PHPExcel_DocumentProperties
public function __construct()
{
// Initialise values
$this->_creator = 'Unknown Creator';
$this->_lastModifiedBy = $this->_creator;
$this->_created = time();
$this->_modified = time();
$this->_title = "Untitled Spreadsheet";
$this->_subject = '';
$this->_description = '';
$this->_keywords = '';
$this->_category = '';
$this->_manager = '';
$this->_company = 'Microsoft Corporation';
$this->_modified = time();
}
/**

View File

@ -50,7 +50,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @access private
* @var string
*/
private $_inputEncoding;
private $_inputEncoding = 'UTF-8';
/**
* Delimiter
@ -58,7 +58,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @access private
* @var string
*/
private $_delimiter;
private $_delimiter = ',';
/**
* Enclosure
@ -66,7 +66,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @access private
* @var string
*/
private $_enclosure;
private $_enclosure = '"';
/**
* Line ending
@ -74,7 +74,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @access private
* @var string
*/
private $_lineEnding;
private $_lineEnding = PHP_EOL;
/**
* Sheet index to read
@ -82,7 +82,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @access private
* @var int
*/
private $_sheetIndex;
private $_sheetIndex = 0;
/**
* Load rows contiguously
@ -90,7 +90,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @access private
* @var int
*/
private $_contiguous;
private $_contiguous = false;
/**
@ -99,7 +99,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @access private
* @var int
*/
private $_contiguousRow;
private $_contiguousRow = -1;
/**
* PHPExcel_Reader_IReadFilter instance
@ -113,14 +113,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* Create a new PHPExcel_Reader_CSV
*/
public function __construct() {
$this->_inputEncoding = 'UTF-8';
$this->_delimiter = ',';
$this->_enclosure = '"';
$this->_lineEnding = PHP_EOL;
$this->_sheetIndex = 0;
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->_contiguous = false;
$this->_contiguousRow = -1;
} // function __construct()
/**
@ -236,6 +229,22 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($fileHandle, 3) : fseek($fileHandle, 0);
break;
case 'UTF-16LE':
fgets($fileHandle, 3) == "\xFF\xFE" ?
fseek($fileHandle, 2) : fseek($fileHandle, 0);
break;
case 'UTF-16BE':
fgets($fileHandle, 3) == "\xFE\xFF" ?
fseek($fileHandle, 2) : fseek($fileHandle, 0);
break;
case 'UTF-32LE':
fgets($fileHandle, 5) == "\xFF\xFE\x00\x00" ?
fseek($fileHandle, 4) : fseek($fileHandle, 0);
break;
case 'UTF-32BE':
fgets($fileHandle, 5) == "\x00\x00\xFE\xFF" ?
fseek($fileHandle, 4) : fseek($fileHandle, 0);
break;
default:
break;
}
@ -244,42 +253,40 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
$this->_enclosure . $this->_enclosure
);
// Loop through file
$currentRow = 0;
if ($this->_contiguousRow == -1) {
$this->_contiguousRow = $objPHPExcel->getActiveSheet()->getHighestRow();
// Set our starting row based on whether we're in contiguous mode or not
$currentRow = 1;
if ($this->_contiguous) {
$currentRow = ($this->_contiguousRow == -1) ? $objPHPExcel->getActiveSheet()->getHighestRow(): $this->_contiguousRow;
}
$rowData = array();
// Loop through each line of the file in turn
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
++$currentRow;
$rowDataCount = count($rowData);
$columnLetter = 'A';
for ($i = 0; $i < $rowDataCount; ++$i) {
if ($rowData[$i] != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
foreach($rowData as $rowDatum) {
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
// Unescape enclosures
$rowData[$i] = str_replace($escapeEnclosures, $this->_enclosure, $rowData[$i]);
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);
// Convert encoding if necessary
if ($this->_inputEncoding !== 'UTF-8') {
$rowData[$i] = PHPExcel_Shared_String::ConvertEncoding($rowData[$i], 'UTF-8', $this->_inputEncoding);
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
}
if ($this->_contiguous) {
// Set cell value
$objPHPExcel->getActiveSheet()->getCell($columnLetter . $this->_contiguousRow)->setValue($rowData[$i]);
} else {
// Set cell value
$objPHPExcel->getActiveSheet()->getCell($columnLetter . $currentRow)->setValue($rowData[$i]);
}
// Set cell value
$objPHPExcel->getActiveSheet()->getCell($columnLetter . $currentRow)->setValue($rowDatum);
}
++$columnLetter;
}
++$this->_contiguousRow;
++$currentRow;
}
// Close file
fclose($fileHandle);
if ($this->_contiguous) {
$this->_contiguousRow = $currentRow;
}
// Return
return $objPHPExcel;
} // function loadIntoExisting()

View File

@ -63,7 +63,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
*
* @var int
*/
private $_sheetIndex;
private $_sheetIndex = 0;
/**
* Formats
@ -158,7 +158,6 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
* Create a new PHPExcel_Reader_Excel2003XML
*/
public function __construct() {
$this->_sheetIndex = 0;
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}

View File

@ -431,7 +431,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// add style to cellXf collection
$objStyle = new PHPExcel_Style;
$this->_readStyle($objStyle, $style);
self::_readStyle($objStyle, $style);
$excel->addCellXf($objStyle);
}
@ -458,7 +458,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// add style to cellStyleXf collection
$objStyle = new PHPExcel_Style;
$this->_readStyle($objStyle, $cellStyle);
self::_readStyle($objStyle, $cellStyle);
$excel->addCellStyleXf($objStyle);
}
}
@ -468,7 +468,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
if ($xmlStyles->dxfs) {
foreach ($xmlStyles->dxfs->dxf as $dxf) {
$style = new PHPExcel_Style;
$this->_readStyle($style, $dxf);
self::_readStyle($style, $dxf);
$dxfs[] = $style;
}
}
@ -480,7 +480,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
if (isset($cellStyles[intval($cellStyle['xfId'])])) {
// Set default style
$style = new PHPExcel_Style;
$this->_readStyle($style, $cellStyles[intval($cellStyle['xfId'])]);
self::_readStyle($style, $cellStyles[intval($cellStyle['xfId'])]);
// normal style, currently not using it for anything
}
@ -1439,7 +1439,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
private function _readStyle($docStyle, $style) {
private static function _readStyle($docStyle, $style) {
// format code
if (isset($style->numFmt)) {
$docStyle->getNumberFormat()->setFormatCode($style->numFmt);

View File

@ -63,7 +63,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
*
* @var int
*/
private $_sheetIndex;
private $_sheetIndex = 0;
/**
* Formats
@ -167,7 +167,6 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
* Create a new PHPExcel_Reader_Gnumeric
*/
public function __construct() {
$this->_sheetIndex = 0;
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
}

View File

@ -63,7 +63,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
*
* @var int
*/
private $_sheetIndex;
private $_sheetIndex = 0;
/**
* Formats
@ -158,7 +158,6 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
* Create a new PHPExcel_Reader_OOCalc
*/
public function __construct() {
$this->_sheetIndex = 0;
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}

View File

@ -49,14 +49,14 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
*
* @var string
*/
private $_inputEncoding;
private $_inputEncoding = 'ANSI';
/**
* Sheet index to read
*
* @var int
*/
private $_sheetIndex;
private $_sheetIndex = 0;
/**
* Formats
@ -83,8 +83,6 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
* Create a new PHPExcel_Reader_SYLK
*/
public function __construct() {
$this->_inputEncoding = 'ANSI';
$this->_sheetIndex = 0;
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}

View File

@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
@ -30,7 +30,7 @@
* PHPExcel_Style_Alignment
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Alignment implements PHPExcel_IComparable
@ -54,42 +54,42 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
*
* @var string
*/
private $_horizontal;
private $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
/**
* Vertical
*
* @var string
*/
private $_vertical;
private $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
/**
* Text rotation
*
* @var int
*/
private $_textRotation;
private $_textRotation = 0;
/**
* Wrap text
*
* @var boolean
*/
private $_wrapText;
private $_wrapText = false;
/**
* Shrink to fit
*
* @var boolean
*/
private $_shrinkToFit;
private $_shrinkToFit = false;
/**
* Indent - only possible with horizontal alignment left and right
*
* @var int
*/
private $_indent;
private $_indent = 0;
/**
* Parent Borders
@ -112,22 +112,14 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
*/
private $_parent;
/**
* Create a new PHPExcel_Style_Alignment
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
/**
* Create a new PHPExcel_Style_Alignment
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
$this->_isSupervisor = $isSupervisor;
// 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;
}
}
/**
* Bind parent. Only used for supervisor
@ -205,24 +197,24 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
return array('alignment' => $array);
}
/**
* 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
* @return PHPExcel_Style_Alignment
*/
/**
* 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
* @return PHPExcel_Style_Alignment
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
@ -253,28 +245,28 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
return $this;
}
/**
* Get Horizontal
*
* @return string
*/
public function getHorizontal() {
/**
* Get Horizontal
*
* @return string
*/
public function getHorizontal() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHorizontal();
}
return $this->_horizontal;
}
return $this->_horizontal;
}
/**
* Set Horizontal
*
* @param string $pValue
* @return PHPExcel_Style_Alignment
*/
public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
}
/**
* Set Horizontal
*
* @param string $pValue
* @return PHPExcel_Style_Alignment
*/
public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('horizontal' => $pValue));
@ -284,30 +276,30 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
$this->_horizontal = $pValue;
}
return $this;
}
}
/**
* Get Vertical
*
* @return string
*/
public function getVertical() {
/**
* Get Vertical
*
* @return string
*/
public function getVertical() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getVertical();
}
return $this->_vertical;
}
return $this->_vertical;
}
/**
* Set Vertical
*
* @param string $pValue
* @return PHPExcel_Style_Alignment
*/
public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
}
/**
* Set Vertical
*
* @param string $pValue
* @return PHPExcel_Style_Alignment
*/
public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('vertical' => $pValue));
@ -316,70 +308,70 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
$this->_vertical = $pValue;
}
return $this;
}
}
/**
* Get TextRotation
*
* @return int
*/
public function getTextRotation() {
/**
* Get TextRotation
*
* @return int
*/
public function getTextRotation() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getTextRotation();
}
return $this->_textRotation;
}
return $this->_textRotation;
}
/**
* Set TextRotation
*
* @param int $pValue
* @throws Exception
* @return PHPExcel_Style_Alignment
*/
public function setTextRotation($pValue = 0) {
/**
* Set TextRotation
*
* @param int $pValue
* @throws Exception
* @return PHPExcel_Style_Alignment
*/
public function setTextRotation($pValue = 0) {
// Excel2007 value 255 => PHPExcel value -165
if ($pValue == 255) {
$pValue = -165;
}
if ($pValue == 255) {
$pValue = -165;
}
// Set rotation
if ( ($pValue >= -90 && $pValue <= 90) || $pValue == -165 ) {
if ( ($pValue >= -90 && $pValue <= 90) || $pValue == -165 ) {
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('rotation' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->_textRotation = $pValue;
}
} else {
throw new Exception("Text rotation should be a value between -90 and 90.");
}
} else {
throw new Exception("Text rotation should be a value between -90 and 90.");
}
return $this;
}
return $this;
}
/**
* Get Wrap Text
*
* @return boolean
*/
public function getWrapText() {
/**
* Get Wrap Text
*
* @return boolean
*/
public function getWrapText() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getWrapText();
}
return $this->_wrapText;
}
return $this->_wrapText;
}
/**
* Set Wrap Text
*
* @param boolean $pValue
* @return PHPExcel_Style_Alignment
*/
public function setWrapText($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
/**
* Set Wrap Text
*
* @param boolean $pValue
* @return PHPExcel_Style_Alignment
*/
public function setWrapText($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('wrap' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -387,30 +379,30 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
$this->_wrapText = $pValue;
}
return $this;
}
}
/**
* Get Shrink to fit
*
* @return boolean
*/
public function getShrinkToFit() {
/**
* Get Shrink to fit
*
* @return boolean
*/
public function getShrinkToFit() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getShrinkToFit();
}
return $this->_shrinkToFit;
}
return $this->_shrinkToFit;
}
/**
* Set Shrink to fit
*
* @param boolean $pValue
* @return PHPExcel_Style_Alignment
*/
public function setShrinkToFit($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
/**
* Set Shrink to fit
*
* @param boolean $pValue
* @return PHPExcel_Style_Alignment
*/
public function setShrinkToFit($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -418,27 +410,27 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
$this->_shrinkToFit = $pValue;
}
return $this;
}
}
/**
* Get indent
*
* @return int
*/
public function getIndent() {
/**
* Get indent
*
* @return int
*/
public function getIndent() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getIndent();
}
return $this->_indent;
}
return $this->_indent;
}
/**
* Set indent
*
* @param int $pValue
* @return PHPExcel_Style_Alignment
*/
public function setIndent($pValue = 0) {
/**
* Set indent
*
* @param int $pValue
* @return PHPExcel_Style_Alignment
*/
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
@ -451,7 +443,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
$this->_indent = $pValue;
}
return $this;
}
}
/**
* Get hash code
@ -462,16 +454,16 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
}
return md5(
$this->_horizontal
. $this->_vertical
. $this->_textRotation
. ($this->_wrapText ? 't' : 'f')
. ($this->_shrinkToFit ? 't' : 'f')
return md5(
$this->_horizontal
. $this->_vertical
. $this->_textRotation
. ($this->_wrapText ? 't' : 'f')
. ($this->_shrinkToFit ? 't' : 'f')
. $this->_indent
. __CLASS__
);
}
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.

View File

@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
@ -30,7 +30,7 @@
* PHPExcel_Style_Border
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Border implements PHPExcel_IComparable
@ -56,7 +56,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
*
* @var string
*/
private $_borderStyle;
private $_borderStyle = PHPExcel_Style_Border::BORDER_NONE;
/**
* Border color
@ -86,23 +86,22 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
*/
private $_parentPropertyName;
/**
* Create a new PHPExcel_Style_Border
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
/**
* Create a new PHPExcel_Style_Border
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
$this->_isSupervisor = $isSupervisor;
// Initialise values
$this->_borderStyle = PHPExcel_Style_Border::BORDER_NONE;
// Initialise values
$this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor);
// bind parent if we are a supervisor
if ($isSupervisor) {
$this->_color->bindParent($this, '_color');
}
}
}
/**
* Bind parent. Only used for supervisor
@ -253,24 +252,24 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
return $this->_parent->getStyleArray(array($key => $array));
}
/**
* 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
* @return PHPExcel_Style_Border
*/
/**
* 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
* @return PHPExcel_Style_Border
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
@ -289,29 +288,29 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
return $this;
}
/**
* Get Border style
*
* @return string
*/
public function getBorderStyle() {
/**
* Get Border style
*
* @return string
*/
public function getBorderStyle() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getBorderStyle();
}
return $this->_borderStyle;
}
return $this->_borderStyle;
}
/**
* Set Border style
*
* @param string $pValue
* @return PHPExcel_Style_Border
*/
public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
/**
* Set Border style
*
* @param string $pValue
* @return PHPExcel_Style_Border
*/
public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Border::BORDER_NONE;
}
if ($pValue == '') {
$pValue = PHPExcel_Style_Border::BORDER_NONE;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('style' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -319,25 +318,25 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
$this->_borderStyle = $pValue;
}
return $this;
}
}
/**
* Get Border Color
*
* @return PHPExcel_Style_Color
*/
public function getColor() {
return $this->_color;
}
/**
* Get Border Color
*
* @return PHPExcel_Style_Color
*/
public function getColor() {
return $this->_color;
}
/**
* Set Border Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
* @return PHPExcel_Style_Border
*/
public function setColor(PHPExcel_Style_Color $pValue = null) {
/**
* Set Border Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
* @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;
@ -348,7 +347,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
$this->_color = $color;
}
return $this;
}
}
/**
* Get hash code
@ -359,12 +358,12 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
}
return md5(
$this->_borderStyle
. $this->_color->getHashCode()
. __CLASS__
);
}
return md5(
$this->_borderStyle
. $this->_color->getHashCode()
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.

View File

@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
@ -30,7 +30,7 @@
* PHPExcel_Style_Fill
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Fill implements PHPExcel_IComparable
@ -63,14 +63,14 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
*
* @var string
*/
private $_fillType;
private $_fillType = PHPExcel_Style_Fill::FILL_NONE;
/**
* Rotation
*
* @var double
*/
private $_rotation;
private $_rotation = 0;
/**
* Start color
@ -107,17 +107,15 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
*/
private $_parent;
/**
* Create a new PHPExcel_Style_Fill
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
/**
* Create a new PHPExcel_Style_Fill
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
$this->_isSupervisor = $isSupervisor;
// Initialise values
$this->_fillType = PHPExcel_Style_Fill::FILL_NONE;
$this->_rotation = 0;
// Initialise values
$this->_startColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_WHITE, $isSupervisor);
$this->_endColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor);
@ -126,7 +124,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
$this->_startColor->bindParent($this, '_startColor');
$this->_endColor->bindParent($this, '_endColor');
}
}
}
/**
* Bind parent. Only used for supervisor
@ -204,28 +202,28 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
return array('fill' => $array);
}
/**
* 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
* @return PHPExcel_Style_Fill
*/
/**
* 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
* @return PHPExcel_Style_Fill
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
@ -253,25 +251,25 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
return $this;
}
/**
* Get Fill Type
*
* @return string
*/
public function getFillType() {
/**
* Get Fill Type
*
* @return string
*/
public function getFillType() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getFillType();
}
return $this->_fillType;
}
}
/**
* Set Fill Type
*
* @param string $pValue PHPExcel_Style_Fill fill type
* @return PHPExcel_Style_Fill
*/
public function setFillType($pValue = PHPExcel_Style_Fill::FILL_NONE) {
/**
* Set Fill Type
*
* @param string $pValue PHPExcel_Style_Fill fill type
* @return PHPExcel_Style_Fill
*/
public function setFillType($pValue = PHPExcel_Style_Fill::FILL_NONE) {
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('type' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -279,27 +277,27 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
$this->_fillType = $pValue;
}
return $this;
}
}
/**
* Get Rotation
*
* @return double
*/
public function getRotation() {
/**
* Get Rotation
*
* @return double
*/
public function getRotation() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getRotation();
}
return $this->_rotation;
}
return $this->_rotation;
}
/**
* Set Rotation
*
* @param double $pValue
* @return PHPExcel_Style_Fill
*/
public function setRotation($pValue = 0) {
/**
* Set Rotation
*
* @param double $pValue
* @return PHPExcel_Style_Fill
*/
public function setRotation($pValue = 0) {
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('rotation' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -307,25 +305,25 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
$this->_rotation = $pValue;
}
return $this;
}
}
/**
* Get Start Color
*
* @return PHPExcel_Style_Color
*/
public function getStartColor() {
return $this->_startColor;
}
/**
* Get Start Color
*
* @return PHPExcel_Style_Color
*/
public function getStartColor() {
return $this->_startColor;
}
/**
* Set Start Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
* @return PHPExcel_Style_Fill
*/
public function setStartColor(PHPExcel_Style_Color $pValue = null) {
/**
* Set Start Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
* @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;
@ -336,25 +334,25 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
$this->_startColor = $color;
}
return $this;
}
}
/**
* Get End Color
*
* @return PHPExcel_Style_Color
*/
public function getEndColor() {
return $this->_endColor;
}
/**
* Get End Color
*
* @return PHPExcel_Style_Color
*/
public function getEndColor() {
return $this->_endColor;
}
/**
* Set End Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
* @return PHPExcel_Style_Fill
*/
public function setEndColor(PHPExcel_Style_Color $pValue = null) {
/**
* Set End Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
* @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;
@ -365,7 +363,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
$this->_endColor = $color;
}
return $this;
}
}
/**
* Get hash code
@ -376,14 +374,14 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
}
return md5(
$this->getFillType()
. $this->getRotation()
. $this->getStartColor()->getHashCode()
. $this->getEndColor()->getHashCode()
. __CLASS__
);
}
return md5(
$this->getFillType()
. $this->getRotation()
. $this->getStartColor()->getHashCode()
. $this->getEndColor()->getHashCode()
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.

View File

@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
@ -30,7 +30,7 @@
* PHPExcel_Style_Font
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Font implements PHPExcel_IComparable
@ -43,53 +43,60 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
const UNDERLINE_SINGLEACCOUNTING = 'singleAccounting';
/**
* Name
* Font Name
*
* @var string
*/
private $_name;
private $_name = 'Calibri';
/**
* Font Size
*
* @var float
*/
private $_size = 11;
/**
* Bold
*
* @var boolean
*/
private $_bold;
private $_bold = false;
/**
* Italic
*
* @var boolean
*/
private $_italic;
private $_italic = false;
/**
* Superscript
*
* @var boolean
*/
private $_superScript;
private $_superScript = false;
/**
* Subscript
*
* @var boolean
*/
private $_subScript;
private $_subScript = false;
/**
* Underline
*
* @var string
*/
private $_underline;
private $_underline = PHPExcel_Style_Font::UNDERLINE_NONE;
/**
* Strikethrough
*
* @var boolean
*/
private $_strikethrough;
private $_strikethrough = false;
/**
* Foreground color
@ -120,29 +127,21 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
private $_parent;
/**
* Create a new PHPExcel_Style_Font
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
* Create a new PHPExcel_Style_Font
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
$this->_isSupervisor = $isSupervisor;
// Initialise values
$this->_name = 'Calibri';
$this->_size = 11;
$this->_bold = false;
$this->_italic = false;
$this->_superScript = false;
$this->_subScript = false;
$this->_underline = PHPExcel_Style_Font::UNDERLINE_NONE;
$this->_strikethrough = false;
// Initialise values
$this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor);
// bind parent if we are a supervisor
if ($isSupervisor) {
$this->_color->bindParent($this, '_color');
}
}
}
/**
* Bind parent. Only used for supervisor
@ -219,28 +218,28 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
return array('font' => $array);
}
/**
* 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
* @return PHPExcel_Style_Font
*/
/**
* 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
* @return PHPExcel_Style_Font
*/
public function applyFromArray($pStyles = null) {
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
@ -280,28 +279,28 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
return $this;
}
/**
* Get Name
*
* @return string
*/
public function getName() {
/**
* Get Name
*
* @return string
*/
public function getName() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getName();
}
return $this->_name;
}
return $this->_name;
}
/**
* Set Name
*
* @param string $pValue
* @return PHPExcel_Style_Font
*/
public function setName($pValue = 'Calibri') {
if ($pValue == '') {
$pValue = 'Calibri';
}
/**
* Set Name
*
* @param string $pValue
* @return PHPExcel_Style_Font
*/
public function setName($pValue = 'Calibri') {
if ($pValue == '') {
$pValue = 'Calibri';
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('name' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -309,30 +308,30 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
$this->_name = $pValue;
}
return $this;
}
}
/**
* Get Size
*
* @return double
*/
public function getSize() {
/**
* Get Size
*
* @return double
*/
public function getSize() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getSize();
}
return $this->_size;
}
return $this->_size;
}
/**
* Set Size
*
* @param double $pValue
* @return PHPExcel_Style_Font
*/
public function setSize($pValue = 10) {
if ($pValue == '') {
$pValue = 10;
}
/**
* Set Size
*
* @param double $pValue
* @return PHPExcel_Style_Font
*/
public function setSize($pValue = 10) {
if ($pValue == '') {
$pValue = 10;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('size' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -340,30 +339,30 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
$this->_size = $pValue;
}
return $this;
}
}
/**
* Get Bold
*
* @return boolean
*/
public function getBold() {
/**
* Get Bold
*
* @return boolean
*/
public function getBold() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getBold();
}
return $this->_bold;
}
return $this->_bold;
}
/**
* Set Bold
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setBold($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
/**
* Set Bold
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setBold($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('bold' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -371,30 +370,30 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
$this->_bold = $pValue;
}
return $this;
}
}
/**
* Get Italic
*
* @return boolean
*/
public function getItalic() {
/**
* Get Italic
*
* @return boolean
*/
public function getItalic() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getItalic();
}
return $this->_italic;
}
return $this->_italic;
}
/**
* Set Italic
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setItalic($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
/**
* Set Italic
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setItalic($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('italic' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -402,30 +401,30 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
$this->_italic = $pValue;
}
return $this;
}
}
/**
* Get SuperScript
*
* @return boolean
*/
public function getSuperScript() {
/**
* Get SuperScript
*
* @return boolean
*/
public function getSuperScript() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getSuperScript();
}
return $this->_superScript;
}
return $this->_superScript;
}
/**
* Set SuperScript
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setSuperScript($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
/**
* Set SuperScript
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setSuperScript($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('superScript' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -434,30 +433,30 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
$this->_subScript = !$pValue;
}
return $this;
}
}
/**
* Get SubScript
*
* @return boolean
*/
public function getSubScript() {
/**
* Get SubScript
*
* @return boolean
*/
public function getSubScript() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getSubScript();
}
return $this->_subScript;
}
return $this->_subScript;
}
/**
* Set SubScript
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setSubScript($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
/**
* Set SubScript
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setSubScript($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('subScript' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -466,30 +465,30 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
$this->_superScript = !$pValue;
}
return $this;
}
}
/**
* Get Underline
*
* @return string
*/
public function getUnderline() {
/**
* Get Underline
*
* @return string
*/
public function getUnderline() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getUnderline();
}
return $this->_underline;
}
return $this->_underline;
}
/**
* Set Underline
*
* @param string $pValue PHPExcel_Style_Font underline type
* @return PHPExcel_Style_Font
*/
public function setUnderline($pValue = PHPExcel_Style_Font::UNDERLINE_NONE) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Font::UNDERLINE_NONE;
}
/**
* Set Underline
*
* @param string $pValue PHPExcel_Style_Font underline type
* @return PHPExcel_Style_Font
*/
public function setUnderline($pValue = PHPExcel_Style_Font::UNDERLINE_NONE) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Font::UNDERLINE_NONE;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('underline' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -497,51 +496,51 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
$this->_underline = $pValue;
}
return $this;
}
}
/**
* Get Striketrough
*
* @deprecated Use getStrikethrough() instead.
* @return boolean
*/
public function getStriketrough() {
return $this->getStrikethrough();
}
/**
* Get Striketrough
*
* @deprecated Use getStrikethrough() instead.
* @return boolean
*/
public function getStriketrough() {
return $this->getStrikethrough();
}
/**
* Set Striketrough
*
* @deprecated Use setStrikethrough() instead.
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setStriketrough($pValue = false) {
return $this->setStrikethrough($pValue);
}
/**
* Set Striketrough
*
* @deprecated Use setStrikethrough() instead.
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setStriketrough($pValue = false) {
return $this->setStrikethrough($pValue);
}
/**
* Get Strikethrough
*
* @return boolean
*/
public function getStrikethrough() {
/**
* Get Strikethrough
*
* @return boolean
*/
public function getStrikethrough() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getStrikethrough();
}
return $this->_strikethrough;
}
return $this->_strikethrough;
}
/**
* Set Strikethrough
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setStrikethrough($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
/**
* Set Strikethrough
*
* @param boolean $pValue
* @return PHPExcel_Style_Font
*/
public function setStrikethrough($pValue = false) {
if ($pValue == '') {
$pValue = false;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('strike' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@ -549,25 +548,25 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
$this->_strikethrough = $pValue;
}
return $this;
}
}
/**
* Get Color
*
* @return PHPExcel_Style_Color
*/
public function getColor() {
return $this->_color;
}
/**
* Get Color
*
* @return PHPExcel_Style_Color
*/
public function getColor() {
return $this->_color;
}
/**
* Set Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
* @return PHPExcel_Style_Font
*/
public function setColor(PHPExcel_Style_Color $pValue = null) {
/**
* Set Color
*
* @param PHPExcel_Style_Color $pValue
* @throws Exception
* @return PHPExcel_Style_Font
*/
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;
@ -578,7 +577,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
$this->_color = $color;
}
return $this;
}
}
/**
* Get hash code
@ -589,19 +588,19 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
}
return md5(
$this->_name
. $this->_size
. ($this->_bold ? 't' : 'f')
. ($this->_italic ? 't' : 'f')
return md5(
$this->_name
. $this->_size
. ($this->_bold ? 't' : 'f')
. ($this->_italic ? 't' : 'f')
. ($this->_superScript ? 't' : 'f')
. ($this->_subScript ? 't' : 'f')
. $this->_underline
. ($this->_strikethrough ? 't' : 'f')
. $this->_color->getHashCode()
. __CLASS__
);
}
. $this->_underline
. ($this->_strikethrough ? 't' : 'f')
. $this->_color->getHashCode()
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.

View File

@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
@ -30,7 +30,7 @@
* PHPExcel_Style_NumberFormat
*
* @category PHPExcel
* @package PHPExcel_Style
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
@ -94,14 +94,14 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
*
* @var string
*/
private $_formatCode;
private $_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
/**
* Built-in format Code
*
* @var string
*/
private $_builtInFormatCode;
private $_builtInFormatCode = 0;
/**
* Parent Borders
@ -131,10 +131,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
{
// Supervisor?
$this->_isSupervisor = $isSupervisor;
// Initialise values
$this->_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
$this->_builtInFormatCode = 0;
}
/**
@ -217,9 +213,9 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray(
* array(
* 'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
* )
* array(
* 'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
* )
* );
* </code>
*
@ -497,8 +493,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
/**
* Convert a value in a pre-defined format to a PHP string
*
* @param mixed $value Value to format
* @param string $format Format code
* @param mixed $value Value to format
* @param string $format Format code
* @param array $callBack Callback function for additional formatting of string
* @return string Formatted string
*/
@ -623,7 +619,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
// Scale thousands, millions,...
// This is indicated by a number of commas after a digit placeholder:
// #, or 0.0,,
// #, or 0.0,,
$scale = 1; // same as no scale
$matches = array();
if (preg_match('/(#|0)(,+)/', $format, $matches)) {

View File

@ -337,13 +337,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->_pageSetup = new PHPExcel_Worksheet_PageSetup();
// Set page margins
$this->_pageMargins = new PHPExcel_Worksheet_PageMargins();
$this->_pageMargins = new PHPExcel_Worksheet_PageMargins();
// Set page header/footer
$this->_headerFooter = new PHPExcel_Worksheet_HeaderFooter();
// Set sheet view
$this->_sheetView = new PHPExcel_Worksheet_SheetView();
$this->_sheetView = new PHPExcel_Worksheet_SheetView();
// Drawing collection
$this->_drawingCollection = new ArrayObject();
@ -351,14 +351,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Protection
$this->_protection = new PHPExcel_Worksheet_Protection();
// Gridlines
$this->_showGridlines = true;
$this->_printGridlines = false;
// Outline summary
$this->_showSummaryBelow = true;
$this->_showSummaryRight = true;
// Default row dimension
$this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(null);

View File

@ -49,35 +49,35 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @var double
*/
private $_width;
private $_width = -1;
/**
* Auto size?
*
* @var bool
*/
private $_autoSize;
private $_autoSize = false;
/**
* Visible?
*
* @var bool
*/
private $_visible;
private $_visible = true;
/**
* Outline level
*
* @var int
*/
private $_outlineLevel = 0;
private $_outlineLevel = 0;
/**
* Collapsed
*
* @var bool
*/
private $_collapsed;
private $_collapsed = false;
/**
* Index to cellXf
@ -95,11 +95,6 @@ class PHPExcel_Worksheet_ColumnDimension
{
// Initialise values
$this->_columnIndex = $pIndex;
$this->_width = -1;
$this->_autoSize = false;
$this->_visible = true;
$this->_outlineLevel = 0;
$this->_collapsed = false;
// set default index to cellXf
$this->_xfIndex = 0;

View File

@ -108,70 +108,70 @@ class PHPExcel_Worksheet_HeaderFooter
*
* @var string
*/
private $_oddHeader;
private $_oddHeader = '';
/**
* OddFooter
*
* @var string
*/
private $_oddFooter;
private $_oddFooter = '';
/**
* EvenHeader
*
* @var string
*/
private $_evenHeader;
private $_evenHeader = '';
/**
* EvenFooter
*
* @var string
*/
private $_evenFooter;
private $_evenFooter = '';
/**
* FirstHeader
*
* @var string
*/
private $_firstHeader;
private $_firstHeader = '';
/**
* FirstFooter
*
* @var string
*/
private $_firstFooter;
private $_firstFooter = '';
/**
* Different header for Odd/Even, defaults to false
*
* @var boolean
*/
private $_differentOddEven;
private $_differentOddEven = false;
/**
* Different header for first page, defaults to false
*
* @var boolean
*/
private $_differentFirst;
private $_differentFirst = false;
/**
* Scale with document, defaults to true
*
* @var boolean
*/
private $_scaleWithDocument;
private $_scaleWithDocument = true;
/**
* Align with margins, defaults to true
*
* @var boolean
*/
private $_alignWithMargins;
private $_alignWithMargins = true;
/**
* Header/footer images
@ -185,18 +185,6 @@ class PHPExcel_Worksheet_HeaderFooter
*/
public function __construct()
{
// Initialise values
$this->_oddHeader = '';
$this->_oddFooter = '';
$this->_evenHeader = '';
$this->_evenFooter = '';
$this->_firstHeader = '';
$this->_firstFooter = '';
$this->_differentOddEven = false;
$this->_differentFirst = false;
$this->_scaleWithDocument = true;
$this->_alignWithMargins = true;
$this->_headerFooterImages = array();
}
/**

View File

@ -40,55 +40,48 @@ class PHPExcel_Worksheet_PageMargins
*
* @var double
*/
private $_left;
private $_left = 0.7;
/**
* Right
*
* @var double
*/
private $_right;
private $_right = 0.7;
/**
* Top
*
* @var double
*/
private $_top;
private $_top = 0.75;
/**
* Bottom
*
* @var double
*/
private $_bottom;
private $_bottom = 0.75;
/**
* Header
*
* @var double
*/
private $_header;
private $_header = 0.3;
/**
* Footer
*
* @var double
*/
private $_footer;
private $_footer = 0.3;
/**
* Create a new PHPExcel_Worksheet_PageMargins
*/
public function __construct()
{
// Initialise values
$this->_left = 0.7;
$this->_right = 0.7;
$this->_top = 0.75;
$this->_bottom = 0.75;
$this->_header = 0.3;
$this->_footer = 0.3;
}
/**

View File

@ -189,14 +189,14 @@ class PHPExcel_Worksheet_PageSetup
*
* @var int
*/
private $_paperSize;
private $_paperSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER;
/**
* Orientation
*
* @var string
*/
private $_orientation;
private $_orientation = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT;
/**
* Scale (Print Scale)
@ -206,7 +206,7 @@ class PHPExcel_Worksheet_PageSetup
*
* @var int?
*/
private $_scale;
private $_scale = 100;
/**
* Fit To Page
@ -214,7 +214,7 @@ class PHPExcel_Worksheet_PageSetup
*
* @var boolean
*/
private $_fitToPage;
private $_fitToPage = false;
/**
* Fit To Height
@ -222,7 +222,7 @@ class PHPExcel_Worksheet_PageSetup
*
* @var int?
*/
private $_fitToHeight;
private $_fitToHeight = 1;
/**
* Fit To Width
@ -230,7 +230,7 @@ class PHPExcel_Worksheet_PageSetup
*
* @var int?
*/
private $_fitToWidth;
private $_fitToWidth = 1;
/**
* Columns to repeat at left
@ -279,19 +279,6 @@ class PHPExcel_Worksheet_PageSetup
*/
public function __construct()
{
// Initialise values
$this->_paperSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER;
$this->_orientation = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT;
$this->_scale = 100;
$this->_fitToPage = false;
$this->_fitToHeight = 1;
$this->_fitToWidth = 1;
$this->_columnsToRepeatAtLeft = array('', '');
$this->_rowsToRepeatAtTop = array(0, 0);
$this->_horizontalCentered = false;
$this->_verticalCentered = false;
$this->_printArea = null;
$this->_firstPageNumber = null;
}
/**

View File

@ -40,143 +40,125 @@ class PHPExcel_Worksheet_Protection
*
* @var boolean
*/
private $_sheet;
private $_sheet = false;
/**
* Objects
*
* @var boolean
*/
private $_objects;
private $_objects = false;
/**
* Scenarios
*
* @var boolean
*/
private $_scenarios;
private $_scenarios = false;
/**
* Format cells
*
* @var boolean
*/
private $_formatCells;
private $_formatCells = false;
/**
* Format columns
*
* @var boolean
*/
private $_formatColumns;
private $_formatColumns = false;
/**
* Format rows
*
* @var boolean
*/
private $_formatRows;
private $_formatRows = false;
/**
* Insert columns
*
* @var boolean
*/
private $_insertColumns;
private $_insertColumns = false;
/**
* Insert rows
*
* @var boolean
*/
private $_insertRows;
private $_insertRows = false;
/**
* Insert hyperlinks
*
* @var boolean
*/
private $_insertHyperlinks;
private $_insertHyperlinks = false;
/**
* Delete columns
*
* @var boolean
*/
private $_deleteColumns;
private $_deleteColumns = false;
/**
* Delete rows
*
* @var boolean
*/
private $_deleteRows;
private $_deleteRows = false;
/**
* Select locked cells
*
* @var boolean
*/
private $_selectLockedCells;
private $_selectLockedCells = false;
/**
* Sort
*
* @var boolean
*/
private $_sort;
private $_sort = false;
/**
* AutoFilter
*
* @var boolean
*/
private $_autoFilter;
private $_autoFilter = false;
/**
* Pivot tables
*
* @var boolean
*/
private $_pivotTables;
private $_pivotTables = false;
/**
* Select unlocked cells
*
* @var boolean
*/
private $_selectUnlockedCells;
private $_selectUnlockedCells = false;
/**
* Password
*
* @var string
*/
private $_password;
private $_password = '';
/**
* Create a new PHPExcel_Worksheet_Protection
*/
public function __construct()
{
// Initialise values
$this->_sheet = false;
$this->_objects = false;
$this->_scenarios = false;
$this->_formatCells = false;
$this->_formatColumns = false;
$this->_formatRows = false;
$this->_insertColumns = false;
$this->_insertRows = false;
$this->_insertHyperlinks = false;
$this->_deleteColumns = false;
$this->_deleteRows = false;
$this->_selectLockedCells = false;
$this->_sort = false;
$this->_autoFilter = false;
$this->_pivotTables = false;
$this->_selectUnlockedCells = false;
$this->_password = '';
}
/**

View File

@ -49,28 +49,28 @@ class PHPExcel_Worksheet_RowDimension
*
* @var double
*/
private $_rowHeight;
private $_rowHeight = -1;
/**
* Visible?
*
* @var bool
*/
private $_visible;
private $_visible = true;
/**
* Outline level
*
* @var int
*/
private $_outlineLevel = 0;
private $_outlineLevel = 0;
/**
* Collapsed
*
* @var bool
*/
private $_collapsed;
private $_collapsed = false;
/**
* Index to cellXf. Null value means row has no explicit cellXf format.
@ -88,10 +88,6 @@ class PHPExcel_Worksheet_RowDimension
{
// Initialise values
$this->_rowIndex = $pIndex;
$this->_rowHeight = -1;
$this->_visible = true;
$this->_outlineLevel = 0;
$this->_collapsed = false;
// set row dimension as unformatted by default
$this->_xfIndex = null;

View File

@ -42,7 +42,7 @@ class PHPExcel_Worksheet_SheetView
*
* @var int
*/
private $_zoomScale;
private $_zoomScale = 100;
/**
* ZoomScaleNormal
@ -51,16 +51,13 @@ class PHPExcel_Worksheet_SheetView
*
* @var int
*/
private $_zoomScaleNormal;
private $_zoomScaleNormal = 100;
/**
* Create a new PHPExcel_Worksheet_SheetView
*/
public function __construct()
{
// Initialise values
$this->_zoomScale = 100;
$this->_zoomScaleNormal = 100;
}
/**

View File

@ -46,28 +46,28 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter {
*
* @var string
*/
private $_delimiter;
private $_delimiter = ',';
/**
* Enclosure
*
* @var string
*/
private $_enclosure;
private $_enclosure = '"';
/**
* Line ending
*
* @var string
*/
private $_lineEnding;
private $_lineEnding = PHP_EOL;
/**
* Sheet index to write
*
* @var int
*/
private $_sheetIndex;
private $_sheetIndex = 0;
/**
* Pre-calculate formulas
@ -90,10 +90,6 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter {
*/
public function __construct(PHPExcel $phpExcel) {
$this->_phpExcel = $phpExcel;
$this->_delimiter = ',';
$this->_enclosure = '"';
$this->_lineEnding = PHP_EOL;
$this->_sheetIndex = 0;
}
/**

View File

@ -40,7 +40,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
*
* @var boolean
*/
private $_preCalculateFormulas;
private $_preCalculateFormulas = true;
/**
* PHPExcel object
@ -54,28 +54,28 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
*
* @var integer
*/
private $_BIFF_version;
private $_BIFF_version = 0x0600;
/**
* Total number of shared strings in workbook
*
* @var int
*/
private $_str_total;
private $_str_total = 0;
/**
* Number of unique shared strings in workbook
*
* @var int
*/
private $_str_unique;
private $_str_unique = 0;
/**
* Array of unique shared strings in workbook
*
* @var array
*/
private $_str_table;
private $_str_table = array();
/**
* Color cache. Mapping between RGB value and color index.
@ -105,15 +105,9 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
* @param PHPExcel $phpExcel PHPExcel object
*/
public function __construct(PHPExcel $phpExcel) {
$this->_preCalculateFormulas = true;
$this->_phpExcel = $phpExcel;
$this->_BIFF_version = 0x0600;
$this->_str_total = 0;
$this->_str_unique = 0;
$this->_str_table = array();
$this->_parser = new PHPExcel_Writer_Excel5_Parser($this->_BIFF_version);
$this->_parser = new PHPExcel_Writer_Excel5_Parser($this->_BIFF_version);
}
/**

View File

@ -46,7 +46,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
*
* @var int
*/
private $_sheetIndex;
private $_sheetIndex = 0;
/**
* Pre-calculate formulas
@ -60,7 +60,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
*
* @var string
*/
private $_imagesRoot = '.';
private $_imagesRoot = '.';
/**
* Use inline CSS?
@ -95,28 +95,28 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
*
* @var boolean
*/
private $_spansAreCalculated;
private $_spansAreCalculated = false;
/**
* Excel cells that should not be written as HTML cells
*
* @var array
*/
private $_isSpannedCell;
private $_isSpannedCell = array();
/**
* Excel cells that are upper-left corner in a cell merge
*
* @var array
*/
private $_isBaseCell;
private $_isBaseCell = array();
/**
* Excel rows that should not be written as HTML rows
*
* @var array
*/
private $_isSpannedRow;
private $_isSpannedRow = array();
/**
* Is the current writer creating PDF?
@ -140,13 +140,6 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
public function __construct(PHPExcel $phpExcel) {
$this->_phpExcel = $phpExcel;
$this->_defaultFont = $this->_phpExcel->getDefaultStyle()->getFont();
$this->_sheetIndex = 0;
$this->_imagesRoot = '.';
$this->_spansAreCalculated = false;
$this->_isSpannedCell = array();
$this->_isBaseCell = array();
$this->_isSpannedRow = array();
}
/**