More PSR-2 work

This commit is contained in:
MarkBaker 2015-05-07 01:14:36 +01:00
parent 3c3154c4a3
commit 4f8c9bfc96
15 changed files with 1298 additions and 1340 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_RichText
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_RichText
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText implements PHPExcel_IComparable class PHPExcel_RichText implements PHPExcel_IComparable
{ {
/** /**
@ -40,7 +32,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
* *
* @var PHPExcel_RichText_ITextElement[] * @var PHPExcel_RichText_ITextElement[]
*/ */
private $_richTextElements; private $richTextElements;
/** /**
* Create a new PHPExcel_RichText instance * Create a new PHPExcel_RichText instance
@ -51,10 +43,10 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function __construct(PHPExcel_Cell $pCell = null) public function __construct(PHPExcel_Cell $pCell = null)
{ {
// Initialise variables // Initialise variables
$this->_richTextElements = array(); $this->richTextElements = array();
// Rich-Text string attached to cell? // Rich-Text string attached to cell?
if ($pCell !== NULL) { if ($pCell !== null) {
// Add cell text and style // Add cell text and style
if ($pCell->getValue() != "") { if ($pCell->getValue() != "") {
$objRun = new PHPExcel_RichText_Run($pCell->getValue()); $objRun = new PHPExcel_RichText_Run($pCell->getValue());
@ -76,7 +68,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*/ */
public function addText(PHPExcel_RichText_ITextElement $pText = null) public function addText(PHPExcel_RichText_ITextElement $pText = null)
{ {
$this->_richTextElements[] = $pText; $this->richTextElements[] = $pText;
return $this; return $this;
} }
@ -119,7 +111,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$returnValue = ''; $returnValue = '';
// Loop through all PHPExcel_RichText_ITextElement // Loop through all PHPExcel_RichText_ITextElement
foreach ($this->_richTextElements as $text) { foreach ($this->richTextElements as $text) {
$returnValue .= $text->getText(); $returnValue .= $text->getText();
} }
@ -144,7 +136,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*/ */
public function getRichTextElements() public function getRichTextElements()
{ {
return $this->_richTextElements; return $this->richTextElements;
} }
/** /**
@ -157,7 +149,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function setRichTextElements($pElements = null) public function setRichTextElements($pElements = null)
{ {
if (is_array($pElements)) { if (is_array($pElements)) {
$this->_richTextElements = $pElements; $this->richTextElements = $pElements;
} else { } else {
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
} }
@ -172,13 +164,13 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function getHashCode() public function getHashCode()
{ {
$hashElements = ''; $hashElements = '';
foreach ($this->_richTextElements as $element) { foreach ($this->richTextElements as $element) {
$hashElements .= $element->getHashCode(); $hashElements .= $element->getHashCode();
} }
return md5( return md5(
$hashElements $hashElements .
. __CLASS__ __CLASS__
); );
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_RichText_ITextElement
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -22,15 +23,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_RichText_ITextElement
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_RichText_ITextElement interface PHPExcel_RichText_ITextElement
{ {
/** /**

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_RichText_Run
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -22,15 +23,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_RichText_Run
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{ {
/** /**
@ -38,7 +30,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
* *
* @var PHPExcel_Style_Font * @var PHPExcel_Style_Font
*/ */
private $_font; private $font;
/** /**
* Create a new PHPExcel_RichText_Run instance * Create a new PHPExcel_RichText_Run instance
@ -49,7 +41,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
{ {
// Initialise variables // Initialise variables
$this->setText($pText); $this->setText($pText);
$this->_font = new PHPExcel_Style_Font(); $this->font = new PHPExcel_Style_Font();
} }
/** /**
@ -57,8 +49,9 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
* *
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function getFont() { public function getFont()
return $this->_font; {
return $this->font;
} }
/** /**
@ -68,8 +61,9 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_RichText_ITextElement * @return PHPExcel_RichText_ITextElement
*/ */
public function setFont(PHPExcel_Style_Font $pFont = null) { public function setFont(PHPExcel_Style_Font $pFont = null)
$this->_font = $pFont; {
$this->font = $pFont;
return $this; return $this;
} }
@ -78,18 +72,20 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
return md5( return md5(
$this->getText() $this->getText() .
. $this->_font->getHashCode() $this->_font->getHashCode() .
. __CLASS__ __CLASS__
); );
} }
/** /**
* 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()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_RichText_TextElement
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -22,15 +23,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_RichText_TextElement
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{ {
/** /**
@ -38,7 +30,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* *
* @var string * @var string
*/ */
private $_text; private $text;
/** /**
* Create a new PHPExcel_RichText_TextElement instance * Create a new PHPExcel_RichText_TextElement instance
@ -48,7 +40,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
public function __construct($pText = '') public function __construct($pText = '')
{ {
// Initialise variables // Initialise variables
$this->_text = $pText; $this->text = $pText;
} }
/** /**
@ -56,8 +48,9 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* *
* @return string Text * @return string Text
*/ */
public function getText() { public function getText()
return $this->_text; {
return $this->text;
} }
/** /**
@ -66,8 +59,9 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* @param $pText string Text * @param $pText string Text
* @return PHPExcel_RichText_ITextElement * @return PHPExcel_RichText_ITextElement
*/ */
public function setText($pText = '') { public function setText($pText = '')
$this->_text = $pText; {
$this->text = $pText;
return $this; return $this;
} }
@ -76,7 +70,8 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* *
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function getFont() { public function getFont()
{
return null; return null;
} }
@ -85,17 +80,19 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
return md5( return md5(
$this->_text $this->_text .
. __CLASS__ __CLASS__
); );
} }
/** /**
* 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()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -1,6 +1,16 @@
<?php <?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel * PHPExcel_Settings
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,17 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
class PHPExcel_Settings class PHPExcel_Settings
{ {
/** constants */ /** constants */
@ -51,11 +50,11 @@ class PHPExcel_Settings
const PDF_RENDERER_MPDF = 'mPDF'; const PDF_RENDERER_MPDF = 'mPDF';
private static $_chartRenderers = array( private static $chartRenderers = array(
self::CHART_RENDERER_JPGRAPH, self::CHART_RENDERER_JPGRAPH,
); );
private static $_pdfRenderers = array( private static $pdfRenderers = array(
self::PDF_RENDERER_TCPDF, self::PDF_RENDERER_TCPDF,
self::PDF_RENDERER_DOMPDF, self::PDF_RENDERER_DOMPDF,
self::PDF_RENDERER_MPDF, self::PDF_RENDERER_MPDF,
@ -69,7 +68,7 @@ class PHPExcel_Settings
* *
* @var string * @var string
*/ */
private static $_zipClass = self::ZIPARCHIVE; private static $zipClass = self::ZIPARCHIVE;
/** /**
@ -79,14 +78,14 @@ class PHPExcel_Settings
* *
* @var string * @var string
*/ */
private static $_chartRendererName = NULL; private static $chartRendererName;
/** /**
* Directory Path to the external Library used for rendering charts * Directory Path to the external Library used for rendering charts
* *
* @var string * @var string
*/ */
private static $_chartRendererPath = NULL; private static $chartRendererPath;
/** /**
@ -96,21 +95,21 @@ class PHPExcel_Settings
* *
* @var string * @var string
*/ */
private static $_pdfRendererName = NULL; private static $pdfRendererName;
/** /**
* Directory Path to the external Library used for rendering PDF files * Directory Path to the external Library used for rendering PDF files
* *
* @var string * @var string
*/ */
private static $_pdfRendererPath = NULL; private static $pdfRendererPath;
/** /**
* Default options for libxml loader * Default options for libxml loader
* *
* @var int * @var int
*/ */
private static $_libXmlLoaderOptions = null; private static $libXmlLoaderOptions = null;
/** /**
* Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive) * Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
@ -123,11 +122,11 @@ class PHPExcel_Settings
{ {
if (($zipClass === self::PCLZIP) || if (($zipClass === self::PCLZIP) ||
($zipClass === self::ZIPARCHIVE)) { ($zipClass === self::ZIPARCHIVE)) {
self::$_zipClass = $zipClass; self::$zipClass = $zipClass;
return TRUE; return true;
}
return false;
} }
return FALSE;
} // function setZipClass()
/** /**
@ -140,8 +139,8 @@ class PHPExcel_Settings
*/ */
public static function getZipClass() public static function getZipClass()
{ {
return self::$_zipClass; return self::$zipClass;
} // function getZipClass() }
/** /**
@ -152,7 +151,7 @@ class PHPExcel_Settings
public static function getCacheStorageMethod() public static function getCacheStorageMethod()
{ {
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod(); return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
} // function getCacheStorageMethod() }
/** /**
@ -163,7 +162,7 @@ class PHPExcel_Settings
public static function getCacheStorageClass() public static function getCacheStorageClass()
{ {
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass(); return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
} // function getCacheStorageClass() }
/** /**
@ -173,13 +172,10 @@ class PHPExcel_Settings
* @param array $arguments Optional configuration arguments for the cacheing method * @param array $arguments Optional configuration arguments for the cacheing method
* @return boolean Success or failure * @return boolean Success or failure
*/ */
public static function setCacheStorageMethod( public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments = array())
$method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
$arguments = array()
)
{ {
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments); return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
} // function setCacheStorageMethod() }
/** /**
@ -188,10 +184,10 @@ class PHPExcel_Settings
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk") * @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
* @return boolean Success or failure * @return boolean Success or failure
*/ */
public static function setLocale($locale='en_us') public static function setLocale($locale = 'en_us')
{ {
return PHPExcel_Calculation::getInstance()->setLocale($locale); return PHPExcel_Calculation::getInstance()->setLocale($locale);
} // function setLocale() }
/** /**
@ -205,10 +201,11 @@ class PHPExcel_Settings
*/ */
public static function setChartRenderer($libraryName, $libraryBaseDir) public static function setChartRenderer($libraryName, $libraryBaseDir)
{ {
if (!self::setChartRendererName($libraryName)) if (!self::setChartRendererName($libraryName)) {
return FALSE; return false;
}
return self::setChartRendererPath($libraryBaseDir); return self::setChartRendererPath($libraryBaseDir);
} // function setChartRenderer() }
/** /**
@ -221,14 +218,13 @@ class PHPExcel_Settings
*/ */
public static function setChartRendererName($libraryName) public static function setChartRendererName($libraryName)
{ {
if (!in_array($libraryName,self::$_chartRenderers)) { if (!in_array($libraryName, self::$chartRenderers)) {
return FALSE; return false;
} }
self::$chartRendererName = $libraryName;
self::$_chartRendererName = $libraryName; return true;
}
return TRUE;
} // function setChartRendererName()
/** /**
@ -240,12 +236,12 @@ class PHPExcel_Settings
public static function setChartRendererPath($libraryBaseDir) public static function setChartRendererPath($libraryBaseDir)
{ {
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
return FALSE; return false;
} }
self::$_chartRendererPath = $libraryBaseDir; self::$chartRendererPath = $libraryBaseDir;
return TRUE; return true;
} // function setChartRendererPath() }
/** /**
@ -257,8 +253,8 @@ class PHPExcel_Settings
*/ */
public static function getChartRendererName() public static function getChartRendererName()
{ {
return self::$_chartRendererName; return self::$chartRendererName;
} // function getChartRendererName() }
/** /**
@ -269,8 +265,8 @@ class PHPExcel_Settings
*/ */
public static function getChartRendererPath() public static function getChartRendererPath()
{ {
return self::$_chartRendererPath; return self::$chartRendererPath;
} // function getChartRendererPath() }
/** /**
@ -286,10 +282,11 @@ class PHPExcel_Settings
*/ */
public static function setPdfRenderer($libraryName, $libraryBaseDir) public static function setPdfRenderer($libraryName, $libraryBaseDir)
{ {
if (!self::setPdfRendererName($libraryName)) if (!self::setPdfRendererName($libraryName)) {
return FALSE; return false;
}
return self::setPdfRendererPath($libraryBaseDir); return self::setPdfRendererPath($libraryBaseDir);
} // function setPdfRenderer() }
/** /**
@ -304,14 +301,13 @@ class PHPExcel_Settings
*/ */
public static function setPdfRendererName($libraryName) public static function setPdfRendererName($libraryName)
{ {
if (!in_array($libraryName,self::$_pdfRenderers)) { if (!in_array($libraryName, self::$pdfRenderers)) {
return FALSE; return false;
} }
self::$_pdfRendererName = $libraryName; self::$_pdfRendererName = $libraryName;
return TRUE; return true;
} // function setPdfRendererName() }
/** /**
@ -323,12 +319,12 @@ class PHPExcel_Settings
public static function setPdfRendererPath($libraryBaseDir) public static function setPdfRendererPath($libraryBaseDir)
{ {
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
return FALSE; return false;
} }
self::$_pdfRendererPath = $libraryBaseDir; self::$pdfRendererPath = $libraryBaseDir;
return TRUE; return true;
} // function setPdfRendererPath() }
/** /**
@ -342,8 +338,8 @@ class PHPExcel_Settings
*/ */
public static function getPdfRendererName() public static function getPdfRendererName()
{ {
return self::$_pdfRendererName; return self::$pdfRendererName;
} // function getPdfRendererName() }
/** /**
* Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use * Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
@ -353,8 +349,8 @@ class PHPExcel_Settings
*/ */
public static function getPdfRendererPath() public static function getPdfRendererPath()
{ {
return self::$_pdfRendererPath; return self::$pdfRendererPath;
} // function getPdfRendererPath() }
/** /**
* Set default options for libxml loader * Set default options for libxml loader
@ -370,7 +366,7 @@ class PHPExcel_Settings
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
} }
self::$_libXmlLoaderOptions = $options; self::$_libXmlLoaderOptions = $options;
} // function setLibXmlLoaderOptions }
/** /**
* Get default options for libxml loader. * Get default options for libxml loader.
@ -384,8 +380,8 @@ class PHPExcel_Settings
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR); self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
} }
if (version_compare(PHP_VERSION, '5.2.11') >= 0) { if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); @libxml_disable_entity_loader(self::$libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
} }
return self::$_libXmlLoaderOptions; return self::$_libXmlLoaderOptions;
} // function getLibXmlLoaderOptions }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_CellIterator
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -22,18 +23,7 @@
* @package PHPExcel_Worksheet * @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.8.0, 2014-03-02 * @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_CellIterator
*
* Used to iterate rows in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
abstract class PHPExcel_Worksheet_CellIterator abstract class PHPExcel_Worksheet_CellIterator
{ {
@ -42,27 +32,28 @@ abstract class PHPExcel_Worksheet_CellIterator
* *
* @var PHPExcel_Worksheet * @var PHPExcel_Worksheet
*/ */
protected $_subject; protected $subject;
/** /**
* Current iterator position * Current iterator position
* *
* @var mixed * @var mixed
*/ */
protected $_position = null; protected $position = null;
/** /**
* Iterate only existing cells * Iterate only existing cells
* *
* @var boolean * @var boolean
*/ */
protected $_onlyExistingCells = false; protected $onlyExistingCells = false;
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_subject); {
unset($this->subject);
} }
/** /**
@ -70,8 +61,9 @@ abstract class PHPExcel_Worksheet_CellIterator
* *
* @return boolean * @return boolean
*/ */
public function getIterateOnlyExistingCells() { public function getIterateOnlyExistingCells()
return $this->_onlyExistingCells; {
return $this->onlyExistingCells;
} }
/** /**
@ -87,8 +79,9 @@ abstract class PHPExcel_Worksheet_CellIterator
* @param boolean $value * @param boolean $value
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function setIterateOnlyExistingCells($value = true) { public function setIterateOnlyExistingCells($value = true)
$this->_onlyExistingCells = (boolean) $value; {
$this->onlyExistingCells = (boolean) $value;
$this->adjustForExistingOnlyRange(); $this->adjustForExistingOnlyRange();
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_Column
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_Column
*
* Represents a column in PHPExcel_Worksheet, used by PHPExcel_Worksheet_ColumnIterator
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Column class PHPExcel_Worksheet_Column
{ {
/** /**
@ -42,14 +32,14 @@ class PHPExcel_Worksheet_Column
* *
* @var PHPExcel_Worksheet * @var PHPExcel_Worksheet
*/ */
private $_parent; private $parent;
/** /**
* Column index * Column index
* *
* @var string * @var string
*/ */
private $_columnIndex; private $columnIndex;
/** /**
* Create a new column * Create a new column
@ -57,17 +47,19 @@ class PHPExcel_Worksheet_Column
* @param PHPExcel_Worksheet $parent * @param PHPExcel_Worksheet $parent
* @param string $columnIndex * @param string $columnIndex
*/ */
public function __construct(PHPExcel_Worksheet $parent = null, $columnIndex = 'A') { public function __construct(PHPExcel_Worksheet $parent = null, $columnIndex = 'A')
{
// Set parent and column index // Set parent and column index
$this->_parent = $parent; $this->parent = $parent;
$this->_columnIndex = $columnIndex; $this->columnIndex = $columnIndex;
} }
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_parent); {
unset($this->parent);
} }
/** /**
@ -75,8 +67,9 @@ class PHPExcel_Worksheet_Column
* *
* @return int * @return int
*/ */
public function getColumnIndex() { public function getColumnIndex()
return $this->_columnIndex; {
return $this->columnIndex;
} }
/** /**
@ -86,7 +79,8 @@ class PHPExcel_Worksheet_Column
* @param integer $endRow Optionally, the row number at which to stop iterating * @param integer $endRow Optionally, the row number at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator * @return PHPExcel_Worksheet_CellIterator
*/ */
public function getCellIterator($startRow = 1, $endRow = null) { public function getCellIterator($startRow = 1, $endRow = null)
return new PHPExcel_Worksheet_ColumnCellIterator($this->_parent, $this->_columnIndex, $startRow, $endRow); {
return new PHPExcel_Worksheet_ColumnCellIterator($this->parent, $this->columnIndex, $startRow, $endRow);
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_ColumnCellIterator
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_ColumnCellIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{ {
/** /**
@ -42,21 +32,21 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* *
* @var string * @var string
*/ */
protected $_columnIndex; protected $columnIndex;
/** /**
* Start position * Start position
* *
* @var int * @var int
*/ */
protected $_startRow = 1; protected $startRow = 1;
/** /**
* End position * End position
* *
* @var int * @var int
*/ */
protected $_endRow = 1; protected $endRow = 1;
/** /**
* Create a new row iterator * Create a new row iterator
@ -66,10 +56,11 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* @param integer $startRow The row number at which to start iterating * @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating * @param integer $endRow Optionally, the row number at which to stop iterating
*/ */
public function __construct(PHPExcel_Worksheet $subject = null, $columnIndex, $startRow = 1, $endRow = null) { public function __construct(PHPExcel_Worksheet $subject = null, $columnIndex = 'A', $startRow = 1, $endRow = null)
{
// Set subject // Set subject
$this->_subject = $subject; $this->subject = $subject;
$this->_columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1; $this->columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1;
$this->resetEnd($endRow); $this->resetEnd($endRow);
$this->resetStart($startRow); $this->resetStart($startRow);
} }
@ -77,8 +68,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_subject); {
unset($this->subject);
} }
/** /**
@ -88,8 +80,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* @return PHPExcel_Worksheet_ColumnCellIterator * @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function resetStart($startRow = 1) { public function resetStart($startRow = 1)
$this->_startRow = $startRow; {
$this->startRow = $startRow;
$this->adjustForExistingOnlyRange(); $this->adjustForExistingOnlyRange();
$this->seek($startRow); $this->seek($startRow);
@ -103,8 +96,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* @return PHPExcel_Worksheet_ColumnCellIterator * @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function resetEnd($endRow = null) { public function resetEnd($endRow = null)
$this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow(); {
$this->endRow = ($endRow) ? $endRow : $this->subject->getHighestRow();
$this->adjustForExistingOnlyRange(); $this->adjustForExistingOnlyRange();
return $this; return $this;
@ -117,13 +111,14 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* @return PHPExcel_Worksheet_ColumnCellIterator * @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function seek($row = 1) { public function seek($row = 1)
if (($row < $this->_startRow) || ($row > $this->_endRow)) { {
throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})"); if (($row < $this->startRow) || ($row > $this->endRow)) {
} elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $row))) { throw new PHPExcel_Exception("Row $row is out of range ({$this->startRow} - {$this->endRow})");
} elseif ($this->onlyExistingCells && !($this->subject->cellExistsByColumnAndRow($this->columnIndex, $row))) {
throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist'); throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist');
} }
$this->_position = $row; $this->position = $row;
return $this; return $this;
} }
@ -131,8 +126,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
/** /**
* Rewind the iterator to the starting row * Rewind the iterator to the starting row
*/ */
public function rewind() { public function rewind()
$this->_position = $this->_startRow; {
$this->position = $this->startRow;
} }
/** /**
@ -140,8 +136,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* *
* @return PHPExcel_Worksheet_Row * @return PHPExcel_Worksheet_Row
*/ */
public function current() { public function current()
return $this->_subject->getCellByColumnAndRow($this->_columnIndex, $this->_position); {
return $this->subject->getCellByColumnAndRow($this->columnIndex, $this->position);
} }
/** /**
@ -149,34 +146,37 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* *
* @return int * @return int
*/ */
public function key() { public function key()
return $this->_position; {
return $this->position;
} }
/** /**
* Set the iterator to its next value * Set the iterator to its next value
*/ */
public function next() { public function next()
{
do { do {
++$this->_position; ++$this->position;
} while (($this->_onlyExistingCells) && } while (($this->onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) && (!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->position)) &&
($this->_position <= $this->_endRow)); ($this->position <= $this->endRow));
} }
/** /**
* Set the iterator to its previous value * Set the iterator to its previous value
*/ */
public function prev() { public function prev()
if ($this->_position <= $this->_startRow) { {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})"); if ($this->position <= $this->startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})");
} }
do { do {
--$this->_position; --$this->position;
} while (($this->_onlyExistingCells) && } while (($this->onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) && (!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->position)) &&
($this->_position >= $this->_startRow)); ($this->position >= $this->startRow));
} }
/** /**
@ -184,8 +184,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* *
* @return boolean * @return boolean
*/ */
public function valid() { public function valid()
return $this->_position <= $this->_endRow; {
return $this->position <= $this->endRow;
} }
/** /**
@ -193,23 +194,23 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* *
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
protected function adjustForExistingOnlyRange() { protected function adjustForExistingOnlyRange()
if ($this->_onlyExistingCells) { {
while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_startRow)) && if ($this->onlyExistingCells) {
($this->_startRow <= $this->_endRow)) { while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) &&
++$this->_startRow; ($this->startRow <= $this->endRow)) {
++$this->startRow;
} }
if ($this->_startRow > $this->_endRow) { if ($this->startRow > $this->endRow) {
throw new PHPExcel_Exception('No cells exist within the specified range'); throw new PHPExcel_Exception('No cells exist within the specified range');
} }
while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_endRow)) && while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) &&
($this->_endRow >= $this->_startRow)) { ($this->endRow >= $this->startRow)) {
--$this->_endRow; --$this->endRow;
} }
if ($this->_endRow < $this->_startRow) { if ($this->endRow < $this->startRow) {
throw new PHPExcel_Exception('No cells exist within the specified range'); throw new PHPExcel_Exception('No cells exist within the specified range');
} }
} }
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_ColumnDimension
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_ColumnDimension
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_ColumnDimension class PHPExcel_Worksheet_ColumnDimension
{ {
/** /**
@ -105,7 +97,8 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return string * @return string
*/ */
public function getColumnIndex() { public function getColumnIndex()
{
return $this->_columnIndex; return $this->_columnIndex;
} }
@ -115,7 +108,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param string $pValue * @param string $pValue
* @return PHPExcel_Worksheet_ColumnDimension * @return PHPExcel_Worksheet_ColumnDimension
*/ */
public function setColumnIndex($pValue) { public function setColumnIndex($pValue)
{
$this->_columnIndex = $pValue; $this->_columnIndex = $pValue;
return $this; return $this;
} }
@ -125,7 +119,8 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return double * @return double
*/ */
public function getWidth() { public function getWidth()
{
return $this->_width; return $this->_width;
} }
@ -135,7 +130,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param double $pValue * @param double $pValue
* @return PHPExcel_Worksheet_ColumnDimension * @return PHPExcel_Worksheet_ColumnDimension
*/ */
public function setWidth($pValue = -1) { public function setWidth($pValue = -1)
{
$this->_width = $pValue; $this->_width = $pValue;
return $this; return $this;
} }
@ -145,7 +141,8 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return bool * @return bool
*/ */
public function getAutoSize() { public function getAutoSize()
{
return $this->_autoSize; return $this->_autoSize;
} }
@ -155,7 +152,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param bool $pValue * @param bool $pValue
* @return PHPExcel_Worksheet_ColumnDimension * @return PHPExcel_Worksheet_ColumnDimension
*/ */
public function setAutoSize($pValue = false) { public function setAutoSize($pValue = false)
{
$this->_autoSize = $pValue; $this->_autoSize = $pValue;
return $this; return $this;
} }
@ -165,7 +163,8 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return bool * @return bool
*/ */
public function getVisible() { public function getVisible()
{
return $this->_visible; return $this->_visible;
} }
@ -175,7 +174,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param bool $pValue * @param bool $pValue
* @return PHPExcel_Worksheet_ColumnDimension * @return PHPExcel_Worksheet_ColumnDimension
*/ */
public function setVisible($pValue = true) { public function setVisible($pValue = true)
{
$this->_visible = $pValue; $this->_visible = $pValue;
return $this; return $this;
} }
@ -185,7 +185,8 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return int * @return int
*/ */
public function getOutlineLevel() { public function getOutlineLevel()
{
return $this->_outlineLevel; return $this->_outlineLevel;
} }
@ -198,7 +199,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_ColumnDimension * @return PHPExcel_Worksheet_ColumnDimension
*/ */
public function setOutlineLevel($pValue) { public function setOutlineLevel($pValue)
{
if ($pValue < 0 || $pValue > 7) { if ($pValue < 0 || $pValue > 7) {
throw new PHPExcel_Exception("Outline level must range between 0 and 7."); throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
} }
@ -212,7 +214,8 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return bool * @return bool
*/ */
public function getCollapsed() { public function getCollapsed()
{
return $this->_collapsed; return $this->_collapsed;
} }
@ -222,7 +225,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param bool $pValue * @param bool $pValue
* @return PHPExcel_Worksheet_ColumnDimension * @return PHPExcel_Worksheet_ColumnDimension
*/ */
public function setCollapsed($pValue = true) { public function setCollapsed($pValue = true)
{
$this->_collapsed = $pValue; $this->_collapsed = $pValue;
return $this; return $this;
} }
@ -252,7 +256,8 @@ class PHPExcel_Worksheet_ColumnDimension
/** /**
* 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()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_ColumnIterator
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_ColumnIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_ColumnIterator implements Iterator class PHPExcel_Worksheet_ColumnIterator implements Iterator
{ {
/** /**
@ -42,21 +32,21 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* *
* @var PHPExcel_Worksheet * @var PHPExcel_Worksheet
*/ */
private $_subject; private $subject;
/** /**
* Current iterator position * Current iterator position
* *
* @var int * @var int
*/ */
private $_position = 0; private $position = 0;
/** /**
* Start position * Start position
* *
* @var int * @var int
*/ */
private $_startColumn = 0; private $startColumn = 0;
/** /**
@ -64,7 +54,7 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* *
* @var int * @var int
*/ */
private $_endColumn = 0; private $endColumn = 0;
/** /**
@ -74,9 +64,10 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* @param string $startColumn The column address at which to start iterating * @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating * @param string $endColumn Optionally, the column address at which to stop iterating
*/ */
public function __construct(PHPExcel_Worksheet $subject = null, $startColumn = 'A', $endColumn = null) { public function __construct(PHPExcel_Worksheet $subject = null, $startColumn = 'A', $endColumn = null)
{
// Set subject // Set subject
$this->_subject = $subject; $this->subject = $subject;
$this->resetEnd($endColumn); $this->resetEnd($endColumn);
$this->resetStart($startColumn); $this->resetStart($startColumn);
} }
@ -84,8 +75,9 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_subject); {
unset($this->subject);
} }
/** /**
@ -94,9 +86,10 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* @param integer $startColumn The column address at which to start iterating * @param integer $startColumn The column address at which to start iterating
* @return PHPExcel_Worksheet_ColumnIterator * @return PHPExcel_Worksheet_ColumnIterator
*/ */
public function resetStart($startColumn = 'A') { public function resetStart($startColumn = 'A')
{
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; $startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
$this->_startColumn = $startColumnIndex; $this->startColumn = $startColumnIndex;
$this->seek($startColumn); $this->seek($startColumn);
return $this; return $this;
@ -108,9 +101,10 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* @param string $endColumn The column address at which to stop iterating * @param string $endColumn The column address at which to stop iterating
* @return PHPExcel_Worksheet_ColumnIterator * @return PHPExcel_Worksheet_ColumnIterator
*/ */
public function resetEnd($endColumn = null) { public function resetEnd($endColumn = null)
$endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn(); {
$this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; $endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn();
$this->endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
return $this; return $this;
} }
@ -122,12 +116,13 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* @return PHPExcel_Worksheet_ColumnIterator * @return PHPExcel_Worksheet_ColumnIterator
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function seek($column = 'A') { public function seek($column = 'A')
{
$column = PHPExcel_Cell::columnIndexFromString($column) - 1; $column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->_startColumn) || ($column > $this->_endColumn)) { if (($column < $this->startColumn) || ($column > $this->endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})"); throw new PHPExcel_Exception("Column $column is out of range ({$this->startColumn} - {$this->endColumn})");
} }
$this->_position = $column; $this->position = $column;
return $this; return $this;
} }
@ -135,8 +130,9 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
/** /**
* Rewind the iterator to the starting column * Rewind the iterator to the starting column
*/ */
public function rewind() { public function rewind()
$this->_position = $this->_startColumn; {
$this->position = $this->startColumn;
} }
/** /**
@ -144,8 +140,9 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* *
* @return PHPExcel_Worksheet_Column * @return PHPExcel_Worksheet_Column
*/ */
public function current() { public function current()
return new PHPExcel_Worksheet_Column($this->_subject, PHPExcel_Cell::stringFromColumnIndex($this->_position)); {
return new PHPExcel_Worksheet_Column($this->subject, PHPExcel_Cell::stringFromColumnIndex($this->position));
} }
/** /**
@ -153,15 +150,17 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* *
* @return string * @return string
*/ */
public function key() { public function key()
return PHPExcel_Cell::stringFromColumnIndex($this->_position); {
return PHPExcel_Cell::stringFromColumnIndex($this->position);
} }
/** /**
* Set the iterator to its next value * Set the iterator to its next value
*/ */
public function next() { public function next()
++$this->_position; {
++$this->position;
} }
/** /**
@ -169,16 +168,17 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* *
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function prev() { public function prev()
if ($this->_position <= $this->_startColumn) { {
if ($this->position <= $this->startColumn) {
throw new PHPExcel_Exception( throw new PHPExcel_Exception(
"Column is already at the beginning of range (" . "Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " . PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")" PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . ")"
); );
} }
--$this->_position; --$this->position;
} }
/** /**
@ -186,7 +186,8 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* *
* @return boolean * @return boolean
*/ */
public function valid() { public function valid()
return $this->_position <= $this->_endColumn; {
return $this->position <= $this->endColumn;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_Row
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_Row
*
* Represents a row in PHPExcel_Worksheet, used by PHPExcel_Worksheet_RowIterator
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Row class PHPExcel_Worksheet_Row
{ {
/** /**
@ -42,14 +32,14 @@ class PHPExcel_Worksheet_Row
* *
* @var PHPExcel_Worksheet * @var PHPExcel_Worksheet
*/ */
private $_parent; private $parent;
/** /**
* Row index * Row index
* *
* @var int * @var int
*/ */
private $_rowIndex = 0; private $rowIndex = 0;
/** /**
* Create a new row * Create a new row
@ -57,17 +47,19 @@ class PHPExcel_Worksheet_Row
* @param PHPExcel_Worksheet $parent * @param PHPExcel_Worksheet $parent
* @param int $rowIndex * @param int $rowIndex
*/ */
public function __construct(PHPExcel_Worksheet $parent = null, $rowIndex = 1) { public function __construct(PHPExcel_Worksheet $parent = null, $rowIndex = 1)
{
// Set parent and row index // Set parent and row index
$this->_parent = $parent; $this->parent = $parent;
$this->_rowIndex = $rowIndex; $this->rowIndex = $rowIndex;
} }
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_parent); {
unset($this->parent);
} }
/** /**
@ -75,8 +67,9 @@ class PHPExcel_Worksheet_Row
* *
* @return int * @return int
*/ */
public function getRowIndex() { public function getRowIndex()
return $this->_rowIndex; {
return $this->rowIndex;
} }
/** /**
@ -86,7 +79,8 @@ class PHPExcel_Worksheet_Row
* @param string $endColumn Optionally, the column address at which to stop iterating * @param string $endColumn Optionally, the column address at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator * @return PHPExcel_Worksheet_CellIterator
*/ */
public function getCellIterator($startColumn = 'A', $endColumn = null) { public function getCellIterator($startColumn = 'A', $endColumn = null)
return new PHPExcel_Worksheet_RowCellIterator($this->_parent, $this->_rowIndex, $startColumn, $endColumn); {
return new PHPExcel_Worksheet_RowCellIterator($this->parent, $this->rowIndex, $startColumn, $endColumn);
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_RowCellIterator
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_RowCellIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{ {
/** /**
@ -42,21 +32,21 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* *
* @var int * @var int
*/ */
protected $_rowIndex; protected $rowIndex;
/** /**
* Start position * Start position
* *
* @var int * @var int
*/ */
protected $_startColumn = 0; protected $startColumn = 0;
/** /**
* End position * End position
* *
* @var int * @var int
*/ */
protected $_endColumn = 0; protected $endColumn = 0;
/** /**
* Create a new column iterator * Create a new column iterator
@ -66,10 +56,11 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* @param string $startColumn The column address at which to start iterating * @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating * @param string $endColumn Optionally, the column address at which to stop iterating
*/ */
public function __construct(PHPExcel_Worksheet $subject = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null) { public function __construct(PHPExcel_Worksheet $subject = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null)
{
// Set subject and row index // Set subject and row index
$this->_subject = $subject; $this->subject = $subject;
$this->_rowIndex = $rowIndex; $this->rowIndex = $rowIndex;
$this->resetEnd($endColumn); $this->resetEnd($endColumn);
$this->resetStart($startColumn); $this->resetStart($startColumn);
} }
@ -77,8 +68,9 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_subject); {
unset($this->subject);
} }
/** /**
@ -88,11 +80,12 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* @return PHPExcel_Worksheet_RowCellIterator * @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function resetStart($startColumn = 'A') { public function resetStart($startColumn = 'A')
{
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; $startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
$this->_startColumn = $startColumnIndex; $this->startColumn = $startColumnIndex;
$this->adjustForExistingOnlyRange(); $this->adjustForExistingOnlyRange();
$this->seek(PHPExcel_Cell::stringFromColumnIndex($this->_startColumn)); $this->seek(PHPExcel_Cell::stringFromColumnIndex($this->startColumn));
return $this; return $this;
} }
@ -104,9 +97,10 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* @return PHPExcel_Worksheet_RowCellIterator * @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function resetEnd($endColumn = null) { public function resetEnd($endColumn = null)
$endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn(); {
$this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; $endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn();
$this->endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
$this->adjustForExistingOnlyRange(); $this->adjustForExistingOnlyRange();
return $this; return $this;
@ -119,14 +113,15 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* @return PHPExcel_Worksheet_RowCellIterator * @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function seek($column = 'A') { public function seek($column = 'A')
{
$column = PHPExcel_Cell::columnIndexFromString($column) - 1; $column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->_startColumn) || ($column > $this->_endColumn)) { if (($column < $this->startColumn) || ($column > $this->endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})"); throw new PHPExcel_Exception("Column $column is out of range ({$this->startColumn} - {$this->endColumn})");
} elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($column, $this->_rowIndex))) { } elseif ($this->onlyExistingCells && !($this->subject->cellExistsByColumnAndRow($column, $this->rowIndex))) {
throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist'); throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist');
} }
$this->_position = $column; $this->position = $column;
return $this; return $this;
} }
@ -134,8 +129,9 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
/** /**
* Rewind the iterator to the starting column * Rewind the iterator to the starting column
*/ */
public function rewind() { public function rewind()
$this->_position = $this->_startColumn; {
$this->position = $this->startColumn;
} }
/** /**
@ -143,8 +139,9 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* *
* @return PHPExcel_Cell * @return PHPExcel_Cell
*/ */
public function current() { public function current()
return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex); {
return $this->subject->getCellByColumnAndRow($this->position, $this->rowIndex);
} }
/** /**
@ -152,19 +149,21 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* *
* @return string * @return string
*/ */
public function key() { public function key()
return PHPExcel_Cell::stringFromColumnIndex($this->_position); {
return PHPExcel_Cell::stringFromColumnIndex($this->position);
} }
/** /**
* Set the iterator to its next value * Set the iterator to its next value
*/ */
public function next() { public function next()
{
do { do {
++$this->_position; ++$this->position;
} while (($this->_onlyExistingCells) && } while (($this->onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) && (!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) &&
($this->_position <= $this->_endColumn)); ($this->position <= $this->endColumn));
} }
/** /**
@ -172,20 +171,21 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* *
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function prev() { public function prev()
if ($this->_position <= $this->_startColumn) { {
if ($this->position <= $this->startColumn) {
throw new PHPExcel_Exception( throw new PHPExcel_Exception(
"Column is already at the beginning of range (" . "Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " . PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")" PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . ")"
); );
} }
do { do {
--$this->_position; --$this->position;
} while (($this->_onlyExistingCells) && } while (($this->onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) && (!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) &&
($this->_position >= $this->_startColumn)); ($this->position >= $this->startColumn));
} }
/** /**
@ -193,8 +193,9 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* *
* @return boolean * @return boolean
*/ */
public function valid() { public function valid()
return $this->_position <= $this->_endColumn; {
return $this->position <= $this->endColumn;
} }
/** /**
@ -202,23 +203,23 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* *
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
protected function adjustForExistingOnlyRange() { protected function adjustForExistingOnlyRange()
if ($this->_onlyExistingCells) { {
while ((!$this->_subject->cellExistsByColumnAndRow($this->_startColumn, $this->_rowIndex)) && if ($this->onlyExistingCells) {
($this->_startColumn <= $this->_endColumn)) { while ((!$this->subject->cellExistsByColumnAndRow($this->startColumn, $this->rowIndex)) &&
++$this->_startColumn; ($this->startColumn <= $this->endColumn)) {
++$this->startColumn;
} }
if ($this->_startColumn > $this->_endColumn) { if ($this->startColumn > $this->endColumn) {
throw new PHPExcel_Exception('No cells exist within the specified range'); throw new PHPExcel_Exception('No cells exist within the specified range');
} }
while ((!$this->_subject->cellExistsByColumnAndRow($this->_endColumn, $this->_rowIndex)) && while ((!$this->subject->cellExistsByColumnAndRow($this->endColumn, $this->rowIndex)) &&
($this->_endColumn >= $this->_startColumn)) { ($this->endColumn >= $this->startColumn)) {
--$this->_endColumn; --$this->endColumn;
} }
if ($this->_endColumn < $this->_startColumn) { if ($this->endColumn < $this->startColumn) {
throw new PHPExcel_Exception('No cells exist within the specified range'); throw new PHPExcel_Exception('No cells exist within the specified range');
} }
} }
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_RowDimension
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_RowDimension
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_RowDimension class PHPExcel_Worksheet_RowDimension
{ {
/** /**
@ -105,7 +97,8 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return int * @return int
*/ */
public function getRowIndex() { public function getRowIndex()
{
return $this->_rowIndex; return $this->_rowIndex;
} }
@ -115,7 +108,8 @@ class PHPExcel_Worksheet_RowDimension
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function setRowIndex($pValue) { public function setRowIndex($pValue)
{
$this->_rowIndex = $pValue; $this->_rowIndex = $pValue;
return $this; return $this;
} }
@ -125,7 +119,8 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return double * @return double
*/ */
public function getRowHeight() { public function getRowHeight()
{
return $this->_rowHeight; return $this->_rowHeight;
} }
@ -135,7 +130,8 @@ class PHPExcel_Worksheet_RowDimension
* @param double $pValue * @param double $pValue
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function setRowHeight($pValue = -1) { public function setRowHeight($pValue = -1)
{
$this->_rowHeight = $pValue; $this->_rowHeight = $pValue;
return $this; return $this;
} }
@ -145,7 +141,8 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return bool * @return bool
*/ */
public function getZeroHeight() { public function getZeroHeight()
{
return $this->_zeroHeight; return $this->_zeroHeight;
} }
@ -155,7 +152,8 @@ class PHPExcel_Worksheet_RowDimension
* @param bool $pValue * @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function setZeroHeight($pValue = false) { public function setZeroHeight($pValue = false)
{
$this->_zeroHeight = $pValue; $this->_zeroHeight = $pValue;
return $this; return $this;
} }
@ -165,7 +163,8 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return bool * @return bool
*/ */
public function getVisible() { public function getVisible()
{
return $this->_visible; return $this->_visible;
} }
@ -175,7 +174,8 @@ class PHPExcel_Worksheet_RowDimension
* @param bool $pValue * @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function setVisible($pValue = true) { public function setVisible($pValue = true)
{
$this->_visible = $pValue; $this->_visible = $pValue;
return $this; return $this;
} }
@ -185,7 +185,8 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return int * @return int
*/ */
public function getOutlineLevel() { public function getOutlineLevel()
{
return $this->_outlineLevel; return $this->_outlineLevel;
} }
@ -198,7 +199,8 @@ class PHPExcel_Worksheet_RowDimension
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function setOutlineLevel($pValue) { public function setOutlineLevel($pValue)
{
if ($pValue < 0 || $pValue > 7) { if ($pValue < 0 || $pValue > 7) {
throw new PHPExcel_Exception("Outline level must range between 0 and 7."); throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
} }
@ -212,7 +214,8 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return bool * @return bool
*/ */
public function getCollapsed() { public function getCollapsed()
{
return $this->_collapsed; return $this->_collapsed;
} }
@ -222,7 +225,8 @@ class PHPExcel_Worksheet_RowDimension
* @param bool $pValue * @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function setCollapsed($pValue = true) { public function setCollapsed($pValue = true)
{
$this->_collapsed = $pValue; $this->_collapsed = $pValue;
return $this; return $this;
} }
@ -252,7 +256,8 @@ class PHPExcel_Worksheet_RowDimension
/** /**
* 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()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_RowIterator
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_RowIterator
*
* Used to iterate rows in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_RowIterator implements Iterator class PHPExcel_Worksheet_RowIterator implements Iterator
{ {
/** /**
@ -42,21 +32,21 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* *
* @var PHPExcel_Worksheet * @var PHPExcel_Worksheet
*/ */
private $_subject; private $subject;
/** /**
* Current iterator position * Current iterator position
* *
* @var int * @var int
*/ */
private $_position = 1; private $position = 1;
/** /**
* Start position * Start position
* *
* @var int * @var int
*/ */
private $_startRow = 1; private $startRow = 1;
/** /**
@ -64,7 +54,7 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* *
* @var int * @var int
*/ */
private $_endRow = 1; private $endRow = 1;
/** /**
@ -74,9 +64,10 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* @param integer $startRow The row number at which to start iterating * @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating * @param integer $endRow Optionally, the row number at which to stop iterating
*/ */
public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null) { public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null)
{
// Set subject // Set subject
$this->_subject = $subject; $this->subject = $subject;
$this->resetEnd($endRow); $this->resetEnd($endRow);
$this->resetStart($startRow); $this->resetStart($startRow);
} }
@ -84,8 +75,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_subject); {
unset($this->subject);
} }
/** /**
@ -94,8 +86,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* @param integer $startRow The row number at which to start iterating * @param integer $startRow The row number at which to start iterating
* @return PHPExcel_Worksheet_RowIterator * @return PHPExcel_Worksheet_RowIterator
*/ */
public function resetStart($startRow = 1) { public function resetStart($startRow = 1)
$this->_startRow = $startRow; {
$this->startRow = $startRow;
$this->seek($startRow); $this->seek($startRow);
return $this; return $this;
@ -107,8 +100,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* @param integer $endRow The row number at which to stop iterating * @param integer $endRow The row number at which to stop iterating
* @return PHPExcel_Worksheet_RowIterator * @return PHPExcel_Worksheet_RowIterator
*/ */
public function resetEnd($endRow = null) { public function resetEnd($endRow = null)
$this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow(); {
$this->endRow = ($endRow) ? $endRow : $this->subject->getHighestRow();
return $this; return $this;
} }
@ -120,11 +114,12 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* @return PHPExcel_Worksheet_RowIterator * @return PHPExcel_Worksheet_RowIterator
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function seek($row = 1) { public function seek($row = 1)
if (($row < $this->_startRow) || ($row > $this->_endRow)) { {
throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})"); if (($row < $this->startRow) || ($row > $this->endRow)) {
throw new PHPExcel_Exception("Row $row is out of range ({$this->startRow} - {$this->endRow})");
} }
$this->_position = $row; $this->position = $row;
return $this; return $this;
} }
@ -132,8 +127,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
/** /**
* Rewind the iterator to the starting row * Rewind the iterator to the starting row
*/ */
public function rewind() { public function rewind()
$this->_position = $this->_startRow; {
$this->position = $this->startRow;
} }
/** /**
@ -141,8 +137,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* *
* @return PHPExcel_Worksheet_Row * @return PHPExcel_Worksheet_Row
*/ */
public function current() { public function current()
return new PHPExcel_Worksheet_Row($this->_subject, $this->_position); {
return new PHPExcel_Worksheet_Row($this->subject, $this->position);
} }
/** /**
@ -150,26 +147,29 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* *
* @return int * @return int
*/ */
public function key() { public function key()
return $this->_position; {
return $this->position;
} }
/** /**
* Set the iterator to its next value * Set the iterator to its next value
*/ */
public function next() { public function next()
++$this->_position; {
++$this->position;
} }
/** /**
* Set the iterator to its previous value * Set the iterator to its previous value
*/ */
public function prev() { public function prev()
if ($this->_position <= $this->_startRow) { {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})"); if ($this->position <= $this->startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})");
} }
--$this->_position; --$this->position;
} }
/** /**
@ -177,7 +177,8 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* *
* @return boolean * @return boolean
*/ */
public function valid() { public function valid()
return $this->_position <= $this->_endRow; {
return $this->position <= $this->endRow;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_WorksheetIterator
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_WorksheetIterator
*
* Used to iterate worksheets in PHPExcel
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_WorksheetIterator implements Iterator class PHPExcel_WorksheetIterator implements Iterator
{ {
/** /**
@ -42,14 +32,14 @@ class PHPExcel_WorksheetIterator implements Iterator
* *
* @var PHPExcel * @var PHPExcel
*/ */
private $_subject; private $subject;
/** /**
* Current iterator position * Current iterator position
* *
* @var int * @var int
*/ */
private $_position = 0; private $position = 0;
/** /**
* Create a new worksheet iterator * Create a new worksheet iterator
@ -59,7 +49,7 @@ class PHPExcel_WorksheetIterator implements Iterator
public function __construct(PHPExcel $subject = null) public function __construct(PHPExcel $subject = null)
{ {
// Set subject // Set subject
$this->_subject = $subject; $this->subject = $subject;
} }
/** /**
@ -67,7 +57,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/ */
public function __destruct() public function __destruct()
{ {
unset($this->_subject); unset($this->subject);
} }
/** /**
@ -75,7 +65,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/ */
public function rewind() public function rewind()
{ {
$this->_position = 0; $this->position = 0;
} }
/** /**
@ -85,7 +75,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/ */
public function current() public function current()
{ {
return $this->_subject->getSheet($this->_position); return $this->subject->getSheet($this->position);
} }
/** /**
@ -95,7 +85,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/ */
public function key() public function key()
{ {
return $this->_position; return $this->position;
} }
/** /**
@ -103,7 +93,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/ */
public function next() public function next()
{ {
++$this->_position; ++$this->position;
} }
/** /**
@ -113,6 +103,6 @@ class PHPExcel_WorksheetIterator implements Iterator
*/ */
public function valid() public function valid()
{ {
return $this->_position < $this->_subject->getSheetCount(); return $this->position < $this->subject->getSheetCount();
} }
} }