PSR2 Fixes

This commit is contained in:
Progi1984 2015-05-16 13:04:38 +02:00
parent 4c8dd00dff
commit 1bf5ea414b
7 changed files with 441 additions and 365 deletions

View File

@ -752,16 +752,19 @@ class PHPExcel_Chart_Renderer_jpgraph
switch ($chartType) { switch ($chartType) {
case 'area3DChart': case 'area3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'areaChart': case 'areaChart':
$this->renderPlotLine($i, true, true, $dimensions); $this->renderPlotLine($i, true, true, $dimensions);
break; break;
case 'bar3DChart': case 'bar3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'barChart': case 'barChart':
$this->renderPlotBar($i, $dimensions); $this->renderPlotBar($i, $dimensions);
break; break;
case 'line3DChart': case 'line3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'lineChart': case 'lineChart':
$this->renderPlotLine($i, false, true, $dimensions); $this->renderPlotLine($i, false, true, $dimensions);
break; break;
@ -812,26 +815,31 @@ class PHPExcel_Chart_Renderer_jpgraph
switch ($chartType) { switch ($chartType) {
case 'area3DChart': case 'area3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'areaChart': case 'areaChart':
$this->renderAreaChart($groupCount, $dimensions); $this->renderAreaChart($groupCount, $dimensions);
break; break;
case 'bar3DChart': case 'bar3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'barChart': case 'barChart':
$this->renderBarChart($groupCount, $dimensions); $this->renderBarChart($groupCount, $dimensions);
break; break;
case 'line3DChart': case 'line3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'lineChart': case 'lineChart':
$this->renderLineChart($groupCount, $dimensions); $this->renderLineChart($groupCount, $dimensions);
break; break;
case 'pie3DChart': case 'pie3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'pieChart': case 'pieChart':
$this->renderPieChart($groupCount, $dimensions, false, false); $this->renderPieChart($groupCount, $dimensions, false, false);
break; break;
case 'doughnut3DChart': case 'doughnut3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'doughnutChart': case 'doughnutChart':
$this->renderPieChart($groupCount, $dimensions, true, true); $this->renderPieChart($groupCount, $dimensions, true, true);
break; break;
@ -846,6 +854,7 @@ class PHPExcel_Chart_Renderer_jpgraph
break; break;
case 'surface3DChart': case 'surface3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'surfaceChart': case 'surfaceChart':
$this->renderContourChart($groupCount, $dimensions); $this->renderContourChart($groupCount, $dimensions);
break; break;

View File

@ -3,7 +3,7 @@
class PHPExcel_Helper_HTML class PHPExcel_Helper_HTML
{ {
protected static $colourMap = array( protected static $colourMap = array(
'aliceblue' => 'f0f8ff', 'aliceblue' => 'f0f8ff',
'antiquewhite' => 'faebd7', 'antiquewhite' => 'faebd7',
'antiquewhite1' => 'ffefdb', 'antiquewhite1' => 'ffefdb',
'antiquewhite2' => 'eedfcc', 'antiquewhite2' => 'eedfcc',
@ -573,7 +573,8 @@ class PHPExcel_Helper_HTML
protected $richTextObject; protected $richTextObject;
protected function initialise() { protected function initialise()
{
$this->face = $this->size = $this->color = null; $this->face = $this->size = $this->color = null;
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false; $this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
@ -582,7 +583,8 @@ class PHPExcel_Helper_HTML
$this->stringData = ''; $this->stringData = '';
} }
public function toRichTextObject($html) { public function toRichTextObject($html)
{
$this->initialise(); $this->initialise();
// Create a new DOM object // Create a new DOM object
@ -594,15 +596,17 @@ class PHPExcel_Helper_HTML
// Discard excess white space // Discard excess white space
$dom->preserveWhiteSpace = false; $dom->preserveWhiteSpace = false;
$this->richTextObject = new PHPExcel_RichText();; $this->richTextObject = new PHPExcel_RichText();
$this->parseElements($dom); $this->parseElements($dom);
return $this->richTextObject; return $this->richTextObject;
} }
protected function buildTextRun() { protected function buildTextRun()
{
$text = $this->stringData; $text = $this->stringData;
if (trim($text) === '') if (trim($text) === '') {
return; return;
}
$richtextRun = $this->richTextObject->createTextRun($this->stringData); $richtextRun = $this->richTextObject->createTextRun($this->stringData);
if ($this->face) { if ($this->face) {
@ -612,7 +616,7 @@ class PHPExcel_Helper_HTML
$richtextRun->getFont()->setSize($this->size); $richtextRun->getFont()->setSize($this->size);
} }
if ($this->color) { if ($this->color) {
$richtextRun->getFont()->setColor( new PHPExcel_Style_Color( 'ff' . $this->color ) ); $richtextRun->getFont()->setColor(new PHPExcel_Style_Color('ff' . $this->color));
} }
if ($this->bold) { if ($this->bold) {
$richtextRun->getFont()->setBold(true); $richtextRun->getFont()->setBold(true);
@ -635,7 +639,8 @@ class PHPExcel_Helper_HTML
$this->stringData = ''; $this->stringData = '';
} }
protected function rgbToColour($rgb) { protected function rgbToColour($rgb)
{
preg_match_all('/\d+/', $rgb, $values); preg_match_all('/\d+/', $rgb, $values);
foreach ($values[0] as &$value) { foreach ($values[0] as &$value) {
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT); $value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
@ -643,11 +648,13 @@ class PHPExcel_Helper_HTML
return implode($values[0]); return implode($values[0]);
} }
protected function colourNameLookup($rgb) { protected function colourNameLookup($rgb)
{
return self::$colourMap[$rgb]; return self::$colourMap[$rgb];
} }
protected function startFontTag($tag) { protected function startFontTag($tag)
{
foreach ($tag->attributes as $attribute) { foreach ($tag->attributes as $attribute) {
$attributeName = strtolower($attribute->name); $attributeName = strtolower($attribute->name);
$attributeValue = $attribute->value; $attributeValue = $attribute->value;
@ -666,69 +673,85 @@ class PHPExcel_Helper_HTML
} }
} }
protected function endFontTag() { protected function endFontTag()
{
$this->face = $this->size = $this->color = null; $this->face = $this->size = $this->color = null;
} }
protected function startBoldTag() { protected function startBoldTag()
{
$this->bold = true; $this->bold = true;
} }
protected function endBoldTag() { protected function endBoldTag()
{
$this->bold = false; $this->bold = false;
} }
protected function startItalicTag() { protected function startItalicTag()
{
$this->italic = true; $this->italic = true;
} }
protected function endItalicTag() { protected function endItalicTag()
{
$this->italic = false; $this->italic = false;
} }
protected function startUnderlineTag() { protected function startUnderlineTag()
{
$this->underline = true; $this->underline = true;
} }
protected function endUnderlineTag() { protected function endUnderlineTag()
{
$this->underline = false; $this->underline = false;
} }
protected function startSubscriptTag() { protected function startSubscriptTag()
{
$this->subscript = true; $this->subscript = true;
} }
protected function endSubscriptTag() { protected function endSubscriptTag()
{
$this->subscript = false; $this->subscript = false;
} }
protected function startSuperscriptTag() { protected function startSuperscriptTag()
{
$this->superscript = true; $this->superscript = true;
} }
protected function endSuperscriptTag() { protected function endSuperscriptTag()
{
$this->superscript = false; $this->superscript = false;
} }
protected function startStrikethruTag() { protected function startStrikethruTag()
{
$this->strikethrough = true; $this->strikethrough = true;
} }
protected function endStrikethruTag() { protected function endStrikethruTag()
{
$this->strikethrough = false; $this->strikethrough = false;
} }
protected function breakTag() { protected function breakTag()
{
$this->stringData .= PHP_EOL; $this->stringData .= PHP_EOL;
} }
protected function parseTextNode(DOMText $textNode) { protected function parseTextNode(DOMText $textNode)
{
$domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue)); $domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue));
$this->stringData .= $domText; $this->stringData .= $domText;
$this->buildTextRun(); $this->buildTextRun();
} }
protected function handleCallback($element, $callbackTag, $callbacks) { protected function handleCallback($element, $callbackTag, $callbacks)
{
if (isset($callbacks[$callbackTag])) { if (isset($callbacks[$callbackTag])) {
$elementHandler = $callbacks[$callbackTag]; $elementHandler = $callbacks[$callbackTag];
if (method_exists($this, $elementHandler)) { if (method_exists($this, $elementHandler)) {
@ -737,7 +760,8 @@ class PHPExcel_Helper_HTML
} }
} }
protected function parseElementNode(DOMElement $element) { protected function parseElementNode(DOMElement $element)
{
$callbackTag = strtolower($element->nodeName); $callbackTag = strtolower($element->nodeName);
$this->stack[] = $callbackTag; $this->stack[] = $callbackTag;
@ -750,7 +774,8 @@ class PHPExcel_Helper_HTML
$this->handleCallback($element, $callbackTag, $this->endTagCallbacks); $this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
} }
protected function parseElements(DOMNode $element) { protected function parseElements(DOMNode $element)
{
foreach ($element->childNodes as $child) { foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) { if ($child instanceof DOMText) {
$this->parseTextNode($child); $this->parseTextNode($child);

View File

@ -70,7 +70,7 @@ class PHPExcel_IOFactory
* Private constructor for PHPExcel_IOFactory * Private constructor for PHPExcel_IOFactory
*/ */
private function __construct() private function __construct()
{ {
} }
/** /**

View File

@ -42,7 +42,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @var boolean * @var boolean
*/ */
protected $_readDataOnly = FALSE; protected $_readDataOnly = false;
/** /**
* Read charts that are defined in the workbook? * Read charts that are defined in the workbook?
@ -50,7 +50,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @var boolean * @var boolean
*/ */
protected $_includeCharts = FALSE; protected $_includeCharts = false;
/** /**
* Restrict which sheets should be loaded? * Restrict which sheets should be loaded?
@ -58,16 +58,16 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @var array of string * @var array of string
*/ */
protected $_loadSheetsOnly = NULL; protected $_loadSheetsOnly = null;
/** /**
* PHPExcel_Reader_IReadFilter instance * PHPExcel_Reader_IReadFilter instance
* *
* @var PHPExcel_Reader_IReadFilter * @var PHPExcel_Reader_IReadFilter
*/ */
protected $_readFilter = NULL; protected $_readFilter = null;
protected $_fileHandle = NULL; protected $_fileHandle = null;
/** /**
@ -77,7 +77,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return boolean * @return boolean
*/ */
public function getReadDataOnly() { public function getReadDataOnly()
{
return $this->_readDataOnly; return $this->_readDataOnly;
} }
@ -90,7 +91,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel_Reader_IReader
*/ */
public function setReadDataOnly($pValue = FALSE) { public function setReadDataOnly($pValue = false)
{
$this->_readDataOnly = $pValue; $this->_readDataOnly = $pValue;
return $this; return $this;
} }
@ -103,7 +105,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return boolean * @return boolean
*/ */
public function getIncludeCharts() { public function getIncludeCharts()
{
return $this->_includeCharts; return $this->_includeCharts;
} }
@ -117,7 +120,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel_Reader_IReader
*/ */
public function setIncludeCharts($pValue = FALSE) { public function setIncludeCharts($pValue = false)
{
$this->_includeCharts = (boolean) $pValue; $this->_includeCharts = (boolean) $pValue;
return $this; return $this;
} }
@ -143,13 +147,13 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel_Reader_IReader
*/ */
public function setLoadSheetsOnly($value = NULL) public function setLoadSheetsOnly($value = null)
{ {
if ($value === NULL) if ($value === null) {
return $this->setLoadAllSheets(); return $this->setLoadAllSheets();
}
$this->_loadSheetsOnly = is_array($value) ? $this->_loadSheetsOnly = is_array($value) ? $value : array($value);
$value : array($value);
return $this; return $this;
} }
@ -161,7 +165,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function setLoadAllSheets() public function setLoadAllSheets()
{ {
$this->_loadSheetsOnly = NULL; $this->_loadSheetsOnly = null;
return $this; return $this;
} }
@ -170,7 +174,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return PHPExcel_Reader_IReadFilter * @return PHPExcel_Reader_IReadFilter
*/ */
public function getReadFilter() { public function getReadFilter()
{
return $this->_readFilter; return $this->_readFilter;
} }
@ -180,7 +185,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* @param PHPExcel_Reader_IReadFilter $pValue * @param PHPExcel_Reader_IReadFilter $pValue
* @return PHPExcel_Reader_IReader * @return PHPExcel_Reader_IReader
*/ */
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue)
{
$this->_readFilter = $pValue; $this->_readFilter = $pValue;
return $this; return $this;
} }
@ -201,7 +207,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
// Open file // Open file
$this->_fileHandle = fopen($pFilename, 'r'); $this->_fileHandle = fopen($pFilename, 'r');
if ($this->_fileHandle === FALSE) { if ($this->_fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading."); throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
} }
} }
@ -219,11 +225,11 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
try { try {
$this->_openFile($pFilename); $this->_openFile($pFilename);
} catch (Exception $e) { } catch (Exception $e) {
return FALSE; return false;
} }
$readable = $this->_isValidFormat(); $readable = $this->_isValidFormat();
fclose ($this->_fileHandle); fclose($this->_fileHandle);
return $readable; return $readable;
} }
@ -236,7 +242,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
public function securityScan($xml) public function securityScan($xml)
{ {
$pattern = '/\\0?' . implode('\\0?', str_split('<!DOCTYPE')) . '\\0?/'; $pattern = '/\\0?' . implode('\\0?', str_split('<!DOCTYPE')) . '\\0?/';
if (preg_match($pattern, $xml)) { if (preg_match($pattern, $xml)) {
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks'); throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
} }
return $xml; return $xml;

View File

@ -62,7 +62,8 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
/** /**
* Create a new PHPExcel_Reader_Excel2003XML * Create a new PHPExcel_Reader_Excel2003XML
*/ */
public function __construct() { public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
} }
@ -238,8 +239,8 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
} }
protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue)
protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { {
$styleAttributeValue = strtolower($styleAttributeValue); $styleAttributeValue = strtolower($styleAttributeValue);
foreach ($styleList as $style) { foreach ($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) { if ($styleAttributeValue == strtolower($style)) {
@ -250,13 +251,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return false; return false;
} }
/** /**
* pixel units to excel width units(units of 1/256th of a character width) * pixel units to excel width units(units of 1/256th of a character width)
* @param pxs * @param pxs
* @return * @return
*/ */
protected static function _pixel2WidthUnits($pxs) { protected static function _pixel2WidthUnits($pxs)
{
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219); $UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
$widthUnits = 256 * ($pxs / 7); $widthUnits = 256 * ($pxs / 7);
@ -264,25 +265,24 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $widthUnits; return $widthUnits;
} }
/** /**
* excel width units(units of 1/256th of a character width) to pixel units * excel width units(units of 1/256th of a character width) to pixel units
* @param widthUnits * @param widthUnits
* @return * @return
*/ */
protected static function _widthUnits2Pixel($widthUnits) { protected static function _widthUnits2Pixel($widthUnits)
{
$pixels = ($widthUnits / 256) * 7; $pixels = ($widthUnits / 256) * 7;
$offsetWidthUnits = $widthUnits % 256; $offsetWidthUnits = $widthUnits % 256;
$pixels += round($offsetWidthUnits / (256 / 7)); $pixels += round($offsetWidthUnits / (256 / 7));
return $pixels; return $pixels;
} }
protected static function _hex2str($hex)
protected static function _hex2str($hex) { {
return chr(hexdec($hex[1])); return chr(hexdec($hex[1]));
} }
/** /**
* Loads PHPExcel from file into PHPExcel instance * Loads PHPExcel from file into PHPExcel instance
* *
@ -293,35 +293,34 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
*/ */
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{ {
$fromFormats = array('\-', '\ '); $fromFormats = array('\-', '\ ');
$toFormats = array('-', ' '); $toFormats = array('-', ' ');
$underlineStyles = array ( $underlineStyles = array (
PHPExcel_Style_Font::UNDERLINE_NONE, PHPExcel_Style_Font::UNDERLINE_NONE,
PHPExcel_Style_Font::UNDERLINE_DOUBLE, PHPExcel_Style_Font::UNDERLINE_DOUBLE,
PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING, PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING,
PHPExcel_Style_Font::UNDERLINE_SINGLE, PHPExcel_Style_Font::UNDERLINE_SINGLE,
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING
); );
$verticalAlignmentStyles = array ( $verticalAlignmentStyles = array (
PHPExcel_Style_Alignment::VERTICAL_BOTTOM, PHPExcel_Style_Alignment::VERTICAL_BOTTOM,
PHPExcel_Style_Alignment::VERTICAL_TOP, PHPExcel_Style_Alignment::VERTICAL_TOP,
PHPExcel_Style_Alignment::VERTICAL_CENTER, PHPExcel_Style_Alignment::VERTICAL_CENTER,
PHPExcel_Style_Alignment::VERTICAL_JUSTIFY PHPExcel_Style_Alignment::VERTICAL_JUSTIFY
); );
$horizontalAlignmentStyles = array ( $horizontalAlignmentStyles = array (
PHPExcel_Style_Alignment::HORIZONTAL_GENERAL, PHPExcel_Style_Alignment::HORIZONTAL_GENERAL,
PHPExcel_Style_Alignment::HORIZONTAL_LEFT, PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
PHPExcel_Style_Alignment::HORIZONTAL_RIGHT, PHPExcel_Style_Alignment::HORIZONTAL_RIGHT,
PHPExcel_Style_Alignment::HORIZONTAL_CENTER, PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS, PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS,
PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY
); );
$timezoneObj = new DateTimeZone('Europe/London'); $timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC'); $GMT = new DateTimeZone('UTC');
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
@ -339,40 +338,40 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) { foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
switch ($propertyName) { switch ($propertyName) {
case 'Title' : case 'Title' :
$docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Subject' : case 'Subject' :
$docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Author' : case 'Author' :
$docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Created' : case 'Created' :
$creationDate = strtotime($propertyValue); $creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
break; break;
case 'LastAuthor' : case 'LastAuthor' :
$docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'LastSaved' : case 'LastSaved' :
$lastSaveDate = strtotime($propertyValue); $lastSaveDate = strtotime($propertyValue);
$docProps->setModified($lastSaveDate); $docProps->setModified($lastSaveDate);
break; break;
case 'Company' : case 'Company' :
$docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Category' : case 'Category' :
$docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Manager' : case 'Manager' :
$docProps->setManager(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setManager(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Keywords' : case 'Keywords' :
$docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Description' : case 'Description' :
$docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
} }
} }
} }
@ -421,113 +420,113 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo $styleType.'<br />'; // echo $styleType.'<br />';
switch ($styleType) { switch ($styleType) {
case 'Alignment' : case 'Alignment' :
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue; $styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'Vertical' : case 'Vertical' :
if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) { if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue; $this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
} }
break; break;
case 'Horizontal' : case 'Horizontal' :
if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) { if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue; $this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
} }
break; break;
case 'WrapText' : case 'WrapText' :
$this->_styles[$styleID]['alignment']['wrap'] = true; $this->_styles[$styleID]['alignment']['wrap'] = true;
break; break;
}
} }
break; }
break;
case 'Borders' : case 'Borders' :
foreach ($styleData->Border as $borderStyle) { foreach ($styleData->Border as $borderStyle) {
$borderAttributes = $borderStyle->attributes($namespaces['ss']); $borderAttributes = $borderStyle->attributes($namespaces['ss']);
$thisBorder = array(); $thisBorder = array();
foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) { foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) {
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />'; // echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
switch ($borderStyleKey) { switch ($borderStyleKey) {
case 'LineStyle' : case 'LineStyle' :
$thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; $thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
// $thisBorder['style'] = $borderStyleValue; // $thisBorder['style'] = $borderStyleValue;
break; break;
case 'Weight' : case 'Weight' :
// $thisBorder['style'] = $borderStyleValue; // $thisBorder['style'] = $borderStyleValue;
break; break;
case 'Position' : case 'Position' :
$borderPosition = strtolower($borderStyleValue); $borderPosition = strtolower($borderStyleValue);
break; break;
case 'Color' : case 'Color' :
$borderColour = substr($borderStyleValue,1); $borderColour = substr($borderStyleValue,1);
$thisBorder['color']['rgb'] = $borderColour; $thisBorder['color']['rgb'] = $borderColour;
break; break;
}
}
if (!empty($thisBorder)) {
if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) {
$this->_styles[$styleID]['borders'][$borderPosition] = $thisBorder;
}
} }
} }
break; if (!empty($thisBorder)) {
if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) {
$this->_styles[$styleID]['borders'][$borderPosition] = $thisBorder;
}
}
}
break;
case 'Font' : case 'Font' :
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue; $styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'FontName' : case 'FontName' :
$this->_styles[$styleID]['font']['name'] = $styleAttributeValue; $this->_styles[$styleID]['font']['name'] = $styleAttributeValue;
break; break;
case 'Size' : case 'Size' :
$this->_styles[$styleID]['font']['size'] = $styleAttributeValue; $this->_styles[$styleID]['font']['size'] = $styleAttributeValue;
break; break;
case 'Color' : case 'Color' :
$this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue,1); $this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue,1);
break; break;
case 'Bold' : case 'Bold' :
$this->_styles[$styleID]['font']['bold'] = true; $this->_styles[$styleID]['font']['bold'] = true;
break; break;
case 'Italic' : case 'Italic' :
$this->_styles[$styleID]['font']['italic'] = true; $this->_styles[$styleID]['font']['italic'] = true;
break; break;
case 'Underline' : case 'Underline' :
if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) { if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['font']['underline'] = $styleAttributeValue; $this->_styles[$styleID]['font']['underline'] = $styleAttributeValue;
} }
break; break;
}
} }
break; }
break;
case 'Interior' : case 'Interior' :
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'Color' : case 'Color' :
$this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue,1); $this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue,1);
break; break;
}
} }
break; }
break;
case 'NumberFormat' : case 'NumberFormat' :
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue); $styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue);
switch ($styleAttributeValue) { switch ($styleAttributeValue) {
case 'Short Date' : case 'Short Date' :
$styleAttributeValue = 'dd/mm/yyyy'; $styleAttributeValue = 'dd/mm/yyyy';
break; break;
}
if ($styleAttributeValue > '') {
$this->_styles[$styleID]['numberformat']['code'] = $styleAttributeValue;
}
} }
break; if ($styleAttributeValue > '') {
$this->_styles[$styleID]['numberformat']['code'] = $styleAttributeValue;
}
}
break;
case 'Protection' : case 'Protection' :
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
} }
break; break;
} }
} }
// print_r($this->_styles[$styleID]); // print_r($this->_styles[$styleID]);
@ -588,14 +587,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$columnID = 'A'; $columnID = 'A';
foreach ($rowData->Cell as $cell) { foreach ($rowData->Cell as $cell) {
$cell_ss = $cell->attributes($namespaces['ss']); $cell_ss = $cell->attributes($namespaces['ss']);
if (isset($cell_ss['Index'])) { if (isset($cell_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1); $columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1);
} }
$cellRange = $columnID.$rowID; $cellRange = $columnID.$rowID;
if ($this->getReadFilter() !== NULL) { if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue; continue;
} }
@ -643,27 +641,27 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
const TYPE_ERROR = 'e'; const TYPE_ERROR = 'e';
*/ */
case 'String' : case 'String' :
$cellValue = self::_convertStringEncoding($cellValue, $this->_charSet); $cellValue = self::_convertStringEncoding($cellValue, $this->_charSet);
$type = PHPExcel_Cell_DataType::TYPE_STRING; $type = PHPExcel_Cell_DataType::TYPE_STRING;
break; break;
case 'Number' : case 'Number' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$cellValue = (float) $cellValue; $cellValue = (float) $cellValue;
if (floor($cellValue) == $cellValue) { if (floor($cellValue) == $cellValue) {
$cellValue = (integer) $cellValue; $cellValue = (integer) $cellValue;
} }
break; break;
case 'Boolean' : case 'Boolean' :
$type = PHPExcel_Cell_DataType::TYPE_BOOL; $type = PHPExcel_Cell_DataType::TYPE_BOOL;
$cellValue = ($cellValue != 0); $cellValue = ($cellValue != 0);
break; break;
case 'DateTime' : case 'DateTime' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue)); $cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue));
break; break;
case 'Error' : case 'Error' :
$type = PHPExcel_Cell_DataType::TYPE_ERROR; $type = PHPExcel_Cell_DataType::TYPE_ERROR;
break; break;
} }
} }
@ -700,16 +698,24 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
foreach ($cellReferences as $cellReference) { foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0]; $rowReference = $cellReference[2][0];
// Empty R reference is the current row // Empty R reference is the current row
if ($rowReference == '') $rowReference = $rowID; if ($rowReference == '') {
$rowReference = $rowID;
}
// Bracketed R references are relative to the current row // Bracketed R references are relative to the current row
if ($rowReference{0} == '[') $rowReference = $rowID + trim($rowReference,'[]'); if ($rowReference{0} == '[') {
$rowReference = $rowID + trim($rowReference,'[]');
}
$columnReference = $cellReference[4][0]; $columnReference = $cellReference[4][0];
// Empty C reference is the current column // Empty C reference is the current column
if ($columnReference == '') $columnReference = $columnNumber; if ($columnReference == '') {
$columnReference = $columnNumber;
}
// Bracketed C references are relative to the current column // Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]'); if ($columnReference{0} == '[') {
$columnReference = $columnNumber + trim($columnReference,'[]');
}
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0])); $value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0]));
} }
} }
} }
@ -743,9 +749,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo $annotation,'<br />'; // echo $annotation,'<br />';
$annotation = strip_tags($node); $annotation = strip_tags($node);
// echo 'Annotation: ', $annotation,'<br />'; // echo 'Annotation: ', $annotation,'<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) $objPHPExcel->getActiveSheet()->getComment($columnID.$rowID)->setAuthor(self::_convertStringEncoding($author , $this->_charSet))->setText($this->_parseRichText($annotation) );
->setAuthor(self::_convertStringEncoding($author , $this->_charSet))
->setText($this->_parseRichText($annotation) );
} }
if (($cellIsSet) && (isset($cell_ss['StyleID']))) { if (($cellIsSet) && (isset($cell_ss['StyleID']))) {
@ -756,7 +760,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// print_r($this->_styles[$style]); // print_r($this->_styles[$style]);
// echo '<br />'; // echo '<br />';
if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) { if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(NULL); $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(null);
} }
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]); $objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]);
} }
@ -790,20 +794,21 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
protected static function _convertStringEncoding($string, $charset) { protected static function _convertStringEncoding($string, $charset)
{
if ($charset != 'UTF-8') { if ($charset != 'UTF-8') {
return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8', $charset); return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $charset);
} }
return $string; return $string;
} }
protected function _parseRichText($is = '') { protected function _parseRichText($is = '')
{
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
$value->createText(self::_convertStringEncoding($is, $this->_charSet)); $value->createText(self::_convertStringEncoding($is, $this->_charSet));
return $value; return $value;
} }
} }

