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
@ -19,46 +20,37 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_RichText * @package PHPExcel_RichText
* @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 ##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
{ {
/** /**
* Get text * Get text
* *
* @return string Text * @return string Text
*/ */
public function getText(); public function getText();
/** /**
* Set text * Set text
* *
* @param $pText string Text * @param $pText string Text
* @return PHPExcel_RichText_ITextElement * @return PHPExcel_RichText_ITextElement
*/ */
public function setText($pText = ''); public function setText($pText = '');
/** /**
* Get font * Get font
* *
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function getFont(); public function getFont();
/** /**
* Get hash code * Get hash code
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode(); public function getHashCode();
} }

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
@ -19,84 +20,79 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_RichText * @package PHPExcel_RichText
* @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 ##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
{ {
/** /**
* Font * Font
* *
* @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
* *
* @param string $pText Text * @param string $pText Text
*/ */
public function __construct($pText = '') public function __construct($pText = '')
{ {
// Initialise variables // Initialise variables
$this->setText($pText); $this->setText($pText);
$this->_font = new PHPExcel_Style_Font(); $this->font = new PHPExcel_Style_Font();
} }
/** /**
* Get font * Get font
* *
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function getFont() { public function getFont()
return $this->_font; {
} 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__
);
} }
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Set font
*/ *
public function __clone() { * @param PHPExcel_Style_Font $pFont Font
$vars = get_object_vars($this); * @throws PHPExcel_Exception
foreach ($vars as $key => $value) { * @return PHPExcel_RichText_ITextElement
if (is_object($value)) { */
$this->$key = clone $value; public function setFont(PHPExcel_Style_Font $pFont = null)
} else { {
$this->$key = $value; $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 <?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
@ -19,90 +20,86 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_RichText * @package PHPExcel_RichText
* @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 ##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
{ {
/** /**
* Text * Text
* *
* @var string * @var string
*/ */
private $_text; private $text;
/** /**
* Create a new PHPExcel_RichText_TextElement instance * Create a new PHPExcel_RichText_TextElement instance
* *
* @param string $pText Text * @param string $pText Text
*/ */
public function __construct($pText = '') public function __construct($pText = '')
{ {
// Initialise variables // Initialise variables
$this->_text = $pText; $this->text = $pText;
} }
/** /**
* Get text * Get text
* *
* @return string Text * @return string Text
*/ */
public function getText() { public function getText()
return $this->_text; {
} 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__
);
} }
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Set text
*/ *
public function __clone() { * @param $pText string Text
$vars = get_object_vars($this); * @return PHPExcel_RichText_ITextElement
foreach ($vars as $key => $value) { */
if (is_object($value)) { public function setText($pText = '')
$this->$key = clone $value; {
} else { $this->text = $pText;
$this->$key = $value; 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 <?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,38 +34,27 @@
* @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 */
/** Available Zip library classes */ /** Available Zip library classes */
const PCLZIP = 'PHPExcel_Shared_ZipArchive'; const PCLZIP = 'PHPExcel_Shared_ZipArchive';
const ZIPARCHIVE = 'ZipArchive'; const ZIPARCHIVE = 'ZipArchive';
/** Optional Chart Rendering libraries */ /** Optional Chart Rendering libraries */
const CHART_RENDERER_JPGRAPH = 'jpgraph'; const CHART_RENDERER_JPGRAPH = 'jpgraph';
/** Optional PDF Rendering libraries */ /** Optional PDF Rendering libraries */
const PDF_RENDERER_TCPDF = 'tcPDF'; const PDF_RENDERER_TCPDF = 'tcPDF';
const PDF_RENDERER_DOMPDF = 'DomPDF'; const PDF_RENDERER_DOMPDF = 'DomPDF';
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,
@ -64,84 +63,84 @@ class PHPExcel_Settings
/** /**
* Name of the class used for Zip file management * Name of the class used for Zip file management
* e.g. * e.g.
* ZipArchive * ZipArchive
* *
* @var string * @var string
*/ */
private static $_zipClass = self::ZIPARCHIVE; private static $zipClass = self::ZIPARCHIVE;
/** /**
* Name of the external Library used for rendering charts * Name of the external Library used for rendering charts
* e.g. * e.g.
* jpgraph * jpgraph
* *
* @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;
/** /**
* Name of the external Library used for rendering PDF files * Name of the external Library used for rendering PDF files
* e.g. * e.g.
* mPDF * mPDF
* *
* @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)
* *
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management * @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
* @return boolean Success or failure * @return boolean Success or failure
*/ */
public static function setZipClass($zipClass) public static function setZipClass($zipClass)
{ {
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() }
/** /**
* Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive) * 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 * @return string Name of the Zip handler Class that PHPExcel is configured to use
* for Zip file management * for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
*/ */
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,97 +184,97 @@ 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() }
/** /**
* Set details of the external library that PHPExcel should use for rendering charts * Set details of the external library that PHPExcel should use for rendering charts
* *
* @param string $libraryName Internal reference name of the library * @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* @param string $libraryBaseDir Directory path to the library's base folder * @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) 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() }
/** /**
* Identify to PHPExcel the external library to use for rendering charts * Identify to PHPExcel the external library to use for rendering charts
* *
* @param string $libraryName Internal reference name of the library * @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* *
* @return boolean Success or failure * @return boolean Success or failure
*/ */
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()
/** /**
* Tell PHPExcel where to find the external library to use for rendering charts * Tell PHPExcel where to find the external library to use for rendering charts
* *
* @param string $libraryBaseDir Directory path to the library's base folder * @param string $libraryBaseDir Directory path to the library's base folder
* @return boolean Success or failure * @return boolean Success or failure
*/ */
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() }
/** /**
* Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph) * 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 * @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is
* currently configured to use * currently configured to use
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
*/ */
public static function getChartRendererName() public static function getChartRendererName()
{ {
return self::$_chartRendererName; return self::$chartRendererName;
} // function getChartRendererName() }
/** /**
* Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use * 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 * @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() public static function getChartRendererPath()
{ {
return self::$_chartRendererPath; return self::$chartRendererPath;
} // function getChartRendererPath() }
/** /**
* Set details of the external library that PHPExcel should use for rendering PDF files * Set details of the external library that PHPExcel should use for rendering PDF files
* *
* @param string $libraryName Internal reference name of the library * @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF * PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF * or PHPExcel_Settings::PDF_RENDERER_MPDF
* @param string $libraryBaseDir Directory path to the library's base folder * @param string $libraryBaseDir Directory path to the library's base folder
* *
@ -286,32 +282,32 @@ 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() }
/** /**
* Identify to PHPExcel the external library to use for rendering PDF files * Identify to PHPExcel the external library to use for rendering PDF files
* *
* @param string $libraryName Internal reference name of the library * @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF * PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF * or PHPExcel_Settings::PDF_RENDERER_MPDF
* *
* @return boolean Success or failure * @return boolean Success or failure
*/ */
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,38 +319,38 @@ 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() }
/** /**
* Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf) * 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 * @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, * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF * PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF * or PHPExcel_Settings::PDF_RENDERER_MPDF
*/ */
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
* *
* @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is * @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() 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
* *
@ -21,74 +22,66 @@
* @category PHPExcel * @category PHPExcel
* @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
{ {
/** /**
* PHPExcel_Worksheet to iterate * PHPExcel_Worksheet to iterate
* *
* @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);
/**
* Get loop only existing cells
*
* @return boolean
*/
public function getIterateOnlyExistingCells() {
return $this->_onlyExistingCells;
} }
/** /**
* 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 * @throws PHPExcel_Exception
*/ */
abstract protected function adjustForExistingOnlyRange(); abstract protected function adjustForExistingOnlyRange();
/** /**
* Set the iterator to loop only existing cells * Set the iterator to loop only existing cells
* *
* @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
* *
@ -21,72 +22,65 @@
* @category PHPExcel * @category PHPExcel
* @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 ##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
{ {
/** /**
* PHPExcel_Worksheet * PHPExcel_Worksheet
* *
* @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
* *
* @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 {
$this->_parent = $parent; // Set parent and column index
$this->_columnIndex = $columnIndex; $this->parent = $parent;
} $this->columnIndex = $columnIndex;
}
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_parent); {
} unset($this->parent);
}
/** /**
* Get column index * Get column index
* *
* @return int * @return int
*/ */
public function getColumnIndex() { public function getColumnIndex()
return $this->_columnIndex; {
} return $this->columnIndex;
}
/** /**
* Get cell iterator * Get cell 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
* @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
* *
@ -19,197 +20,197 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @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##
*/
/**
* 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) * @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 class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{ {
/** /**
* Column index * Column index
* *
* @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
* *
* @param PHPExcel_Worksheet $subject The worksheet to iterate over * @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param string $columnIndex The column that we want to iterate * @param string $columnIndex The column that we want to iterate
* @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 {
$this->_subject = $subject; // Set subject
$this->_columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1; $this->subject = $subject;
$this->resetEnd($endRow); $this->columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1;
$this->resetStart($startRow); $this->resetEnd($endRow);
} $this->resetStart($startRow);
}
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_subject); {
} unset($this->subject);
}
/** /**
* (Re)Set the start row and the current row pointer * (Re)Set the start row and the current row pointer
* *
* @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_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);
return $this; return $this;
} }
/** /**
* (Re)Set the end row * (Re)Set the end row
* *
* @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_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;
} }
/** /**
* Set the row pointer to the selected row * Set the row pointer to the selected row
* *
* @param integer $row The row number to set the current pointer at * @param integer $row The row number to set the current pointer at
* @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;
} }
/** /**
* 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;
}
/** /**
* Return the current cell in this worksheet column * Return the current cell in this worksheet column
* *
* @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);
}
/** /**
* Return the current iterator key * Return the current iterator key
* *
* @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));
} }
/** /**
* Indicate if more rows exist in the worksheet range of rows that we're iterating * Indicate if more rows exist in the worksheet range of rows that we're iterating
* *
* @return boolean * @return boolean
*/ */
public function valid() { public function valid()
return $this->_position <= $this->_endRow; {
} 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 * @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,67 +25,58 @@
* @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
{ {
/** /**
* Column index * Column index
* *
* @var int * @var int
*/ */
private $_columnIndex; private $_columnIndex;
/** /**
* Column width * Column width
* *
* When this is set to a negative value, the column width should be ignored by IWriter * When this is set to a negative value, the column width should be ignored by IWriter
* *
* @var double * @var double
*/ */
private $_width = -1; private $_width = -1;
/** /**
* Auto size? * Auto size?
* *
* @var bool * @var bool
*/ */
private $_autoSize = false; private $_autoSize = false;
/** /**
* Visible? * Visible?
* *
* @var bool * @var bool
*/ */
private $_visible = true; private $_visible = true;
/** /**
* Outline level * Outline level
* *
* @var int * @var int
*/ */
private $_outlineLevel = 0; private $_outlineLevel = 0;
/** /**
* Collapsed * Collapsed
* *
* @var bool * @var bool
*/ */
private $_collapsed = false; private $_collapsed = false;
/** /**
* Index to cellXf * Index to cellXf
* *
* @var int * @var int
*/ */
private $_xfIndex; private $_xfIndex;
/** /**
* Create a new PHPExcel_Worksheet_ColumnDimension * Create a new PHPExcel_Worksheet_ColumnDimension
@ -93,11 +85,11 @@ class PHPExcel_Worksheet_ColumnDimension
*/ */
public function __construct($pIndex = 'A') public function __construct($pIndex = 'A')
{ {
// Initialise values // Initialise values
$this->_columnIndex = $pIndex; $this->_columnIndex = $pIndex;
// set default index to cellXf // set default index to cellXf
$this->_xfIndex = 0; $this->_xfIndex = 0;
} }
/** /**
@ -105,8 +97,9 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return string * @return string
*/ */
public function getColumnIndex() { public function getColumnIndex()
return $this->_columnIndex; {
return $this->_columnIndex;
} }
/** /**
@ -115,9 +108,10 @@ 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; {
return $this; $this->_columnIndex = $pValue;
return $this;
} }
/** /**
@ -125,8 +119,9 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return double * @return double
*/ */
public function getWidth() { public function getWidth()
return $this->_width; {
return $this->_width;
} }
/** /**
@ -135,9 +130,10 @@ 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; {
return $this; $this->_width = $pValue;
return $this;
} }
/** /**
@ -145,8 +141,9 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return bool * @return bool
*/ */
public function getAutoSize() { public function getAutoSize()
return $this->_autoSize; {
return $this->_autoSize;
} }
/** /**
@ -155,9 +152,10 @@ 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; {
return $this; $this->_autoSize = $pValue;
return $this;
} }
/** /**
@ -165,8 +163,9 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return bool * @return bool
*/ */
public function getVisible() { public function getVisible()
return $this->_visible; {
return $this->_visible;
} }
/** /**
@ -175,9 +174,10 @@ 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; {
return $this; $this->_visible = $pValue;
return $this;
} }
/** /**
@ -185,8 +185,9 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return int * @return int
*/ */
public function getOutlineLevel() { public function getOutlineLevel()
return $this->_outlineLevel; {
return $this->_outlineLevel;
} }
/** /**
@ -198,13 +199,14 @@ 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) { {
throw new PHPExcel_Exception("Outline level must range between 0 and 7."); if ($pValue < 0 || $pValue > 7) {
} throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
}
$this->_outlineLevel = $pValue; $this->_outlineLevel = $pValue;
return $this; return $this;
} }
/** /**
@ -212,8 +214,9 @@ class PHPExcel_Worksheet_ColumnDimension
* *
* @return bool * @return bool
*/ */
public function getCollapsed() { public function getCollapsed()
return $this->_collapsed; {
return $this->_collapsed;
} }
/** /**
@ -222,45 +225,47 @@ 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; {
return $this; $this->_collapsed = $pValue;
return $this;
} }
/** /**
* Get index to cellXf * Get index to cellXf
* *
* @return int * @return int
*/ */
public function getXfIndex() public function getXfIndex()
{ {
return $this->_xfIndex; return $this->_xfIndex;
} }
/** /**
* Set index to cellXf * Set index to cellXf
* *
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_ColumnDimension * @return PHPExcel_Worksheet_ColumnDimension
*/ */
public function setXfIndex($pValue = 0) public function setXfIndex($pValue = 0)
{ {
$this->_xfIndex = $pValue; $this->_xfIndex = $pValue;
return $this; return $this;
} }
/** /**
* 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); {
foreach ($vars as $key => $value) { $vars = get_object_vars($this);
if (is_object($value)) { foreach ($vars as $key => $value) {
$this->$key = clone $value; if (is_object($value)) {
} else { $this->$key = clone $value;
$this->$key = $value; } else {
} $this->$key = $value;
} }
} }
}
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_ColumnIterator
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -19,174 +20,174 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @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##
*/
/**
* 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) * @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 class PHPExcel_Worksheet_ColumnIterator implements Iterator
{ {
/** /**
* PHPExcel_Worksheet to iterate * PHPExcel_Worksheet to iterate
* *
* @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;
/** /**
* End position * End position
* *
* @var int * @var int
*/ */
private $_endColumn = 0; private $endColumn = 0;
/** /**
* Create a new column iterator * Create a new column iterator
* *
* @param PHPExcel_Worksheet $subject The worksheet to iterate over * @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @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 {
$this->_subject = $subject; // Set subject
$this->resetEnd($endColumn); $this->subject = $subject;
$this->resetStart($startColumn); $this->resetEnd($endColumn);
} $this->resetStart($startColumn);
}
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_subject); {
} unset($this->subject);
}
/** /**
* (Re)Set the start column and the current column pointer * (Re)Set the start column and the current column pointer
* *
* @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;
}
/**
* (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;
return $this; return $this;
} }
/** /**
* Rewind the iterator to the starting column * (Re)Set the end column
*/ *
public function rewind() { * @param string $endColumn The column address at which to stop iterating
$this->_position = $this->_startColumn; * @return PHPExcel_Worksheet_ColumnIterator
} */
public function resetEnd($endColumn = null)
{
$endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn();
$this->endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
/** return $this;
* 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 * Set the column pointer to the selected column
* *
* @return string * @param string $column The column address to set the current pointer at
*/ * @return PHPExcel_Worksheet_ColumnIterator
public function key() { * @throws PHPExcel_Exception
return PHPExcel_Cell::stringFromColumnIndex($this->_position); */
} 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;
/** return $this;
* Set the iterator to its next value }
*/
public function next() {
++$this->_position;
}
/** /**
* 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 * @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;
} }
/** /**
* Indicate if more columns exist in the worksheet range of columns that we're iterating * Indicate if more columns exist in the worksheet range of columns that we're iterating
* *
* @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
* *
@ -21,72 +22,65 @@
* @category PHPExcel * @category PHPExcel
* @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 ##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
{ {
/** /**
* PHPExcel_Worksheet * PHPExcel_Worksheet
* *
* @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
* *
* @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 {
$this->_parent = $parent; // Set parent and row index
$this->_rowIndex = $rowIndex; $this->parent = $parent;
} $this->rowIndex = $rowIndex;
}
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_parent); {
} unset($this->parent);
}
/** /**
* Get row index * Get row index
* *
* @return int * @return int
*/ */
public function getRowIndex() { public function getRowIndex()
return $this->_rowIndex; {
} return $this->rowIndex;
}
/** /**
* Get cell iterator * Get cell 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
* @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
* *
@ -19,206 +20,206 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @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##
*/
/**
* 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) * @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 class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{ {
/** /**
* Row index * Row index
* *
* @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
* *
* @param PHPExcel_Worksheet $subject The worksheet to iterate over * @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param integer $rowIndex The row that we want to iterate * @param integer $rowIndex The row that we want to iterate
* @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 {
$this->_subject = $subject; // Set subject and row index
$this->_rowIndex = $rowIndex; $this->subject = $subject;
$this->resetEnd($endColumn); $this->rowIndex = $rowIndex;
$this->resetStart($startColumn); $this->resetEnd($endColumn);
} $this->resetStart($startColumn);
}
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_subject); {
} unset($this->subject);
}
/** /**
* (Re)Set the start column and the current column pointer * (Re)Set the start column and the current column pointer
* *
* @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_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;
}
/**
* (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;
return $this; return $this;
} }
/** /**
* Rewind the iterator to the starting column * (Re)Set the end column
*/ *
public function rewind() { * @param string $endColumn The column address at which to stop iterating
$this->_position = $this->_startColumn; * @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;
* 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 * Set the column pointer to the selected column
* *
* @return string * @param string $column The column address to set the current pointer at
*/ * @return PHPExcel_Worksheet_RowCellIterator
public function key() { * @throws PHPExcel_Exception
return PHPExcel_Cell::stringFromColumnIndex($this->_position); */
} 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;
/** return $this;
* Set the iterator to its next value }
*/
public function next() { /**
* 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 { 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));
} }
/** /**
* Set the iterator to its previous value * Set the iterator to its previous value
* *
* @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));
} }
/** /**
* Indicate if more columns exist in the worksheet range of columns that we're iterating * Indicate if more columns exist in the worksheet range of columns that we're iterating
* *
* @return boolean * @return boolean
*/ */
public function valid() { public function valid()
return $this->_position <= $this->_endColumn; {
} 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 * @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
* *
@ -21,70 +22,61 @@
* @category PHPExcel * @category PHPExcel
* @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 ##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
{ {
/** /**
* Row index * Row index
* *
* @var int * @var int
*/ */
private $_rowIndex; private $_rowIndex;
/** /**
* Row height (in pt) * Row height (in pt)
* *
* When this is set to a negative value, the row height should be ignored by IWriter * When this is set to a negative value, the row height should be ignored by IWriter
* *
* @var double * @var double
*/ */
private $_rowHeight = -1; private $_rowHeight = -1;
/** /**
* ZeroHeight for Row? * ZeroHeight for Row?
* *
* @var bool * @var bool
*/ */
private $_zeroHeight = false; private $_zeroHeight = false;
/** /**
* Visible? * Visible?
* *
* @var bool * @var bool
*/ */
private $_visible = true; private $_visible = true;
/** /**
* Outline level * Outline level
* *
* @var int * @var int
*/ */
private $_outlineLevel = 0; private $_outlineLevel = 0;
/** /**
* Collapsed * Collapsed
* *
* @var bool * @var bool
*/ */
private $_collapsed = false; private $_collapsed = false;
/** /**
* Index to cellXf. Null value means row has no explicit cellXf format. * Index to cellXf. Null value means row has no explicit cellXf format.
* *
* @var int|null * @var int|null
*/ */
private $_xfIndex; private $_xfIndex;
/** /**
* Create a new PHPExcel_Worksheet_RowDimension * Create a new PHPExcel_Worksheet_RowDimension
@ -93,11 +85,11 @@ class PHPExcel_Worksheet_RowDimension
*/ */
public function __construct($pIndex = 0) public function __construct($pIndex = 0)
{ {
// Initialise values // Initialise values
$this->_rowIndex = $pIndex; $this->_rowIndex = $pIndex;
// set row dimension as unformatted by default // set row dimension as unformatted by default
$this->_xfIndex = null; $this->_xfIndex = null;
} }
/** /**
@ -105,8 +97,9 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return int * @return int
*/ */
public function getRowIndex() { public function getRowIndex()
return $this->_rowIndex; {
return $this->_rowIndex;
} }
/** /**
@ -115,9 +108,10 @@ 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; {
return $this; $this->_rowIndex = $pValue;
return $this;
} }
/** /**
@ -125,8 +119,9 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return double * @return double
*/ */
public function getRowHeight() { public function getRowHeight()
return $this->_rowHeight; {
return $this->_rowHeight;
} }
/** /**
@ -135,38 +130,42 @@ 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; {
return $this; $this->_rowHeight = $pValue;
return $this;
} }
/** /**
* Get ZeroHeight * Get ZeroHeight
* *
* @return bool * @return bool
*/ */
public function getZeroHeight() { public function getZeroHeight()
return $this->_zeroHeight; {
} return $this->_zeroHeight;
}
/** /**
* Set ZeroHeight * Set ZeroHeight
* *
* @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; {
return $this; $this->_zeroHeight = $pValue;
} return $this;
}
/** /**
* Get Visible * Get Visible
* *
* @return bool * @return bool
*/ */
public function getVisible() { public function getVisible()
return $this->_visible; {
return $this->_visible;
} }
/** /**
@ -175,9 +174,10 @@ 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; {
return $this; $this->_visible = $pValue;
return $this;
} }
/** /**
@ -185,8 +185,9 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return int * @return int
*/ */
public function getOutlineLevel() { public function getOutlineLevel()
return $this->_outlineLevel; {
return $this->_outlineLevel;
} }
/** /**
@ -198,13 +199,14 @@ 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) { {
throw new PHPExcel_Exception("Outline level must range between 0 and 7."); if ($pValue < 0 || $pValue > 7) {
} throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
}
$this->_outlineLevel = $pValue; $this->_outlineLevel = $pValue;
return $this; return $this;
} }
/** /**
@ -212,8 +214,9 @@ class PHPExcel_Worksheet_RowDimension
* *
* @return bool * @return bool
*/ */
public function getCollapsed() { public function getCollapsed()
return $this->_collapsed; {
return $this->_collapsed;
} }
/** /**
@ -222,44 +225,46 @@ 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; {
return $this; $this->_collapsed = $pValue;
return $this;
} }
/** /**
* Get index to cellXf * Get index to cellXf
* *
* @return int * @return int
*/ */
public function getXfIndex() public function getXfIndex()
{ {
return $this->_xfIndex; return $this->_xfIndex;
} }
/** /**
* Set index to cellXf * Set index to cellXf
* *
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function setXfIndex($pValue = 0) public function setXfIndex($pValue = 0)
{ {
$this->_xfIndex = $pValue; $this->_xfIndex = $pValue;
return $this; return $this;
} }
/** /**
* 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); {
foreach ($vars as $key => $value) { $vars = get_object_vars($this);
if (is_object($value)) { foreach ($vars as $key => $value) {
$this->$key = clone $value; if (is_object($value)) {
} else { $this->$key = clone $value;
$this->$key = $value; } else {
} $this->$key = $value;
} }
} }
}
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_RowIterator
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -19,165 +20,165 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @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##
*/
/**
* 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) * @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 class PHPExcel_Worksheet_RowIterator implements Iterator
{ {
/** /**
* PHPExcel_Worksheet to iterate * PHPExcel_Worksheet to iterate
* *
* @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;
/** /**
* End position * End position
* *
* @var int * @var int
*/ */
private $_endRow = 1; private $endRow = 1;
/** /**
* Create a new row iterator * Create a new row iterator
* *
* @param PHPExcel_Worksheet $subject The worksheet to iterate over * @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @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 {
$this->_subject = $subject; // Set subject
$this->resetEnd($endRow); $this->subject = $subject;
$this->resetStart($startRow); $this->resetEnd($endRow);
} $this->resetStart($startRow);
}
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
unset($this->_subject); {
} unset($this->subject);
}
/** /**
* (Re)Set the start row and the current row pointer * (Re)Set the start row and the current row pointer
* *
* @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->seek($startRow); $this->startRow = $startRow;
$this->seek($startRow);
return $this; return $this;
} }
/** /**
* (Re)Set the end row * (Re)Set the end row
* *
* @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;
} }
/** /**
* Set the row pointer to the selected row * Set the row pointer to the selected row
* *
* @param integer $row The row number to set the current pointer at * @param integer $row The row number to set the current pointer at
* @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;
} }
/** /**
* 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;
}
/** /**
* Return the current row in this worksheet * Return the current row in this worksheet
* *
* @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);
}
/** /**
* Return the current iterator key * Return the current iterator key
* *
* @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;
} }
/** /**
* Indicate if more rows exist in the worksheet range of rows that we're iterating * Indicate if more rows exist in the worksheet range of rows that we're iterating
* *
* @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();
} }
} }