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

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText_ITextElement
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -19,46 +20,37 @@
* @category PHPExcel
* @package PHPExcel_RichText
* @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 ##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
{
/**
* Get text
*
* @return string Text
*/
public function getText();
/**
* Get text
*
* @return string Text
*/
public function getText();
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '');
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '');
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont();
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont();
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode();
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode();
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText_Run
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -19,84 +20,79 @@
* @category PHPExcel
* @package PHPExcel_RichText
* @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 ##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
{
/**
* Font
*
* @var PHPExcel_Style_Font
*/
private $_font;
/**
* Font
*
* @var PHPExcel_Style_Font
*/
private $font;
/**
* Create a new PHPExcel_RichText_Run instance
*
* @param string $pText Text
* @param string $pText Text
*/
public function __construct($pText = '')
{
// Initialise variables
$this->setText($pText);
$this->_font = new PHPExcel_Style_Font();
// Initialise variables
$this->setText($pText);
$this->font = new PHPExcel_Style_Font();
}
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont() {
return $this->_font;
}
/**
* Set font
*
* @param PHPExcel_Style_Font $pFont Font
* @throws PHPExcel_Exception
* @return PHPExcel_RichText_ITextElement
*/
public function setFont(PHPExcel_Style_Font $pFont = null) {
$this->_font = $pFont;
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
return md5(
$this->getText()
. $this->_font->getHashCode()
. __CLASS__
);
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont()
{
return $this->font;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Set font
*
* @param PHPExcel_Style_Font $pFont Font
* @throws PHPExcel_Exception
* @return PHPExcel_RichText_ITextElement
*/
public function setFont(PHPExcel_Style_Font $pFont = null)
{
$this->font = $pFont;
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode()
{
return md5(
$this->getText() .
$this->_font->getHashCode() .
__CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText_TextElement
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -19,90 +20,86 @@
* @category PHPExcel
* @package PHPExcel_RichText
* @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 ##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
{
/**
* Text
*
* @var string
*/
private $_text;
/**
* Text
*
* @var string
*/
private $text;
/**
* Create a new PHPExcel_RichText_TextElement instance
*
* @param string $pText Text
* @param string $pText Text
*/
public function __construct($pText = '')
{
// Initialise variables
$this->_text = $pText;
// Initialise variables
$this->text = $pText;
}
/**
* Get text
*
* @return string Text
*/
public function getText() {
return $this->_text;
}
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '') {
$this->_text = $pText;
return $this;
}
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont() {
return null;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
return md5(
$this->_text
. __CLASS__
);
/**
* Get text
*
* @return string Text
*/
public function getText()
{
return $this->text;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '')
{
$this->text = $pText;
return $this;
}
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont()
{
return null;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode()
{
return md5(
$this->_text .
__CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@ -1,6 +1,16 @@
<?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
*
@ -24,38 +34,27 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/** constants */
/** Available Zip library classes */
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
const ZIPARCHIVE = 'ZipArchive';
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
const ZIPARCHIVE = 'ZipArchive';
/** Optional Chart Rendering libraries */
const CHART_RENDERER_JPGRAPH = 'jpgraph';
const CHART_RENDERER_JPGRAPH = 'jpgraph';
/** Optional PDF Rendering libraries */
const PDF_RENDERER_TCPDF = 'tcPDF';
const PDF_RENDERER_DOMPDF = 'DomPDF';
const PDF_RENDERER_MPDF = 'mPDF';
const PDF_RENDERER_TCPDF = 'tcPDF';
const PDF_RENDERER_DOMPDF = 'DomPDF';
const PDF_RENDERER_MPDF = 'mPDF';
private static $_chartRenderers = array(
private static $chartRenderers = array(
self::CHART_RENDERER_JPGRAPH,
);
private static $_pdfRenderers = array(
private static $pdfRenderers = array(
self::PDF_RENDERER_TCPDF,
self::PDF_RENDERER_DOMPDF,
self::PDF_RENDERER_MPDF,
@ -64,84 +63,84 @@ class PHPExcel_Settings
/**
* Name of the class used for Zip file management
* e.g.
* ZipArchive
* e.g.
* ZipArchive
*
* @var string
*/
private static $_zipClass = self::ZIPARCHIVE;
private static $zipClass = self::ZIPARCHIVE;
/**
* Name of the external Library used for rendering charts
* e.g.
* jpgraph
* e.g.
* jpgraph
*
* @var string
*/
private static $_chartRendererName = NULL;
private static $chartRendererName;
/**
* Directory Path to the external Library used for rendering charts
*
* @var string
*/
private static $_chartRendererPath = NULL;
private static $chartRendererPath;
/**
* Name of the external Library used for rendering PDF files
* e.g.
* mPDF
* e.g.
* mPDF
*
* @var string
*/
private static $_pdfRendererName = NULL;
private static $pdfRendererName;
/**
* Directory Path to the external Library used for rendering PDF files
*
* @var string
*/
private static $_pdfRendererPath = NULL;
private static $pdfRendererPath;
/**
* Default options for libxml loader
*
* @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)
*
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
* @return boolean Success or failure
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
* @return boolean Success or failure
*/
public static function setZipClass($zipClass)
{
if (($zipClass === self::PCLZIP) ||
($zipClass === self::ZIPARCHIVE)) {
self::$_zipClass = $zipClass;
return TRUE;
self::$zipClass = $zipClass;
return true;
}
return FALSE;
} // function setZipClass()
return false;
}
/**
* Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
* or Zip file management
* or Zip file management
*
* @return string Name of the Zip handler Class that PHPExcel is configured to use
* for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
* for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
*/
public static function getZipClass()
{
return self::$_zipClass;
} // function getZipClass()
return self::$zipClass;
}
/**
@ -152,7 +151,7 @@ class PHPExcel_Settings
public static function getCacheStorageMethod()
{
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
} // function getCacheStorageMethod()
}
/**
@ -163,7 +162,7 @@ class PHPExcel_Settings
public static function getCacheStorageClass()
{
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
} // function getCacheStorageClass()
}
/**
@ -173,13 +172,10 @@ class PHPExcel_Settings
* @param array $arguments Optional configuration arguments for the cacheing method
* @return boolean Success or failure
*/
public static function setCacheStorageMethod(
$method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
$arguments = array()
)
public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments = array())
{
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
} // function setCacheStorageMethod()
}
/**
@ -188,97 +184,97 @@ class PHPExcel_Settings
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
* @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);
} // function setLocale()
}
/**
* Set details of the external library that PHPExcel should use for rendering charts
*
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* @param string $libraryBaseDir Directory path to the library's base folder
*
* @return boolean Success or failure
* @return boolean Success or failure
*/
public static function setChartRenderer($libraryName, $libraryBaseDir)
{
if (!self::setChartRendererName($libraryName))
return FALSE;
if (!self::setChartRendererName($libraryName)) {
return false;
}
return self::setChartRendererPath($libraryBaseDir);
} // function setChartRenderer()
}
/**
* Identify to PHPExcel the external library to use for rendering charts
*
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
*
* @return boolean Success or failure
* @return boolean Success or failure
*/
public static function setChartRendererName($libraryName)
{
if (!in_array($libraryName,self::$_chartRenderers)) {
return FALSE;
if (!in_array($libraryName, self::$chartRenderers)) {
return false;
}
self::$chartRendererName = $libraryName;
self::$_chartRendererName = $libraryName;
return TRUE;
} // function setChartRendererName()
return true;
}
/**
* Tell PHPExcel where to find the external library to use for rendering charts
*
* @param string $libraryBaseDir Directory path to the library's base folder
* @return boolean Success or failure
* @param string $libraryBaseDir Directory path to the library's base folder
* @return boolean Success or failure
*/
public static function setChartRendererPath($libraryBaseDir)
{
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
return FALSE;
return false;
}
self::$_chartRendererPath = $libraryBaseDir;
self::$chartRendererPath = $libraryBaseDir;
return TRUE;
} // function setChartRendererPath()
return true;
}
/**
* Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph)
*
* @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is
* currently configured to use
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* currently configured to use
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
*/
public static function getChartRendererName()
{
return self::$_chartRendererName;
} // function getChartRendererName()
return self::$chartRendererName;
}
/**
* Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use
*
* @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is
* currently configured to use
* currently configured to use
*/
public static function getChartRendererPath()
{
return self::$_chartRendererPath;
} // function getChartRendererPath()
return self::$chartRendererPath;
}
/**
* Set details of the external library that PHPExcel should use for rendering PDF files
*
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF
* @param string $libraryBaseDir Directory path to the library's base folder
*
@ -286,32 +282,32 @@ class PHPExcel_Settings
*/
public static function setPdfRenderer($libraryName, $libraryBaseDir)
{
if (!self::setPdfRendererName($libraryName))
return FALSE;
if (!self::setPdfRendererName($libraryName)) {
return false;
}
return self::setPdfRendererPath($libraryBaseDir);
} // function setPdfRenderer()
}
/**
* Identify to PHPExcel the external library to use for rendering PDF files
*
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF
*
* @return boolean Success or failure
*/
public static function setPdfRendererName($libraryName)
{
if (!in_array($libraryName,self::$_pdfRenderers)) {
return FALSE;
if (!in_array($libraryName, self::$pdfRenderers)) {
return false;
}
self::$_pdfRendererName = $libraryName;
return TRUE;
} // function setPdfRendererName()
return true;
}
/**
@ -323,38 +319,38 @@ class PHPExcel_Settings
public static function setPdfRendererPath($libraryBaseDir)
{
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
return FALSE;
return false;
}
self::$_pdfRendererPath = $libraryBaseDir;
self::$pdfRendererPath = $libraryBaseDir;
return TRUE;
} // function setPdfRendererPath()
return true;
}
/**
* Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf)
*
* @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is
* currently configured to use
* currently configured to use
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF
*/
public static function getPdfRendererName()
{
return self::$_pdfRendererName;
} // function getPdfRendererName()
return self::$pdfRendererName;
}
/**
* Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
*
* @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is
* currently configured to use
* currently configured to use
*/
public static function getPdfRendererPath()
{
return self::$_pdfRendererPath;
} // function getPdfRendererPath()
return self::$pdfRendererPath;
}
/**
* Set default options for libxml loader
@ -367,10 +363,10 @@ class PHPExcel_Settings
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
}
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
self::$_libXmlLoaderOptions = $options;
} // function setLibXmlLoaderOptions
}
/**
* Get default options for libxml loader.
@ -384,8 +380,8 @@ class PHPExcel_Settings
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
}
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;
} // function getLibXmlLoaderOptions
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_CellIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -21,74 +22,66 @@
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.8.0, 2014-03-02
*/
/**
* 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)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
abstract class PHPExcel_Worksheet_CellIterator
{
/**
* PHPExcel_Worksheet to iterate
*
* @var PHPExcel_Worksheet
*/
protected $_subject;
/**
* PHPExcel_Worksheet to iterate
*
* @var PHPExcel_Worksheet
*/
protected $subject;
/**
* Current iterator position
*
* @var mixed
*/
protected $_position = null;
/**
* Current iterator position
*
* @var mixed
*/
protected $position = null;
/**
* Iterate only existing cells
*
* @var boolean
*/
protected $_onlyExistingCells = false;
/**
* Iterate only existing cells
*
* @var boolean
*/
protected $onlyExistingCells = false;
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
/**
* Get loop only existing cells
*
* @return boolean
*/
public function getIterateOnlyExistingCells() {
return $this->_onlyExistingCells;
/**
* Destructor
*/
public function __destruct()
{
unset($this->subject);
}
/**
* Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
*
/**
* Get loop only existing cells
*
* @return boolean
*/
public function getIterateOnlyExistingCells()
{
return $this->onlyExistingCells;
}
/**
* Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
*
* @throws PHPExcel_Exception
*/
*/
abstract protected function adjustForExistingOnlyRange();
/**
* Set the iterator to loop only existing cells
*
* @param boolean $value
/**
* Set the iterator to loop only existing cells
*
* @param boolean $value
* @throws PHPExcel_Exception
*/
public function setIterateOnlyExistingCells($value = true) {
$this->_onlyExistingCells = (boolean) $value;
*/
public function setIterateOnlyExistingCells($value = true)
{
$this->onlyExistingCells = (boolean) $value;
$this->adjustForExistingOnlyRange();
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_Column
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -21,72 +22,65 @@
* @category PHPExcel
* @package PHPExcel_Worksheet
* @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 ##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
{
/**
* PHPExcel_Worksheet
*
* @var PHPExcel_Worksheet
*/
private $_parent;
/**
* PHPExcel_Worksheet
*
* @var PHPExcel_Worksheet
*/
private $parent;
/**
* Column index
*
* @var string
*/
private $_columnIndex;
/**
* Column index
*
* @var string
*/
private $columnIndex;
/**
* Create a new column
*
* @param PHPExcel_Worksheet $parent
* @param string $columnIndex
*/
public function __construct(PHPExcel_Worksheet $parent = null, $columnIndex = 'A') {
// Set parent and column index
$this->_parent = $parent;
$this->_columnIndex = $columnIndex;
}
/**
* Create a new column
*
* @param PHPExcel_Worksheet $parent
* @param string $columnIndex
*/
public function __construct(PHPExcel_Worksheet $parent = null, $columnIndex = 'A')
{
// Set parent and column index
$this->parent = $parent;
$this->columnIndex = $columnIndex;
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_parent);
}
/**
* Destructor
*/
public function __destruct()
{
unset($this->parent);
}
/**
* Get column index
*
* @return int
*/
public function getColumnIndex() {
return $this->_columnIndex;
}
/**
* Get column index
*
* @return int
*/
public function getColumnIndex()
{
return $this->columnIndex;
}
/**
* Get cell iterator
*
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator
*/
public function getCellIterator($startRow = 1, $endRow = null) {
return new PHPExcel_Worksheet_ColumnCellIterator($this->_parent, $this->_columnIndex, $startRow, $endRow);
}
/**
* Get cell iterator
*
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator
*/
public function getCellIterator($startRow = 1, $endRow = null)
{
return new PHPExcel_Worksheet_ColumnCellIterator($this->parent, $this->columnIndex, $startRow, $endRow);
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_ColumnCellIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -19,197 +20,197 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_ColumnCellIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{
/**
* Column index
*
* @var string
*/
protected $_columnIndex;
/**
* Column index
*
* @var string
*/
protected $columnIndex;
/**
* Start position
*
* @var int
*/
protected $_startRow = 1;
* Start position
*
* @var int
*/
protected $startRow = 1;
/**
* End position
*
* @var int
*/
protected $_endRow = 1;
/**
* End position
*
* @var int
*/
protected $endRow = 1;
/**
* Create a new row iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
/**
* Create a new row iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param string $columnIndex The column that we want to iterate
* @param integer $startRow The row number at which to start 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) {
// Set subject
$this->_subject = $subject;
$this->_columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1;
$this->resetEnd($endRow);
$this->resetStart($startRow);
}
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $columnIndex = 'A', $startRow = 1, $endRow = null)
{
// Set subject
$this->subject = $subject;
$this->columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1;
$this->resetEnd($endRow);
$this->resetStart($startRow);
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
/**
* Destructor
*/
public function __destruct()
{
unset($this->subject);
}
/**
* (Re)Set the start row and the current row pointer
*
* @param integer $startRow The row number at which to start iterating
/**
* (Re)Set the start row and the current row pointer
*
* @param integer $startRow The row number at which to start iterating
* @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception
*/
public function resetStart($startRow = 1) {
$this->_startRow = $startRow;
*/
public function resetStart($startRow = 1)
{
$this->startRow = $startRow;
$this->adjustForExistingOnlyRange();
$this->seek($startRow);
$this->seek($startRow);
return $this;
}
}
/**
* (Re)Set the end row
*
* @param integer $endRow The row number at which to stop iterating
/**
* (Re)Set the end row
*
* @param integer $endRow The row number at which to stop iterating
* @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception
*/
public function resetEnd($endRow = null) {
$this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
*/
public function resetEnd($endRow = null)
{
$this->endRow = ($endRow) ? $endRow : $this->subject->getHighestRow();
$this->adjustForExistingOnlyRange();
return $this;
}
}
/**
* Set the row pointer to the selected row
*
* @param integer $row The row number to set the current pointer at
/**
* Set the row pointer to the selected row
*
* @param integer $row The row number to set the current pointer at
* @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception
*/
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})");
} elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $row))) {
*/
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})");
} elseif ($this->onlyExistingCells && !($this->subject->cellExistsByColumnAndRow($this->columnIndex, $row))) {
throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist');
}
$this->_position = $row;
$this->position = $row;
return $this;
}
}
/**
* Rewind the iterator to the starting row
*/
public function rewind() {
$this->_position = $this->_startRow;
}
/**
* Rewind the iterator to the starting row
*/
public function rewind()
{
$this->position = $this->startRow;
}
/**
* Return the current cell in this worksheet column
*
* @return PHPExcel_Worksheet_Row
*/
public function current() {
return $this->_subject->getCellByColumnAndRow($this->_columnIndex, $this->_position);
}
/**
* Return the current cell in this worksheet column
*
* @return PHPExcel_Worksheet_Row
*/
public function current()
{
return $this->subject->getCellByColumnAndRow($this->columnIndex, $this->position);
}
/**
* Return the current iterator key
*
* @return int
*/
public function key() {
return $this->_position;
}
/**
* Return the current iterator key
*
* @return int
*/
public function key()
{
return $this->position;
}
/**
* Set the iterator to its next value
*/
public function next() {
/**
* Set the iterator to its next value
*/
public function next()
{
do {
++$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) &&
($this->_position <= $this->_endRow));
}
++$this->position;
} while (($this->onlyExistingCells) &&
(!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->position)) &&
($this->position <= $this->endRow));
}
/**
* Set the iterator to its previous value
*/
public function prev() {
if ($this->_position <= $this->_startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})");
/**
* Set the iterator to its previous value
*/
public function prev()
{
if ($this->position <= $this->startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})");
}
do {
--$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) &&
($this->_position >= $this->_startRow));
}
--$this->position;
} while (($this->onlyExistingCells) &&
(!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->position)) &&
($this->position >= $this->startRow));
}
/**
* Indicate if more rows exist in the worksheet range of rows that we're iterating
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endRow;
}
/**
* Indicate if more rows exist in the worksheet range of rows that we're iterating
*
* @return boolean
*/
public function valid()
{
return $this->position <= $this->endRow;
}
/**
* Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
*
/**
* Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
*
* @throws PHPExcel_Exception
*/
protected function adjustForExistingOnlyRange() {
if ($this->_onlyExistingCells) {
while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_startRow)) &&
($this->_startRow <= $this->_endRow)) {
++$this->_startRow;
*/
protected function adjustForExistingOnlyRange()
{
if ($this->onlyExistingCells) {
while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $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');
}
while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_endRow)) &&
($this->_endRow >= $this->_startRow)) {
--$this->_endRow;
while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) &&
($this->endRow >= $this->startRow)) {
--$this->endRow;
}
if ($this->_endRow < $this->_startRow) {
if ($this->endRow < $this->startRow) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
}
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_ColumnDimension
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,67 +25,58 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/**
* Column index
*
* @var int
*/
private $_columnIndex;
/**
* Column index
*
* @var int
*/
private $_columnIndex;
/**
* Column width
*
* When this is set to a negative value, the column width should be ignored by IWriter
*
* @var double
*/
private $_width = -1;
/**
* Column width
*
* When this is set to a negative value, the column width should be ignored by IWriter
*
* @var double
*/
private $_width = -1;
/**
* Auto size?
*
* @var bool
*/
private $_autoSize = false;
/**
* Auto size?
*
* @var bool
*/
private $_autoSize = false;
/**
* Visible?
*
* @var bool
*/
private $_visible = true;
/**
* Visible?
*
* @var bool
*/
private $_visible = true;
/**
* Outline level
*
* @var int
*/
private $_outlineLevel = 0;
/**
* Outline level
*
* @var int
*/
private $_outlineLevel = 0;
/**
* Collapsed
*
* @var bool
*/
private $_collapsed = false;
/**
* Collapsed
*
* @var bool
*/
private $_collapsed = false;
/**
* Index to cellXf
*
* @var int
*/
private $_xfIndex;
/**
* Index to cellXf
*
* @var int
*/
private $_xfIndex;
/**
* Create a new PHPExcel_Worksheet_ColumnDimension
@ -93,11 +85,11 @@ class PHPExcel_Worksheet_ColumnDimension
*/
public function __construct($pIndex = 'A')
{
// Initialise values
$this->_columnIndex = $pIndex;
// Initialise values
$this->_columnIndex = $pIndex;
// set default index to cellXf
$this->_xfIndex = 0;
// set default index to cellXf
$this->_xfIndex = 0;
}
/**
@ -105,8 +97,9 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return string
*/
public function getColumnIndex() {
return $this->_columnIndex;
public function getColumnIndex()
{
return $this->_columnIndex;
}
/**
@ -115,9 +108,10 @@ class PHPExcel_Worksheet_ColumnDimension
* @param string $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setColumnIndex($pValue) {
$this->_columnIndex = $pValue;
return $this;
public function setColumnIndex($pValue)
{
$this->_columnIndex = $pValue;
return $this;
}
/**
@ -125,8 +119,9 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return double
*/
public function getWidth() {
return $this->_width;
public function getWidth()
{
return $this->_width;
}
/**
@ -135,9 +130,10 @@ class PHPExcel_Worksheet_ColumnDimension
* @param double $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setWidth($pValue = -1) {
$this->_width = $pValue;
return $this;
public function setWidth($pValue = -1)
{
$this->_width = $pValue;
return $this;
}
/**
@ -145,8 +141,9 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return bool
*/
public function getAutoSize() {
return $this->_autoSize;
public function getAutoSize()
{
return $this->_autoSize;
}
/**
@ -155,9 +152,10 @@ class PHPExcel_Worksheet_ColumnDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setAutoSize($pValue = false) {
$this->_autoSize = $pValue;
return $this;
public function setAutoSize($pValue = false)
{
$this->_autoSize = $pValue;
return $this;
}
/**
@ -165,8 +163,9 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return bool
*/
public function getVisible() {
return $this->_visible;
public function getVisible()
{
return $this->_visible;
}
/**
@ -175,9 +174,10 @@ class PHPExcel_Worksheet_ColumnDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setVisible($pValue = true) {
$this->_visible = $pValue;
return $this;
public function setVisible($pValue = true)
{
$this->_visible = $pValue;
return $this;
}
/**
@ -185,8 +185,9 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return int
*/
public function getOutlineLevel() {
return $this->_outlineLevel;
public function getOutlineLevel()
{
return $this->_outlineLevel;
}
/**
@ -198,13 +199,14 @@ class PHPExcel_Worksheet_ColumnDimension
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setOutlineLevel($pValue) {
if ($pValue < 0 || $pValue > 7) {
throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
}
public function setOutlineLevel($pValue)
{
if ($pValue < 0 || $pValue > 7) {
throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
}
$this->_outlineLevel = $pValue;
return $this;
$this->_outlineLevel = $pValue;
return $this;
}
/**
@ -212,8 +214,9 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return bool
*/
public function getCollapsed() {
return $this->_collapsed;
public function getCollapsed()
{
return $this->_collapsed;
}
/**
@ -222,45 +225,47 @@ class PHPExcel_Worksheet_ColumnDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setCollapsed($pValue = true) {
$this->_collapsed = $pValue;
return $this;
public function setCollapsed($pValue = true)
{
$this->_collapsed = $pValue;
return $this;
}
/**
* Get index to cellXf
*
* @return int
*/
public function getXfIndex()
{
return $this->_xfIndex;
}
/**
* Get index to cellXf
*
* @return int
*/
public function getXfIndex()
{
return $this->_xfIndex;
}
/**
* Set index to cellXf
*
* @param int $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setXfIndex($pValue = 0)
{
$this->_xfIndex = $pValue;
return $this;
}
/**
* Set index to cellXf
*
* @param int $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setXfIndex($pValue = 0)
{
$this->_xfIndex = $pValue;
return $this;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_ColumnIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -19,174 +20,174 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_ColumnIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Worksheet_ColumnIterator implements Iterator
{
/**
* PHPExcel_Worksheet to iterate
*
* @var PHPExcel_Worksheet
*/
private $_subject;
/**
* PHPExcel_Worksheet to iterate
*
* @var PHPExcel_Worksheet
*/
private $subject;
/**
* Current iterator position
*
* @var int
*/
private $_position = 0;
/**
* Current iterator position
*
* @var int
*/
private $position = 0;
/**
* Start position
*
* @var int
*/
private $_startColumn = 0;
/**
* Start position
*
* @var int
*/
private $startColumn = 0;
/**
* End position
*
* @var int
*/
private $_endColumn = 0;
/**
* End position
*
* @var int
*/
private $endColumn = 0;
/**
* Create a new column iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $startColumn = 'A', $endColumn = null) {
// Set subject
$this->_subject = $subject;
$this->resetEnd($endColumn);
$this->resetStart($startColumn);
}
/**
* Create a new column iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $startColumn = 'A', $endColumn = null)
{
// Set subject
$this->subject = $subject;
$this->resetEnd($endColumn);
$this->resetStart($startColumn);
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
/**
* Destructor
*/
public function __destruct()
{
unset($this->subject);
}
/**
* (Re)Set the start column and the current column pointer
*
* @param integer $startColumn The column address at which to start iterating
/**
* (Re)Set the start column and the current column pointer
*
* @param integer $startColumn The column address at which to start iterating
* @return PHPExcel_Worksheet_ColumnIterator
*/
public function resetStart($startColumn = 'A') {
*/
public function resetStart($startColumn = 'A')
{
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
$this->_startColumn = $startColumnIndex;
$this->seek($startColumn);
return $this;
}
/**
* (Re)Set the end column
*
* @param string $endColumn The column address at which to stop iterating
* @return PHPExcel_Worksheet_ColumnIterator
*/
public function resetEnd($endColumn = null) {
$endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn();
$this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
return $this;
}
/**
* Set the column pointer to the selected column
*
* @param string $column The column address to set the current pointer at
* @return PHPExcel_Worksheet_ColumnIterator
* @throws PHPExcel_Exception
*/
public function seek($column = 'A') {
$column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->_startColumn) || ($column > $this->_endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})");
}
$this->_position = $column;
$this->startColumn = $startColumnIndex;
$this->seek($startColumn);
return $this;
}
/**
* Rewind the iterator to the starting column
*/
public function rewind() {
$this->_position = $this->_startColumn;
}
/**
* (Re)Set the end column
*
* @param string $endColumn The column address at which to stop iterating
* @return PHPExcel_Worksheet_ColumnIterator
*/
public function resetEnd($endColumn = null)
{
$endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn();
$this->endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
/**
* Return the current column in this worksheet
*
* @return PHPExcel_Worksheet_Column
*/
public function current() {
return new PHPExcel_Worksheet_Column($this->_subject, PHPExcel_Cell::stringFromColumnIndex($this->_position));
}
return $this;
}
/**
* Return the current iterator key
*
* @return string
*/
public function key() {
return PHPExcel_Cell::stringFromColumnIndex($this->_position);
}
/**
* Set the column pointer to the selected column
*
* @param string $column The column address to set the current pointer at
* @return PHPExcel_Worksheet_ColumnIterator
* @throws PHPExcel_Exception
*/
public function seek($column = 'A')
{
$column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->startColumn) || ($column > $this->endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->startColumn} - {$this->endColumn})");
}
$this->position = $column;
/**
* Set the iterator to its next value
*/
public function next() {
++$this->_position;
}
return $this;
}
/**
* Set the iterator to its previous value
/**
* Rewind the iterator to the starting column
*/
public function rewind()
{
$this->position = $this->startColumn;
}
/**
* Return the current column in this worksheet
*
* @return PHPExcel_Worksheet_Column
*/
public function current()
{
return new PHPExcel_Worksheet_Column($this->subject, PHPExcel_Cell::stringFromColumnIndex($this->position));
}
/**
* Return the current iterator key
*
* @return string
*/
public function key()
{
return PHPExcel_Cell::stringFromColumnIndex($this->position);
}
/**
* Set the iterator to its next value
*/
public function next()
{
++$this->position;
}
/**
* Set the iterator to its previous value
*
* @throws PHPExcel_Exception
*/
public function prev() {
if ($this->_position <= $this->_startColumn) {
*/
public function prev()
{
if ($this->position <= $this->startColumn) {
throw new PHPExcel_Exception(
"Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")"
"Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . ")"
);
}
--$this->_position;
}
--$this->position;
}
/**
* Indicate if more columns exist in the worksheet range of columns that we're iterating
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endColumn;
}
/**
* Indicate if more columns exist in the worksheet range of columns that we're iterating
*
* @return boolean
*/
public function valid()
{
return $this->position <= $this->endColumn;
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_Row
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -21,72 +22,65 @@
* @category PHPExcel
* @package PHPExcel_Worksheet
* @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 ##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
{
/**
* PHPExcel_Worksheet
*
* @var PHPExcel_Worksheet
*/
private $_parent;
/**
* PHPExcel_Worksheet
*
* @var PHPExcel_Worksheet
*/
private $parent;
/**
* Row index
*
* @var int
*/
private $_rowIndex = 0;
/**
* Row index
*
* @var int
*/
private $rowIndex = 0;
/**
* Create a new row
*
* @param PHPExcel_Worksheet $parent
* @param int $rowIndex
*/
public function __construct(PHPExcel_Worksheet $parent = null, $rowIndex = 1) {
// Set parent and row index
$this->_parent = $parent;
$this->_rowIndex = $rowIndex;
}
/**
* Create a new row
*
* @param PHPExcel_Worksheet $parent
* @param int $rowIndex
*/
public function __construct(PHPExcel_Worksheet $parent = null, $rowIndex = 1)
{
// Set parent and row index
$this->parent = $parent;
$this->rowIndex = $rowIndex;
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_parent);
}
/**
* Destructor
*/
public function __destruct()
{
unset($this->parent);
}
/**
* Get row index
*
* @return int
*/
public function getRowIndex() {
return $this->_rowIndex;
}
/**
* Get row index
*
* @return int
*/
public function getRowIndex()
{
return $this->rowIndex;
}
/**
* Get cell iterator
*
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator
*/
public function getCellIterator($startColumn = 'A', $endColumn = null) {
return new PHPExcel_Worksheet_RowCellIterator($this->_parent, $this->_rowIndex, $startColumn, $endColumn);
}
/**
* Get cell iterator
*
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator
*/
public function getCellIterator($startColumn = 'A', $endColumn = null)
{
return new PHPExcel_Worksheet_RowCellIterator($this->parent, $this->rowIndex, $startColumn, $endColumn);
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_RowCellIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -19,206 +20,206 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_RowCellIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{
/**
* Row index
*
* @var int
*/
protected $_rowIndex;
/**
* Row index
*
* @var int
*/
protected $rowIndex;
/**
* Start position
*
* @var int
*/
protected $_startColumn = 0;
/**
* Start position
*
* @var int
*/
protected $startColumn = 0;
/**
* End position
*
* @var int
*/
protected $_endColumn = 0;
/**
* End position
*
* @var int
*/
protected $endColumn = 0;
/**
* Create a new column iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
/**
* Create a new column iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param integer $rowIndex The row that we want to iterate
* @param string $startColumn The column address at which to start 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) {
// Set subject and row index
$this->_subject = $subject;
$this->_rowIndex = $rowIndex;
$this->resetEnd($endColumn);
$this->resetStart($startColumn);
}
* @param string $startColumn The column address at which to start 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)
{
// Set subject and row index
$this->subject = $subject;
$this->rowIndex = $rowIndex;
$this->resetEnd($endColumn);
$this->resetStart($startColumn);
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
/**
* Destructor
*/
public function __destruct()
{
unset($this->subject);
}
/**
* (Re)Set the start column and the current column pointer
*
* @param integer $startColumn The column address at which to start iterating
/**
* (Re)Set the start column and the current column pointer
*
* @param integer $startColumn The column address at which to start iterating
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function resetStart($startColumn = 'A') {
*/
public function resetStart($startColumn = 'A')
{
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
$this->_startColumn = $startColumnIndex;
$this->startColumn = $startColumnIndex;
$this->adjustForExistingOnlyRange();
$this->seek(PHPExcel_Cell::stringFromColumnIndex($this->_startColumn));
return $this;
}
/**
* (Re)Set the end column
*
* @param string $endColumn The column address at which to stop iterating
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function resetEnd($endColumn = null) {
$endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn();
$this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
$this->adjustForExistingOnlyRange();
return $this;
}
/**
* Set the column pointer to the selected column
*
* @param string $column The column address to set the current pointer at
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function seek($column = 'A') {
$column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->_startColumn) || ($column > $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))) {
throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist');
}
$this->_position = $column;
$this->seek(PHPExcel_Cell::stringFromColumnIndex($this->startColumn));
return $this;
}
/**
* Rewind the iterator to the starting column
*/
public function rewind() {
$this->_position = $this->_startColumn;
}
/**
* (Re)Set the end column
*
* @param string $endColumn The column address at which to stop iterating
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function resetEnd($endColumn = null)
{
$endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn();
$this->endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
$this->adjustForExistingOnlyRange();
/**
* Return the current cell in this worksheet row
*
* @return PHPExcel_Cell
*/
public function current() {
return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
}
return $this;
}
/**
* Return the current iterator key
*
* @return string
*/
public function key() {
return PHPExcel_Cell::stringFromColumnIndex($this->_position);
}
/**
* Set the column pointer to the selected column
*
* @param string $column The column address to set the current pointer at
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function seek($column = 'A')
{
$column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->startColumn) || ($column > $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))) {
throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist');
}
$this->position = $column;
/**
* Set the iterator to its next value
*/
public function next() {
return $this;
}
/**
* Rewind the iterator to the starting column
*/
public function rewind()
{
$this->position = $this->startColumn;
}
/**
* Return the current cell in this worksheet row
*
* @return PHPExcel_Cell
*/
public function current()
{
return $this->subject->getCellByColumnAndRow($this->position, $this->rowIndex);
}
/**
* Return the current iterator key
*
* @return string
*/
public function key()
{
return PHPExcel_Cell::stringFromColumnIndex($this->position);
}
/**
* Set the iterator to its next value
*/
public function next()
{
do {
++$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) &&
($this->_position <= $this->_endColumn));
}
++$this->position;
} while (($this->onlyExistingCells) &&
(!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) &&
($this->position <= $this->endColumn));
}
/**
* Set the iterator to its previous value
/**
* Set the iterator to its previous value
*
* @throws PHPExcel_Exception
*/
public function prev() {
if ($this->_position <= $this->_startColumn) {
*/
public function prev()
{
if ($this->position <= $this->startColumn) {
throw new PHPExcel_Exception(
"Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")"
"Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . ")"
);
}
do {
--$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) &&
($this->_position >= $this->_startColumn));
}
--$this->position;
} while (($this->onlyExistingCells) &&
(!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) &&
($this->position >= $this->startColumn));
}
/**
* Indicate if more columns exist in the worksheet range of columns that we're iterating
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endColumn;
}
/**
* Indicate if more columns exist in the worksheet range of columns that we're iterating
*
* @return boolean
*/
public function valid()
{
return $this->position <= $this->endColumn;
}
/**
* Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
*
/**
* Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
*
* @throws PHPExcel_Exception
*/
protected function adjustForExistingOnlyRange() {
if ($this->_onlyExistingCells) {
while ((!$this->_subject->cellExistsByColumnAndRow($this->_startColumn, $this->_rowIndex)) &&
($this->_startColumn <= $this->_endColumn)) {
++$this->_startColumn;
*/
protected function adjustForExistingOnlyRange()
{
if ($this->onlyExistingCells) {
while ((!$this->subject->cellExistsByColumnAndRow($this->startColumn, $this->rowIndex)) &&
($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');
}
while ((!$this->_subject->cellExistsByColumnAndRow($this->_endColumn, $this->_rowIndex)) &&
($this->_endColumn >= $this->_startColumn)) {
--$this->_endColumn;
while ((!$this->subject->cellExistsByColumnAndRow($this->endColumn, $this->rowIndex)) &&
($this->endColumn >= $this->startColumn)) {
--$this->endColumn;
}
if ($this->_endColumn < $this->_startColumn) {
if ($this->endColumn < $this->startColumn) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
}
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_RowDimension
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -21,70 +22,61 @@
* @category PHPExcel
* @package PHPExcel_Worksheet
* @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 ##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
{
/**
* Row index
*
* @var int
*/
private $_rowIndex;
/**
* Row index
*
* @var int
*/
private $_rowIndex;
/**
* Row height (in pt)
*
* When this is set to a negative value, the row height should be ignored by IWriter
*
* @var double
*/
private $_rowHeight = -1;
/**
* Row height (in pt)
*
* When this is set to a negative value, the row height should be ignored by IWriter
*
* @var double
*/
private $_rowHeight = -1;
/**
* ZeroHeight for Row?
*
* @var bool
*/
private $_zeroHeight = false;
/**
* ZeroHeight for Row?
*
* @var bool
*/
private $_zeroHeight = false;
/**
* Visible?
*
* @var bool
*/
private $_visible = true;
/**
* Visible?
*
* @var bool
*/
private $_visible = true;
/**
* Outline level
*
* @var int
*/
private $_outlineLevel = 0;
/**
* Outline level
*
* @var int
*/
private $_outlineLevel = 0;
/**
* Collapsed
*
* @var bool
*/
private $_collapsed = false;
/**
* Collapsed
*
* @var bool
*/
private $_collapsed = false;
/**
* Index to cellXf. Null value means row has no explicit cellXf format.
*
* @var int|null
*/
private $_xfIndex;
/**
* Index to cellXf. Null value means row has no explicit cellXf format.
*
* @var int|null
*/
private $_xfIndex;
/**
* Create a new PHPExcel_Worksheet_RowDimension
@ -93,11 +85,11 @@ class PHPExcel_Worksheet_RowDimension
*/
public function __construct($pIndex = 0)
{
// Initialise values
$this->_rowIndex = $pIndex;
// Initialise values
$this->_rowIndex = $pIndex;
// set row dimension as unformatted by default
$this->_xfIndex = null;
// set row dimension as unformatted by default
$this->_xfIndex = null;
}
/**
@ -105,8 +97,9 @@ class PHPExcel_Worksheet_RowDimension
*
* @return int
*/
public function getRowIndex() {
return $this->_rowIndex;
public function getRowIndex()
{
return $this->_rowIndex;
}
/**
@ -115,9 +108,10 @@ class PHPExcel_Worksheet_RowDimension
* @param int $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setRowIndex($pValue) {
$this->_rowIndex = $pValue;
return $this;
public function setRowIndex($pValue)
{
$this->_rowIndex = $pValue;
return $this;
}
/**
@ -125,8 +119,9 @@ class PHPExcel_Worksheet_RowDimension
*
* @return double
*/
public function getRowHeight() {
return $this->_rowHeight;
public function getRowHeight()
{
return $this->_rowHeight;
}
/**
@ -135,38 +130,42 @@ class PHPExcel_Worksheet_RowDimension
* @param double $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setRowHeight($pValue = -1) {
$this->_rowHeight = $pValue;
return $this;
public function setRowHeight($pValue = -1)
{
$this->_rowHeight = $pValue;
return $this;
}
/**
* Get ZeroHeight
*
* @return bool
*/
public function getZeroHeight() {
return $this->_zeroHeight;
}
/**
* Get ZeroHeight
*
* @return bool
*/
public function getZeroHeight()
{
return $this->_zeroHeight;
}
/**
* Set ZeroHeight
*
* @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setZeroHeight($pValue = false) {
$this->_zeroHeight = $pValue;
return $this;
}
/**
* Set ZeroHeight
*
* @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setZeroHeight($pValue = false)
{
$this->_zeroHeight = $pValue;
return $this;
}
/**
* Get Visible
*
* @return bool
*/
public function getVisible() {
return $this->_visible;
public function getVisible()
{
return $this->_visible;
}
/**
@ -175,9 +174,10 @@ class PHPExcel_Worksheet_RowDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setVisible($pValue = true) {
$this->_visible = $pValue;
return $this;
public function setVisible($pValue = true)
{
$this->_visible = $pValue;
return $this;
}
/**
@ -185,8 +185,9 @@ class PHPExcel_Worksheet_RowDimension
*
* @return int
*/
public function getOutlineLevel() {
return $this->_outlineLevel;
public function getOutlineLevel()
{
return $this->_outlineLevel;
}
/**
@ -198,13 +199,14 @@ class PHPExcel_Worksheet_RowDimension
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_RowDimension
*/
public function setOutlineLevel($pValue) {
if ($pValue < 0 || $pValue > 7) {
throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
}
public function setOutlineLevel($pValue)
{
if ($pValue < 0 || $pValue > 7) {
throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
}
$this->_outlineLevel = $pValue;
return $this;
$this->_outlineLevel = $pValue;
return $this;
}
/**
@ -212,8 +214,9 @@ class PHPExcel_Worksheet_RowDimension
*
* @return bool
*/
public function getCollapsed() {
return $this->_collapsed;
public function getCollapsed()
{
return $this->_collapsed;
}
/**
@ -222,44 +225,46 @@ class PHPExcel_Worksheet_RowDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setCollapsed($pValue = true) {
$this->_collapsed = $pValue;
return $this;
public function setCollapsed($pValue = true)
{
$this->_collapsed = $pValue;
return $this;
}
/**
* Get index to cellXf
*
* @return int
*/
public function getXfIndex()
{
return $this->_xfIndex;
}
/**
* Get index to cellXf
*
* @return int
*/
public function getXfIndex()
{
return $this->_xfIndex;
}
/**
* Set index to cellXf
*
* @param int $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setXfIndex($pValue = 0)
{
$this->_xfIndex = $pValue;
return $this;
}
/**
* Set index to cellXf
*
* @param int $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setXfIndex($pValue = 0)
{
$this->_xfIndex = $pValue;
return $this;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_RowIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -19,165 +20,165 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_RowIterator
*
* Used to iterate rows in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Worksheet_RowIterator implements Iterator
{
/**
* PHPExcel_Worksheet to iterate
*
* @var PHPExcel_Worksheet
*/
private $_subject;
/**
* PHPExcel_Worksheet to iterate
*
* @var PHPExcel_Worksheet
*/
private $subject;
/**
* Current iterator position
*
* @var int
*/
private $_position = 1;
/**
* Current iterator position
*
* @var int
*/
private $position = 1;
/**
* Start position
*
* @var int
*/
private $_startRow = 1;
/**
* Start position
*
* @var int
*/
private $startRow = 1;
/**
* End position
*
* @var int
*/
private $_endRow = 1;
/**
* End position
*
* @var int
*/
private $endRow = 1;
/**
* Create a new row iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null) {
// Set subject
$this->_subject = $subject;
$this->resetEnd($endRow);
$this->resetStart($startRow);
}
/**
* Create a new row iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null)
{
// Set subject
$this->subject = $subject;
$this->resetEnd($endRow);
$this->resetStart($startRow);
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
/**
* Destructor
*/
public function __destruct()
{
unset($this->subject);
}
/**
* (Re)Set the start row and the current row pointer
*
* @param integer $startRow The row number at which to start iterating
/**
* (Re)Set the start row and the current row pointer
*
* @param integer $startRow The row number at which to start iterating
* @return PHPExcel_Worksheet_RowIterator
*/
public function resetStart($startRow = 1) {
$this->_startRow = $startRow;
$this->seek($startRow);
*/
public function resetStart($startRow = 1)
{
$this->startRow = $startRow;
$this->seek($startRow);
return $this;
}
}
/**
* (Re)Set the end row
*
* @param integer $endRow The row number at which to stop iterating
/**
* (Re)Set the end row
*
* @param integer $endRow The row number at which to stop iterating
* @return PHPExcel_Worksheet_RowIterator
*/
public function resetEnd($endRow = null) {
$this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
*/
public function resetEnd($endRow = null)
{
$this->endRow = ($endRow) ? $endRow : $this->subject->getHighestRow();
return $this;
}
}
/**
* Set the row pointer to the selected row
*
* @param integer $row The row number to set the current pointer at
/**
* Set the row pointer to the selected row
*
* @param integer $row The row number to set the current pointer at
* @return PHPExcel_Worksheet_RowIterator
* @throws PHPExcel_Exception
*/
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})");
*/
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})");
}
$this->_position = $row;
$this->position = $row;
return $this;
}
}
/**
* Rewind the iterator to the starting row
*/
public function rewind() {
$this->_position = $this->_startRow;
}
/**
* Rewind the iterator to the starting row
*/
public function rewind()
{
$this->position = $this->startRow;
}
/**
* Return the current row in this worksheet
*
* @return PHPExcel_Worksheet_Row
*/
public function current() {
return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
}
/**
* Return the current row in this worksheet
*
* @return PHPExcel_Worksheet_Row
*/
public function current()
{
return new PHPExcel_Worksheet_Row($this->subject, $this->position);
}
/**
* Return the current iterator key
*
* @return int
*/
public function key() {
return $this->_position;
}
/**
* Return the current iterator key
*
* @return int
*/
public function key()
{
return $this->position;
}
/**
* Set the iterator to its next value
*/
public function next() {
++$this->_position;
}
/**
* Set the iterator to its next value
*/
public function next()
{
++$this->position;
}
/**
* Set the iterator to its previous value
*/
public function prev() {
if ($this->_position <= $this->_startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})");
/**
* Set the iterator to its previous value
*/
public function prev()
{
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;
}
/**
* Indicate if more rows exist in the worksheet range of rows that we're iterating
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endRow;
}
/**
* Indicate if more rows exist in the worksheet range of rows that we're iterating
*
* @return boolean
*/
public function valid()
{
return $this->position <= $this->endRow;
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_WorksheetIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/**
@ -42,14 +32,14 @@ class PHPExcel_WorksheetIterator implements Iterator
*
* @var PHPExcel
*/
private $_subject;
private $subject;
/**
* Current iterator position
*
* @var int
*/
private $_position = 0;
private $position = 0;
/**
* Create a new worksheet iterator
@ -59,7 +49,7 @@ class PHPExcel_WorksheetIterator implements Iterator
public function __construct(PHPExcel $subject = null)
{
// Set subject
$this->_subject = $subject;
$this->subject = $subject;
}
/**
@ -67,7 +57,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function __destruct()
{
unset($this->_subject);
unset($this->subject);
}
/**
@ -75,7 +65,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function rewind()
{
$this->_position = 0;
$this->position = 0;
}
/**
@ -85,7 +75,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
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()
{
return $this->_position;
return $this->position;
}
/**
@ -103,7 +93,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function next()
{
++$this->_position;
++$this->position;
}
/**
@ -113,6 +103,6 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function valid()
{
return $this->_position < $this->_subject->getSheetCount();
return $this->position < $this->subject->getSheetCount();
}
}