View File

@ -28,11 +28,11 @@
class PHPExcel_ReferenceHelper class PHPExcel_ReferenceHelper
{ {
/** Constants */ /** Constants */
/** Regular Expressions */ /** Regular Expressions */
const REFHELPER_REGEXP_CELLREF = '((\w*|\'[^!]*\')!)?(?<![:a-z\$])(\$?[a-z]{1,3}\$?\d+)(?=[^:!\d\'])'; const REFHELPER_REGEXP_CELLREF = '((\w*|\'[^!]*\')!)?(?<![:a-z\$])(\$?[a-z]{1,3}\$?\d+)(?=[^:!\d\'])';
const REFHELPER_REGEXP_CELLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}\$?\d+):(\$?[a-z]{1,3}\$?\d+)'; const REFHELPER_REGEXP_CELLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}\$?\d+):(\$?[a-z]{1,3}\$?\d+)';
const REFHELPER_REGEXP_ROWRANGE = '((\w*|\'[^!]*\')!)?(\$?\d+):(\$?\d+)'; const REFHELPER_REGEXP_ROWRANGE = '((\w*|\'[^!]*\')!)?(\$?\d+):(\$?\d+)';
const REFHELPER_REGEXP_COLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}):(\$?[a-z]{1,3})'; const REFHELPER_REGEXP_COLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}):(\$?[a-z]{1,3})';
/** /**
* Instance of this class * Instance of this class
@ -436,9 +436,7 @@ class PHPExcel_ReferenceHelper
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows); $newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows);
// Should the cell be updated? Move value and cellXf index from one cell to another. // Should the cell be updated? Move value and cellXf index from one cell to another.
if (($cellIndex >= $beforeColumnIndex) && if (($cellIndex >= $beforeColumnIndex) && ($cell->getRow() >= $beforeRow)) {
($cell->getRow() >= $beforeRow)) {
// Update cell styles // Update cell styles
$pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex()); $pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex());
@ -471,7 +469,6 @@ class PHPExcel_ReferenceHelper
if ($pNumCols > 0 && $beforeColumnIndex - 2 > 0) { if ($pNumCols > 0 && $beforeColumnIndex - 2 > 0) {
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) { for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
// Style // Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex($beforeColumnIndex - 2) . $i; $coordinate = PHPExcel_Cell::stringFromColumnIndex($beforeColumnIndex - 2) . $i;
if ($pSheet->cellExists($coordinate)) { if ($pSheet->cellExists($coordinate)) {
@ -495,7 +492,6 @@ class PHPExcel_ReferenceHelper
if ($pNumRows > 0 && $beforeRow - 1 > 0) { if ($pNumRows > 0 && $beforeRow - 1 > 0) {
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) { for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
// Style // Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1); $coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1);
if ($pSheet->cellExists($coordinate)) { if ($pSheet->cellExists($coordinate)) {
@ -547,7 +543,7 @@ class PHPExcel_ReferenceHelper
if ($pNumCols != 0) { if ($pNumCols != 0) {
$autoFilterColumns = array_keys($autoFilter->getColumns()); $autoFilterColumns = array_keys($autoFilter->getColumns());
if (count($autoFilterColumns) > 0) { if (count($autoFilterColumns) > 0) {
sscanf($pBefore,'%[A-Z]%d', $column, $row); sscanf($pBefore, '%[A-Z]%d', $column, $row);
$columnIndex = PHPExcel_Cell::columnIndexFromString($column); $columnIndex = PHPExcel_Cell::columnIndexFromString($column);
list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
if ($columnIndex <= $rangeEnd[0]) { if ($columnIndex <= $rangeEnd[0]) {
@ -577,7 +573,7 @@ class PHPExcel_ReferenceHelper
$toColRef = $rangeEnd[0]+$pNumCols; $toColRef = $rangeEnd[0]+$pNumCols;
do { do {
$autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1),PHPExcel_Cell::stringFromColumnIndex($toColRef-1)); $autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1), PHPExcel_Cell::stringFromColumnIndex($toColRef-1));
--$endColRef; --$endColRef;
--$toColRef; --$toColRef;
} while ($startColRef <= $endColRef); } while ($startColRef <= $endColRef);
@ -661,12 +657,12 @@ class PHPExcel_ReferenceHelper
$modified4 = substr($this->updateCellReference('$A'.$match[4], $pBefore, $pNumCols, $pNumRows), 2); $modified4 = substr($this->updateCellReference('$A'.$match[4], $pBefore, $pNumCols, $pNumRows), 2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) { if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4; $toString .= $modified3.':'.$modified4;
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = 100000; $column = 100000;
$row = 10000000+trim($match[3],'$'); $row = 10000000 + trim($match[3],'$');
$cellIndex = $column.$row; $cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString); $newCellTokens[$cellIndex] = preg_quote($toString);
@ -686,11 +682,11 @@ class PHPExcel_ReferenceHelper
$modified4 = substr($this->updateCellReference($match[4].'$1', $pBefore, $pNumCols, $pNumRows), 0, -2); $modified4 = substr($this->updateCellReference($match[4].'$1', $pBefore, $pNumCols, $pNumRows), 0, -2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) { if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4; $toString .= $modified3.':'.$modified4;
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($match[3],'$')) + 100000; $column = PHPExcel_Cell::columnIndexFromString(trim($match[3], '$')) + 100000;
$row = 10000000; $row = 10000000;
$cellIndex = $column.$row; $cellIndex = $column.$row;
@ -711,13 +707,13 @@ class PHPExcel_ReferenceHelper
$modified4 = $this->updateCellReference($match[4], $pBefore, $pNumCols, $pNumRows); $modified4 = $this->updateCellReference($match[4], $pBefore, $pNumCols, $pNumRows);
if ($match[3].$match[4] !== $modified3.$modified4) { if ($match[3].$match[4] !== $modified3.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4; $toString .= $modified3.':'.$modified4;
list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]); list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000; $column = PHPExcel_Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row,'$') + 10000000; $row = trim($row, '$') + 10000000;
$cellIndex = $column.$row; $cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString); $newCellTokens[$cellIndex] = preg_quote($toString);
@ -737,13 +733,13 @@ class PHPExcel_ReferenceHelper
$modified3 = $this->updateCellReference($match[3], $pBefore, $pNumCols, $pNumRows); $modified3 = $this->updateCellReference($match[3], $pBefore, $pNumCols, $pNumRows);
if ($match[3] !== $modified3) { if ($match[3] !== $modified3) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3; $toString .= $modified3;
list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]); list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000; $column = PHPExcel_Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row,'$') + 10000000; $row = trim($row, '$') + 10000000;
$cellIndex = $row . $column; $cellIndex = $row . $column;
$newCellTokens[$cellIndex] = preg_quote($toString); $newCellTokens[$cellIndex] = preg_quote($toString);
@ -757,11 +753,11 @@ class PHPExcel_ReferenceHelper
if ($pNumCols > 0 || $pNumRows > 0) { if ($pNumCols > 0 || $pNumRows > 0) {
krsort($cellTokens); krsort($cellTokens);
krsort($newCellTokens); krsort($newCellTokens);
} else { } else {
ksort($cellTokens); ksort($cellTokens);
ksort($newCellTokens); ksort($newCellTokens);
} // Update cell references in the formula } // Update cell references in the formula
$formulaBlock = str_replace('\\','',preg_replace($cellTokens, $newCellTokens, $formulaBlock)); $formulaBlock = str_replace('\\', '', preg_replace($cellTokens, $newCellTokens, $formulaBlock));
} }
} }
} }
@ -839,7 +835,7 @@ class PHPExcel_ReferenceHelper
*/ */
private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
{ {
if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) { if (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {
// Update range // Update range
$range = PHPExcel_Cell::splitRange($pCellRange); $range = PHPExcel_Cell::splitRange($pCellRange);
$ic = count($range); $ic = count($range);

View File

@ -196,7 +196,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @var PHPExcel_Worksheet_AutoFilter * @var PHPExcel_Worksheet_AutoFilter
*/ */
private $_autoFilter = NULL; private $_autoFilter = null;
/** /**
* Freeze pane * Freeze pane
@ -334,7 +334,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
{ {
// Set parent and title // Set parent and title
$this->_parent = $pParent; $this->_parent = $pParent;
$this->setTitle($pTitle, FALSE); $this->setTitle($pTitle, false);
// setTitle can change $pTitle // setTitle can change $pTitle
$this->setCodeName($this->getTitle()); $this->setCodeName($this->getTitle());
$this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE); $this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE);
@ -363,12 +363,12 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->_protection = new PHPExcel_Worksheet_Protection(); $this->_protection = new PHPExcel_Worksheet_Protection();
// Default row dimension // Default row dimension
$this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(NULL); $this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(null);
// Default column dimension // Default column dimension
$this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(NULL); $this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(null);
$this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(NULL, $this); $this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(null, $this);
} }
@ -377,10 +377,11 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* typically so that the worksheet object can be unset * typically so that the worksheet object can be unset
* *
*/ */
public function disconnectCells() { public function disconnectCells()
if ( $this->_cellCollection !== NULL) { {
if ($this->_cellCollection !== null) {
$this->_cellCollection->unsetWorksheetCells(); $this->_cellCollection->unsetWorksheetCells();
$this->_cellCollection = NULL; $this->_cellCollection = null;
} }
// detach ourself from the workbook, so that it can then delete this worksheet successfully // detach ourself from the workbook, so that it can then delete this worksheet successfully
$this->_parent = null; $this->_parent = null;
@ -390,9 +391,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* Code to execute when this worksheet is unset() * Code to execute when this worksheet is unset()
* *
*/ */
function __destruct() { function __destruct()
PHPExcel_Calculation::getInstance($this->_parent) {
->clearCalculationCacheForWorksheet($this->_title); PHPExcel_Calculation::getInstance($this->_parent)->clearCalculationCacheForWorksheet($this->_title);
$this->disconnectCells(); $this->disconnectCells();
} }
@ -402,7 +403,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel_CachedObjectStorage_xxx * @return PHPExcel_CachedObjectStorage_xxx
*/ */
public function getCellCacheController() { public function getCellCacheController()
{
return $this->_cellCollection; return $this->_cellCollection;
} // function getCellCacheController() } // function getCellCacheController()
@ -431,17 +433,17 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
throw new PHPExcel_Exception('Sheet code name cannot be empty.'); throw new PHPExcel_Exception('Sheet code name cannot be empty.');
} }
// Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'" // Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'"
if ((str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) || if ((str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) ||
(PHPExcel_Shared_String::Substring($pValue,-1,1)=='\'') || (PHPExcel_Shared_String::Substring($pValue,-1,1)=='\'') ||
(PHPExcel_Shared_String::Substring($pValue,0,1)=='\'')) { (PHPExcel_Shared_String::Substring($pValue,0,1)=='\'')) {
throw new PHPExcel_Exception('Invalid character found in sheet code name'); throw new PHPExcel_Exception('Invalid character found in sheet code name');
} }
// Maximum 31 characters allowed for sheet title // Maximum 31 characters allowed for sheet title
if ($CharCount > 31) { if ($CharCount > 31) {
throw new PHPExcel_Exception('Maximum 31 characters allowed in sheet code name.'); throw new PHPExcel_Exception('Maximum 31 characters allowed in sheet code name.');
} }
return $pValue; return $pValue;
} }
@ -479,7 +481,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Re-order cell collection // Re-order cell collection
return $this->sortCellCollection(); return $this->sortCellCollection();
} }
if ($this->_cellCollection !== NULL) { if ($this->_cellCollection !== null) {
return $this->_cellCollection->getCellList(); return $this->_cellCollection->getCellList();
} }
return array(); return array();
@ -492,7 +494,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function sortCellCollection() public function sortCellCollection()
{ {
if ($this->_cellCollection !== NULL) { if ($this->_cellCollection !== null) {
return $this->_cellCollection->getSortedCellList(); return $this->_cellCollection->getSortedCellList();
} }
return array(); return array();
@ -725,7 +727,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// There is only something to do if there are some auto-size columns // There is only something to do if there are some auto-size columns
if (!empty($autoSizes)) { if (!empty($autoSizes)) {
// build list of cells references that participate in a merge // build list of cells references that participate in a merge
$isMergeCell = array(); $isMergeCell = array();
foreach ($this->getMergeCells() as $cells) { foreach ($this->getMergeCells() as $cells) {
@ -762,7 +763,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// adjust column widths // adjust column widths
foreach ($autoSizes as $columnIndex => $width) { foreach ($autoSizes as $columnIndex => $width) {
if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth(); if ($width == -1) {
$width = $this->getDefaultColumnDimension()->getWidth();
}
$this->getColumnDimension($columnIndex)->setWidth($width); $this->getColumnDimension($columnIndex)->setWidth($width);
} }
} }
@ -775,7 +778,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel * @return PHPExcel
*/ */
public function getParent() { public function getParent()
{
return $this->_parent; return $this->_parent;
} }
@ -785,7 +789,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param PHPExcel $parent * @param PHPExcel $parent
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function rebindParent(PHPExcel $parent) { public function rebindParent(PHPExcel $parent)
{
if ($this->_parent !== null) { if ($this->_parent !== null) {
$namedRanges = $this->_parent->getNamedRanges(); $namedRanges = $this->_parent->getNamedRanges();
foreach ($namedRanges as $namedRange) { foreach ($namedRanges as $namedRange) {
@ -841,18 +846,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Use name, but append with lowest possible integer // Use name, but append with lowest possible integer
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) { if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29); $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 29);
} }
$i = 1; $i = 1;
while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) { while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) {
++$i; ++$i;
if ($i == 10) { if ($i == 10) {
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) { if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,28); $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 28);
} }
} elseif ($i == 100) { } elseif ($i == 100) {
if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) { if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,27); $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 27);
} }
} }
} }
@ -871,8 +876,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$newTitle = $this->getTitle(); $newTitle = $this->getTitle();
PHPExcel_Calculation::getInstance($this->_parent) PHPExcel_Calculation::getInstance($this->_parent)
->renameCalculationCacheForWorksheet($oldTitle, $newTitle); ->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
if ($updateFormulaCellReferences) if ($updateFormulaCellReferences) {
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle); PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle);
}
} }
return $this; return $this;
@ -883,7 +889,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return string Sheet state (visible, hidden, veryHidden) * @return string Sheet state (visible, hidden, veryHidden)
*/ */
public function getSheetState() { public function getSheetState()
{
return $this->_sheetState; return $this->_sheetState;
} }
@ -893,7 +900,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $value Sheet state (visible, hidden, veryHidden) * @param string $value Sheet state (visible, hidden, veryHidden)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) { public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE)
{
$this->_sheetState = $value; $this->_sheetState = $value;
return $this; return $this;
} }
@ -1159,7 +1167,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if ($namedRange !== NULL) { if ($namedRange !== null) {
$pCoordinate = $namedRange->getRange(); $pCoordinate = $namedRange->getRange();
return $namedRange->getWorksheet()->getCell($pCoordinate); return $namedRange->getWorksheet()->getCell($pCoordinate);
} }
@ -1207,36 +1215,33 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
{ {
$cell = $this->_cellCollection->addCacheData( $cell = $this->_cellCollection->addCacheData(
$pCoordinate, $pCoordinate,
new PHPExcel_Cell( new PHPExcel_Cell(null, PHPExcel_Cell_DataType::TYPE_NULL, $this)
NULL,
PHPExcel_Cell_DataType::TYPE_NULL,
$this
)
); );
$this->_cellCollectionIsSorted = false; $this->_cellCollectionIsSorted = false;
// Coordinates // Coordinates
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate); $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) {
$this->_cachedHighestColumn = $aCoordinates[0]; $this->_cachedHighestColumn = $aCoordinates[0];
}
$this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]); $this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]);
// Cell needs appropriate xfIndex from dimensions records // Cell needs appropriate xfIndex from dimensions records
// but don't create dimension records if they don't already exist // but don't create dimension records if they don't already exist
$rowDimension = $this->getRowDimension($aCoordinates[1], FALSE); $rowDimension = $this->getRowDimension($aCoordinates[1], false);
$columnDimension = $this->getColumnDimension($aCoordinates[0], FALSE); $columnDimension = $this->getColumnDimension($aCoordinates[0], false);
if ($rowDimension !== NULL && $rowDimension->getXfIndex() > 0) { if ($rowDimension !== null && $rowDimension->getXfIndex() > 0) {
// then there is a row dimension with explicit style, assign it to the cell // then there is a row dimension with explicit style, assign it to the cell
$cell->setXfIndex($rowDimension->getXfIndex()); $cell->setXfIndex($rowDimension->getXfIndex());
} elseif ($columnDimension !== NULL && $columnDimension->getXfIndex() > 0) { } elseif ($columnDimension !== null && $columnDimension->getXfIndex() > 0) {
// then there is a column dimension, assign it to the cell // then there is a column dimension, assign it to the cell
$cell->setXfIndex($columnDimension->getXfIndex()); $cell->setXfIndex($columnDimension->getXfIndex());
} }
return $cell; return $cell;
} }
/** /**
* Does the cell at a specific coordinate exist? * Does the cell at a specific coordinate exist?
* *
@ -1256,7 +1261,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if ($namedRange !== NULL) { if ($namedRange !== null) {
$pCoordinate = $namedRange->getRange(); $pCoordinate = $namedRange->getRange();
if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) { if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
if (!$namedRange->getLocalOnly()) { if (!$namedRange->getLocalOnly()) {
@ -1265,16 +1270,17 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
throw new PHPExcel_Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle()); throw new PHPExcel_Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
} }
} }
} else {
return false;
} }
else { return false; }
} }
// Uppercase coordinate // Uppercase coordinate
$pCoordinate = strtoupper($pCoordinate); $pCoordinate = strtoupper($pCoordinate);
if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) { if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) {
throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.'); throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.');
} elseif (strpos($pCoordinate,'$') !== false) { } elseif (strpos($pCoordinate, '$') !== false) {
throw new PHPExcel_Exception('Cell coordinate must not be absolute.'); throw new PHPExcel_Exception('Cell coordinate must not be absolute.');
} else { } else {
// Coordinates // Coordinates
@ -1303,15 +1309,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param int $pRow Numeric index of the row * @param int $pRow Numeric index of the row
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function getRowDimension($pRow = 1, $create = TRUE) public function getRowDimension($pRow = 1, $create = true)
{ {
// Found // Found
$found = null; $found = null;
// Get row dimension // Get row dimension
if (!isset($this->_rowDimensions[$pRow])) { if (!isset($this->_rowDimensions[$pRow])) {
if (!$create) if (!$create) {
return NULL; return null;
}
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow); $this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
$this->_cachedHighestRow = max($this->_cachedHighestRow, $pRow); $this->_cachedHighestRow = max($this->_cachedHighestRow, $pRow);
@ -1325,19 +1332,21 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $pColumn String index of the column * @param string $pColumn String index of the column
* @return PHPExcel_Worksheet_ColumnDimension * @return PHPExcel_Worksheet_ColumnDimension
*/ */
public function getColumnDimension($pColumn = 'A', $create = TRUE) public function getColumnDimension($pColumn = 'A', $create = true)
{ {
// Uppercase coordinate // Uppercase coordinate
$pColumn = strtoupper($pColumn); $pColumn = strtoupper($pColumn);
// Fetch dimensions // Fetch dimensions
if (!isset($this->_columnDimensions[$pColumn])) { if (!isset($this->_columnDimensions[$pColumn])) {
if (!$create) if (!$create) {
return NULL; return null;
}
$this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn); $this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn)) if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn)) {
$this->_cachedHighestColumn = $pColumn; $this->_cachedHighestColumn = $pColumn;
}
} }
return $this->_columnDimensions[$pColumn]; return $this->_columnDimensions[$pColumn];
} }
@ -1488,8 +1497,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null) public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null)
{ {
if (!is_null($pColumn2) && !is_null($pRow2)) { if (!is_null($pColumn2) && !is_null($pRow2)) {
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->getStyle($cellRange); return $this->getStyle($cellRange);
} }
@ -1680,7 +1688,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Uppercase coordinate // Uppercase coordinate
$pRange = strtoupper($pRange); $pRange = strtoupper($pRange);
if (strpos($pRange,':') !== false) { if (strpos($pRange, ':') !== false) {
$this->_mergeCells[$pRange] = $pRange; $this->_mergeCells[$pRange] = $pRange;
// make sure cells are created // make sure cells are created
@ -1699,7 +1707,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
for ($i = 1; $i < $count; $i++) { for ($i = 1; $i < $count; $i++) {
$this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL); $this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
} }
} else { } else {
throw new PHPExcel_Exception('Merge must be set on a range of cells.'); throw new PHPExcel_Exception('Merge must be set on a range of cells.');
} }
@ -1735,7 +1742,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Uppercase coordinate // Uppercase coordinate
$pRange = strtoupper($pRange); $pRange = strtoupper($pRange);
if (strpos($pRange,':') !== false) { if (strpos($pRange, ':') !== false) {
if (isset($this->_mergeCells[$pRange])) { if (isset($this->_mergeCells[$pRange])) {
unset($this->_mergeCells[$pRange]); unset($this->_mergeCells[$pRange]);
} else { } else {
@ -1783,7 +1790,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function setMergeCells($pValue = array()) public function setMergeCells($pValue = array())
{ {
$this->_mergeCells = $pValue; $this->_mergeCells = $pValue;
return $this; return $this;
} }
@ -1896,7 +1902,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function setAutoFilter($pValue) public function setAutoFilter($pValue)
{ {
$pRange = strtoupper($pValue); $pRange = strtoupper($pValue);
if (is_string($pValue)) { if (is_string($pValue)) {
$this->_autoFilter->setRange($pValue); $this->_autoFilter->setRange($pValue);
} elseif (is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) { } elseif (is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) {
@ -1931,7 +1936,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function removeAutoFilter() public function removeAutoFilter()
{ {
$this->_autoFilter->setRange(NULL); $this->_autoFilter->setRange(null);
return $this; return $this;
} }
@ -1961,8 +1966,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
{ {
// Uppercase coordinate // Uppercase coordinate
$pCell = strtoupper($pCell); $pCell = strtoupper($pCell);
if (strpos($pCell, ':') === false && strpos($pCell, ',') === false) {
if (strpos($pCell,':') === false && strpos($pCell,',') === false) {
$this->_freezePane = $pCell; $this->_freezePane = $pCell;
} else { } else {
throw new PHPExcel_Exception('Freeze pane can not be set on a range of cells.'); throw new PHPExcel_Exception('Freeze pane can not be set on a range of cells.');
@ -2001,7 +2005,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) { public function insertNewRowBefore($pBefore = 1, $pNumRows = 1)
{
if ($pBefore >= 1) { if ($pBefore >= 1) {
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this); $objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this);
@ -2019,7 +2024,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) { public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1)
{
if (!is_numeric($pBefore)) { if (!is_numeric($pBefore)) {
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this); $objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this);
@ -2037,7 +2043,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) { public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1)
{
if ($pBefore >= 0) { if ($pBefore >= 0) {
return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols); return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols);
} else { } else {
@ -2053,7 +2060,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function removeRow($pRow = 1, $pNumRows = 1) { public function removeRow($pRow = 1, $pNumRows = 1)
{
if ($pRow >= 1) { if ($pRow >= 1) {
$highestRow = $this->getHighestDataRow(); $highestRow = $this->getHighestDataRow();
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
@ -2076,7 +2084,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function removeColumn($pColumn = 'A', $pNumCols = 1) { public function removeColumn($pColumn = 'A', $pNumCols = 1)
{
if (!is_numeric($pColumn)) { if (!is_numeric($pColumn)) {
$highestColumn = $this->getHighestDataColumn(); $highestColumn = $this->getHighestDataColumn();
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols); $pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
@ -2100,7 +2109,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) { public function removeColumnByIndex($pColumn = 0, $pNumCols = 1)
{
if ($pColumn >= 0) { if ($pColumn >= 0) {
return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols); return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols);
} else { } else {
@ -2113,7 +2123,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getShowGridlines() { public function getShowGridlines()
{
return $this->_showGridlines; return $this->_showGridlines;
} }
@ -2123,7 +2134,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show gridlines (true/false) * @param boolean $pValue Show gridlines (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setShowGridlines($pValue = false) { public function setShowGridlines($pValue = false)
{
$this->_showGridlines = $pValue; $this->_showGridlines = $pValue;
return $this; return $this;
} }
@ -2133,7 +2145,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getPrintGridlines() { public function getPrintGridlines()
{
return $this->_printGridlines; return $this->_printGridlines;
} }
@ -2143,7 +2156,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Print gridlines (true/false) * @param boolean $pValue Print gridlines (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setPrintGridlines($pValue = false) { public function setPrintGridlines($pValue = false)
{
$this->_printGridlines = $pValue; $this->_printGridlines = $pValue;
return $this; return $this;
} }
@ -2153,7 +2167,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getShowRowColHeaders() { public function getShowRowColHeaders()
{
return $this->_showRowColHeaders; return $this->_showRowColHeaders;
} }
@ -2163,7 +2178,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show row and column headers (true/false) * @param boolean $pValue Show row and column headers (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setShowRowColHeaders($pValue = false) { public function setShowRowColHeaders($pValue = false)
{
$this->_showRowColHeaders = $pValue; $this->_showRowColHeaders = $pValue;
return $this; return $this;
} }
@ -2173,7 +2189,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getShowSummaryBelow() { public function getShowSummaryBelow()
{
return $this->_showSummaryBelow; return $this->_showSummaryBelow;
} }
@ -2183,7 +2200,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show summary below (true/false) * @param boolean $pValue Show summary below (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setShowSummaryBelow($pValue = true) { public function setShowSummaryBelow($pValue = true)
{
$this->_showSummaryBelow = $pValue; $this->_showSummaryBelow = $pValue;
return $this; return $this;
} }
@ -2193,7 +2211,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getShowSummaryRight() { public function getShowSummaryRight()
{
return $this->_showSummaryRight; return $this->_showSummaryRight;
} }
@ -2203,7 +2222,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show summary right (true/false) * @param boolean $pValue Show summary right (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setShowSummaryRight($pValue = true) { public function setShowSummaryRight($pValue = true)
{
$this->_showSummaryRight = $pValue; $this->_showSummaryRight = $pValue;
return $this; return $this;
} }
@ -2243,9 +2263,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Uppercase coordinate // Uppercase coordinate
$pCellCoordinate = strtoupper($pCellCoordinate); $pCellCoordinate = strtoupper($pCellCoordinate);
if (strpos($pCellCoordinate,':') !== false || strpos($pCellCoordinate,',') !== false) { if (strpos($pCellCoordinate, ':') !== false || strpos($pCellCoordinate, ',') !== false) {
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells.'); throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells.');
} else if (strpos($pCellCoordinate,'$') !== false) { } else if (strpos($pCellCoordinate, '$') !== false) {
throw new PHPExcel_Exception('Cell coordinate string must not be absolute.'); throw new PHPExcel_Exception('Cell coordinate string must not be absolute.');
} else if ($pCellCoordinate == '') { } else if ($pCellCoordinate == '') {
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string.'); throw new PHPExcel_Exception('Cell coordinate can not be zero-length string.');
@ -2340,7 +2360,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Convert '1:3' to 'A1:XFD3' // Convert '1:3' to 'A1:XFD3'
$pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate); $pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate);
if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) { if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) {
list($first, ) = PHPExcel_Cell::splitRange($pCoordinate); list($first, ) = PHPExcel_Cell::splitRange($pCoordinate);
$this->_activeCell = $first[0]; $this->_activeCell = $first[0];
} else { } else {
@ -2368,7 +2388,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getRightToLeft() { public function getRightToLeft()
{
return $this->_rightToLeft; return $this->_rightToLeft;
} }
@ -2378,7 +2399,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $value Right-to-left true/false * @param boolean $value Right-to-left true/false
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setRightToLeft($value = false) { public function setRightToLeft($value = false)
{
$this->_rightToLeft = $value; $this->_rightToLeft = $value;
return $this; return $this;
} }
@ -2393,7 +2415,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) { public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false)
{
if (is_array($source)) { if (is_array($source)) {
// Convert a 1-D array to 2-D (for ease of looping) // Convert a 1-D array to 2-D (for ease of looping)
if (!is_array(end($source))) { if (!is_array(end($source))) {
@ -2439,7 +2462,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* True - Return rows and columns indexed by their actual row and column IDs * True - Return rows and columns indexed by their actual row and column IDs
* @return array * @return array
*/ */
public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
{
// Returnvalue // Returnvalue
$returnValue = array(); $returnValue = array();
// Identify the range that we need to extract from the worksheet // Identify the range that we need to extract from the worksheet
@ -2511,14 +2535,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @return array * @return array
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
{
$namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this); $namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
if ($namedRange !== NULL) { if ($namedRange !== null) {
$pWorkSheet = $namedRange->getWorksheet(); $pWorkSheet = $namedRange->getWorksheet();
$pCellRange = $namedRange->getRange(); $pCellRange = $namedRange->getRange();
return $pWorkSheet->rangeToArray( $pCellRange, return $pWorkSheet->rangeToArray($pCellRange, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
} }
throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.'); throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.');
@ -2535,7 +2559,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* True - Return rows and columns indexed by their actual row and column IDs * True - Return rows and columns indexed by their actual row and column IDs
* @return array * @return array
*/ */
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
{
// Garbage collect... // Garbage collect...
$this->garbageCollect(); $this->garbageCollect();
@ -2543,8 +2568,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$maxCol = $this->getHighestColumn(); $maxCol = $this->getHighestColumn();
$maxRow = $this->getHighestRow(); $maxRow = $this->getHighestRow();
// Return // Return
return $this->rangeToArray( 'A1:'.$maxCol.$maxRow, return $this->rangeToArray('A1:'.$maxCol.$maxRow, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
} }
/** /**
@ -2555,7 +2579,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel_Worksheet_RowIterator * @return PHPExcel_Worksheet_RowIterator
*/ */
public function getRowIterator($startRow = 1, $endRow = null) { public function getRowIterator($startRow = 1, $endRow = null)
{
return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow); return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow);
} }
@ -2567,7 +2592,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel_Worksheet_ColumnIterator * @return PHPExcel_Worksheet_ColumnIterator
*/ */
public function getColumnIterator($startColumn = 'A', $endColumn = null) { public function getColumnIterator($startColumn = 'A', $endColumn = null)
{
return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn); return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn);
} }
@ -2576,7 +2602,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function garbageCollect() { public function garbageCollect()
{
// Flush cache // Flush cache
$this->_cellCollection->getCacheData('A1'); $this->_cellCollection->getCacheData('A1');
// Build a reference table from images // Build a reference table from images
@ -2620,13 +2647,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
if ($this->_dirty) { if ($this->_dirty) {
$this->_hash = md5( $this->_title . $this->_hash = md5($this->_title . $this->_autoFilter . ($this->_protection->isProtectionEnabled() ? 't' : 'f') . __CLASS__);
$this->_autoFilter .
($this->_protection->isProtectionEnabled() ? 't' : 'f') .
__CLASS__
);
$this->_dirty = false; $this->_dirty = false;
} }
return $this->_hash; return $this->_hash;
@ -2642,17 +2666,15 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param bool $returnRange Return range? (see example) * @param bool $returnRange Return range? (see example)
* @return mixed * @return mixed
*/ */
public static function extractSheetTitle($pRange, $returnRange = false) { public static function extractSheetTitle($pRange, $returnRange = false)
{
// Sheet title included? // Sheet title included?
if (($sep = strpos($pRange, '!')) === false) { if (($sep = strpos($pRange, '!')) === false) {
return ''; return '';
} }
if ($returnRange) { if ($returnRange) {
return array( return array(trim(substr($pRange, 0, $sep),"'"), substr($pRange, $sep + 1));
trim(substr($pRange, 0, $sep),"'"),
substr($pRange, $sep + 1)
);
} }
return substr($pRange, $sep + 1); return substr($pRange, $sep + 1);
@ -2774,7 +2796,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $range * @param string $range
* @return string Adjusted range value * @return string Adjusted range value
*/ */
public function shrinkRangeToFit($range) { public function shrinkRangeToFit($range)
{
$maxCol = $this->getHighestColumn(); $maxCol = $this->getHighestColumn();
$maxRow = $this->getHighestRow(); $maxRow = $this->getHighestRow();
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol); $maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
@ -2783,10 +2806,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
foreach ($rangeBlocks as &$rangeSet) { foreach ($rangeBlocks as &$rangeSet) {
$rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet); $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet);
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) {
if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; } $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol);
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } }
if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; } if ($rangeBoundaries[0][1] > $maxRow) {
$rangeBoundaries[0][1] = $maxRow;
}
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) {
$rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol);
}
if ($rangeBoundaries[1][1] > $maxRow) {
$rangeBoundaries[1][1] = $maxRow;
}
$rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1]; $rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1];
} }
unset($rangeSet); unset($rangeSet);
@ -2802,7 +2833,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function getTabColor() public function getTabColor()
{ {
if ($this->_tabColor === NULL) if ($this->_tabColor === null)
$this->_tabColor = new PHPExcel_Style_Color(); $this->_tabColor = new PHPExcel_Style_Color();
return $this->_tabColor; return $this->_tabColor;
@ -2828,7 +2859,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function isTabColorSet() public function isTabColorSet()
{ {
return ($this->_tabColor !== NULL); return ($this->_tabColor !== null);
} }
/** /**
@ -2845,7 +2876,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
foreach ($this as $key => $val) { foreach ($this as $key => $val) {
if ($key == '_parent') { if ($key == '_parent') {
continue; continue;
@ -2876,7 +2908,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @return objWorksheet * @return objWorksheet
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function setCodeName($pValue=null) { public function setCodeName($pValue=null)
{
// Is this a 'rename' or not? // Is this a 'rename' or not?
if ($this->getCodeName() == $pValue) { if ($this->getCodeName() == $pValue) {
return $this; return $this;
@ -2887,7 +2920,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
self::_checkSheetCodeName($pValue); self::_checkSheetCodeName($pValue);
// We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_' // We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_'
if ($this->getParent()) { if ($this->getParent()) {
// Is there already such sheet name? // Is there already such sheet name?
if ($this->getParent()->sheetCodeNameExists($pValue)) { if ($this->getParent()->sheetCodeNameExists($pValue)) {
@ -2924,14 +2957,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return null|string * @return null|string
*/ */
public function getCodeName() { public function getCodeName()
{
return $this->_codeName; return $this->_codeName;
} }
/** /**
* Sheet has a code name ? * Sheet has a code name ?
* @return boolean * @return boolean
*/ */
public function hasCodeName() { public function hasCodeName()
{
return !(is_null($this->_codeName)); return !(is_null($this->_codeName));
} }
} }