Initial work on namespacing - note, requires PHP 5.3.x minimum

This commit is contained in:
Mark Baker 2013-06-19 23:45:47 +01:00
parent a7ddcc5e68
commit ffed9ab702
172 changed files with 7076 additions and 6861 deletions

156
Classes/Autoloader.php Normal file
View File

@ -0,0 +1,156 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2013 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
namespace PHPExcel;
/**
* PHPExcel\Autoloader
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class Autoloader
{
private $_fileExtension = '.php';
private $_namespace;
private $_includePath;
private $_namespaceSeparator = '\\';
/**
* Creates a new SplClassLoader that loads classes of the
* specified namespace.
*
* @param string $namespace The namespace to use.
* @param string $includePath The directory path for that namespace.
*/
public function __construct($namespace = null, $includePath = null)
{
$this->_namespace = $namespace;
$this->_includePath = $includePath;
}
/**
* Sets the namespace separator used by classes in the namespace of this class loader.
*
* @param string $sep The separator to use.
*/
public function setNamespaceSeparator($sep)
{
$this->_namespaceSeparator = $sep;
}
/**
* Gets the namespace seperator used by classes in the namespace of this class loader.
*
* @return void
*/
public function getNamespaceSeparator()
{
return $this->_namespaceSeparator;
}
/**
* Sets the base include path for all class files in the namespace of this class loader.
*
* @param string $includePath
*/
public function setIncludePath($includePath)
{
$this->_includePath = $includePath;
}
/**
* Gets the base include path for all class files in the namespace of this class loader.
*
* @return string $includePath
*/
public function getIncludePath()
{
return $this->_includePath;
}
/**
* Sets the file extension of class files in the namespace of this class loader.
*
* @param string $fileExtension
*/
public function setFileExtension($fileExtension)
{
$this->_fileExtension = $fileExtension;
}
/**
* Gets the file extension of class files in the namespace of this class loader.
*
* @return string $fileExtension
*/
public function getFileExtension()
{
return $this->_fileExtension;
}
/**
* Installs this class loader on the SPL autoload stack.
*/
public function register()
{
spl_autoload_register(array($this, 'loadClass'));
}
/**
* Uninstalls this class loader from the SPL autoloader stack.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $className The name of the class to load.
* @return void
*/
public function loadClass($className)
{
echo 'Load Class ', $className, PHP_EOL;
if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
$fileName = '';
$namespace = '';
if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
require ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
}
}
}

48
Classes/Bootstrap.php Normal file
View File

@ -0,0 +1,48 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2013 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
namespace PHPExcel;
/** PHPOffice root directory */
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
}
include PHPEXCEL_ROOT . 'Autoloader.php';
$autoloader = new Autoloader('PHPExcel', PHPEXCEL_ROOT);
$autoloader->register();
// As we always try to run the autoloader before anything else, we can use it to do a few
// simple checks and initialisations
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
Shared_String::buildCharacterSets();

View File

@ -1,85 +0,0 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2013 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
PHPExcel_Autoloader::Register();
// As we always try to run the autoloader before anything else, we can use it to do a few
// simple checks and initialisations
//PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
PHPExcel_Shared_String::buildCharacterSets();
/**
* PHPExcel_Autoloader
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Autoloader
{
/**
* Register the Autoloader with SPL
*
*/
public static function Register() {
if (function_exists('__autoload')) {
// Register any existing autoloader function with SPL, so we don't get any clashes
spl_autoload_register('__autoload');
}
// Register ourselves with SPL
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
} // function Register()
/**
* Autoload a class identified by name
*
* @param string $pClassName Name of the object to load
*/
public static function Load($pClassName){
if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
// Either already loaded, or not a PHPExcel class request
return FALSE;
}
$pClassFilePath = PHPEXCEL_ROOT .
str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
'.php';
if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
// Can't load
return FALSE;
}
require($pClassFilePath);
} // function Load()
}

View File

@ -19,21 +19,23 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_APC * PHPExcel\CachedObjectStorage_APC
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Prefix used to uniquely identify cache data for this worksheet * Prefix used to uniquely identify cache data for this worksheet
@ -58,7 +60,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* *
* @access private * @access private
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
@ -66,7 +68,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) { if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
$this->__destruct(); $this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC'); throw new Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
} }
$this->_currentCellIsDirty = false; $this->_currentCellIsDirty = false;
} }
@ -79,11 +81,11 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* *
* @access public * @access public
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -98,7 +100,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
/** /**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? * Is a value set in the current PHPExcel\CachedObjectStorage_ICache for an indexed cell?
* *
* @access public * @access public
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
@ -116,7 +118,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
if ($success === FALSE) { if ($success === FALSE) {
// Entry no longer exists in APC, so clear it from the cache array // Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord); parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); throw new Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
} }
return true; return true;
} }
@ -129,8 +131,8 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* *
* @access public * @access public
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -144,7 +146,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
if ($obj === FALSE) { if ($obj === FALSE) {
// Entry no longer exists in APC, so clear it from the cache array // Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord); parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); throw new Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
} }
} else { } else {
// Return null if requested entry doesn't exist in cache // Return null if requested entry doesn't exist in cache
@ -181,7 +183,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* *
* @access public * @access public
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function deleteCacheData($pCoord) { public function deleteCacheData($pCoord) {
// Delete the entry from APC // Delete the entry from APC
@ -196,11 +198,11 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* Clone the cell collection * Clone the cell collection
* *
* @access public * @access public
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(Worksheet $parent) {
parent::copyCellCollection($parent); parent::copyCellCollection($parent);
// Get a new id for the new file name // Get a new id for the new file name
$baseUnique = $this->_getUniqueID(); $baseUnique = $this->_getUniqueID();
@ -212,11 +214,11 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
if ($obj === FALSE) { if ($obj === FALSE) {
// Entry no longer exists in APC, so clear it from the cache array // Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($cellID); parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC'); throw new Exception('Cell entry '.$cellID.' no longer exists in APC');
} }
if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) { if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
$this->__destruct(); $this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC'); throw new Exception('Failed to store cell '.$cellID.' in APC');
} }
} }
} }
@ -248,10 +250,10 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
/** /**
* Initialise this new cell collection * Initialise this new cell collection
* *
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection * @param PHPExcel\Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments * @param array of mixed $arguments Additional initialisation arguments
*/ */
public function __construct(PHPExcel_Worksheet $parent, $arguments) { public function __construct(Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if ($this->_cachePrefix === NULL) { if ($this->_cachePrefix === NULL) {

View File

@ -19,33 +19,35 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_CacheBase * PHPExcel\CachedObjectStorage_CacheBase
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
abstract class PHPExcel_CachedObjectStorage_CacheBase { abstract class CachedObjectStorage_CacheBase {
/** /**
* Parent worksheet * Parent worksheet
* *
* @var PHPExcel_Worksheet * @var PHPExcel\Worksheet
*/ */
protected $_parent; protected $_parent;
/** /**
* The currently active Cell * The currently active Cell
* *
* @var PHPExcel_Cell * @var PHPExcel\Cell
*/ */
protected $_currentObject = null; protected $_currentObject = null;
@ -76,11 +78,11 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
/** /**
* Initialise this new cell collection * Initialise this new cell collection
* *
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection * @param PHPExcel\Worksheet $parent The worksheet for this cell collection
*/ */
public function __construct(PHPExcel_Worksheet $parent) { public function __construct(Worksheet $parent) {
// Set our parent worksheet. // Set our parent worksheet.
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel\Cell objects when
// they are woken from a serialized state // they are woken from a serialized state
$this->_parent = $parent; $this->_parent = $parent;
} // function __construct() } // function __construct()
@ -89,7 +91,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
/** /**
* Return the parent worksheet for this cell collection * Return the parent worksheet for this cell collection
* *
* @return PHPExcel_Worksheet * @return PHPExcel\Worksheet
*/ */
public function getParent() public function getParent()
{ {
@ -97,7 +99,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
} }
/** /**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? * Is a value set in the current PHPExcel\CachedObjectStorage_ICache for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
* @return boolean * @return boolean
@ -135,11 +137,11 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
/** /**
* Add or Update a cell in cache * Add or Update a cell in cache
* *
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function updateCacheData(PHPExcel_Cell $cell) { public function updateCacheData(Cell $cell) {
return $this->addCacheData($cell->getCoordinate(),$cell); return $this->addCacheData($cell->getCoordinate(),$cell);
} // function updateCacheData() } // function updateCacheData()
@ -148,7 +150,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function deleteCacheData($pCoord) { public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -291,10 +293,10 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(Worksheet $parent) {
$this->_currentCellIsDirty; $this->_currentCellIsDirty;
$this->_storeData(); $this->_storeData();

View File

@ -19,21 +19,23 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_DiscISAM * PHPExcel\CachedObjectStorage_DiscISAM
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_DiscISAM extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Name of the file for this cache * Name of the file for this cache
@ -62,7 +64,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
@ -84,11 +86,11 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -105,8 +107,8 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -149,10 +151,10 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(Worksheet $parent) {
parent::copyCellCollection($parent); parent::copyCellCollection($parent);
// Get a new id for the new file name // Get a new id for the new file name
$baseUnique = $this->_getUniqueID(); $baseUnique = $this->_getUniqueID();
@ -188,13 +190,13 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
/** /**
* Initialise this new cell collection * Initialise this new cell collection
* *
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection * @param PHPExcel\Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments * @param array of mixed $arguments Additional initialisation arguments
*/ */
public function __construct(PHPExcel_Worksheet $parent, $arguments) { public function __construct(Worksheet $parent, $arguments) {
$this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL)) $this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
? $arguments['dir'] ? $arguments['dir']
: PHPExcel_Shared_File::sys_get_temp_dir(); : Shared_File::sys_get_temp_dir();
parent::__construct($parent); parent::__construct($parent);
if (is_null($this->_fileHandle)) { if (is_null($this->_fileHandle)) {

View File

@ -19,47 +19,49 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_ICache * PHPExcel\CachedObjectStorage_ICache
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
interface PHPExcel_CachedObjectStorage_ICache interface CachedObjectStorage_ICache
{ {
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell); public function addCacheData($pCoord, Cell $cell);
/** /**
* Add or Update a cell in cache * Add or Update a cell in cache
* *
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function updateCacheData(PHPExcel_Cell $cell); public function updateCacheData(Cell $cell);
/** /**
* Fetch a cell from cache identified by coordinate address * Fetch a cell from cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to retrieve * @param string $pCoord Coordinate address of the cell to retrieve
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function getCacheData($pCoord); public function getCacheData($pCoord);
@ -67,12 +69,12 @@ interface PHPExcel_CachedObjectStorage_ICache
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function deleteCacheData($pCoord); public function deleteCacheData($pCoord);
/** /**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? * Is a value set in the current PHPExcel\CachedObjectStorage_ICache for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
* @return boolean * @return boolean
@ -96,10 +98,10 @@ interface PHPExcel_CachedObjectStorage_ICache
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent); public function copyCellCollection(Worksheet $parent);
/** /**
* Identify whether the caching method is currently available * Identify whether the caching method is currently available

View File

@ -19,28 +19,30 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_Igbinary * PHPExcel\CachedObjectStorage_Igbinary
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_Igbinary extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
@ -57,11 +59,11 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -78,8 +80,8 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {

View File

@ -19,21 +19,23 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_Memcache * PHPExcel\CachedObjectStorage_Memcache
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Prefix used to uniquely identify cache data for this worksheet * Prefix used to uniquely identify cache data for this worksheet
@ -62,7 +64,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
@ -72,7 +74,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) { if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) { if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
$this->__destruct(); $this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache'); throw new Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
} }
} }
$this->_currentCellIsDirty = false; $this->_currentCellIsDirty = false;
@ -85,11 +87,11 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -104,7 +106,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
/** /**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? * Is a value set in the current PHPExcel\CachedObjectStorage_ICache for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
* @return void * @return void
@ -121,7 +123,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
if ($success === false) { if ($success === false) {
// Entry no longer exists in Memcache, so clear it from the cache array // Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord); parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
} }
return true; return true;
} }
@ -133,8 +135,8 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -148,7 +150,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
if ($obj === false) { if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array // Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord); parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
} }
} else { } else {
// Return null if requested entry doesn't exist in cache // Return null if requested entry doesn't exist in cache
@ -184,7 +186,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function deleteCacheData($pCoord) { public function deleteCacheData($pCoord) {
// Delete the entry from Memcache // Delete the entry from Memcache
@ -198,10 +200,11 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @throws PHPExcel\Exception
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(Worksheet $parent) {
parent::copyCellCollection($parent); parent::copyCellCollection($parent);
// Get a new id for the new file name // Get a new id for the new file name
$baseUnique = $this->_getUniqueID(); $baseUnique = $this->_getUniqueID();
@ -213,16 +216,16 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
if ($obj === false) { if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array // Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($cellID); parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in MemCache'); throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
} }
if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) { if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {
$this->__destruct(); $this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in MemCache'); throw new Exception('Failed to store cell '.$cellID.' in MemCache');
} }
} }
} }
$this->_cachePrefix = $newCachePrefix; $this->_cachePrefix = $newCachePrefix;
} // function copyCellCollection() }
/** /**
@ -249,10 +252,10 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
/** /**
* Initialise this new cell collection * Initialise this new cell collection
* *
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection * @param PHPExcel\Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments * @param array of mixed $arguments Additional initialisation arguments
*/ */
public function __construct(PHPExcel_Worksheet $parent, $arguments) { public function __construct(Worksheet $parent, $arguments) {
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost'; $memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211; $memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
@ -264,13 +267,13 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
// Set a new Memcache object and connect to the Memcache server // Set a new Memcache object and connect to the Memcache server
$this->_memcache = new Memcache(); $this->_memcache = new Memcache();
if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) { if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
throw new PHPExcel_Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort); throw new Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort);
} }
$this->_cacheTime = $cacheTime; $this->_cacheTime = $cacheTime;
parent::__construct($parent); parent::__construct($parent);
} }
} // function __construct() }
/** /**
@ -278,10 +281,10 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* *
* @param string $host Memcache server * @param string $host Memcache server
* @param integer $port Memcache port * @param integer $port Memcache port
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function failureCallback($host, $port) { public function failureCallback($host, $port) {
throw new PHPExcel_Exception('memcache '.$host.':'.$port.' failed'); throw new Exception('memcache '.$host.':'.$port.' failed');
} }

View File

@ -19,21 +19,23 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_Memory * PHPExcel\CachedObjectStorage_Memory
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Dummy method callable from CacheBase, but unused by Memory cache * Dummy method callable from CacheBase, but unused by Memory cache
@ -47,11 +49,11 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return PHPExcel_Cell * @return PHPExcel\Cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
$this->_cellCache[$pCoord] = $cell; $this->_cellCache[$pCoord] = $cell;
// Set current entry to the new/updated entry // Set current entry to the new/updated entry
@ -65,8 +67,8 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
// Check if the entry that has been requested actually exists // Check if the entry that has been requested actually exists
@ -87,10 +89,10 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(Worksheet $parent) {
parent::copyCellCollection($parent); parent::copyCellCollection($parent);
$newCollection = array(); $newCollection = array();

View File

@ -19,28 +19,30 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_MemoryGZip * PHPExcel\CachedObjectStorage_MemoryGZip
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
@ -57,11 +59,11 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -78,8 +80,8 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {

View File

@ -19,28 +19,30 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_MemorySerialized * PHPExcel\CachedObjectStorage_MemorySerialized
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_MemorySerialized extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
@ -57,11 +59,11 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -78,8 +80,8 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {

View File

@ -19,7 +19,7 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
@ -27,13 +27,13 @@
/** /**
* PHPExcel_CachedObjectStorage_PHPTemp * PHPExcel\CachedObjectStorage_PHPTemp
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Name of the file for this cache * Name of the file for this cache
@ -54,7 +54,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
@ -76,11 +76,11 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -97,8 +97,8 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -141,10 +141,10 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(Worksheet $parent) {
parent::copyCellCollection($parent); parent::copyCellCollection($parent);
// Open a new stream for the cell cache data // Open a new stream for the cell cache data
$newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+'); $newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
@ -180,10 +180,10 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
/** /**
* Initialise this new cell collection * Initialise this new cell collection
* *
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection * @param PHPExcel\Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments * @param array of mixed $arguments Additional initialisation arguments
*/ */
public function __construct(PHPExcel_Worksheet $parent, $arguments) { public function __construct(Worksheet $parent, $arguments) {
$this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB'; $this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
parent::__construct($parent); parent::__construct($parent);

View File

@ -19,21 +19,23 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_SQLite * PHPExcel\CachedObjectStorage_SQLite
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Database table name * Database table name
@ -54,14 +56,14 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')"))
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
$this->_currentCellIsDirty = false; $this->_currentCellIsDirty = false;
} }
$this->_currentObjectID = $this->_currentObject = null; $this->_currentObjectID = $this->_currentObject = null;
@ -72,11 +74,11 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -93,8 +95,8 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -105,7 +107,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC); $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
if ($cellResultSet === false) { if ($cellResultSet === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
} elseif ($cellResultSet->numRows() == 0) { } elseif ($cellResultSet->numRows() == 0) {
// Return null if requested entry doesn't exist in cache // Return null if requested entry doesn't exist in cache
return null; return null;
@ -139,7 +141,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC); $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
if ($cellResultSet === false) { if ($cellResultSet === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
} elseif ($cellResultSet->numRows() == 0) { } elseif ($cellResultSet->numRows() == 0) {
// Return null if requested entry doesn't exist in cache // Return null if requested entry doesn't exist in cache
return false; return false;
@ -152,7 +154,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function deleteCacheData($pCoord) { public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -163,7 +165,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
// Check if the requested entry exists in the cache // Check if the requested entry exists in the cache
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
if (!$this->_DBHandle->queryExec($query)) if (!$this->_DBHandle->queryExec($query))
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
$this->_currentCellIsDirty = false; $this->_currentCellIsDirty = false;
} // function deleteCacheData() } // function deleteCacheData()
@ -184,12 +186,12 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'"; $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
$result = $this->_DBHandle->exec($query); $result = $this->_DBHandle->exec($query);
if ($result === false) if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
$query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'"; $query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
$result = $this->_DBHandle->exec($query); $result = $this->_DBHandle->exec($query);
if ($result === false) if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
return TRUE; return TRUE;
} // function moveCell() } // function moveCell()
@ -208,7 +210,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$query = "SELECT id FROM kvp_".$this->_TableName; $query = "SELECT id FROM kvp_".$this->_TableName;
$cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC); $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
if ($cellIdsResult === false) if ($cellIdsResult === false)
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
$cellKeys = array(); $cellKeys = array();
foreach($cellIdsResult as $row) { foreach($cellIdsResult as $row) {
@ -222,10 +224,10 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(Worksheet $parent) {
$this->_currentCellIsDirty; $this->_currentCellIsDirty;
$this->_storeData(); $this->_storeData();
@ -233,7 +235,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$tableName = str_replace('.','_',$this->_getUniqueID()); $tableName = str_replace('.','_',$this->_getUniqueID());
if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
AS SELECT * FROM kvp_'.$this->_TableName)) AS SELECT * FROM kvp_'.$this->_TableName))
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
// Copy the existing cell cache file // Copy the existing cell cache file
$this->_TableName = $tableName; $this->_TableName = $tableName;
@ -261,9 +263,9 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
/** /**
* Initialise this new cell collection * Initialise this new cell collection
* *
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection * @param PHPExcel\Worksheet $parent The worksheet for this cell collection
*/ */
public function __construct(PHPExcel_Worksheet $parent) { public function __construct(Worksheet $parent) {
parent::__construct($parent); parent::__construct($parent);
if (is_null($this->_DBHandle)) { if (is_null($this->_DBHandle)) {
$this->_TableName = str_replace('.','_',$this->_getUniqueID()); $this->_TableName = str_replace('.','_',$this->_getUniqueID());
@ -271,9 +273,9 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$this->_DBHandle = new SQLiteDatabase($_DBName); $this->_DBHandle = new SQLiteDatabase($_DBName);
if ($this->_DBHandle === false) if ($this->_DBHandle === false)
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
} }
} // function __construct() } // function __construct()

View File

@ -19,21 +19,23 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_SQLite3 * PHPExcel\CachedObjectStorage_SQLite3
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Database table name * Database table name
@ -82,7 +84,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
@ -92,7 +94,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
$this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB); $this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
$result = $this->_insertQuery->execute(); $result = $this->_insertQuery->execute();
if ($result === false) if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
$this->_currentCellIsDirty = false; $this->_currentCellIsDirty = false;
} }
$this->_currentObjectID = $this->_currentObject = null; $this->_currentObjectID = $this->_currentObject = null;
@ -103,11 +105,11 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -124,8 +126,8 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -136,7 +138,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT); $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
$cellResult = $this->_selectQuery->execute(); $cellResult = $this->_selectQuery->execute();
if ($cellResult === FALSE) { if ($cellResult === FALSE) {
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
} }
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC); $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
if ($cellData === FALSE) { if ($cellData === FALSE) {
@ -171,7 +173,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT); $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
$cellResult = $this->_selectQuery->execute(); $cellResult = $this->_selectQuery->execute();
if ($cellResult === FALSE) { if ($cellResult === FALSE) {
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
} }
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC); $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
@ -183,7 +185,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function deleteCacheData($pCoord) { public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -195,7 +197,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
$this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT); $this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
$result = $this->_deleteQuery->execute(); $result = $this->_deleteQuery->execute();
if ($result === FALSE) if ($result === FALSE)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
$this->_currentCellIsDirty = FALSE; $this->_currentCellIsDirty = FALSE;
} // function deleteCacheData() } // function deleteCacheData()
@ -216,13 +218,13 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
$this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT); $this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);
$result = $this->_deleteQuery->execute(); $result = $this->_deleteQuery->execute();
if ($result === false) if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
$this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT); $this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);
$this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT); $this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);
$result = $this->_updateQuery->execute(); $result = $this->_updateQuery->execute();
if ($result === false) if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
return TRUE; return TRUE;
} // function moveCell() } // function moveCell()
@ -241,7 +243,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
$query = "SELECT id FROM kvp_".$this->_TableName; $query = "SELECT id FROM kvp_".$this->_TableName;
$cellIdsResult = $this->_DBHandle->query($query); $cellIdsResult = $this->_DBHandle->query($query);
if ($cellIdsResult === false) if ($cellIdsResult === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
$cellKeys = array(); $cellKeys = array();
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) { while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
@ -255,10 +257,10 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(Worksheet $parent) {
$this->_currentCellIsDirty; $this->_currentCellIsDirty;
$this->_storeData(); $this->_storeData();
@ -266,7 +268,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
$tableName = str_replace('.','_',$this->_getUniqueID()); $tableName = str_replace('.','_',$this->_getUniqueID());
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
AS SELECT * FROM kvp_'.$this->_TableName)) AS SELECT * FROM kvp_'.$this->_TableName))
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
// Copy the existing cell cache file // Copy the existing cell cache file
$this->_TableName = $tableName; $this->_TableName = $tableName;
@ -294,9 +296,9 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
/** /**
* Initialise this new cell collection * Initialise this new cell collection
* *
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection * @param PHPExcel\Worksheet $parent The worksheet for this cell collection
*/ */
public function __construct(PHPExcel_Worksheet $parent) { public function __construct(Worksheet $parent) {
parent::__construct($parent); parent::__construct($parent);
if (is_null($this->_DBHandle)) { if (is_null($this->_DBHandle)) {
$this->_TableName = str_replace('.','_',$this->_getUniqueID()); $this->_TableName = str_replace('.','_',$this->_getUniqueID());
@ -304,9 +306,9 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
$this->_DBHandle = new SQLite3($_DBName); $this->_DBHandle = new SQLite3($_DBName);
if ($this->_DBHandle === false) if ($this->_DBHandle === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); throw new Exception($this->_DBHandle->lastErrorMsg());
} }
$this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id"); $this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id");

View File

@ -19,21 +19,23 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorage_Wincache * PHPExcel\CachedObjectStorage_Wincache
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
/** /**
* Prefix used to uniquely identify cache data for this worksheet * Prefix used to uniquely identify cache data for this worksheet
@ -55,7 +57,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
protected function _storeData() { protected function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
@ -65,12 +67,12 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) { if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
$this->__destruct(); $this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
} }
} else { } else {
if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
$this->__destruct(); $this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
} }
} }
$this->_currentCellIsDirty = false; $this->_currentCellIsDirty = false;
@ -84,11 +86,11 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel\Cell $cell Cell to update
* @return void * @return void
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
@ -103,7 +105,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
/** /**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? * Is a value set in the current PHPExcel\CachedObjectStorage_ICache for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
* @return boolean * @return boolean
@ -119,7 +121,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
if ($success === false) { if ($success === false) {
// Entry no longer exists in Wincache, so clear it from the cache array // Entry no longer exists in Wincache, so clear it from the cache array
parent::deleteCacheData($pCoord); parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
} }
return true; return true;
} }
@ -131,8 +133,8 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
@ -148,7 +150,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
if ($success === false) { if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array // Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($pCoord); parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
} }
} else { } else {
// Return null if requested entry doesn't exist in cache // Return null if requested entry doesn't exist in cache
@ -184,7 +186,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function deleteCacheData($pCoord) { public function deleteCacheData($pCoord) {
// Delete the entry from Wincache // Delete the entry from Wincache
@ -198,10 +200,10 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel\Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(Worksheet $parent) {
parent::copyCellCollection($parent); parent::copyCellCollection($parent);
// Get a new id for the new file name // Get a new id for the new file name
$baseUnique = $this->_getUniqueID(); $baseUnique = $this->_getUniqueID();
@ -214,11 +216,11 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
if ($success === false) { if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array // Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($cellID); parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache'); throw new Exception('Cell entry '.$cellID.' no longer exists in Wincache');
} }
if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) { if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) {
$this->__destruct(); $this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache'); throw new Exception('Failed to store cell '.$cellID.' in Wincache');
} }
} }
} }
@ -250,10 +252,10 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
/** /**
* Initialise this new cell collection * Initialise this new cell collection
* *
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection * @param PHPExcel\Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments * @param array of mixed $arguments Additional initialisation arguments
*/ */
public function __construct(PHPExcel_Worksheet $parent, $arguments) { public function __construct(Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->_cachePrefix)) { if (is_null($this->_cachePrefix)) {

View File

@ -20,21 +20,23 @@
* 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_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CachedObjectStorageFactory * PHPExcel\CachedObjectStorageFactory
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel\CachedObjectStorage
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorageFactory class CachedObjectStorageFactory
{ {
const cache_in_memory = 'Memory'; const cache_in_memory = 'Memory';
const cache_in_memory_gzip = 'MemoryGZip'; const cache_in_memory_gzip = 'MemoryGZip';
@ -139,7 +141,7 @@ class PHPExcel_CachedObjectStorageFactory
/** /**
* Return the current cache storage class * Return the current cache storage class
* *
* @return PHPExcel_CachedObjectStorage_ICache|NULL * @return PHPExcel\CachedObjectStorage_ICache|NULL
**/ **/
public static function getCacheStorageClass() public static function getCacheStorageClass()
{ {
@ -167,7 +169,7 @@ class PHPExcel_CachedObjectStorageFactory
{ {
$activeMethods = array(); $activeMethods = array();
foreach(self::$_storageMethods as $storageMethod) { foreach(self::$_storageMethods as $storageMethod) {
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod; $cacheStorageClass = 'PHPExcel\CachedObjectStorage_' . $storageMethod;
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) { if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
$activeMethods[] = $storageMethod; $activeMethods[] = $storageMethod;
} }
@ -190,9 +192,10 @@ class PHPExcel_CachedObjectStorageFactory
return FALSE; return FALSE;
} }
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method; $cacheStorageClass = __NAMESPACE__ . '\CachedObjectStorage_'.$method;
if (!call_user_func(array( $cacheStorageClass, if (!call_user_func(
'cacheMethodIsAvailable'))) { array($cacheStorageClass, 'cacheMethodIsAvailable')
)) {
return FALSE; return FALSE;
} }
@ -204,7 +207,7 @@ class PHPExcel_CachedObjectStorageFactory
} }
if (self::$_cacheStorageMethod === NULL) { if (self::$_cacheStorageMethod === NULL) {
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method; self::$_cacheStorageClass = 'CachedObjectStorage_' . $method;
self::$_cacheStorageMethod = $method; self::$_cacheStorageMethod = $method;
} }
return TRUE; return TRUE;
@ -214,18 +217,19 @@ class PHPExcel_CachedObjectStorageFactory
/** /**
* Initialise the cache storage * Initialise the cache storage
* *
* @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet * @param PHPExcel\Worksheet $parent Enable cell caching for this worksheet
* @return PHPExcel_CachedObjectStorage_ICache * @return PHPExcel\CachedObjectStorage_ICache
**/ **/
public static function getInstance(PHPExcel_Worksheet $parent) public static function getInstance(Worksheet $parent)
{ {
$cacheMethodIsAvailable = TRUE; $cacheMethodIsAvailable = TRUE;
if (self::$_cacheStorageMethod === NULL) { if (self::$_cacheStorageMethod === NULL) {
$cacheMethodIsAvailable = self::initialize(); $cacheMethodIsAvailable = self::initialize();
} }
$cacheStorageClass = __NAMESPACE__ . '\\' . self::$_cacheStorageClass;
if ($cacheMethodIsAvailable) { if ($cacheMethodIsAvailable) {
$instance = new self::$_cacheStorageClass( $parent, $instance = new $cacheStorageClass( $parent,
self::$_storageMethodParameters[self::$_cacheStorageMethod] self::$_storageMethodParameters[self::$_cacheStorageMethod]
); );
if ($instance !== NULL) { if ($instance !== NULL) {

View File

@ -19,21 +19,23 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CalcEngine_CyclicReferenceStack * PHPExcel\CalcEngine_CyclicReferenceStack
* *
* @category PHPExcel_CalcEngine_CyclicReferenceStack * @category PHPExcel\CalcEngine_CyclicReferenceStack
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CalcEngine_CyclicReferenceStack { class CalcEngine_CyclicReferenceStack {
/** /**
* The call stack for calculated cells * The call stack for calculated cells
@ -95,4 +97,4 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
return $this->_stack; return $this->_stack;
} }
} // class PHPExcel_CalcEngine_CyclicReferenceStack }

View File

@ -19,20 +19,22 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_CalcEngine_Logger * PHPExcel\CalcEngine_Logger
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CalcEngine_Logger { class CalcEngine_Logger {
/** /**
* Flag to determine whether a debug log should be generated by the calculation engine * Flag to determine whether a debug log should be generated by the calculation engine
@ -63,7 +65,7 @@ class PHPExcel_CalcEngine_Logger {
/** /**
* The calculation engine cell reference stack * The calculation engine cell reference stack
* *
* @var PHPExcel_CalcEngine_CyclicReferenceStack * @var PHPExcel\CalcEngine_CyclicReferenceStack
*/ */
private $_cellStack; private $_cellStack;
@ -71,9 +73,9 @@ class PHPExcel_CalcEngine_Logger {
/** /**
* Instantiate a Calculation engine logger * Instantiate a Calculation engine logger
* *
* @param PHPExcel_CalcEngine_CyclicReferenceStack $stack * @param PHPExcel\CalcEngine_CyclicReferenceStack $stack
*/ */
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack) { public function __construct(CalcEngine_CyclicReferenceStack $stack) {
$this->_cellStack = $stack; $this->_cellStack = $stack;
} }
@ -149,5 +151,5 @@ class PHPExcel_CalcEngine_Logger {
return $this->_debugLog; return $this->_debugLog;
} // function flushLogger() } // function flushLogger()
} // class PHPExcel_CalcEngine_Logger }

File diff suppressed because it is too large Load Diff

View File

@ -19,31 +19,23 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Calculation_Database * PHPExcel\Calculation_Database
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_Database { class Calculation_Database {
/** /**
@ -65,7 +57,7 @@ class PHPExcel_Calculation_Database {
* *
*/ */
private static function __fieldExtract($database,$field) { private static function __fieldExtract($database,$field) {
$field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field)); $field = strtoupper(Calculation_Functions::flattenSingleValue($field));
$fieldNames = array_map('strtoupper',array_shift($database)); $fieldNames = array_map('strtoupper',array_shift($database));
if (is_numeric($field)) { if (is_numeric($field)) {
@ -107,7 +99,7 @@ class PHPExcel_Calculation_Database {
$testConditionCount = 0; $testConditionCount = 0;
foreach($criteria as $row => $criterion) { foreach($criteria as $row => $criterion) {
if ($criterion[$key] > '') { if ($criterion[$key] > '') {
$testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::_ifCondition($criterion[$key]); $testCondition[] = '[:'.$criteriaName.']'.Calculation_Functions::_ifCondition($criterion[$key]);
$testConditionCount++; $testConditionCount++;
} }
} }
@ -134,12 +126,12 @@ class PHPExcel_Calculation_Database {
$k = array_search($criteriaName,$fieldNames); $k = array_search($criteriaName,$fieldNames);
if (isset($dataValues[$k])) { if (isset($dataValues[$k])) {
$dataValue = $dataValues[$k]; $dataValue = $dataValues[$k];
$dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::_wrapResult(strtoupper($dataValue)) : $dataValue; $dataValue = (is_string($dataValue)) ? Calculation::_wrapResult(strtoupper($dataValue)) : $dataValue;
$testConditionList = str_replace('[:'.$criteriaName.']',$dataValue,$testConditionList); $testConditionList = str_replace('[:'.$criteriaName.']',$dataValue,$testConditionList);
} }
} }
// evaluate the criteria against the row data // evaluate the criteria against the row data
$result = PHPExcel_Calculation::getInstance()->_calculateFormulaValue('='.$testConditionList); $result = Calculation::getInstance()->_calculateFormulaValue('='.$testConditionList);
// If the row failed to meet the criteria, remove it from the database // If the row failed to meet the criteria, remove it from the database
if (!$result) { if (!$result) {
unset($database[$dataRow]); unset($database[$dataRow]);
@ -191,7 +183,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_Statistical::AVERAGE($colData); return Calculation_Statistical::AVERAGE($colData);
} // function DAVERAGE() } // function DAVERAGE()
@ -244,7 +236,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_Statistical::COUNT($colData); return Calculation_Statistical::COUNT($colData);
} // function DCOUNT() } // function DCOUNT()
@ -293,7 +285,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_Statistical::COUNTA($colData); return Calculation_Statistical::COUNTA($colData);
} // function DCOUNTA() } // function DCOUNTA()
@ -341,7 +333,7 @@ class PHPExcel_Calculation_Database {
// Return // Return
if (count($colData) > 1) { if (count($colData) > 1) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
return $colData[0]; return $colData[0];
@ -391,7 +383,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_Statistical::MAX($colData); return Calculation_Statistical::MAX($colData);
} // function DMAX() } // function DMAX()
@ -438,7 +430,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_Statistical::MIN($colData); return Calculation_Statistical::MIN($colData);
} // function DMIN() } // function DMIN()
@ -484,7 +476,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_MathTrig::PRODUCT($colData); return Calculation_MathTrig::PRODUCT($colData);
} // function DPRODUCT() } // function DPRODUCT()
@ -531,7 +523,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_Statistical::STDEV($colData); return Calculation_Statistical::STDEV($colData);
} // function DSTDEV() } // function DSTDEV()
@ -578,7 +570,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_Statistical::STDEVP($colData); return Calculation_Statistical::STDEVP($colData);
} // function DSTDEVP() } // function DSTDEVP()
@ -624,7 +616,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_MathTrig::SUM($colData); return Calculation_MathTrig::SUM($colData);
} // function DSUM() } // function DSUM()
@ -671,7 +663,7 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_Statistical::VARFunc($colData); return Calculation_Statistical::VARFunc($colData);
} // function DVAR() } // function DVAR()
@ -718,8 +710,8 @@ class PHPExcel_Calculation_Database {
} }
// Return // Return
return PHPExcel_Calculation_Statistical::VARP($colData); return Calculation_Statistical::VARP($colData);
} // function DVARP() } // function DVARP()
} // class PHPExcel_Calculation_Database }

View File

@ -19,31 +19,23 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Calculation_DateTime * PHPExcel\Calculation_DateTime
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_DateTime { class Calculation_DateTime {
/** /**
* Identify if a year is a leap year or not * Identify if a year is a leap year or not
@ -101,16 +93,16 @@ class PHPExcel_Calculation_DateTime {
public static function _getDateValue($dateValue) { public static function _getDateValue($dateValue) {
if (!is_numeric($dateValue)) { if (!is_numeric($dateValue)) {
if ((is_string($dateValue)) && if ((is_string($dateValue)) &&
(PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) { (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) { if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
$dateValue = PHPExcel_Shared_Date::PHPToExcel($dateValue); $dateValue = Shared_Date::PHPToExcel($dateValue);
} else { } else {
$saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType(); $saveReturnDateType = Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); Calculation_Functions::setReturnDateType(Calculation_Functions::RETURNDATE_EXCEL);
$dateValue = self::DATEVALUE($dateValue); $dateValue = self::DATEVALUE($dateValue);
PHPExcel_Calculation_Functions::setReturnDateType($saveReturnDateType); Calculation_Functions::setReturnDateType($saveReturnDateType);
} }
} }
return $dateValue; return $dateValue;
@ -124,17 +116,17 @@ class PHPExcel_Calculation_DateTime {
* @return mixed Excel date/time serial value, or string if error * @return mixed Excel date/time serial value, or string if error
*/ */
private static function _getTimeValue($timeValue) { private static function _getTimeValue($timeValue) {
$saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType(); $saveReturnDateType = Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); Calculation_Functions::setReturnDateType(Calculation_Functions::RETURNDATE_EXCEL);
$timeValue = self::TIMEVALUE($timeValue); $timeValue = self::TIMEVALUE($timeValue);
PHPExcel_Calculation_Functions::setReturnDateType($saveReturnDateType); Calculation_Functions::setReturnDateType($saveReturnDateType);
return $timeValue; return $timeValue;
} // function _getTimeValue() } // function _getTimeValue()
private static function _adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) { private static function _adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) {
// Execute function // Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue); $PHPDateObject = Shared_Date::ExcelToPHPObject($dateValue);
$oMonth = (int) $PHPDateObject->format('m'); $oMonth = (int) $PHPDateObject->format('m');
$oYear = (int) $PHPDateObject->format('Y'); $oYear = (int) $PHPDateObject->format('Y');
@ -181,14 +173,14 @@ class PHPExcel_Calculation_DateTime {
$saveTimeZone = date_default_timezone_get(); $saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$retValue = False; $retValue = False;
switch (PHPExcel_Calculation_Functions::getReturnDateType()) { switch (Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : case Calculation_Functions::RETURNDATE_EXCEL :
$retValue = (float) PHPExcel_Shared_Date::PHPToExcel(time()); $retValue = (float) Shared_Date::PHPToExcel(time());
break; break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : case Calculation_Functions::RETURNDATE_PHP_NUMERIC :
$retValue = (integer) time(); $retValue = (integer) time();
break; break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : case Calculation_Functions::RETURNDATE_PHP_OBJECT :
$retValue = new DateTime(); $retValue = new DateTime();
break; break;
} }
@ -221,16 +213,16 @@ class PHPExcel_Calculation_DateTime {
$saveTimeZone = date_default_timezone_get(); $saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$retValue = False; $retValue = False;
$excelDateTime = floor(PHPExcel_Shared_Date::PHPToExcel(time())); $excelDateTime = floor(Shared_Date::PHPToExcel(time()));
switch (PHPExcel_Calculation_Functions::getReturnDateType()) { switch (Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : case Calculation_Functions::RETURNDATE_EXCEL :
$retValue = (float) $excelDateTime; $retValue = (float) $excelDateTime;
break; break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : case Calculation_Functions::RETURNDATE_PHP_NUMERIC :
$retValue = (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateTime); $retValue = (integer) Shared_Date::ExcelToPHP($excelDateTime);
break; break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : case Calculation_Functions::RETURNDATE_PHP_OBJECT :
$retValue = PHPExcel_Shared_Date::ExcelToPHPObject($excelDateTime); $retValue = Shared_Date::ExcelToPHPObject($excelDateTime);
break; break;
} }
date_default_timezone_set($saveTimeZone); date_default_timezone_set($saveTimeZone);
@ -290,37 +282,37 @@ class PHPExcel_Calculation_DateTime {
* depending on the value of the ReturnDateType flag * depending on the value of the ReturnDateType flag
*/ */
public static function DATE($year = 0, $month = 1, $day = 1) { public static function DATE($year = 0, $month = 1, $day = 1) {
$year = PHPExcel_Calculation_Functions::flattenSingleValue($year); $year = Calculation_Functions::flattenSingleValue($year);
$month = PHPExcel_Calculation_Functions::flattenSingleValue($month); $month = Calculation_Functions::flattenSingleValue($month);
$day = PHPExcel_Calculation_Functions::flattenSingleValue($day); $day = Calculation_Functions::flattenSingleValue($day);
if (($month !== NULL) && (!is_numeric($month))) { if (($month !== NULL) && (!is_numeric($month))) {
$month = PHPExcel_Shared_Date::monthStringToNumber($month); $month = Shared_Date::monthStringToNumber($month);
} }
if (($day !== NULL) && (!is_numeric($day))) { if (($day !== NULL) && (!is_numeric($day))) {
$day = PHPExcel_Shared_Date::dayStringToNumber($day); $day = Shared_Date::dayStringToNumber($day);
} }
$year = ($year !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($year) : 0; $year = ($year !== NULL) ? Shared_String::testStringAsNumeric($year) : 0;
$month = ($month !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($month) : 0; $month = ($month !== NULL) ? Shared_String::testStringAsNumeric($month) : 0;
$day = ($day !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($day) : 0; $day = ($day !== NULL) ? Shared_String::testStringAsNumeric($day) : 0;
if ((!is_numeric($year)) || if ((!is_numeric($year)) ||
(!is_numeric($month)) || (!is_numeric($month)) ||
(!is_numeric($day))) { (!is_numeric($day))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$year = (integer) $year; $year = (integer) $year;
$month = (integer) $month; $month = (integer) $month;
$day = (integer) $day; $day = (integer) $day;
$baseYear = PHPExcel_Shared_Date::getExcelCalendar(); $baseYear = Shared_Date::getExcelCalendar();
// Validate parameters // Validate parameters
if ($year < ($baseYear-1900)) { if ($year < ($baseYear-1900)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
if ((($baseYear-1900) != 0) && ($year < $baseYear) && ($year >= 1900)) { if ((($baseYear-1900) != 0) && ($year < $baseYear) && ($year >= 1900)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
if (($year < $baseYear) && ($year >= ($baseYear-1900))) { if (($year < $baseYear) && ($year >= ($baseYear-1900))) {
@ -340,18 +332,18 @@ class PHPExcel_Calculation_DateTime {
// Re-validate the year parameter after adjustments // Re-validate the year parameter after adjustments
if (($year < $baseYear) || ($year >= 10000)) { if (($year < $baseYear) || ($year >= 10000)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
// Execute function // Execute function
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day); $excelDateValue = Shared_Date::FormattedPHPToExcel($year, $month, $day);
switch (PHPExcel_Calculation_Functions::getReturnDateType()) { switch (Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : case Calculation_Functions::RETURNDATE_EXCEL :
return (float) $excelDateValue; return (float) $excelDateValue;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : case Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue); return (integer) Shared_Date::ExcelToPHP($excelDateValue);
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : case Calculation_Functions::RETURNDATE_PHP_OBJECT :
return PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue); return Shared_Date::ExcelToPHPObject($excelDateValue);
} }
} // function DATE() } // function DATE()
@ -384,16 +376,16 @@ class PHPExcel_Calculation_DateTime {
* depending on the value of the ReturnDateType flag * depending on the value of the ReturnDateType flag
*/ */
public static function TIME($hour = 0, $minute = 0, $second = 0) { public static function TIME($hour = 0, $minute = 0, $second = 0) {
$hour = PHPExcel_Calculation_Functions::flattenSingleValue($hour); $hour = Calculation_Functions::flattenSingleValue($hour);
$minute = PHPExcel_Calculation_Functions::flattenSingleValue($minute); $minute = Calculation_Functions::flattenSingleValue($minute);
$second = PHPExcel_Calculation_Functions::flattenSingleValue($second); $second = Calculation_Functions::flattenSingleValue($second);
if ($hour == '') { $hour = 0; } if ($hour == '') { $hour = 0; }
if ($minute == '') { $minute = 0; } if ($minute == '') { $minute = 0; }
if ($second == '') { $second = 0; } if ($second == '') { $second = 0; }
if ((!is_numeric($hour)) || (!is_numeric($minute)) || (!is_numeric($second))) { if ((!is_numeric($hour)) || (!is_numeric($minute)) || (!is_numeric($second))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$hour = (integer) $hour; $hour = (integer) $hour;
$minute = (integer) $minute; $minute = (integer) $minute;
@ -419,21 +411,21 @@ class PHPExcel_Calculation_DateTime {
if ($hour > 23) { if ($hour > 23) {
$hour = $hour % 24; $hour = $hour % 24;
} elseif ($hour < 0) { } elseif ($hour < 0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
// Execute function // Execute function
switch (PHPExcel_Calculation_Functions::getReturnDateType()) { switch (Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : case Calculation_Functions::RETURNDATE_EXCEL :
$date = 0; $date = 0;
$calendar = PHPExcel_Shared_Date::getExcelCalendar(); $calendar = Shared_Date::getExcelCalendar();
if ($calendar != PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900) { if ($calendar != Shared_Date::CALENDAR_WINDOWS_1900) {
$date = 1; $date = 1;
} }
return (float) PHPExcel_Shared_Date::FormattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second); return (float) Shared_Date::FormattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : case Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600 return (integer) Shared_Date::ExcelToPHP(Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : case Calculation_Functions::RETURNDATE_PHP_OBJECT :
$dayAdjust = 0; $dayAdjust = 0;
if ($hour < 0) { if ($hour < 0) {
$dayAdjust = floor($hour / 24); $dayAdjust = floor($hour / 24);
@ -479,7 +471,7 @@ class PHPExcel_Calculation_DateTime {
* depending on the value of the ReturnDateType flag * depending on the value of the ReturnDateType flag
*/ */
public static function DATEVALUE($dateValue = 1) { public static function DATEVALUE($dateValue = 1) {
$dateValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($dateValue),'"'); $dateValue = trim(Calculation_Functions::flattenSingleValue($dateValue),'"');
// Strip any ordinals because they're allowed in Excel (English only) // Strip any ordinals because they're allowed in Excel (English only)
$dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui','$1$3',$dateValue); $dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui','$1$3',$dateValue);
// Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany) // Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany)
@ -490,7 +482,7 @@ class PHPExcel_Calculation_DateTime {
foreach($t1 as &$t) { foreach($t1 as &$t) {
if ((is_numeric($t)) && ($t > 31)) { if ((is_numeric($t)) && ($t > 31)) {
if ($yearFound) { if ($yearFound) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} else { } else {
if ($t < 100) { $t += 1900; } if ($t < 100) { $t += 1900; }
$yearFound = true; $yearFound = true;
@ -522,16 +514,16 @@ class PHPExcel_Calculation_DateTime {
$testVal3 = strftime('%Y'); $testVal3 = strftime('%Y');
} }
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$PHPDateArray = date_parse($testVal1.'-'.$testVal2.'-'.$testVal3); $PHPDateArray = date_parse($testVal1.'-'.$testVal2.'-'.$testVal3);
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) { if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
$PHPDateArray = date_parse($testVal2.'-'.$testVal1.'-'.$testVal3); $PHPDateArray = date_parse($testVal2.'-'.$testVal1.'-'.$testVal3);
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) { if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
} }
@ -540,21 +532,21 @@ class PHPExcel_Calculation_DateTime {
// Execute function // Execute function
if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); } if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); }
if ($PHPDateArray['year'] < 1900) if ($PHPDateArray['year'] < 1900)
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); } if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); }
if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); } if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); }
$excelDateValue = floor(PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second'])); $excelDateValue = floor(Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']));
switch (PHPExcel_Calculation_Functions::getReturnDateType()) { switch (Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : case Calculation_Functions::RETURNDATE_EXCEL :
return (float) $excelDateValue; return (float) $excelDateValue;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : case Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue); return (integer) Shared_Date::ExcelToPHP($excelDateValue);
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : case Calculation_Functions::RETURNDATE_PHP_OBJECT :
return new DateTime($PHPDateArray['year'].'-'.$PHPDateArray['month'].'-'.$PHPDateArray['day'].' 00:00:00'); return new DateTime($PHPDateArray['year'].'-'.$PHPDateArray['month'].'-'.$PHPDateArray['day'].' 00:00:00');
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function DATEVALUE() } // function DATEVALUE()
@ -581,27 +573,27 @@ class PHPExcel_Calculation_DateTime {
* depending on the value of the ReturnDateType flag * depending on the value of the ReturnDateType flag
*/ */
public static function TIMEVALUE($timeValue) { public static function TIMEVALUE($timeValue) {
$timeValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($timeValue),'"'); $timeValue = trim(Calculation_Functions::flattenSingleValue($timeValue),'"');
$timeValue = str_replace(array('/','.'),array('-','-'),$timeValue); $timeValue = str_replace(array('/','.'),array('-','-'),$timeValue);
$PHPDateArray = date_parse($timeValue); $PHPDateArray = date_parse($timeValue);
if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) { if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']); $excelDateValue = Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']);
} else { } else {
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(1900,1,1,$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']) - 1; $excelDateValue = Shared_Date::FormattedPHPToExcel(1900,1,1,$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']) - 1;
} }
switch (PHPExcel_Calculation_Functions::getReturnDateType()) { switch (Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : case Calculation_Functions::RETURNDATE_EXCEL :
return (float) $excelDateValue; return (float) $excelDateValue;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : case Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;; return (integer) $phpDateValue = Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : case Calculation_Functions::RETURNDATE_PHP_OBJECT :
return new DateTime('1900-01-01 '.$PHPDateArray['hour'].':'.$PHPDateArray['minute'].':'.$PHPDateArray['second']); return new DateTime('1900-01-01 '.$PHPDateArray['hour'].':'.$PHPDateArray['minute'].':'.$PHPDateArray['second']);
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function TIMEVALUE() } // function TIMEVALUE()
@ -616,36 +608,36 @@ class PHPExcel_Calculation_DateTime {
* @return integer Interval between the dates * @return integer Interval between the dates
*/ */
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') { public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') {
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); $startDate = Calculation_Functions::flattenSingleValue($startDate);
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); $endDate = Calculation_Functions::flattenSingleValue($endDate);
$unit = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($unit)); $unit = strtoupper(Calculation_Functions::flattenSingleValue($unit));
if (is_string($startDate = self::_getDateValue($startDate))) { if (is_string($startDate = self::_getDateValue($startDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (is_string($endDate = self::_getDateValue($endDate))) { if (is_string($endDate = self::_getDateValue($endDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
// Validate parameters // Validate parameters
if ($startDate >= $endDate) { if ($startDate >= $endDate) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
// Execute function // Execute function
$difference = $endDate - $startDate; $difference = $endDate - $startDate;
$PHPStartDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($startDate); $PHPStartDateObject = Shared_Date::ExcelToPHPObject($startDate);
$startDays = $PHPStartDateObject->format('j'); $startDays = $PHPStartDateObject->format('j');
$startMonths = $PHPStartDateObject->format('n'); $startMonths = $PHPStartDateObject->format('n');
$startYears = $PHPStartDateObject->format('Y'); $startYears = $PHPStartDateObject->format('Y');
$PHPEndDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($endDate); $PHPEndDateObject = Shared_Date::ExcelToPHPObject($endDate);
$endDays = $PHPEndDateObject->format('j'); $endDays = $PHPEndDateObject->format('j');
$endMonths = $PHPEndDateObject->format('n'); $endMonths = $PHPEndDateObject->format('n');
$endYears = $PHPEndDateObject->format('Y'); $endYears = $PHPEndDateObject->format('Y');
$retVal = PHPExcel_Calculation_Functions::NaN(); $retVal = Calculation_Functions::NaN();
switch ($unit) { switch ($unit) {
case 'D': case 'D':
$retVal = intval($difference); $retVal = intval($difference);
@ -698,7 +690,7 @@ class PHPExcel_Calculation_DateTime {
} }
break; break;
default: default:
$retVal = PHPExcel_Calculation_Functions::NaN(); $retVal = Calculation_Functions::NaN();
} }
return $retVal; return $retVal;
} // function DATEDIF() } // function DATEDIF()
@ -734,27 +726,27 @@ class PHPExcel_Calculation_DateTime {
* @return integer Number of days between start date and end date * @return integer Number of days between start date and end date
*/ */
public static function DAYS360($startDate = 0, $endDate = 0, $method = false) { public static function DAYS360($startDate = 0, $endDate = 0, $method = false) {
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); $startDate = Calculation_Functions::flattenSingleValue($startDate);
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); $endDate = Calculation_Functions::flattenSingleValue($endDate);
if (is_string($startDate = self::_getDateValue($startDate))) { if (is_string($startDate = self::_getDateValue($startDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (is_string($endDate = self::_getDateValue($endDate))) { if (is_string($endDate = self::_getDateValue($endDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (!is_bool($method)) { if (!is_bool($method)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
// Execute function // Execute function
$PHPStartDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($startDate); $PHPStartDateObject = Shared_Date::ExcelToPHPObject($startDate);
$startDay = $PHPStartDateObject->format('j'); $startDay = $PHPStartDateObject->format('j');
$startMonth = $PHPStartDateObject->format('n'); $startMonth = $PHPStartDateObject->format('n');
$startYear = $PHPStartDateObject->format('Y'); $startYear = $PHPStartDateObject->format('Y');
$PHPEndDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($endDate); $PHPEndDateObject = Shared_Date::ExcelToPHPObject($endDate);
$endDay = $PHPEndDateObject->format('j'); $endDay = $PHPEndDateObject->format('j');
$endMonth = $PHPEndDateObject->format('n'); $endMonth = $PHPEndDateObject->format('n');
$endYear = $PHPEndDateObject->format('Y'); $endYear = $PHPEndDateObject->format('Y');
@ -789,15 +781,15 @@ class PHPExcel_Calculation_DateTime {
* @return float fraction of the year * @return float fraction of the year
*/ */
public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) { public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) {
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); $startDate = Calculation_Functions::flattenSingleValue($startDate);
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); $endDate = Calculation_Functions::flattenSingleValue($endDate);
$method = PHPExcel_Calculation_Functions::flattenSingleValue($method); $method = Calculation_Functions::flattenSingleValue($method);
if (is_string($startDate = self::_getDateValue($startDate))) { if (is_string($startDate = self::_getDateValue($startDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (is_string($endDate = self::_getDateValue($endDate))) { if (is_string($endDate = self::_getDateValue($endDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) { if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) {
@ -856,7 +848,7 @@ class PHPExcel_Calculation_DateTime {
return self::DAYS360($startDate,$endDate,True) / 360; return self::DAYS360($startDate,$endDate,True) / 360;
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function YEARFRAC() } // function YEARFRAC()
@ -885,20 +877,20 @@ class PHPExcel_Calculation_DateTime {
*/ */
public static function NETWORKDAYS($startDate,$endDate) { public static function NETWORKDAYS($startDate,$endDate) {
// Retrieve the mandatory start and end date that are referenced in the function definition // Retrieve the mandatory start and end date that are referenced in the function definition
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); $startDate = Calculation_Functions::flattenSingleValue($startDate);
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); $endDate = Calculation_Functions::flattenSingleValue($endDate);
// Flush the mandatory start and end date that are referenced in the function definition, and get the optional days // Flush the mandatory start and end date that are referenced in the function definition, and get the optional days
$dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); $dateArgs = Calculation_Functions::flattenArray(func_get_args());
array_shift($dateArgs); array_shift($dateArgs);
array_shift($dateArgs); array_shift($dateArgs);
// Validate the start and end dates // Validate the start and end dates
if (is_string($startDate = $sDate = self::_getDateValue($startDate))) { if (is_string($startDate = $sDate = self::_getDateValue($startDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$startDate = (float) floor($startDate); $startDate = (float) floor($startDate);
if (is_string($endDate = $eDate = self::_getDateValue($endDate))) { if (is_string($endDate = $eDate = self::_getDateValue($endDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$endDate = (float) floor($endDate); $endDate = (float) floor($endDate);
@ -923,7 +915,7 @@ class PHPExcel_Calculation_DateTime {
$holidayCountedArray = array(); $holidayCountedArray = array();
foreach ($dateArgs as $holidayDate) { foreach ($dateArgs as $holidayDate) {
if (is_string($holidayDate = self::_getDateValue($holidayDate))) { if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) { if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) { if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) {
@ -967,15 +959,15 @@ class PHPExcel_Calculation_DateTime {
*/ */
public static function WORKDAY($startDate,$endDays) { public static function WORKDAY($startDate,$endDays) {
// Retrieve the mandatory start date and days that are referenced in the function definition // Retrieve the mandatory start date and days that are referenced in the function definition
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); $startDate = Calculation_Functions::flattenSingleValue($startDate);
$endDays = PHPExcel_Calculation_Functions::flattenSingleValue($endDays); $endDays = Calculation_Functions::flattenSingleValue($endDays);
// Flush the mandatory start date and days that are referenced in the function definition, and get the optional days // Flush the mandatory start date and days that are referenced in the function definition, and get the optional days
$dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); $dateArgs = Calculation_Functions::flattenArray(func_get_args());
array_shift($dateArgs); array_shift($dateArgs);
array_shift($dateArgs); array_shift($dateArgs);
if ((is_string($startDate = self::_getDateValue($startDate))) || (!is_numeric($endDays))) { if ((is_string($startDate = self::_getDateValue($startDate))) || (!is_numeric($endDays))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$startDate = (float) floor($startDate); $startDate = (float) floor($startDate);
$endDays = (int) floor($endDays); $endDays = (int) floor($endDays);
@ -1007,7 +999,7 @@ class PHPExcel_Calculation_DateTime {
foreach ($dateArgs as $holidayDate) { foreach ($dateArgs as $holidayDate) {
if (($holidayDate !== NULL) && (trim($holidayDate) > '')) { if (($holidayDate !== NULL) && (trim($holidayDate) > '')) {
if (is_string($holidayDate = self::_getDateValue($holidayDate))) { if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (self::DAYOFWEEK($holidayDate,3) < 5) { if (self::DAYOFWEEK($holidayDate,3) < 5) {
$holidayDates[] = $holidayDate; $holidayDates[] = $holidayDate;
@ -1044,13 +1036,13 @@ class PHPExcel_Calculation_DateTime {
} }
} }
switch (PHPExcel_Calculation_Functions::getReturnDateType()) { switch (Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : case Calculation_Functions::RETURNDATE_EXCEL :
return (float) $endDate; return (float) $endDate;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : case Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP($endDate); return (integer) Shared_Date::ExcelToPHP($endDate);
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : case Calculation_Functions::RETURNDATE_PHP_OBJECT :
return PHPExcel_Shared_Date::ExcelToPHPObject($endDate); return Shared_Date::ExcelToPHPObject($endDate);
} }
} // function WORKDAY() } // function WORKDAY()
@ -1069,18 +1061,18 @@ class PHPExcel_Calculation_DateTime {
* @return int Day of the month * @return int Day of the month
*/ */
public static function DAYOFMONTH($dateValue = 1) { public static function DAYOFMONTH($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); $dateValue = Calculation_Functions::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) { if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif ($dateValue == 0.0) { } elseif ($dateValue == 0.0) {
return 0; return 0;
} elseif ($dateValue < 0.0) { } elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
// Execute function // Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue); $PHPDateObject = Shared_Date::ExcelToPHPObject($dateValue);
return (int) $PHPDateObject->format('j'); return (int) $PHPDateObject->format('j');
} // function DAYOFMONTH() } // function DAYOFMONTH()
@ -1104,24 +1096,24 @@ class PHPExcel_Calculation_DateTime {
* @return int Day of the week value * @return int Day of the week value
*/ */
public static function DAYOFWEEK($dateValue = 1, $style = 1) { public static function DAYOFWEEK($dateValue = 1, $style = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); $dateValue = Calculation_Functions::flattenSingleValue($dateValue);
$style = PHPExcel_Calculation_Functions::flattenSingleValue($style); $style = Calculation_Functions::flattenSingleValue($style);
if (!is_numeric($style)) { if (!is_numeric($style)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif (($style < 1) || ($style > 3)) { } elseif (($style < 1) || ($style > 3)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$style = floor($style); $style = floor($style);
if (is_string($dateValue = self::_getDateValue($dateValue))) { if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) { } elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
// Execute function // Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue); $PHPDateObject = Shared_Date::ExcelToPHPObject($dateValue);
$DoW = $PHPDateObject->format('w'); $DoW = $PHPDateObject->format('w');
$firstDay = 1; $firstDay = 1;
@ -1135,7 +1127,7 @@ class PHPExcel_Calculation_DateTime {
--$DoW; --$DoW;
break; break;
} }
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_EXCEL) {
// Test for Excel's 1900 leap year, and introduce the error as required // Test for Excel's 1900 leap year, and introduce the error as required
if (($PHPDateObject->format('Y') == 1900) && ($PHPDateObject->format('n') <= 2)) { if (($PHPDateObject->format('Y') == 1900) && ($PHPDateObject->format('n') <= 2)) {
--$DoW; --$DoW;
@ -1170,24 +1162,24 @@ class PHPExcel_Calculation_DateTime {
* @return int Week Number * @return int Week Number
*/ */
public static function WEEKOFYEAR($dateValue = 1, $method = 1) { public static function WEEKOFYEAR($dateValue = 1, $method = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); $dateValue = Calculation_Functions::flattenSingleValue($dateValue);
$method = PHPExcel_Calculation_Functions::flattenSingleValue($method); $method = Calculation_Functions::flattenSingleValue($method);
if (!is_numeric($method)) { if (!is_numeric($method)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif (($method < 1) || ($method > 2)) { } elseif (($method < 1) || ($method > 2)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$method = floor($method); $method = floor($method);
if (is_string($dateValue = self::_getDateValue($dateValue))) { if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) { } elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
// Execute function // Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue); $PHPDateObject = Shared_Date::ExcelToPHPObject($dateValue);
$dayOfYear = $PHPDateObject->format('z'); $dayOfYear = $PHPDateObject->format('z');
$dow = $PHPDateObject->format('w'); $dow = $PHPDateObject->format('w');
$PHPDateObject->modify('-'.$dayOfYear.' days'); $PHPDateObject->modify('-'.$dayOfYear.' days');
@ -1214,16 +1206,16 @@ class PHPExcel_Calculation_DateTime {
* @return int Month of the year * @return int Month of the year
*/ */
public static function MONTHOFYEAR($dateValue = 1) { public static function MONTHOFYEAR($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); $dateValue = Calculation_Functions::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) { if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) { } elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
// Execute function // Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue); $PHPDateObject = Shared_Date::ExcelToPHPObject($dateValue);
return (int) $PHPDateObject->format('n'); return (int) $PHPDateObject->format('n');
} // function MONTHOFYEAR() } // function MONTHOFYEAR()
@ -1243,16 +1235,16 @@ class PHPExcel_Calculation_DateTime {
* @return int Year * @return int Year
*/ */
public static function YEAR($dateValue = 1) { public static function YEAR($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); $dateValue = Calculation_Functions::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) { if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) { } elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
// Execute function // Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue); $PHPDateObject = Shared_Date::ExcelToPHPObject($dateValue);
return (int) $PHPDateObject->format('Y'); return (int) $PHPDateObject->format('Y');
} // function YEAR() } // function YEAR()
@ -1272,27 +1264,27 @@ class PHPExcel_Calculation_DateTime {
* @return int Hour * @return int Hour
*/ */
public static function HOUROFDAY($timeValue = 0) { public static function HOUROFDAY($timeValue = 0) {
$timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue); $timeValue = Calculation_Functions::flattenSingleValue($timeValue);
if (!is_numeric($timeValue)) { if (!is_numeric($timeValue)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$testVal = strtok($timeValue,'/-: '); $testVal = strtok($timeValue,'/-: ');
if (strlen($testVal) < strlen($timeValue)) { if (strlen($testVal) < strlen($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
$timeValue = self::_getTimeValue($timeValue); $timeValue = self::_getTimeValue($timeValue);
if (is_string($timeValue)) { if (is_string($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
// Execute function // Execute function
if ($timeValue >= 1) { if ($timeValue >= 1) {
$timeValue = fmod($timeValue,1); $timeValue = fmod($timeValue,1);
} elseif ($timeValue < 0.0) { } elseif ($timeValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue); $timeValue = Shared_Date::ExcelToPHP($timeValue);
return (int) gmdate('G',$timeValue); return (int) gmdate('G',$timeValue);
} // function HOUROFDAY() } // function HOUROFDAY()
@ -1312,27 +1304,27 @@ class PHPExcel_Calculation_DateTime {
* @return int Minute * @return int Minute
*/ */
public static function MINUTEOFHOUR($timeValue = 0) { public static function MINUTEOFHOUR($timeValue = 0) {
$timeValue = $timeTester = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue); $timeValue = $timeTester = Calculation_Functions::flattenSingleValue($timeValue);
if (!is_numeric($timeValue)) { if (!is_numeric($timeValue)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$testVal = strtok($timeValue,'/-: '); $testVal = strtok($timeValue,'/-: ');
if (strlen($testVal) < strlen($timeValue)) { if (strlen($testVal) < strlen($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
$timeValue = self::_getTimeValue($timeValue); $timeValue = self::_getTimeValue($timeValue);
if (is_string($timeValue)) { if (is_string($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
// Execute function // Execute function
if ($timeValue >= 1) { if ($timeValue >= 1) {
$timeValue = fmod($timeValue,1); $timeValue = fmod($timeValue,1);
} elseif ($timeValue < 0.0) { } elseif ($timeValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue); $timeValue = Shared_Date::ExcelToPHP($timeValue);
return (int) gmdate('i',$timeValue); return (int) gmdate('i',$timeValue);
} // function MINUTEOFHOUR() } // function MINUTEOFHOUR()
@ -1352,27 +1344,27 @@ class PHPExcel_Calculation_DateTime {
* @return int Second * @return int Second
*/ */
public static function SECONDOFMINUTE($timeValue = 0) { public static function SECONDOFMINUTE($timeValue = 0) {
$timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue); $timeValue = Calculation_Functions::flattenSingleValue($timeValue);
if (!is_numeric($timeValue)) { if (!is_numeric($timeValue)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$testVal = strtok($timeValue,'/-: '); $testVal = strtok($timeValue,'/-: ');
if (strlen($testVal) < strlen($timeValue)) { if (strlen($testVal) < strlen($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
$timeValue = self::_getTimeValue($timeValue); $timeValue = self::_getTimeValue($timeValue);
if (is_string($timeValue)) { if (is_string($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
// Execute function // Execute function
if ($timeValue >= 1) { if ($timeValue >= 1) {
$timeValue = fmod($timeValue,1); $timeValue = fmod($timeValue,1);
} elseif ($timeValue < 0.0) { } elseif ($timeValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue); $timeValue = Shared_Date::ExcelToPHP($timeValue);
return (int) gmdate('s',$timeValue); return (int) gmdate('s',$timeValue);
} // function SECONDOFMINUTE() } // function SECONDOFMINUTE()
@ -1398,27 +1390,27 @@ class PHPExcel_Calculation_DateTime {
* depending on the value of the ReturnDateType flag * depending on the value of the ReturnDateType flag
*/ */
public static function EDATE($dateValue = 1, $adjustmentMonths = 0) { public static function EDATE($dateValue = 1, $adjustmentMonths = 0) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); $dateValue = Calculation_Functions::flattenSingleValue($dateValue);
$adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths); $adjustmentMonths = Calculation_Functions::flattenSingleValue($adjustmentMonths);
if (!is_numeric($adjustmentMonths)) { if (!is_numeric($adjustmentMonths)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$adjustmentMonths = floor($adjustmentMonths); $adjustmentMonths = floor($adjustmentMonths);
if (is_string($dateValue = self::_getDateValue($dateValue))) { if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
// Execute function // Execute function
$PHPDateObject = self::_adjustDateByMonths($dateValue,$adjustmentMonths); $PHPDateObject = self::_adjustDateByMonths($dateValue,$adjustmentMonths);
switch (PHPExcel_Calculation_Functions::getReturnDateType()) { switch (Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : case Calculation_Functions::RETURNDATE_EXCEL :
return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject); return (float) Shared_Date::PHPToExcel($PHPDateObject);
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : case Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject)); return (integer) Shared_Date::ExcelToPHP(Shared_Date::PHPToExcel($PHPDateObject));
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : case Calculation_Functions::RETURNDATE_PHP_OBJECT :
return $PHPDateObject; return $PHPDateObject;
} }
} // function EDATE() } // function EDATE()
@ -1443,16 +1435,16 @@ class PHPExcel_Calculation_DateTime {
* depending on the value of the ReturnDateType flag * depending on the value of the ReturnDateType flag
*/ */
public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) { public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); $dateValue = Calculation_Functions::flattenSingleValue($dateValue);
$adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths); $adjustmentMonths = Calculation_Functions::flattenSingleValue($adjustmentMonths);
if (!is_numeric($adjustmentMonths)) { if (!is_numeric($adjustmentMonths)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$adjustmentMonths = floor($adjustmentMonths); $adjustmentMonths = floor($adjustmentMonths);
if (is_string($dateValue = self::_getDateValue($dateValue))) { if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
// Execute function // Execute function
@ -1461,15 +1453,15 @@ class PHPExcel_Calculation_DateTime {
$adjustDaysString = '-'.$adjustDays.' days'; $adjustDaysString = '-'.$adjustDays.' days';
$PHPDateObject->modify($adjustDaysString); $PHPDateObject->modify($adjustDaysString);
switch (PHPExcel_Calculation_Functions::getReturnDateType()) { switch (Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : case Calculation_Functions::RETURNDATE_EXCEL :
return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject); return (float) Shared_Date::PHPToExcel($PHPDateObject);
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : case Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject)); return (integer) Shared_Date::ExcelToPHP(Shared_Date::PHPToExcel($PHPDateObject));
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : case Calculation_Functions::RETURNDATE_PHP_OBJECT :
return $PHPDateObject; return $PHPDateObject;
} }
} // function EOMONTH() } // function EOMONTH()
} // class PHPExcel_Calculation_DateTime }

View File

@ -19,35 +19,27 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** EULER */ /** EULER */
define('EULER', 2.71828182845904523536); define('EULER', 2.71828182845904523536);
/** /**
* PHPExcel_Calculation_Engineering * PHPExcel\Calculation_Engineering
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_Engineering { class Calculation_Engineering {
/** /**
* Details of the Units of measure that can be used in CONVERTUOM() * Details of the Units of measure that can be used in CONVERTUOM()
@ -766,7 +758,7 @@ class PHPExcel_Calculation_Engineering {
if (strlen($xVal) <= $places) { if (strlen($xVal) <= $places) {
return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10); return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10);
} else { } else {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
} }
@ -794,17 +786,17 @@ class PHPExcel_Calculation_Engineering {
* *
*/ */
public static function BESSELI($x, $ord) { public static function BESSELI($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = (is_null($x)) ? 0.0 : Calculation_Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); $ord = (is_null($ord)) ? 0.0 : Calculation_Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) { if ((is_numeric($x)) && (is_numeric($ord))) {
$ord = floor($ord); $ord = floor($ord);
if ($ord < 0) { if ($ord < 0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
if (abs($x) <= 30) { if (abs($x) <= 30) {
$fResult = $fTerm = pow($x / 2, $ord) / PHPExcel_Calculation_MathTrig::FACT($ord); $fResult = $fTerm = pow($x / 2, $ord) / Calculation_MathTrig::FACT($ord);
$ordK = 1; $ordK = 1;
$fSqrX = ($x * $x) / 4; $fSqrX = ($x * $x) / 4;
do { do {
@ -821,9 +813,9 @@ class PHPExcel_Calculation_Engineering {
$fResult = -$fResult; $fResult = -$fResult;
} }
} }
return (is_nan($fResult)) ? PHPExcel_Calculation_Functions::NaN() : $fResult; return (is_nan($fResult)) ? Calculation_Functions::NaN() : $fResult;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function BESSELI() } // function BESSELI()
@ -846,18 +838,18 @@ class PHPExcel_Calculation_Engineering {
* *
*/ */
public static function BESSELJ($x, $ord) { public static function BESSELJ($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = (is_null($x)) ? 0.0 : Calculation_Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); $ord = (is_null($ord)) ? 0.0 : Calculation_Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) { if ((is_numeric($x)) && (is_numeric($ord))) {
$ord = floor($ord); $ord = floor($ord);
if ($ord < 0) { if ($ord < 0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$fResult = 0; $fResult = 0;
if (abs($x) <= 30) { if (abs($x) <= 30) {
$fResult = $fTerm = pow($x / 2, $ord) / PHPExcel_Calculation_MathTrig::FACT($ord); $fResult = $fTerm = pow($x / 2, $ord) / Calculation_MathTrig::FACT($ord);
$ordK = 1; $ordK = 1;
$fSqrX = ($x * $x) / -4; $fSqrX = ($x * $x) / -4;
do { do {
@ -875,9 +867,9 @@ class PHPExcel_Calculation_Engineering {
$fResult = -$fResult; $fResult = -$fResult;
} }
} }
return (is_nan($fResult)) ? PHPExcel_Calculation_Functions::NaN() : $fResult; return (is_nan($fResult)) ? Calculation_Functions::NaN() : $fResult;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function BESSELJ() } // function BESSELJ()
@ -935,12 +927,12 @@ class PHPExcel_Calculation_Engineering {
* *
*/ */
public static function BESSELK($x, $ord) { public static function BESSELK($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = (is_null($x)) ? 0.0 : Calculation_Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); $ord = (is_null($ord)) ? 0.0 : Calculation_Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) { if ((is_numeric($x)) && (is_numeric($ord))) {
if (($ord < 0) || ($x == 0.0)) { if (($ord < 0) || ($x == 0.0)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
switch(floor($ord)) { switch(floor($ord)) {
@ -957,9 +949,9 @@ class PHPExcel_Calculation_Engineering {
$fBk = $fBkp; $fBk = $fBkp;
} }
} }
return (is_nan($fBk)) ? PHPExcel_Calculation_Functions::NaN() : $fBk; return (is_nan($fBk)) ? Calculation_Functions::NaN() : $fBk;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function BESSELK() } // function BESSELK()
@ -1015,12 +1007,12 @@ class PHPExcel_Calculation_Engineering {
* @return float * @return float
*/ */
public static function BESSELY($x, $ord) { public static function BESSELY($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = (is_null($x)) ? 0.0 : Calculation_Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); $ord = (is_null($ord)) ? 0.0 : Calculation_Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) { if ((is_numeric($x)) && (is_numeric($ord))) {
if (($ord < 0) || ($x == 0.0)) { if (($ord < 0) || ($x == 0.0)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
switch(floor($ord)) { switch(floor($ord)) {
@ -1037,9 +1029,9 @@ class PHPExcel_Calculation_Engineering {
$fBy = $fByp; $fBy = $fByp;
} }
} }
return (is_nan($fBy)) ? PHPExcel_Calculation_Functions::NaN() : $fBy; return (is_nan($fBy)) ? Calculation_Functions::NaN() : $fBy;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function BESSELY() } // function BESSELY()
@ -1062,24 +1054,24 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function BINTODEC($x) { public static function BINTODEC($x) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
if (is_bool($x)) { if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x; $x = (int) $x;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$x = floor($x); $x = floor($x);
} }
$x = (string) $x; $x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/',$x,$out)) { if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
if (strlen($x) > 10) { if (strlen($x) > 10) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} elseif (strlen($x) == 10) { } elseif (strlen($x) == 10) {
// Two's Complement // Two's Complement
$x = substr($x,-9); $x = substr($x,-9);
@ -1114,25 +1106,25 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function BINTOHEX($x, $places=NULL) { public static function BINTOHEX($x, $places=NULL) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); $places = Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) { if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x; $x = (int) $x;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$x = floor($x); $x = floor($x);
} }
$x = (string) $x; $x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/',$x,$out)) { if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
if (strlen($x) > 10) { if (strlen($x) > 10) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} elseif (strlen($x) == 10) { } elseif (strlen($x) == 10) {
// Two's Complement // Two's Complement
return str_repeat('F',8).substr(strtoupper(dechex(bindec(substr($x,-9)))),-2); return str_repeat('F',8).substr(strtoupper(dechex(bindec(substr($x,-9)))),-2);
@ -1168,25 +1160,25 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function BINTOOCT($x, $places=NULL) { public static function BINTOOCT($x, $places=NULL) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); $places = Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) { if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x; $x = (int) $x;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$x = floor($x); $x = floor($x);
} }
$x = (string) $x; $x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/',$x,$out)) { if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
if (strlen($x) > 10) { if (strlen($x) > 10) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} elseif (strlen($x) == 10) { } elseif (strlen($x) == 10) {
// Two's Complement // Two's Complement
return str_repeat('7',7).substr(strtoupper(decoct(bindec(substr($x,-9)))),-3); return str_repeat('7',7).substr(strtoupper(decoct(bindec(substr($x,-9)))),-3);
@ -1226,19 +1218,19 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function DECTOBIN($x, $places=NULL) { public static function DECTOBIN($x, $places=NULL) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); $places = Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) { if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x; $x = (int) $x;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
$x = (string) $x; $x = (string) $x;
if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) { if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = (string) floor($x); $x = (string) floor($x);
$r = decbin($x); $r = decbin($x);
@ -1246,7 +1238,7 @@ class PHPExcel_Calculation_Engineering {
// Two's Complement // Two's Complement
$r = substr($r,-10); $r = substr($r,-10);
} elseif (strlen($r) > 11) { } elseif (strlen($r) > 11) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
return self::_nbrConversionFormat($r,$places); return self::_nbrConversionFormat($r,$places);
@ -1282,19 +1274,19 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function DECTOHEX($x, $places=null) { public static function DECTOHEX($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); $places = Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) { if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x; $x = (int) $x;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
$x = (string) $x; $x = (string) $x;
if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) { if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = (string) floor($x); $x = (string) floor($x);
$r = strtoupper(dechex($x)); $r = strtoupper(dechex($x));
@ -1336,19 +1328,19 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function DECTOOCT($x, $places=null) { public static function DECTOOCT($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); $places = Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) { if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x; $x = (int) $x;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
$x = (string) $x; $x = (string) $x;
if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) { if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = (string) floor($x); $x = (string) floor($x);
$r = decoct($x); $r = decoct($x);
@ -1393,15 +1385,15 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function HEXTOBIN($x, $places=null) { public static function HEXTOBIN($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); $places = Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) { if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = (string) $x; $x = (string) $x;
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$binVal = decbin(hexdec($x)); $binVal = decbin(hexdec($x));
@ -1429,14 +1421,14 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function HEXTODEC($x) { public static function HEXTODEC($x) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
if (is_bool($x)) { if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = (string) $x; $x = (string) $x;
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
return hexdec($x); return hexdec($x);
} // function HEXTODEC() } // function HEXTODEC()
@ -1475,15 +1467,15 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function HEXTOOCT($x, $places=null) { public static function HEXTOOCT($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); $places = Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) { if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = (string) $x; $x = (string) $x;
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$octVal = decoct(hexdec($x)); $octVal = decoct(hexdec($x));
@ -1526,15 +1518,15 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function OCTTOBIN($x, $places=null) { public static function OCTTOBIN($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); $places = Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) { if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = (string) $x; $x = (string) $x;
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$r = decbin(octdec($x)); $r = decbin(octdec($x));
@ -1562,14 +1554,14 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function OCTTODEC($x) { public static function OCTTODEC($x) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
if (is_bool($x)) { if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = (string) $x; $x = (string) $x;
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
return octdec($x); return octdec($x);
} // function OCTTODEC() } // function OCTTODEC()
@ -1605,15 +1597,15 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function OCTTOHEX($x, $places=null) { public static function OCTTOHEX($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); $places = Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) { if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = (string) $x; $x = (string) $x;
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$hexVal = strtoupper(dechex(octdec($x))); $hexVal = strtoupper(dechex(octdec($x)));
@ -1638,9 +1630,9 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function COMPLEX($realNumber=0.0, $imaginary=0.0, $suffix='i') { public static function COMPLEX($realNumber=0.0, $imaginary=0.0, $suffix='i') {
$realNumber = (is_null($realNumber)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); $realNumber = (is_null($realNumber)) ? 0.0 : Calculation_Functions::flattenSingleValue($realNumber);
$imaginary = (is_null($imaginary)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($imaginary); $imaginary = (is_null($imaginary)) ? 0.0 : Calculation_Functions::flattenSingleValue($imaginary);
$suffix = (is_null($suffix)) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix); $suffix = (is_null($suffix)) ? 'i' : Calculation_Functions::flattenSingleValue($suffix);
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) && if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
(($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) { (($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) {
@ -1668,7 +1660,7 @@ class PHPExcel_Calculation_Engineering {
return (string) $realNumber.$imaginary.$suffix; return (string) $realNumber.$imaginary.$suffix;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function COMPLEX() } // function COMPLEX()
@ -1687,7 +1679,7 @@ class PHPExcel_Calculation_Engineering {
* @return float * @return float
*/ */
public static function IMAGINARY($complexNumber) { public static function IMAGINARY($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
return $parsedComplex['imaginary']; return $parsedComplex['imaginary'];
@ -1708,7 +1700,7 @@ class PHPExcel_Calculation_Engineering {
* @return float * @return float
*/ */
public static function IMREAL($complexNumber) { public static function IMREAL($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
return $parsedComplex['real']; return $parsedComplex['real'];
@ -1727,7 +1719,7 @@ class PHPExcel_Calculation_Engineering {
* @return float * @return float
*/ */
public static function IMABS($complexNumber) { public static function IMABS($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
@ -1748,7 +1740,7 @@ class PHPExcel_Calculation_Engineering {
* @return float * @return float
*/ */
public static function IMARGUMENT($complexNumber) { public static function IMARGUMENT($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
@ -1782,7 +1774,7 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function IMCONJUGATE($complexNumber) { public static function IMCONJUGATE($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
@ -1810,7 +1802,7 @@ class PHPExcel_Calculation_Engineering {
* @return string|float * @return string|float
*/ */
public static function IMCOS($complexNumber) { public static function IMCOS($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
@ -1834,7 +1826,7 @@ class PHPExcel_Calculation_Engineering {
* @return string|float * @return string|float
*/ */
public static function IMSIN($complexNumber) { public static function IMSIN($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
@ -1858,7 +1850,7 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function IMSQRT($complexNumber) { public static function IMSQRT($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
@ -1887,12 +1879,12 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function IMLN($complexNumber) { public static function IMLN($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) { if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$logR = log(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']))); $logR = log(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
@ -1918,12 +1910,12 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function IMLOG10($complexNumber) { public static function IMLOG10($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) { if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) { } elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return log10($parsedComplex['real']); return log10($parsedComplex['real']);
} }
@ -1944,12 +1936,12 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function IMLOG2($complexNumber) { public static function IMLOG2($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) { if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) { } elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return log($parsedComplex['real'],2); return log($parsedComplex['real'],2);
} }
@ -1970,7 +1962,7 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function IMEXP($complexNumber) { public static function IMEXP($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
@ -2003,11 +1995,11 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function IMPOWER($complexNumber,$realNumber) { public static function IMPOWER($complexNumber,$realNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); $complexNumber = Calculation_Functions::flattenSingleValue($complexNumber);
$realNumber = PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); $realNumber = Calculation_Functions::flattenSingleValue($realNumber);
if (!is_numeric($realNumber)) { if (!is_numeric($realNumber)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$parsedComplex = self::_parseComplex($complexNumber); $parsedComplex = self::_parseComplex($complexNumber);
@ -2038,15 +2030,15 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function IMDIV($complexDividend,$complexDivisor) { public static function IMDIV($complexDividend,$complexDivisor) {
$complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend); $complexDividend = Calculation_Functions::flattenSingleValue($complexDividend);
$complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor); $complexDivisor = Calculation_Functions::flattenSingleValue($complexDivisor);
$parsedComplexDividend = self::_parseComplex($complexDividend); $parsedComplexDividend = self::_parseComplex($complexDividend);
$parsedComplexDivisor = self::_parseComplex($complexDivisor); $parsedComplexDivisor = self::_parseComplex($complexDivisor);
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') && if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') &&
($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) { ($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) { if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) {
$parsedComplexDivisor['suffix'] = $parsedComplexDividend['suffix']; $parsedComplexDivisor['suffix'] = $parsedComplexDividend['suffix'];
@ -2082,15 +2074,15 @@ class PHPExcel_Calculation_Engineering {
* @return string * @return string
*/ */
public static function IMSUB($complexNumber1,$complexNumber2) { public static function IMSUB($complexNumber1,$complexNumber2) {
$complexNumber1 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber1); $complexNumber1 = Calculation_Functions::flattenSingleValue($complexNumber1);
$complexNumber2 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber2); $complexNumber2 = Calculation_Functions::flattenSingleValue($complexNumber2);
$parsedComplex1 = self::_parseComplex($complexNumber1); $parsedComplex1 = self::_parseComplex($complexNumber1);
$parsedComplex2 = self::_parseComplex($complexNumber2); $parsedComplex2 = self::_parseComplex($complexNumber2);
if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) && if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) &&
($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) { ($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) { } elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) {
$parsedComplex1['suffix'] = $parsedComplex2['suffix']; $parsedComplex1['suffix'] = $parsedComplex2['suffix'];
} }
@ -2119,14 +2111,14 @@ class PHPExcel_Calculation_Engineering {
$activeSuffix = ''; $activeSuffix = '';
// Loop through the arguments // Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); $aArgs = Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) { foreach ($aArgs as $arg) {
$parsedComplex = self::_parseComplex($arg); $parsedComplex = self::_parseComplex($arg);
if ($activeSuffix == '') { if ($activeSuffix == '') {
$activeSuffix = $parsedComplex['suffix']; $activeSuffix = $parsedComplex['suffix'];
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) { } elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$returnValue['real'] += $parsedComplex['real']; $returnValue['real'] += $parsedComplex['real'];
@ -2155,7 +2147,7 @@ class PHPExcel_Calculation_Engineering {
$activeSuffix = ''; $activeSuffix = '';
// Loop through the arguments // Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); $aArgs = Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) { foreach ($aArgs as $arg) {
$parsedComplex = self::_parseComplex($arg); $parsedComplex = self::_parseComplex($arg);
@ -2163,7 +2155,7 @@ class PHPExcel_Calculation_Engineering {
if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) { if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
$activeSuffix = $parsedComplex['suffix']; $activeSuffix = $parsedComplex['suffix'];
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) { } elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']); $returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']);
$returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']); $returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']);
@ -2190,8 +2182,8 @@ class PHPExcel_Calculation_Engineering {
* @return int * @return int
*/ */
public static function DELTA($a, $b=0) { public static function DELTA($a, $b=0) {
$a = PHPExcel_Calculation_Functions::flattenSingleValue($a); $a = Calculation_Functions::flattenSingleValue($a);
$b = PHPExcel_Calculation_Functions::flattenSingleValue($b); $b = Calculation_Functions::flattenSingleValue($b);
return (int) ($a == $b); return (int) ($a == $b);
} // function DELTA() } // function DELTA()
@ -2213,8 +2205,8 @@ class PHPExcel_Calculation_Engineering {
* @return int * @return int
*/ */
public static function GESTEP($number, $step=0) { public static function GESTEP($number, $step=0) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
$step = PHPExcel_Calculation_Functions::flattenSingleValue($step); $step = Calculation_Functions::flattenSingleValue($step);
return (int) ($number >= $step); return (int) ($number >= $step);
} // function GESTEP() } // function GESTEP()
@ -2266,8 +2258,8 @@ class PHPExcel_Calculation_Engineering {
* @return float * @return float
*/ */
public static function ERF($lower, $upper = NULL) { public static function ERF($lower, $upper = NULL) {
$lower = PHPExcel_Calculation_Functions::flattenSingleValue($lower); $lower = Calculation_Functions::flattenSingleValue($lower);
$upper = PHPExcel_Calculation_Functions::flattenSingleValue($upper); $upper = Calculation_Functions::flattenSingleValue($upper);
if (is_numeric($lower)) { if (is_numeric($lower)) {
if (is_null($upper)) { if (is_null($upper)) {
@ -2277,7 +2269,7 @@ class PHPExcel_Calculation_Engineering {
return self::_erfVal($upper) - self::_erfVal($lower); return self::_erfVal($upper) - self::_erfVal($lower);
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function ERF() } // function ERF()
@ -2330,12 +2322,12 @@ class PHPExcel_Calculation_Engineering {
* @return float * @return float
*/ */
public static function ERFC($x) { public static function ERFC($x) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
if (is_numeric($x)) { if (is_numeric($x)) {
return self::_erfcVal($x); return self::_erfcVal($x);
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function ERFC() } // function ERFC()
@ -2419,12 +2411,12 @@ class PHPExcel_Calculation_Engineering {
* @return float * @return float
*/ */
public static function CONVERTUOM($value, $fromUOM, $toUOM) { public static function CONVERTUOM($value, $fromUOM, $toUOM) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value); $value = Calculation_Functions::flattenSingleValue($value);
$fromUOM = PHPExcel_Calculation_Functions::flattenSingleValue($fromUOM); $fromUOM = Calculation_Functions::flattenSingleValue($fromUOM);
$toUOM = PHPExcel_Calculation_Functions::flattenSingleValue($toUOM); $toUOM = Calculation_Functions::flattenSingleValue($toUOM);
if (!is_numeric($value)) { if (!is_numeric($value)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$fromMultiplier = 1.0; $fromMultiplier = 1.0;
if (isset(self::$_conversionUnits[$fromUOM])) { if (isset(self::$_conversionUnits[$fromUOM])) {
@ -2435,12 +2427,12 @@ class PHPExcel_Calculation_Engineering {
if (isset(self::$_conversionMultipliers[$fromMultiplier])) { if (isset(self::$_conversionMultipliers[$fromMultiplier])) {
$fromMultiplier = self::$_conversionMultipliers[$fromMultiplier]['multiplier']; $fromMultiplier = self::$_conversionMultipliers[$fromMultiplier]['multiplier'];
} else { } else {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
if ((isset(self::$_conversionUnits[$fromUOM])) && (self::$_conversionUnits[$fromUOM]['AllowPrefix'])) { if ((isset(self::$_conversionUnits[$fromUOM])) && (self::$_conversionUnits[$fromUOM]['AllowPrefix'])) {
$unitGroup1 = self::$_conversionUnits[$fromUOM]['Group']; $unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
} else { } else {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
} }
$value *= $fromMultiplier; $value *= $fromMultiplier;
@ -2454,16 +2446,16 @@ class PHPExcel_Calculation_Engineering {
if (isset(self::$_conversionMultipliers[$toMultiplier])) { if (isset(self::$_conversionMultipliers[$toMultiplier])) {
$toMultiplier = self::$_conversionMultipliers[$toMultiplier]['multiplier']; $toMultiplier = self::$_conversionMultipliers[$toMultiplier]['multiplier'];
} else { } else {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
if ((isset(self::$_conversionUnits[$toUOM])) && (self::$_conversionUnits[$toUOM]['AllowPrefix'])) { if ((isset(self::$_conversionUnits[$toUOM])) && (self::$_conversionUnits[$toUOM]['AllowPrefix'])) {
$unitGroup2 = self::$_conversionUnits[$toUOM]['Group']; $unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
} else { } else {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
} }
if ($unitGroup1 != $unitGroup2) { if ($unitGroup1 != $unitGroup2) {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
if (($fromUOM == $toUOM) && ($fromMultiplier == $toMultiplier)) { if (($fromUOM == $toUOM) && ($fromMultiplier == $toMultiplier)) {
@ -2502,4 +2494,4 @@ class PHPExcel_Calculation_Engineering {
return ($value * self::$_unitConversions[$unitGroup1][$fromUOM][$toUOM]) / $toMultiplier; return ($value * self::$_unitConversions[$unitGroup1][$fromUOM][$toUOM]) / $toMultiplier;
} // function CONVERTUOM() } // function CONVERTUOM()
} // class PHPExcel_Calculation_Engineering }

View File

@ -19,7 +19,7 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
@ -27,13 +27,13 @@
/** /**
* PHPExcel_Calculation_Exception * PHPExcel\Calculation_Exception
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_Exception extends PHPExcel_Exception { class Calculation_Exception extends Exception {
/** /**
* Error handler callback * Error handler callback
* *

View File

@ -19,25 +19,25 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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_Calculation_ExceptionHandler * PHPExcel\Calculation_ExceptionHandler
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_ExceptionHandler { class Calculation_ExceptionHandler {
/** /**
* Register errorhandler * Register errorhandler
*/ */
public function __construct() { public function __construct() {
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL); set_error_handler(array(__NAMESPACE__ . '\Calculation_Exception', 'errorHandlerCallback'), E_ALL);
} }
/** /**

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
@ -49,14 +49,17 @@ PARTLY BASED ON:
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Calculation_FormulaParser * PHPExcel\Calculation_FormulaParser
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_FormulaParser { class Calculation_FormulaParser {
/* Character constants */ /* Character constants */
const QUOTE_DOUBLE = '"'; const QUOTE_DOUBLE = '"';
const QUOTE_SINGLE = '\''; const QUOTE_SINGLE = '\'';
@ -85,21 +88,21 @@ class PHPExcel_Calculation_FormulaParser {
/** /**
* Tokens * Tokens
* *
* @var PHPExcel_Calculation_FormulaToken[] * @var PHPExcel\Calculation_FormulaToken[]
*/ */
private $_tokens = array(); private $_tokens = array();
/** /**
* Create a new PHPExcel_Calculation_FormulaParser * Create a new PHPExcel\Calculation_FormulaParser
* *
* @param string $pFormula Formula to parse * @param string $pFormula Formula to parse
* @throws PHPExcel_Calculation_Exception * @throws PHPExcel\Calculation_Exception
*/ */
public function __construct($pFormula = '') public function __construct($pFormula = '')
{ {
// Check parameters // Check parameters
if (is_null($pFormula)) { if (is_null($pFormula)) {
throw new PHPExcel_Calculation_Exception("Invalid parameter passed: formula"); throw new Calculation_Exception("Invalid parameter passed: formula");
} }
// Initialise values // Initialise values
@ -122,13 +125,13 @@ class PHPExcel_Calculation_FormulaParser {
* *
* @param int $pId Token id * @param int $pId Token id
* @return string * @return string
* @throws PHPExcel_Calculation_Exception * @throws PHPExcel\Calculation_Exception
*/ */
public function getToken($pId = 0) { public function getToken($pId = 0) {
if (isset($this->_tokens[$pId])) { if (isset($this->_tokens[$pId])) {
return $this->_tokens[$pId]; return $this->_tokens[$pId];
} else { } else {
throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist."); throw new Calculation_Exception("Token with id $pId does not exist.");
} }
} }
@ -144,7 +147,7 @@ class PHPExcel_Calculation_FormulaParser {
/** /**
* Get Tokens * Get Tokens
* *
* @return PHPExcel_Calculation_FormulaToken[] * @return PHPExcel\Calculation_FormulaToken[]
*/ */
public function getTokens() { public function getTokens() {
return $this->_tokens; return $this->_tokens;
@ -179,13 +182,13 @@ class PHPExcel_Calculation_FormulaParser {
// embeds are doubled // embeds are doubled
// end marks token // end marks token
if ($inString) { if ($inString) {
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) { if ($this->_formula{$index} == Calculation_FormulaParser::QUOTE_DOUBLE) {
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) { if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == Calculation_FormulaParser::QUOTE_DOUBLE)) {
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE; $value .= Calculation_FormulaParser::QUOTE_DOUBLE;
++$index; ++$index;
} else { } else {
$inString = false; $inString = false;
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_TEXT); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND, Calculation_FormulaToken::TOKEN_SUBTYPE_TEXT);
$value = ""; $value = "";
} }
} else { } else {
@ -199,9 +202,9 @@ class PHPExcel_Calculation_FormulaParser {
// embeds are double // embeds are double
// end does not mark a token // end does not mark a token
if ($inPath) { if ($inPath) {
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) { if ($this->_formula{$index} == Calculation_FormulaParser::QUOTE_SINGLE) {
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) { if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == Calculation_FormulaParser::QUOTE_SINGLE)) {
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE; $value .= Calculation_FormulaParser::QUOTE_SINGLE;
++$index; ++$index;
} else { } else {
$inPath = false; $inPath = false;
@ -217,7 +220,7 @@ class PHPExcel_Calculation_FormulaParser {
// no embeds (changed to "()" by Excel) // no embeds (changed to "()" by Excel)
// end does not mark a token // end does not mark a token
if ($inRange) { if ($inRange) {
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) { if ($this->_formula{$index} == Calculation_FormulaParser::BRACKET_CLOSE) {
$inRange = false; $inRange = false;
} }
$value .= $this->_formula{$index}; $value .= $this->_formula{$index};
@ -232,14 +235,14 @@ class PHPExcel_Calculation_FormulaParser {
++$index; ++$index;
if (in_array($value, $ERRORS)) { if (in_array($value, $ERRORS)) {
$inError = false; $inError = false;
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_ERROR); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND, Calculation_FormulaToken::TOKEN_SUBTYPE_ERROR);
$value = ""; $value = "";
} }
continue; continue;
} }
// scientific notation check // scientific notation check
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->_formula{$index}) !== false) { if (strpos(Calculation_FormulaParser::OPERATORS_SN, $this->_formula{$index}) !== false) {
if (strlen($value) > 1) { if (strlen($value) > 1) {
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->_formula{$index}) != 0) { if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->_formula{$index}) != 0) {
$value .= $this->_formula{$index}; $value .= $this->_formula{$index};
@ -252,9 +255,9 @@ class PHPExcel_Calculation_FormulaParser {
// independent character evaluation (order not important) // independent character evaluation (order not important)
// establish state-dependent character evaluations // establish state-dependent character evaluations
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) { if ($this->_formula{$index} == Calculation_FormulaParser::QUOTE_DOUBLE) {
if (strlen($value > 0)) { // unexpected if (strlen($value > 0)) { // unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = ""; $value = "";
} }
$inString = true; $inString = true;
@ -262,9 +265,9 @@ class PHPExcel_Calculation_FormulaParser {
continue; continue;
} }
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) { if ($this->_formula{$index} == Calculation_FormulaParser::QUOTE_SINGLE) {
if (strlen($value) > 0) { // unexpected if (strlen($value) > 0) { // unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = ""; $value = "";
} }
$inPath = true; $inPath = true;
@ -272,36 +275,36 @@ class PHPExcel_Calculation_FormulaParser {
continue; continue;
} }
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) { if ($this->_formula{$index} == Calculation_FormulaParser::BRACKET_OPEN) {
$inRange = true; $inRange = true;
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN; $value .= Calculation_FormulaParser::BRACKET_OPEN;
++$index; ++$index;
continue; continue;
} }
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) { if ($this->_formula{$index} == Calculation_FormulaParser::ERROR_START) {
if (strlen($value) > 0) { // unexpected if (strlen($value) > 0) { // unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = ""; $value = "";
} }
$inError = true; $inError = true;
$value .= PHPExcel_Calculation_FormulaParser::ERROR_START; $value .= Calculation_FormulaParser::ERROR_START;
++$index; ++$index;
continue; continue;
} }
// mark start and end of arrays and array rows // mark start and end of arrays and array rows
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) { if ($this->_formula{$index} == Calculation_FormulaParser::BRACE_OPEN) {
if (strlen($value) > 0) { // unexpected if (strlen($value) > 0) { // unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = ""; $value = "";
} }
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAY", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START); $tmp = new Calculation_FormulaToken("ARRAY", Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp; $tokens1[] = $tmp;
$stack[] = clone $tmp; $stack[] = clone $tmp;
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START); $tmp = new Calculation_FormulaToken("ARRAYROW", Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp; $tokens1[] = $tmp;
$stack[] = clone $tmp; $stack[] = clone $tmp;
@ -309,21 +312,21 @@ class PHPExcel_Calculation_FormulaParser {
continue; continue;
} }
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) { if ($this->_formula{$index} == Calculation_FormulaParser::SEMICOLON) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = ""; $value = "";
} }
$tmp = array_pop($stack); $tmp = array_pop($stack);
$tmp->setValue(""); $tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP); $tmp->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp; $tokens1[] = $tmp;
$tmp = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT); $tmp = new Calculation_FormulaToken(",", Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
$tokens1[] = $tmp; $tokens1[] = $tmp;
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START); $tmp = new Calculation_FormulaToken("ARRAYROW", Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp; $tokens1[] = $tmp;
$stack[] = clone $tmp; $stack[] = clone $tmp;
@ -331,20 +334,20 @@ class PHPExcel_Calculation_FormulaParser {
continue; continue;
} }
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) { if ($this->_formula{$index} == Calculation_FormulaParser::BRACE_CLOSE) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = ""; $value = "";
} }
$tmp = array_pop($stack); $tmp = array_pop($stack);
$tmp->setValue(""); $tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP); $tmp->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp; $tokens1[] = $tmp;
$tmp = array_pop($stack); $tmp = array_pop($stack);
$tmp->setValue(""); $tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP); $tmp->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp; $tokens1[] = $tmp;
++$index; ++$index;
@ -352,14 +355,14 @@ class PHPExcel_Calculation_FormulaParser {
} }
// trim white-space // trim white-space
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) { if ($this->_formula{$index} == Calculation_FormulaParser::WHITESPACE) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = ""; $value = "";
} }
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE); $tokens1[] = new Calculation_FormulaToken("", Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
++$index; ++$index;
while (($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) { while (($this->_formula{$index} == Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
++$index; ++$index;
} }
continue; continue;
@ -369,46 +372,46 @@ class PHPExcel_Calculation_FormulaParser {
if (($index + 2) <= $formulaLength) { if (($index + 2) <= $formulaLength) {
if (in_array(substr($this->_formula, $index, 2), $COMPARATORS_MULTI)) { if (in_array(substr($this->_formula, $index, 2), $COMPARATORS_MULTI)) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = ""; $value = "";
} }
$tokens1[] = new PHPExcel_Calculation_FormulaToken(substr($this->_formula, $index, 2), PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL); $tokens1[] = new Calculation_FormulaToken(substr($this->_formula, $index, 2), Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
$index += 2; $index += 2;
continue; continue;
} }
} }
// standard infix operators // standard infix operators
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->_formula{$index}) !== false) { if (strpos(Calculation_FormulaParser::OPERATORS_INFIX, $this->_formula{$index}) !== false) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] =new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = ""; $value = "";
} }
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX); $tokens1[] = new Calculation_FormulaToken($this->_formula{$index}, Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
++$index; ++$index;
continue; continue;
} }
// standard postfix operators (only one) // standard postfix operators (only one)
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->_formula{$index}) !== false) { if (strpos(Calculation_FormulaParser::OPERATORS_POSTFIX, $this->_formula{$index}) !== false) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = ""; $value = "";
} }
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX); $tokens1[] = new Calculation_FormulaToken($this->_formula{$index}, Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
++$index; ++$index;
continue; continue;
} }
// start subexpression or function // start subexpression or function
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) { if ($this->_formula{$index} == Calculation_FormulaParser::PAREN_OPEN) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START); $tmp = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp; $tokens1[] = $tmp;
$stack[] = clone $tmp; $stack[] = clone $tmp;
$value = ""; $value = "";
} else { } else {
$tmp = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START); $tmp = new Calculation_FormulaToken("", Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION, Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp; $tokens1[] = $tmp;
$stack[] = clone $tmp; $stack[] = clone $tmp;
} }
@ -417,36 +420,36 @@ class PHPExcel_Calculation_FormulaParser {
} }
// function, subexpression, or array parameters, or operand unions // function, subexpression, or array parameters, or operand unions
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) { if ($this->_formula{$index} == Calculation_FormulaParser::COMMA) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = ""; $value = "";
} }
$tmp = array_pop($stack); $tmp = array_pop($stack);
$tmp->setValue(""); $tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP); $tmp->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$stack[] = $tmp; $stack[] = $tmp;
if ($tmp->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) { if ($tmp->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_UNION); $tokens1[] = new Calculation_FormulaToken(",", Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, Calculation_FormulaToken::TOKEN_SUBTYPE_UNION);
} else { } else {
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT); $tokens1[] = new Calculation_FormulaToken(",", Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
} }
++$index; ++$index;
continue; continue;
} }
// stop subexpression // stop subexpression
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) { if ($this->_formula{$index} == Calculation_FormulaParser::PAREN_CLOSE) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = ""; $value = "";
} }
$tmp = array_pop($stack); $tmp = array_pop($stack);
$tmp->setValue(""); $tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP); $tmp->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp; $tokens1[] = $tmp;
++$index; ++$index;
@ -460,7 +463,7 @@ class PHPExcel_Calculation_FormulaParser {
// dump remaining accumulation // dump remaining accumulation
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
} }
// move tokenList to new set, excluding unnecessary white-space tokens and converting necessary ones to intersections // move tokenList to new set, excluding unnecessary white-space tokens and converting necessary ones to intersections
@ -482,7 +485,7 @@ class PHPExcel_Calculation_FormulaParser {
continue; continue;
} }
if ($token->getTokenType() != PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE) { if ($token->getTokenType() != Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE) {
$tokens2[] = $token; $tokens2[] = $token;
continue; continue;
} }
@ -492,9 +495,9 @@ class PHPExcel_Calculation_FormulaParser {
} }
if (! ( if (! (
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND) ($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) ) { ) ) {
continue; continue;
} }
@ -504,14 +507,14 @@ class PHPExcel_Calculation_FormulaParser {
} }
if (! ( if (! (
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) || (($nextToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) || (($nextToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND) ($nextToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) ) { ) ) {
continue; continue;
} }
$tokens2[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_INTERSECTION); $tokens2[] = new Calculation_FormulaToken($value, Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, Calculation_FormulaToken::TOKEN_SUBTYPE_INTERSECTION);
} }
// move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators // move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators
@ -536,34 +539,34 @@ class PHPExcel_Calculation_FormulaParser {
continue; continue;
} }
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") { if ($token->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
if ($i == 0) { if ($i == 0) {
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX); $token->setTokenType(Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
} else if ( } else if (
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) || ($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND) ($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) { ) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH); $token->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
} else { } else {
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX); $token->setTokenType(Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
} }
$this->_tokens[] = $token; $this->_tokens[] = $token;
continue; continue;
} }
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") { if ($token->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
if ($i == 0) { if ($i == 0) {
continue; continue;
} else if ( } else if (
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) || ($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND) ($previousToken->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) { ) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH); $token->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
} else { } else {
continue; continue;
} }
@ -572,35 +575,35 @@ class PHPExcel_Calculation_FormulaParser {
continue; continue;
} }
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) { if ($token->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) { if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL); $token->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
} else if ($token->getValue() == "&") { } else if ($token->getValue() == "&") {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_CONCATENATION); $token->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_CONCATENATION);
} else { } else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH); $token->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
} }
$this->_tokens[] = $token; $this->_tokens[] = $token;
continue; continue;
} }
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) { if ($token->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_OPERAND && $token->getTokenSubType() == Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if (!is_numeric($token->getValue())) { if (!is_numeric($token->getValue())) {
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) { if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL); $token->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
} else { } else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_RANGE); $token->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_RANGE);
} }
} else { } else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER); $token->setTokenSubType(Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER);
} }
$this->_tokens[] = $token; $this->_tokens[] = $token;
continue; continue;
} }
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) { if ($token->getTokenType() == Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
if (strlen($token->getValue() > 0)) { if (strlen($token->getValue() > 0)) {
if (substr($token->getValue(), 0, 1) == "@") { if (substr($token->getValue(), 0, 1) == "@") {
$token->setValue(substr($token->getValue(), 1)); $token->setValue(substr($token->getValue(), 1));

View File

@ -19,7 +19,7 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
@ -50,14 +50,16 @@ PARTLY BASED ON:
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Calculation_FormulaToken * PHPExcel\Calculation_FormulaToken
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_FormulaToken { class Calculation_FormulaToken {
/* Token types */ /* Token types */
const TOKEN_TYPE_NOOP = 'Noop'; const TOKEN_TYPE_NOOP = 'Noop';
const TOKEN_TYPE_OPERAND = 'Operand'; const TOKEN_TYPE_OPERAND = 'Operand';
@ -106,13 +108,13 @@ class PHPExcel_Calculation_FormulaToken {
private $_tokenSubType; private $_tokenSubType;
/** /**
* Create a new PHPExcel_Calculation_FormulaToken * Create a new PHPExcel\Calculation_FormulaToken
* *
* @param string $pValue * @param string $pValue
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*) * @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
* @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*) * @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
*/ */
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) public function __construct($pValue, $pTokenType = Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
{ {
// Initialise values // Initialise values
$this->_value = $pValue; $this->_value = $pValue;
@ -152,7 +154,7 @@ class PHPExcel_Calculation_FormulaToken {
* *
* @param string $value * @param string $value
*/ */
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) { public function setTokenType($value = Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) {
$this->_tokenType = $value; $this->_tokenType = $value;
} }
@ -170,7 +172,7 @@ class PHPExcel_Calculation_FormulaToken {
* *
* @param string $value * @param string $value
*/ */
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) { public function setTokenSubType($value = Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
$this->_tokenSubType = $value; $this->_tokenSubType = $value;
} }
} }

View File

@ -19,21 +19,23 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Calculation_Function * PHPExcel\Calculation_Function
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_Function { class Calculation_Function {
/* Function categories */ /* Function categories */
const CATEGORY_CUBE = 'Cube'; const CATEGORY_CUBE = 'Cube';
const CATEGORY_DATABASE = 'Database'; const CATEGORY_DATABASE = 'Database';
@ -69,12 +71,12 @@ class PHPExcel_Calculation_Function {
private $_phpExcelName; private $_phpExcelName;
/** /**
* Create a new PHPExcel_Calculation_Function * Create a new PHPExcel\Calculation_Function
* *
* @param string $pCategory Category (represented by CATEGORY_*) * @param string $pCategory Category (represented by CATEGORY_*)
* @param string $pExcelName Excel function name * @param string $pExcelName Excel function name
* @param string $pPHPExcelName PHPExcel function mapping * @param string $pPHPExcelName PHPExcel function mapping
* @throws PHPExcel_Calculation_Exception * @throws PHPExcel\Calculation_Exception
*/ */
public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL) public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL)
{ {
@ -84,7 +86,7 @@ class PHPExcel_Calculation_Function {
$this->_excelName = $pExcelName; $this->_excelName = $pExcelName;
$this->_phpExcelName = $pPHPExcelName; $this->_phpExcelName = $pPHPExcelName;
} else { } else {
throw new PHPExcel_Calculation_Exception("Invalid parameters passed."); throw new Calculation_Exception("Invalid parameters passed.");
} }
} }
@ -101,13 +103,13 @@ class PHPExcel_Calculation_Function {
* Set Category (represented by CATEGORY_*) * Set Category (represented by CATEGORY_*)
* *
* @param string $value * @param string $value
* @throws PHPExcel_Calculation_Exception * @throws PHPExcel\Calculation_Exception
*/ */
public function setCategory($value = null) { public function setCategory($value = null) {
if (!is_null($value)) { if (!is_null($value)) {
$this->_category = $value; $this->_category = $value;
} else { } else {
throw new PHPExcel_Calculation_Exception("Invalid parameter passed."); throw new Calculation_Exception("Invalid parameter passed.");
} }
} }

View File

@ -19,22 +19,13 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** MAX_VALUE */ /** MAX_VALUE */
define('MAX_VALUE', 1.2e308); define('MAX_VALUE', 1.2e308);
@ -50,13 +41,13 @@ define('PRECISION', 8.88E-016);
/** /**
* PHPExcel_Calculation_Functions * PHPExcel\Calculation_Functions
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_Functions { class Calculation_Functions {
/** constants */ /** constants */
const COMPATIBILITY_EXCEL = 'Excel'; const COMPATIBILITY_EXCEL = 'Excel';
@ -108,9 +99,9 @@ class PHPExcel_Calculation_Functions {
* @category Function Configuration * @category Function Configuration
* @param string $compatibilityMode Compatibility Mode * @param string $compatibilityMode Compatibility Mode
* Permitted values are: * Permitted values are:
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel' * PHPExcel\Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric' * PHPExcel\Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc' * PHPExcel\Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
* @return boolean (Success or Failure) * @return boolean (Success or Failure)
*/ */
public static function setCompatibilityMode($compatibilityMode) { public static function setCompatibilityMode($compatibilityMode) {
@ -131,9 +122,9 @@ class PHPExcel_Calculation_Functions {
* @category Function Configuration * @category Function Configuration
* @return string Compatibility Mode * @return string Compatibility Mode
* Possible Return values are: * Possible Return values are:
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel' * PHPExcel\Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric' * PHPExcel\Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc' * PHPExcel\Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
*/ */
public static function getCompatibilityMode() { public static function getCompatibilityMode() {
return self::$compatibilityMode; return self::$compatibilityMode;
@ -147,9 +138,9 @@ class PHPExcel_Calculation_Functions {
* @category Function Configuration * @category Function Configuration
* @param string $returnDateType Return Date Format * @param string $returnDateType Return Date Format
* Permitted values are: * Permitted values are:
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P' * PHPExcel\Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O' * PHPExcel\Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E' * PHPExcel\Calculation_Functions::RETURNDATE_EXCEL 'E'
* @return boolean Success or failure * @return boolean Success or failure
*/ */
public static function setReturnDateType($returnDateType) { public static function setReturnDateType($returnDateType) {
@ -170,9 +161,9 @@ class PHPExcel_Calculation_Functions {
* @category Function Configuration * @category Function Configuration
* @return string Return Date Format * @return string Return Date Format
* Possible Return values are: * Possible Return values are:
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P' * PHPExcel\Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O' * PHPExcel\Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E' * PHPExcel\Calculation_Functions::RETURNDATE_EXCEL 'E'
*/ */
public static function getReturnDateType() { public static function getReturnDateType() {
return self::$ReturnDateType; return self::$ReturnDateType;
@ -307,16 +298,16 @@ class PHPExcel_Calculation_Functions {
public static function _ifCondition($condition) { public static function _ifCondition($condition) {
$condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition); $condition = Calculation_Functions::flattenSingleValue($condition);
if (!isset($condition{0})) if (!isset($condition{0}))
$condition = '=""'; $condition = '=""';
if (!in_array($condition{0},array('>', '<', '='))) { if (!in_array($condition{0},array('>', '<', '='))) {
if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); } if (!is_numeric($condition)) { $condition = Calculation::_wrapResult(strtoupper($condition)); }
return '='.$condition; return '='.$condition;
} else { } else {
preg_match('/([<>=]+)(.*)/',$condition,$matches); preg_match('/([<>=]+)(.*)/',$condition,$matches);
list(,$operator,$operand) = $matches; list(,$operator,$operand) = $matches;
if (!is_numeric($operand)) { $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); } if (!is_numeric($operand)) { $operand = Calculation::_wrapResult(strtoupper($operand)); }
return $operator.$operand; return $operator.$operand;
} }
} // function _ifCondition() } // function _ifCondition()
@ -663,7 +654,7 @@ class PHPExcel_Calculation_Functions {
return $value; return $value;
} // function flattenSingleValue() } // function flattenSingleValue()
} // class PHPExcel_Calculation_Functions }
// //

View File

@ -19,31 +19,23 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Calculation_Logical * PHPExcel\Calculation_Logical
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_Logical { class Calculation_Logical {
/** /**
* TRUE * TRUE
@ -105,7 +97,7 @@ class PHPExcel_Calculation_Logical {
$returnValue = TRUE; $returnValue = TRUE;
// Loop through the arguments // Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); $aArgs = Calculation_Functions::flattenArray(func_get_args());
$argCount = -1; $argCount = -1;
foreach ($aArgs as $argCount => $arg) { foreach ($aArgs as $argCount => $arg) {
// Is it a boolean value? // Is it a boolean value?
@ -115,12 +107,12 @@ class PHPExcel_Calculation_Logical {
$returnValue = $returnValue && ($arg != 0); $returnValue = $returnValue && ($arg != 0);
} elseif (is_string($arg)) { } elseif (is_string($arg)) {
$arg = strtoupper($arg); $arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) { if (($arg == 'TRUE') || ($arg == Calculation::getTRUE())) {
$arg = TRUE; $arg = TRUE;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) { } elseif (($arg == 'FALSE') || ($arg == Calculation::getFALSE())) {
$arg = FALSE; $arg = FALSE;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$returnValue = $returnValue && ($arg != 0); $returnValue = $returnValue && ($arg != 0);
} }
@ -128,7 +120,7 @@ class PHPExcel_Calculation_Logical {
// Return // Return
if ($argCount < 0) { if ($argCount < 0) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
return $returnValue; return $returnValue;
} // function LOGICAL_AND() } // function LOGICAL_AND()
@ -160,7 +152,7 @@ class PHPExcel_Calculation_Logical {
$returnValue = FALSE; $returnValue = FALSE;
// Loop through the arguments // Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); $aArgs = Calculation_Functions::flattenArray(func_get_args());
$argCount = -1; $argCount = -1;
foreach ($aArgs as $argCount => $arg) { foreach ($aArgs as $argCount => $arg) {
// Is it a boolean value? // Is it a boolean value?
@ -170,12 +162,12 @@ class PHPExcel_Calculation_Logical {
$returnValue = $returnValue || ($arg != 0); $returnValue = $returnValue || ($arg != 0);
} elseif (is_string($arg)) { } elseif (is_string($arg)) {
$arg = strtoupper($arg); $arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) { if (($arg == 'TRUE') || ($arg == Calculation::getTRUE())) {
$arg = TRUE; $arg = TRUE;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) { } elseif (($arg == 'FALSE') || ($arg == Calculation::getFALSE())) {
$arg = FALSE; $arg = FALSE;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$returnValue = $returnValue || ($arg != 0); $returnValue = $returnValue || ($arg != 0);
} }
@ -183,7 +175,7 @@ class PHPExcel_Calculation_Logical {
// Return // Return
if ($argCount < 0) { if ($argCount < 0) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
return $returnValue; return $returnValue;
} // function LOGICAL_OR() } // function LOGICAL_OR()
@ -210,15 +202,15 @@ class PHPExcel_Calculation_Logical {
* @return boolean The boolean inverse of the argument. * @return boolean The boolean inverse of the argument.
*/ */
public static function NOT($logical=FALSE) { public static function NOT($logical=FALSE) {
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical); $logical = Calculation_Functions::flattenSingleValue($logical);
if (is_string($logical)) { if (is_string($logical)) {
$logical = strtoupper($logical); $logical = strtoupper($logical);
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) { if (($logical == 'TRUE') || ($logical == Calculation::getTRUE())) {
return FALSE; return FALSE;
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) { } elseif (($logical == 'FALSE') || ($logical == Calculation::getFALSE())) {
return TRUE; return TRUE;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
@ -258,9 +250,9 @@ class PHPExcel_Calculation_Logical {
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition * @return mixed The value of returnIfTrue or returnIfFalse determined by condition
*/ */
public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) { public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) {
$condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition); $condition = (is_null($condition)) ? TRUE : (boolean) Calculation_Functions::flattenSingleValue($condition);
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue); $returnIfTrue = (is_null($returnIfTrue)) ? 0 : Calculation_Functions::flattenSingleValue($returnIfTrue);
$returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse); $returnIfFalse = (is_null($returnIfFalse)) ? FALSE : Calculation_Functions::flattenSingleValue($returnIfFalse);
return ($condition) ? $returnIfTrue : $returnIfFalse; return ($condition) ? $returnIfTrue : $returnIfFalse;
} // function STATEMENT_IF() } // function STATEMENT_IF()
@ -279,10 +271,10 @@ class PHPExcel_Calculation_Logical {
* @return mixed The value of errorpart or testValue determined by error condition * @return mixed The value of errorpart or testValue determined by error condition
*/ */
public static function IFERROR($testValue = '', $errorpart = '') { public static function IFERROR($testValue = '', $errorpart = '') {
$testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue); $testValue = (is_null($testValue)) ? '' : Calculation_Functions::flattenSingleValue($testValue);
$errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart); $errorpart = (is_null($errorpart)) ? '' : Calculation_Functions::flattenSingleValue($errorpart);
return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue); return self::STATEMENT_IF(Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
} // function IFERROR() } // function IFERROR()
} // class PHPExcel_Calculation_Logical }

View File

@ -19,32 +19,23 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Calculation_LookupRef * PHPExcel\Calculation_LookupRef
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_LookupRef { class Calculation_LookupRef {
/** /**
* CELL_ADDRESS * CELL_ADDRESS
@ -68,13 +59,13 @@ class PHPExcel_Calculation_LookupRef {
* @return string * @return string
*/ */
public static function CELL_ADDRESS($row, $column, $relativity=1, $referenceStyle=True, $sheetText='') { public static function CELL_ADDRESS($row, $column, $relativity=1, $referenceStyle=True, $sheetText='') {
$row = PHPExcel_Calculation_Functions::flattenSingleValue($row); $row = Calculation_Functions::flattenSingleValue($row);
$column = PHPExcel_Calculation_Functions::flattenSingleValue($column); $column = Calculation_Functions::flattenSingleValue($column);
$relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity); $relativity = Calculation_Functions::flattenSingleValue($relativity);
$sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText); $sheetText = Calculation_Functions::flattenSingleValue($sheetText);
if (($row < 1) || ($column < 1)) { if (($row < 1) || ($column < 1)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if ($sheetText > '') { if ($sheetText > '') {
@ -83,7 +74,7 @@ class PHPExcel_Calculation_LookupRef {
} }
if ((!is_bool($referenceStyle)) || $referenceStyle) { if ((!is_bool($referenceStyle)) || $referenceStyle) {
$rowRelative = $columnRelative = '$'; $rowRelative = $columnRelative = '$';
$column = PHPExcel_Cell::stringFromColumnIndex($column-1); $column = Cell::stringFromColumnIndex($column-1);
if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; } if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; }
if (($relativity == 3) || ($relativity == 4)) { $rowRelative = ''; } if (($relativity == 3) || ($relativity == 4)) { $rowRelative = ''; }
return $sheetText.$columnRelative.$column.$rowRelative.$row; return $sheetText.$columnRelative.$column.$rowRelative.$row;
@ -115,7 +106,7 @@ class PHPExcel_Calculation_LookupRef {
if (is_array($cellAddress)) { if (is_array($cellAddress)) {
foreach($cellAddress as $columnKey => $value) { foreach($cellAddress as $columnKey => $value) {
$columnKey = preg_replace('/[^a-z]/i','',$columnKey); $columnKey = preg_replace('/[^a-z]/i','',$columnKey);
return (integer) PHPExcel_Cell::columnIndexFromString($columnKey); return (integer) Cell::columnIndexFromString($columnKey);
} }
} else { } else {
if (strpos($cellAddress,'!') !== false) { if (strpos($cellAddress,'!') !== false) {
@ -127,12 +118,12 @@ class PHPExcel_Calculation_LookupRef {
$endAddress = preg_replace('/[^a-z]/i','',$endAddress); $endAddress = preg_replace('/[^a-z]/i','',$endAddress);
$returnValue = array(); $returnValue = array();
do { do {
$returnValue[] = (integer) PHPExcel_Cell::columnIndexFromString($startAddress); $returnValue[] = (integer) Cell::columnIndexFromString($startAddress);
} while ($startAddress++ != $endAddress); } while ($startAddress++ != $endAddress);
return $returnValue; return $returnValue;
} else { } else {
$cellAddress = preg_replace('/[^a-z]/i','',$cellAddress); $cellAddress = preg_replace('/[^a-z]/i','',$cellAddress);
return (integer) PHPExcel_Cell::columnIndexFromString($cellAddress); return (integer) Cell::columnIndexFromString($cellAddress);
} }
} }
} // function COLUMN() } // function COLUMN()
@ -153,13 +144,13 @@ class PHPExcel_Calculation_LookupRef {
if (is_null($cellAddress) || $cellAddress === '') { if (is_null($cellAddress) || $cellAddress === '') {
return 1; return 1;
} elseif (!is_array($cellAddress)) { } elseif (!is_array($cellAddress)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$x = array_keys($cellAddress); $x = array_keys($cellAddress);
$x = array_shift($x); $x = array_shift($x);
$isMatrix = (is_numeric($x)); $isMatrix = (is_numeric($x));
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); list($columns,$rows) = Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) { if ($isMatrix) {
return $rows; return $rows;
@ -228,12 +219,12 @@ class PHPExcel_Calculation_LookupRef {
if (is_null($cellAddress) || $cellAddress === '') { if (is_null($cellAddress) || $cellAddress === '') {
return 1; return 1;
} elseif (!is_array($cellAddress)) { } elseif (!is_array($cellAddress)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$i = array_keys($cellAddress); $i = array_keys($cellAddress);
$isMatrix = (is_numeric(array_shift($i))); $isMatrix = (is_numeric(array_shift($i)));
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); list($columns,$rows) = Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) { if ($isMatrix) {
return $columns; return $columns;
@ -253,18 +244,18 @@ class PHPExcel_Calculation_LookupRef {
* @category Logical Functions * @category Logical Functions
* @param string $linkURL Value to check, is also the value returned when no error * @param string $linkURL Value to check, is also the value returned when no error
* @param string $displayName Value to return when testValue is an error condition * @param string $displayName Value to return when testValue is an error condition
* @param PHPExcel_Cell $pCell The cell to set the hyperlink in * @param PHPExcel\Cell $pCell The cell to set the hyperlink in
* @return mixed The value of $displayName (or $linkURL if $displayName was blank) * @return mixed The value of $displayName (or $linkURL if $displayName was blank)
*/ */
public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null) { public static function HYPERLINK($linkURL = '', $displayName = null, Cell $pCell = null) {
$args = func_get_args(); $args = func_get_args();
$pCell = array_pop($args); $pCell = array_pop($args);
$linkURL = (is_null($linkURL)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($linkURL); $linkURL = (is_null($linkURL)) ? '' : Calculation_Functions::flattenSingleValue($linkURL);
$displayName = (is_null($displayName)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($displayName); $displayName = (is_null($displayName)) ? '' : Calculation_Functions::flattenSingleValue($displayName);
if ((!is_object($pCell)) || (trim($linkURL) == '')) { if ((!is_object($pCell)) || (trim($linkURL) == '')) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} }
if ((is_object($displayName)) || trim($displayName) == '') { if ((is_object($displayName)) || trim($displayName) == '') {
@ -289,16 +280,16 @@ class PHPExcel_Calculation_LookupRef {
* NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010 * NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010
* *
* @param cellAddress $cellAddress The cell address of the current cell (containing this formula) * @param cellAddress $cellAddress The cell address of the current cell (containing this formula)
* @param PHPExcel_Cell $pCell The current cell (containing this formula) * @param PHPExcel\Cell $pCell The current cell (containing this formula)
* @return mixed The cells referenced by cellAddress * @return mixed The cells referenced by cellAddress
* *
* @todo Support for the optional a1 parameter introduced in Excel 2010 * @todo Support for the optional a1 parameter introduced in Excel 2010
* *
*/ */
public static function INDIRECT($cellAddress = NULL, PHPExcel_Cell $pCell = NULL) { public static function INDIRECT($cellAddress = NULL, Cell $pCell = NULL) {
$cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress); $cellAddress = Calculation_Functions::flattenSingleValue($cellAddress);
if (is_null($cellAddress) || $cellAddress === '') { if (is_null($cellAddress) || $cellAddress === '') {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} }
$cellAddress1 = $cellAddress; $cellAddress1 = $cellAddress;
@ -307,10 +298,10 @@ class PHPExcel_Calculation_LookupRef {
list($cellAddress1,$cellAddress2) = explode(':',$cellAddress); list($cellAddress1,$cellAddress2) = explode(':',$cellAddress);
} }
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) || if ((!preg_match('/^'.Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) ||
((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) { ((!is_null($cellAddress2)) && (!preg_match('/^'.Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) {
if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) { if (!preg_match('/^'.Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} }
if (strpos($cellAddress,'!') !== FALSE) { if (strpos($cellAddress,'!') !== FALSE) {
@ -321,7 +312,7 @@ class PHPExcel_Calculation_LookupRef {
$pSheet = $pCell->getParent(); $pSheet = $pCell->getParent();
} }
return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, FALSE); return Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, FALSE);
} }
if (strpos($cellAddress,'!') !== FALSE) { if (strpos($cellAddress,'!') !== FALSE) {
@ -332,7 +323,7 @@ class PHPExcel_Calculation_LookupRef {
$pSheet = $pCell->getParent(); $pSheet = $pCell->getParent();
} }
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, FALSE); return Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, FALSE);
} // function INDIRECT() } // function INDIRECT()
@ -362,10 +353,10 @@ class PHPExcel_Calculation_LookupRef {
* @return string A reference to a cell or range of cells * @return string A reference to a cell or range of cells
*/ */
public static function OFFSET($cellAddress=Null,$rows=0,$columns=0,$height=null,$width=null) { public static function OFFSET($cellAddress=Null,$rows=0,$columns=0,$height=null,$width=null) {
$rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows); $rows = Calculation_Functions::flattenSingleValue($rows);
$columns = PHPExcel_Calculation_Functions::flattenSingleValue($columns); $columns = Calculation_Functions::flattenSingleValue($columns);
$height = PHPExcel_Calculation_Functions::flattenSingleValue($height); $height = Calculation_Functions::flattenSingleValue($height);
$width = PHPExcel_Calculation_Functions::flattenSingleValue($width); $width = Calculation_Functions::flattenSingleValue($width);
if ($cellAddress == Null) { if ($cellAddress == Null) {
return 0; return 0;
} }
@ -373,7 +364,7 @@ class PHPExcel_Calculation_LookupRef {
$args = func_get_args(); $args = func_get_args();
$pCell = array_pop($args); $pCell = array_pop($args);
if (!is_object($pCell)) { if (!is_object($pCell)) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} }
$sheetName = NULL; $sheetName = NULL;
@ -386,23 +377,23 @@ class PHPExcel_Calculation_LookupRef {
} else { } else {
$startCell = $endCell = $cellAddress; $startCell = $endCell = $cellAddress;
} }
list($startCellColumn,$startCellRow) = PHPExcel_Cell::coordinateFromString($startCell); list($startCellColumn,$startCellRow) = Cell::coordinateFromString($startCell);
list($endCellColumn,$endCellRow) = PHPExcel_Cell::coordinateFromString($endCell); list($endCellColumn,$endCellRow) = Cell::coordinateFromString($endCell);
$startCellRow += $rows; $startCellRow += $rows;
$startCellColumn = PHPExcel_Cell::columnIndexFromString($startCellColumn) - 1; $startCellColumn = Cell::columnIndexFromString($startCellColumn) - 1;
$startCellColumn += $columns; $startCellColumn += $columns;
if (($startCellRow <= 0) || ($startCellColumn < 0)) { if (($startCellRow <= 0) || ($startCellColumn < 0)) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} }
$endCellColumn = PHPExcel_Cell::columnIndexFromString($endCellColumn) - 1; $endCellColumn = Cell::columnIndexFromString($endCellColumn) - 1;
if (($width != null) && (!is_object($width))) { if (($width != null) && (!is_object($width))) {
$endCellColumn = $startCellColumn + $width - 1; $endCellColumn = $startCellColumn + $width - 1;
} else { } else {
$endCellColumn += $columns; $endCellColumn += $columns;
} }
$startCellColumn = PHPExcel_Cell::stringFromColumnIndex($startCellColumn); $startCellColumn = Cell::stringFromColumnIndex($startCellColumn);
if (($height != null) && (!is_object($height))) { if (($height != null) && (!is_object($height))) {
$endCellRow = $startCellRow + $height - 1; $endCellRow = $startCellRow + $height - 1;
@ -411,9 +402,9 @@ class PHPExcel_Calculation_LookupRef {
} }
if (($endCellRow <= 0) || ($endCellColumn < 0)) { if (($endCellRow <= 0) || ($endCellColumn < 0)) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} }
$endCellColumn = PHPExcel_Cell::stringFromColumnIndex($endCellColumn); $endCellColumn = Cell::stringFromColumnIndex($endCellColumn);
$cellAddress = $startCellColumn.$startCellRow; $cellAddress = $startCellColumn.$startCellRow;
if (($startCellColumn != $endCellColumn) || ($startCellRow != $endCellRow)) { if (($startCellColumn != $endCellColumn) || ($startCellRow != $endCellRow)) {
@ -426,7 +417,7 @@ class PHPExcel_Calculation_LookupRef {
$pSheet = $pCell->getParent(); $pSheet = $pCell->getParent();
} }
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False); return Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False);
} // function OFFSET() } // function OFFSET()
@ -450,7 +441,7 @@ class PHPExcel_Calculation_LookupRef {
*/ */
public static function CHOOSE() { public static function CHOOSE() {
$chooseArgs = func_get_args(); $chooseArgs = func_get_args();
$chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs)); $chosenEntry = Calculation_Functions::flattenArray(array_shift($chooseArgs));
$entryCount = count($chooseArgs) - 1; $entryCount = count($chooseArgs) - 1;
if(is_array($chosenEntry)) { if(is_array($chosenEntry)) {
@ -459,15 +450,15 @@ class PHPExcel_Calculation_LookupRef {
if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) { if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) {
--$chosenEntry; --$chosenEntry;
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$chosenEntry = floor($chosenEntry); $chosenEntry = floor($chosenEntry);
if (($chosenEntry <= 0) || ($chosenEntry > $entryCount)) { if (($chosenEntry <= 0) || ($chosenEntry > $entryCount)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (is_array($chooseArgs[$chosenEntry])) { if (is_array($chooseArgs[$chosenEntry])) {
return PHPExcel_Calculation_Functions::flattenArray($chooseArgs[$chosenEntry]); return Calculation_Functions::flattenArray($chooseArgs[$chosenEntry]);
} else { } else {
return $chooseArgs[$chosenEntry]; return $chooseArgs[$chosenEntry];
} }
@ -488,26 +479,26 @@ class PHPExcel_Calculation_LookupRef {
* @return integer The relative position of the found item * @return integer The relative position of the found item
*/ */
public static function MATCH($lookup_value, $lookup_array, $match_type=1) { public static function MATCH($lookup_value, $lookup_array, $match_type=1) {
$lookup_array = PHPExcel_Calculation_Functions::flattenArray($lookup_array); $lookup_array = Calculation_Functions::flattenArray($lookup_array);
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); $lookup_value = Calculation_Functions::flattenSingleValue($lookup_value);
$match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type); $match_type = (is_null($match_type)) ? 1 : (int) Calculation_Functions::flattenSingleValue($match_type);
// MATCH is not case sensitive // MATCH is not case sensitive
$lookup_value = strtolower($lookup_value); $lookup_value = strtolower($lookup_value);
// lookup_value type has to be number, text, or logical values // lookup_value type has to be number, text, or logical values
if ((!is_numeric($lookup_value)) && (!is_string($lookup_value)) && (!is_bool($lookup_value))) { if ((!is_numeric($lookup_value)) && (!is_string($lookup_value)) && (!is_bool($lookup_value))) {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
// match_type is 0, 1 or -1 // match_type is 0, 1 or -1
if (($match_type !== 0) && ($match_type !== -1) && ($match_type !== 1)) { if (($match_type !== 0) && ($match_type !== -1) && ($match_type !== 1)) {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
// lookup_array should not be empty // lookup_array should not be empty
$lookupArraySize = count($lookup_array); $lookupArraySize = count($lookup_array);
if ($lookupArraySize <= 0) { if ($lookupArraySize <= 0) {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
// lookup_array should contain only number, text, or logical values, or empty (null) cells // lookup_array should contain only number, text, or logical values, or empty (null) cells
@ -515,7 +506,7 @@ class PHPExcel_Calculation_LookupRef {
// check the type of the value // check the type of the value
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) && if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
(!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) { (!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
// convert strings to lowercase for case-insensitive testing // convert strings to lowercase for case-insensitive testing
if (is_string($lookupArrayValue)) { if (is_string($lookupArrayValue)) {
@ -583,7 +574,7 @@ class PHPExcel_Calculation_LookupRef {
} }
// unsuccessful in finding a match, return #N/A error value // unsuccessful in finding a match, return #N/A error value
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} // function MATCH() } // function MATCH()
@ -603,18 +594,18 @@ class PHPExcel_Calculation_LookupRef {
public static function INDEX($arrayValues,$rowNum = 0,$columnNum = 0) { public static function INDEX($arrayValues,$rowNum = 0,$columnNum = 0) {
if (($rowNum < 0) || ($columnNum < 0)) { if (($rowNum < 0) || ($columnNum < 0)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (!is_array($arrayValues)) { if (!is_array($arrayValues)) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} }
$rowKeys = array_keys($arrayValues); $rowKeys = array_keys($arrayValues);
$columnKeys = @array_keys($arrayValues[$rowKeys[0]]); $columnKeys = @array_keys($arrayValues[$rowKeys[0]]);
if ($columnNum > count($columnKeys)) { if ($columnNum > count($columnKeys)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif ($columnNum == 0) { } elseif ($columnNum == 0) {
if ($rowNum == 0) { if ($rowNum == 0) {
return $arrayValues; return $arrayValues;
@ -636,7 +627,7 @@ class PHPExcel_Calculation_LookupRef {
} }
$columnNum = $columnKeys[--$columnNum]; $columnNum = $columnKeys[--$columnNum];
if ($rowNum > count($rowKeys)) { if ($rowNum > count($rowKeys)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif ($rowNum == 0) { } elseif ($rowNum == 0) {
return $arrayValues[$columnNum]; return $arrayValues[$columnNum];
} }
@ -691,23 +682,23 @@ class PHPExcel_Calculation_LookupRef {
* @return mixed The value of the found cell * @return mixed The value of the found cell
*/ */
public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) { public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) {
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); $lookup_value = Calculation_Functions::flattenSingleValue($lookup_value);
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number); $index_number = Calculation_Functions::flattenSingleValue($index_number);
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match); $not_exact_match = Calculation_Functions::flattenSingleValue($not_exact_match);
// index_number must be greater than or equal to 1 // index_number must be greater than or equal to 1
if ($index_number < 1) { if ($index_number < 1) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
// index_number must be less than or equal to the number of columns in lookup_array // index_number must be less than or equal to the number of columns in lookup_array
if ((!is_array($lookup_array)) || (empty($lookup_array))) { if ((!is_array($lookup_array)) || (empty($lookup_array))) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} else { } else {
$f = array_keys($lookup_array); $f = array_keys($lookup_array);
$firstRow = array_pop($f); $firstRow = array_pop($f);
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} else { } else {
$columnKeys = array_keys($lookup_array[$firstRow]); $columnKeys = array_keys($lookup_array[$firstRow]);
$returnColumn = $columnKeys[--$index_number]; $returnColumn = $columnKeys[--$index_number];
@ -732,7 +723,7 @@ class PHPExcel_Calculation_LookupRef {
if ($rowNumber !== false) { if ($rowNumber !== false) {
if ((!$not_exact_match) && ($rowValue != $lookup_value)) { if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
// if an exact match is required, we have what we need to return an appropriate response // if an exact match is required, we have what we need to return an appropriate response
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} else { } else {
// otherwise return the appropriate value // otherwise return the appropriate value
$result = $lookup_array[$rowNumber][$returnColumn]; $result = $lookup_array[$rowNumber][$returnColumn];
@ -743,7 +734,7 @@ class PHPExcel_Calculation_LookupRef {
} }
} }
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} // function VLOOKUP() } // function VLOOKUP()
@ -757,23 +748,23 @@ class PHPExcel_Calculation_LookupRef {
* @return mixed The value of the found cell * @return mixed The value of the found cell
*/ */
public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) { public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) {
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); $lookup_value = Calculation_Functions::flattenSingleValue($lookup_value);
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number); $index_number = Calculation_Functions::flattenSingleValue($index_number);
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match); $not_exact_match = Calculation_Functions::flattenSingleValue($not_exact_match);
// index_number must be greater than or equal to 1 // index_number must be greater than or equal to 1
if ($index_number < 1) { if ($index_number < 1) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
// index_number must be less than or equal to the number of columns in lookup_array // index_number must be less than or equal to the number of columns in lookup_array
if ((!is_array($lookup_array)) || (empty($lookup_array))) { if ((!is_array($lookup_array)) || (empty($lookup_array))) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} else { } else {
$f = array_keys($lookup_array); $f = array_keys($lookup_array);
$firstRow = array_pop($f); $firstRow = array_pop($f);
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
return PHPExcel_Calculation_Functions::REF(); return Calculation_Functions::REF();
} else { } else {
$columnKeys = array_keys($lookup_array[$firstRow]); $columnKeys = array_keys($lookup_array[$firstRow]);
$firstkey = $f[0] - 1; $firstkey = $f[0] - 1;
@ -799,7 +790,7 @@ class PHPExcel_Calculation_LookupRef {
if ($rowNumber !== false) { if ($rowNumber !== false) {
if ((!$not_exact_match) && ($rowValue != $lookup_value)) { if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
// if an exact match is required, we have what we need to return an appropriate response // if an exact match is required, we have what we need to return an appropriate response
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} else { } else {
// otherwise return the appropriate value // otherwise return the appropriate value
$result = $lookup_array[$returnColumn][$rowNumber]; $result = $lookup_array[$returnColumn][$rowNumber];
@ -807,7 +798,7 @@ class PHPExcel_Calculation_LookupRef {
} }
} }
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} // function HLOOKUP() } // function HLOOKUP()
@ -820,10 +811,10 @@ class PHPExcel_Calculation_LookupRef {
* @return mixed The value of the found cell * @return mixed The value of the found cell
*/ */
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector=null) { public static function LOOKUP($lookup_value, $lookup_vector, $result_vector=null) {
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); $lookup_value = Calculation_Functions::flattenSingleValue($lookup_value);
if (!is_array($lookup_vector)) { if (!is_array($lookup_vector)) {
return PHPExcel_Calculation_Functions::NA(); return Calculation_Functions::NA();
} }
$lookupRows = count($lookup_vector); $lookupRows = count($lookup_vector);
$l = array_keys($lookup_vector); $l = array_keys($lookup_vector);
@ -878,4 +869,4 @@ class PHPExcel_Calculation_LookupRef {
return self::VLOOKUP($lookup_value,$lookup_vector,2); return self::VLOOKUP($lookup_value,$lookup_vector,2);
} // function LOOKUP() } // function LOOKUP()
} // class PHPExcel_Calculation_LookupRef }

View File

@ -19,31 +19,23 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Calculation_MathTrig * PHPExcel\Calculation_MathTrig
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_MathTrig { class Calculation_MathTrig {
// //
// Private method to return an array of the factors of the input value // Private method to return an array of the factors of the input value
@ -98,8 +90,8 @@ class PHPExcel_Calculation_MathTrig {
* @return float The inverse tangent of the specified x- and y-coordinates. * @return float The inverse tangent of the specified x- and y-coordinates.
*/ */
public static function ATAN2($xCoordinate = NULL, $yCoordinate = NULL) { public static function ATAN2($xCoordinate = NULL, $yCoordinate = NULL) {
$xCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($xCoordinate); $xCoordinate = Calculation_Functions::flattenSingleValue($xCoordinate);
$yCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($yCoordinate); $yCoordinate = Calculation_Functions::flattenSingleValue($yCoordinate);
$xCoordinate = ($xCoordinate !== NULL) ? $xCoordinate : 0.0; $xCoordinate = ($xCoordinate !== NULL) ? $xCoordinate : 0.0;
$yCoordinate = ($yCoordinate !== NULL) ? $yCoordinate : 0.0; $yCoordinate = ($yCoordinate !== NULL) ? $yCoordinate : 0.0;
@ -110,12 +102,12 @@ class PHPExcel_Calculation_MathTrig {
$yCoordinate = (float) $yCoordinate; $yCoordinate = (float) $yCoordinate;
if (($xCoordinate == 0) && ($yCoordinate == 0)) { if (($xCoordinate == 0) && ($yCoordinate == 0)) {
return PHPExcel_Calculation_Functions::DIV0(); return Calculation_Functions::DIV0();
} }
return atan2($yCoordinate, $xCoordinate); return atan2($yCoordinate, $xCoordinate);
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function ATAN2() } // function ATAN2()
@ -137,11 +129,11 @@ class PHPExcel_Calculation_MathTrig {
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function CEILING($number, $significance = NULL) { public static function CEILING($number, $significance = NULL) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
$significance = PHPExcel_Calculation_Functions::flattenSingleValue($significance); $significance = Calculation_Functions::flattenSingleValue($significance);
if ((is_null($significance)) && if ((is_null($significance)) &&
(PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) { (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
$significance = $number/abs($number); $significance = $number/abs($number);
} }
@ -151,10 +143,10 @@ class PHPExcel_Calculation_MathTrig {
} elseif (self::SIGN($number) == self::SIGN($significance)) { } elseif (self::SIGN($number) == self::SIGN($significance)) {
return ceil($number / $significance) * $significance; return ceil($number / $significance) * $significance;
} else { } else {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function CEILING() } // function CEILING()
@ -174,18 +166,18 @@ class PHPExcel_Calculation_MathTrig {
* @return int Number of combinations * @return int Number of combinations
*/ */
public static function COMBIN($numObjs, $numInSet) { public static function COMBIN($numObjs, $numInSet) {
$numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs); $numObjs = Calculation_Functions::flattenSingleValue($numObjs);
$numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet); $numInSet = Calculation_Functions::flattenSingleValue($numInSet);
if ((is_numeric($numObjs)) && (is_numeric($numInSet))) { if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
if ($numObjs < $numInSet) { if ($numObjs < $numInSet) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} elseif ($numInSet < 0) { } elseif ($numInSet < 0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet); return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet);
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function COMBIN() } // function COMBIN()
@ -207,7 +199,7 @@ class PHPExcel_Calculation_MathTrig {
* @return int Rounded Number * @return int Rounded Number
*/ */
public static function EVEN($number) { public static function EVEN($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
if (is_null($number)) { if (is_null($number)) {
return 0; return 0;
@ -219,7 +211,7 @@ class PHPExcel_Calculation_MathTrig {
$significance = 2 * self::SIGN($number); $significance = 2 * self::SIGN($number);
return (int) self::CEILING($number,$significance); return (int) self::CEILING($number,$significance);
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function EVEN() } // function EVEN()
@ -238,16 +230,16 @@ class PHPExcel_Calculation_MathTrig {
* @return int Factorial * @return int Factorial
*/ */
public static function FACT($factVal) { public static function FACT($factVal) {
$factVal = PHPExcel_Calculation_Functions::flattenSingleValue($factVal); $factVal = Calculation_Functions::flattenSingleValue($factVal);
if (is_numeric($factVal)) { if (is_numeric($factVal)) {
if ($factVal < 0) { if ($factVal < 0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$factLoop = floor($factVal); $factLoop = floor($factVal);
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC) {
if ($factVal > $factLoop) { if ($factVal > $factLoop) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
} }
@ -257,7 +249,7 @@ class PHPExcel_Calculation_MathTrig {
} }
return $factorial ; return $factorial ;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function FACT() } // function FACT()
@ -275,12 +267,12 @@ class PHPExcel_Calculation_MathTrig {
* @return int Double Factorial * @return int Double Factorial
*/ */
public static function FACTDOUBLE($factVal) { public static function FACTDOUBLE($factVal) {
$factLoop = PHPExcel_Calculation_Functions::flattenSingleValue($factVal); $factLoop = Calculation_Functions::flattenSingleValue($factVal);
if (is_numeric($factLoop)) { if (is_numeric($factLoop)) {
$factLoop = floor($factLoop); $factLoop = floor($factLoop);
if ($factVal < 0) { if ($factVal < 0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$factorial = 1; $factorial = 1;
while ($factLoop > 1) { while ($factLoop > 1) {
@ -289,7 +281,7 @@ class PHPExcel_Calculation_MathTrig {
} }
return $factorial ; return $factorial ;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function FACTDOUBLE() } // function FACTDOUBLE()
@ -308,24 +300,24 @@ class PHPExcel_Calculation_MathTrig {
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function FLOOR($number, $significance = NULL) { public static function FLOOR($number, $significance = NULL) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
$significance = PHPExcel_Calculation_Functions::flattenSingleValue($significance); $significance = Calculation_Functions::flattenSingleValue($significance);
if ((is_null($significance)) && (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) { if ((is_null($significance)) && (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
$significance = $number/abs($number); $significance = $number/abs($number);
} }
if ((is_numeric($number)) && (is_numeric($significance))) { if ((is_numeric($number)) && (is_numeric($significance))) {
if ((float) $significance == 0.0) { if ((float) $significance == 0.0) {
return PHPExcel_Calculation_Functions::DIV0(); return Calculation_Functions::DIV0();
} }
if (self::SIGN($number) == self::SIGN($significance)) { if (self::SIGN($number) == self::SIGN($significance)) {
return floor($number / $significance) * $significance; return floor($number / $significance) * $significance;
} else { } else {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function FLOOR() } // function FLOOR()
@ -348,13 +340,13 @@ class PHPExcel_Calculation_MathTrig {
$returnValue = 1; $returnValue = 1;
$allValuesFactors = array(); $allValuesFactors = array();
// Loop through arguments // Loop through arguments
foreach(PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $value) { foreach(Calculation_Functions::flattenArray(func_get_args()) as $value) {
if (!is_numeric($value)) { if (!is_numeric($value)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} elseif ($value == 0) { } elseif ($value == 0) {
continue; continue;
} elseif($value < 0) { } elseif($value < 0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$myFactors = self::_factors($value); $myFactors = self::_factors($value);
$myCountedFactors = array_count_values($myFactors); $myCountedFactors = array_count_values($myFactors);
@ -419,7 +411,7 @@ class PHPExcel_Calculation_MathTrig {
* @return integer Integer value * @return integer Integer value
*/ */
public static function INT($number) { public static function INT($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
if (is_null($number)) { if (is_null($number)) {
return 0; return 0;
@ -429,7 +421,7 @@ class PHPExcel_Calculation_MathTrig {
if (is_numeric($number)) { if (is_numeric($number)) {
return (int) floor($number); return (int) floor($number);
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function INT() } // function INT()
@ -453,14 +445,14 @@ class PHPExcel_Calculation_MathTrig {
$returnValue = 1; $returnValue = 1;
$allPoweredFactors = array(); $allPoweredFactors = array();
// Loop through arguments // Loop through arguments
foreach(PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $value) { foreach(Calculation_Functions::flattenArray(func_get_args()) as $value) {
if (!is_numeric($value)) { if (!is_numeric($value)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if ($value == 0) { if ($value == 0) {
return 0; return 0;
} elseif ($value < 0) { } elseif ($value < 0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$myFactors = self::_factors(floor($value)); $myFactors = self::_factors(floor($value));
$myCountedFactors = array_count_values($myFactors); $myCountedFactors = array_count_values($myFactors);
@ -500,13 +492,13 @@ class PHPExcel_Calculation_MathTrig {
* @return float * @return float
*/ */
public static function LOG_BASE($number = NULL, $base = 10) { public static function LOG_BASE($number = NULL, $base = 10) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
$base = (is_null($base)) ? 10 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($base); $base = (is_null($base)) ? 10 : (float) Calculation_Functions::flattenSingleValue($base);
if ((!is_numeric($base)) || (!is_numeric($number))) if ((!is_numeric($base)) || (!is_numeric($number)))
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
if (($base <= 0) || ($number <= 0)) if (($base <= 0) || ($number <= 0))
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
return log($number, $base); return log($number, $base);
} // function LOG_BASE() } // function LOG_BASE()
@ -534,7 +526,7 @@ class PHPExcel_Calculation_MathTrig {
$column = 0; $column = 0;
foreach($matrixRow as $matrixCell) { foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) { if ((is_string($matrixCell)) || ($matrixCell === null)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$matrixData[$column][$row] = $matrixCell; $matrixData[$column][$row] = $matrixCell;
++$column; ++$column;
@ -542,13 +534,13 @@ class PHPExcel_Calculation_MathTrig {
if ($column > $maxColumn) { $maxColumn = $column; } if ($column > $maxColumn) { $maxColumn = $column; }
++$row; ++$row;
} }
if ($row != $maxColumn) { return PHPExcel_Calculation_Functions::VALUE(); } if ($row != $maxColumn) { return Calculation_Functions::VALUE(); }
try { try {
$matrix = new PHPExcel_Shared_JAMA_Matrix($matrixData); $matrix = new Shared_JAMA_Matrix($matrixData);
return $matrix->det(); return $matrix->det();
} catch (PHPExcel_Exception $ex) { } catch (Exception $ex) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} // function MDETERM() } // function MDETERM()
@ -576,7 +568,7 @@ class PHPExcel_Calculation_MathTrig {
$column = 0; $column = 0;
foreach($matrixRow as $matrixCell) { foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) { if ((is_string($matrixCell)) || ($matrixCell === null)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$matrixData[$column][$row] = $matrixCell; $matrixData[$column][$row] = $matrixCell;
++$column; ++$column;
@ -584,13 +576,13 @@ class PHPExcel_Calculation_MathTrig {
if ($column > $maxColumn) { $maxColumn = $column; } if ($column > $maxColumn) { $maxColumn = $column; }
++$row; ++$row;
} }
if ($row != $maxColumn) { return PHPExcel_Calculation_Functions::VALUE(); } if ($row != $maxColumn) { return Calculation_Functions::VALUE(); }
try { try {
$matrix = new PHPExcel_Shared_JAMA_Matrix($matrixData); $matrix = new Shared_JAMA_Matrix($matrixData);
return $matrix->inverse()->getArray(); return $matrix->inverse()->getArray();
} catch (PHPExcel_Exception $ex) { } catch (Exception $ex) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} // function MINVERSE() } // function MINVERSE()
@ -613,7 +605,7 @@ class PHPExcel_Calculation_MathTrig {
$columnA = 0; $columnA = 0;
foreach($matrixRow as $matrixCell) { foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) { if ((is_string($matrixCell)) || ($matrixCell === null)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$matrixAData[$rowA][$columnA] = $matrixCell; $matrixAData[$rowA][$columnA] = $matrixCell;
++$columnA; ++$columnA;
@ -621,29 +613,29 @@ class PHPExcel_Calculation_MathTrig {
++$rowA; ++$rowA;
} }
try { try {
$matrixA = new PHPExcel_Shared_JAMA_Matrix($matrixAData); $matrixA = new Shared_JAMA_Matrix($matrixAData);
$rowB = 0; $rowB = 0;
foreach($matrixData2 as $matrixRow) { foreach($matrixData2 as $matrixRow) {
if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); } if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
$columnB = 0; $columnB = 0;
foreach($matrixRow as $matrixCell) { foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) { if ((is_string($matrixCell)) || ($matrixCell === null)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$matrixBData[$rowB][$columnB] = $matrixCell; $matrixBData[$rowB][$columnB] = $matrixCell;
++$columnB; ++$columnB;
} }
++$rowB; ++$rowB;
} }
$matrixB = new PHPExcel_Shared_JAMA_Matrix($matrixBData); $matrixB = new Shared_JAMA_Matrix($matrixBData);
if (($rowA != $columnB) || ($rowB != $columnA)) { if (($rowA != $columnB) || ($rowB != $columnA)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
return $matrixA->times($matrixB)->getArray(); return $matrixA->times($matrixB)->getArray();
} catch (PHPExcel_Exception $ex) { } catch (Exception $ex) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} // function MMULT() } // function MMULT()
@ -656,11 +648,11 @@ class PHPExcel_Calculation_MathTrig {
* @return int Remainder * @return int Remainder
*/ */
public static function MOD($a = 1, $b = 1) { public static function MOD($a = 1, $b = 1) {
$a = PHPExcel_Calculation_Functions::flattenSingleValue($a); $a = Calculation_Functions::flattenSingleValue($a);
$b = PHPExcel_Calculation_Functions::flattenSingleValue($b); $b = Calculation_Functions::flattenSingleValue($b);
if ($b == 0.0) { if ($b == 0.0) {
return PHPExcel_Calculation_Functions::DIV0(); return Calculation_Functions::DIV0();
} elseif (($a < 0.0) && ($b > 0.0)) { } elseif (($a < 0.0) && ($b > 0.0)) {
return $b - fmod(abs($a),$b); return $b - fmod(abs($a),$b);
} elseif (($a > 0.0) && ($b < 0.0)) { } elseif (($a > 0.0) && ($b < 0.0)) {
@ -681,8 +673,8 @@ class PHPExcel_Calculation_MathTrig {
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function MROUND($number,$multiple) { public static function MROUND($number,$multiple) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
$multiple = PHPExcel_Calculation_Functions::flattenSingleValue($multiple); $multiple = Calculation_Functions::flattenSingleValue($multiple);
if ((is_numeric($number)) && (is_numeric($multiple))) { if ((is_numeric($number)) && (is_numeric($multiple))) {
if ($multiple == 0) { if ($multiple == 0) {
@ -692,9 +684,9 @@ class PHPExcel_Calculation_MathTrig {
$multiplier = 1 / $multiple; $multiplier = 1 / $multiple;
return round($number * $multiplier) / $multiplier; return round($number * $multiplier) / $multiplier;
} }
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function MROUND() } // function MROUND()
@ -710,16 +702,16 @@ class PHPExcel_Calculation_MathTrig {
$summer = 0; $summer = 0;
$divisor = 1; $divisor = 1;
// Loop through arguments // Loop through arguments
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) { foreach (Calculation_Functions::flattenArray(func_get_args()) as $arg) {
// Is it a numeric value? // Is it a numeric value?
if (is_numeric($arg)) { if (is_numeric($arg)) {
if ($arg < 1) { if ($arg < 1) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$summer += floor($arg); $summer += floor($arg);
$divisor *= self::FACT($arg); $divisor *= self::FACT($arg);
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
@ -741,7 +733,7 @@ class PHPExcel_Calculation_MathTrig {
* @return int Rounded Number * @return int Rounded Number
*/ */
public static function ODD($number) { public static function ODD($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
if (is_null($number)) { if (is_null($number)) {
return 1; return 1;
@ -762,7 +754,7 @@ class PHPExcel_Calculation_MathTrig {
return (int) $result; return (int) $result;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function ODD() } // function ODD()
@ -776,19 +768,19 @@ class PHPExcel_Calculation_MathTrig {
* @return float * @return float
*/ */
public static function POWER($x = 0, $y = 2) { public static function POWER($x = 0, $y = 2) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); $x = Calculation_Functions::flattenSingleValue($x);
$y = PHPExcel_Calculation_Functions::flattenSingleValue($y); $y = Calculation_Functions::flattenSingleValue($y);
// Validate parameters // Validate parameters
if ($x == 0.0 && $y == 0.0) { if ($x == 0.0 && $y == 0.0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} elseif ($x == 0.0 && $y < 0.0) { } elseif ($x == 0.0 && $y < 0.0) {
return PHPExcel_Calculation_Functions::DIV0(); return Calculation_Functions::DIV0();
} }
// Return // Return
$result = pow($x, $y); $result = pow($x, $y);
return (!is_nan($result) && !is_infinite($result)) ? $result : PHPExcel_Calculation_Functions::NaN(); return (!is_nan($result) && !is_infinite($result)) ? $result : Calculation_Functions::NaN();
} // function POWER() } // function POWER()
@ -810,7 +802,7 @@ class PHPExcel_Calculation_MathTrig {
$returnValue = null; $returnValue = null;
// Loop through arguments // Loop through arguments
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) { foreach (Calculation_Functions::flattenArray(func_get_args()) as $arg) {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) { if (is_null($returnValue)) {
@ -848,7 +840,7 @@ class PHPExcel_Calculation_MathTrig {
$returnValue = null; $returnValue = null;
// Loop through arguments // Loop through arguments
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) { foreach (Calculation_Functions::flattenArray(func_get_args()) as $arg) {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) { if (is_null($returnValue)) {
@ -876,8 +868,8 @@ class PHPExcel_Calculation_MathTrig {
* @return int Random number * @return int Random number
*/ */
public static function RAND($min = 0, $max = 0) { public static function RAND($min = 0, $max = 0) {
$min = PHPExcel_Calculation_Functions::flattenSingleValue($min); $min = Calculation_Functions::flattenSingleValue($min);
$max = PHPExcel_Calculation_Functions::flattenSingleValue($max); $max = Calculation_Functions::flattenSingleValue($max);
if ($min == 0 && $max == 0) { if ($min == 0 && $max == 0) {
return (rand(0,10000000)) / 10000000; return (rand(0,10000000)) / 10000000;
@ -888,10 +880,10 @@ class PHPExcel_Calculation_MathTrig {
public static function ROMAN($aValue, $style=0) { public static function ROMAN($aValue, $style=0) {
$aValue = PHPExcel_Calculation_Functions::flattenSingleValue($aValue); $aValue = Calculation_Functions::flattenSingleValue($aValue);
$style = (is_null($style)) ? 0 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($style); $style = (is_null($style)) ? 0 : (integer) Calculation_Functions::flattenSingleValue($style);
if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) { if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
$aValue = (integer) $aValue; $aValue = (integer) $aValue;
if ($aValue == 0) { if ($aValue == 0) {
@ -926,8 +918,8 @@ class PHPExcel_Calculation_MathTrig {
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function ROUNDUP($number,$digits) { public static function ROUNDUP($number,$digits) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
$digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits); $digits = Calculation_Functions::flattenSingleValue($digits);
if ((is_numeric($number)) && (is_numeric($digits))) { if ((is_numeric($number)) && (is_numeric($digits))) {
$significance = pow(10,(int) $digits); $significance = pow(10,(int) $digits);
@ -937,7 +929,7 @@ class PHPExcel_Calculation_MathTrig {
return ceil($number * $significance) / $significance; return ceil($number * $significance) / $significance;
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function ROUNDUP() } // function ROUNDUP()
@ -951,8 +943,8 @@ class PHPExcel_Calculation_MathTrig {
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function ROUNDDOWN($number,$digits) { public static function ROUNDDOWN($number,$digits) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
$digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits); $digits = Calculation_Functions::flattenSingleValue($digits);
if ((is_numeric($number)) && (is_numeric($digits))) { if ((is_numeric($number)) && (is_numeric($digits))) {
$significance = pow(10,(int) $digits); $significance = pow(10,(int) $digits);
@ -962,7 +954,7 @@ class PHPExcel_Calculation_MathTrig {
return floor($number * $significance) / $significance; return floor($number * $significance) / $significance;
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function ROUNDDOWN() } // function ROUNDDOWN()
@ -982,7 +974,7 @@ class PHPExcel_Calculation_MathTrig {
$returnValue = 0; $returnValue = 0;
// Loop through arguments // Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); $aArgs = Calculation_Functions::flattenArray(func_get_args());
$x = array_shift($aArgs); $x = array_shift($aArgs);
$n = array_shift($aArgs); $n = array_shift($aArgs);
@ -996,13 +988,13 @@ class PHPExcel_Calculation_MathTrig {
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue += $arg * pow($x,$n + ($m * $i++)); $returnValue += $arg * pow($x,$n + ($m * $i++));
} else { } else {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
} }
// Return // Return
return $returnValue; return $returnValue;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function SERIESSUM() } // function SERIESSUM()
@ -1016,7 +1008,7 @@ class PHPExcel_Calculation_MathTrig {
* @return int sign value * @return int sign value
*/ */
public static function SIGN($number) { public static function SIGN($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
if (is_bool($number)) if (is_bool($number))
return (int) $number; return (int) $number;
@ -1026,7 +1018,7 @@ class PHPExcel_Calculation_MathTrig {
} }
return $number / abs($number); return $number / abs($number);
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function SIGN() } // function SIGN()
@ -1039,15 +1031,15 @@ class PHPExcel_Calculation_MathTrig {
* @return float Square Root of Number * Pi * @return float Square Root of Number * Pi
*/ */
public static function SQRTPI($number) { public static function SQRTPI($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $number = Calculation_Functions::flattenSingleValue($number);
if (is_numeric($number)) { if (is_numeric($number)) {
if ($number < 0) { if ($number < 0) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
return sqrt($number * M_PI) ; return sqrt($number * M_PI) ;
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function SQRTPI() } // function SQRTPI()
@ -1062,7 +1054,7 @@ class PHPExcel_Calculation_MathTrig {
* @return float * @return float
*/ */
public static function SUBTOTAL() { public static function SUBTOTAL() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); $aArgs = Calculation_Functions::flattenArray(func_get_args());
// Calculate // Calculate
$subtotal = array_shift($aArgs); $subtotal = array_shift($aArgs);
@ -1070,41 +1062,41 @@ class PHPExcel_Calculation_MathTrig {
if ((is_numeric($subtotal)) && (!is_string($subtotal))) { if ((is_numeric($subtotal)) && (!is_string($subtotal))) {
switch($subtotal) { switch($subtotal) {
case 1 : case 1 :
return PHPExcel_Calculation_Statistical::AVERAGE($aArgs); return Calculation_Statistical::AVERAGE($aArgs);
break; break;
case 2 : case 2 :
return PHPExcel_Calculation_Statistical::COUNT($aArgs); return Calculation_Statistical::COUNT($aArgs);
break; break;
case 3 : case 3 :
return PHPExcel_Calculation_Statistical::COUNTA($aArgs); return Calculation_Statistical::COUNTA($aArgs);
break; break;
case 4 : case 4 :
return PHPExcel_Calculation_Statistical::MAX($aArgs); return Calculation_Statistical::MAX($aArgs);
break; break;
case 5 : case 5 :
return PHPExcel_Calculation_Statistical::MIN($aArgs); return Calculation_Statistical::MIN($aArgs);
break; break;
case 6 : case 6 :
return self::PRODUCT($aArgs); return self::PRODUCT($aArgs);
break; break;
case 7 : case 7 :
return PHPExcel_Calculation_Statistical::STDEV($aArgs); return Calculation_Statistical::STDEV($aArgs);
break; break;
case 8 : case 8 :
return PHPExcel_Calculation_Statistical::STDEVP($aArgs); return Calculation_Statistical::STDEVP($aArgs);
break; break;
case 9 : case 9 :
return self::SUM($aArgs); return self::SUM($aArgs);
break; break;
case 10 : case 10 :
return PHPExcel_Calculation_Statistical::VARFunc($aArgs); return Calculation_Statistical::VARFunc($aArgs);
break; break;
case 11 : case 11 :
return PHPExcel_Calculation_Statistical::VARP($aArgs); return Calculation_Statistical::VARP($aArgs);
break; break;
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function SUBTOTAL() } // function SUBTOTAL()
@ -1126,7 +1118,7 @@ class PHPExcel_Calculation_MathTrig {
$returnValue = 0; $returnValue = 0;
// Loop through the arguments // Loop through the arguments
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) { foreach (Calculation_Functions::flattenArray(func_get_args()) as $arg) {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue += $arg; $returnValue += $arg;
@ -1156,17 +1148,17 @@ class PHPExcel_Calculation_MathTrig {
// Return value // Return value
$returnValue = 0; $returnValue = 0;
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs); $aArgs = Calculation_Functions::flattenArray($aArgs);
$sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs); $sumArgs = Calculation_Functions::flattenArray($sumArgs);
if (empty($sumArgs)) { if (empty($sumArgs)) {
$sumArgs = $aArgs; $sumArgs = $aArgs;
} }
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition); $condition = Calculation_Functions::_ifCondition($condition);
// Loop through arguments // Loop through arguments
foreach ($aArgs as $key => $arg) { foreach ($aArgs as $key => $arg) {
if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } if (!is_numeric($arg)) { $arg = Calculation::_wrapResult(strtoupper($arg)); }
$testCondition = '='.$arg.$condition; $testCondition = '='.$arg.$condition;
if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
// Is it a value within our criteria // Is it a value within our criteria
$returnValue += $sumArgs[$key]; $returnValue += $sumArgs[$key];
} }
@ -1191,7 +1183,7 @@ class PHPExcel_Calculation_MathTrig {
public static function SUMPRODUCT() { public static function SUMPRODUCT() {
$arrayList = func_get_args(); $arrayList = func_get_args();
$wrkArray = PHPExcel_Calculation_Functions::flattenArray(array_shift($arrayList)); $wrkArray = Calculation_Functions::flattenArray(array_shift($arrayList));
$wrkCellCount = count($wrkArray); $wrkCellCount = count($wrkArray);
for ($i=0; $i< $wrkCellCount; ++$i) { for ($i=0; $i< $wrkCellCount; ++$i) {
@ -1201,10 +1193,10 @@ class PHPExcel_Calculation_MathTrig {
} }
foreach($arrayList as $matrixData) { foreach($arrayList as $matrixData) {
$array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData); $array2 = Calculation_Functions::flattenArray($matrixData);
$count = count($array2); $count = count($array2);
if ($wrkCellCount != $count) { if ($wrkCellCount != $count) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
foreach ($array2 as $i => $val) { foreach ($array2 as $i => $val) {
@ -1237,7 +1229,7 @@ class PHPExcel_Calculation_MathTrig {
$returnValue = 0; $returnValue = 0;
// Loop through arguments // Loop through arguments
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) { foreach (Calculation_Functions::flattenArray(func_get_args()) as $arg) {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue += ($arg * $arg); $returnValue += ($arg * $arg);
@ -1257,8 +1249,8 @@ class PHPExcel_Calculation_MathTrig {
* @return float * @return float
*/ */
public static function SUMX2MY2($matrixData1,$matrixData2) { public static function SUMX2MY2($matrixData1,$matrixData2) {
$array1 = PHPExcel_Calculation_Functions::flattenArray($matrixData1); $array1 = Calculation_Functions::flattenArray($matrixData1);
$array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData2); $array2 = Calculation_Functions::flattenArray($matrixData2);
$count1 = count($array1); $count1 = count($array1);
$count2 = count($array2); $count2 = count($array2);
if ($count1 < $count2) { if ($count1 < $count2) {
@ -1287,8 +1279,8 @@ class PHPExcel_Calculation_MathTrig {
* @return float * @return float
*/ */
public static function SUMX2PY2($matrixData1,$matrixData2) { public static function SUMX2PY2($matrixData1,$matrixData2) {
$array1 = PHPExcel_Calculation_Functions::flattenArray($matrixData1); $array1 = Calculation_Functions::flattenArray($matrixData1);
$array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData2); $array2 = Calculation_Functions::flattenArray($matrixData2);
$count1 = count($array1); $count1 = count($array1);
$count2 = count($array2); $count2 = count($array2);
if ($count1 < $count2) { if ($count1 < $count2) {
@ -1317,8 +1309,8 @@ class PHPExcel_Calculation_MathTrig {
* @return float * @return float
*/ */
public static function SUMXMY2($matrixData1,$matrixData2) { public static function SUMXMY2($matrixData1,$matrixData2) {
$array1 = PHPExcel_Calculation_Functions::flattenArray($matrixData1); $array1 = Calculation_Functions::flattenArray($matrixData1);
$array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData2); $array2 = Calculation_Functions::flattenArray($matrixData2);
$count1 = count($array1); $count1 = count($array1);
$count2 = count($array2); $count2 = count($array2);
if ($count1 < $count2) { if ($count1 < $count2) {
@ -1349,12 +1341,12 @@ class PHPExcel_Calculation_MathTrig {
* @return float Truncated value * @return float Truncated value
*/ */
public static function TRUNC($value = 0, $digits = 0) { public static function TRUNC($value = 0, $digits = 0) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value); $value = Calculation_Functions::flattenSingleValue($value);
$digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits); $digits = Calculation_Functions::flattenSingleValue($digits);
// Validate parameters // Validate parameters
if ((!is_numeric($value)) || (!is_numeric($digits))) if ((!is_numeric($value)) || (!is_numeric($digits)))
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
$digits = floor($digits); $digits = floor($digits);
// Truncate // Truncate
@ -1366,4 +1358,4 @@ class PHPExcel_Calculation_MathTrig {
return (intval($value * $adjust)) / $adjust; return (intval($value * $adjust)) / $adjust;
} // function TRUNC() } // function TRUNC()
} // class PHPExcel_Calculation_MathTrig }

File diff suppressed because it is too large Load Diff

View File

@ -19,31 +19,23 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Calculation_TextData * PHPExcel\Calculation_TextData
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_TextData { class Calculation_TextData {
private static $_invalidChars = Null; private static $_invalidChars = Null;
@ -61,7 +53,7 @@ class PHPExcel_Calculation_TextData {
if (ord($c{0}) >= 252 && ord($c{0}) <= 253) if (ord($c{0}) >= 252 && ord($c{0}) <= 253)
return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128); return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
if (ord($c{0}) >= 254 && ord($c{0}) <= 255) //error if (ord($c{0}) >= 254 && ord($c{0}) <= 255) //error
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
return 0; return 0;
} // function _uniord() } // function _uniord()
@ -72,10 +64,10 @@ class PHPExcel_Calculation_TextData {
* @return int * @return int
*/ */
public static function CHARACTER($character) { public static function CHARACTER($character) {
$character = PHPExcel_Calculation_Functions::flattenSingleValue($character); $character = Calculation_Functions::flattenSingleValue($character);
if ((!is_numeric($character)) || ($character < 0)) { if ((!is_numeric($character)) || ($character < 0)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (function_exists('mb_convert_encoding')) { if (function_exists('mb_convert_encoding')) {
@ -93,10 +85,10 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function TRIMNONPRINTABLE($stringValue = '') { public static function TRIMNONPRINTABLE($stringValue = '') {
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue); $stringValue = Calculation_Functions::flattenSingleValue($stringValue);
if (is_bool($stringValue)) { if (is_bool($stringValue)) {
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); return ($stringValue) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
if (self::$_invalidChars == Null) { if (self::$_invalidChars == Null) {
@ -117,10 +109,10 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function TRIMSPACES($stringValue = '') { public static function TRIMSPACES($stringValue = '') {
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue); $stringValue = Calculation_Functions::flattenSingleValue($stringValue);
if (is_bool($stringValue)) { if (is_bool($stringValue)) {
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); return ($stringValue) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
if (is_string($stringValue) || is_numeric($stringValue)) { if (is_string($stringValue) || is_numeric($stringValue)) {
@ -138,13 +130,13 @@ class PHPExcel_Calculation_TextData {
*/ */
public static function ASCIICODE($characters) { public static function ASCIICODE($characters) {
if (($characters === NULL) || ($characters === '')) if (($characters === NULL) || ($characters === ''))
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
$characters = PHPExcel_Calculation_Functions::flattenSingleValue($characters); $characters = Calculation_Functions::flattenSingleValue($characters);
if (is_bool($characters)) { if (is_bool($characters)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$characters = (int) $characters; $characters = (int) $characters;
} else { } else {
$characters = ($characters) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $characters = ($characters) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
} }
@ -169,13 +161,13 @@ class PHPExcel_Calculation_TextData {
$returnValue = ''; $returnValue = '';
// Loop through arguments // Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); $aArgs = Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) { foreach ($aArgs as $arg) {
if (is_bool($arg)) { if (is_bool($arg)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { if (Calculation_Functions::getCompatibilityMode() == Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$arg = (int) $arg; $arg = (int) $arg;
} else { } else {
$arg = ($arg) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $arg = ($arg) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
} }
$returnValue .= $arg; $returnValue .= $arg;
@ -199,12 +191,12 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function DOLLAR($value = 0, $decimals = 2) { public static function DOLLAR($value = 0, $decimals = 2) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value); $value = Calculation_Functions::flattenSingleValue($value);
$decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals); $decimals = is_null($decimals) ? 0 : Calculation_Functions::flattenSingleValue($decimals);
// Validate parameters // Validate parameters
if (!is_numeric($value) || !is_numeric($decimals)) { if (!is_numeric($value) || !is_numeric($decimals)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$decimals = floor($decimals); $decimals = floor($decimals);
@ -214,10 +206,10 @@ class PHPExcel_Calculation_TextData {
} else { } else {
$round = pow(10,abs($decimals)); $round = pow(10,abs($decimals));
if ($value < 0) { $round = 0-$round; } if ($value < 0) { $round = 0-$round; }
$value = PHPExcel_Calculation_MathTrig::MROUND($value, $round); $value = Calculation_MathTrig::MROUND($value, $round);
} }
return PHPExcel_Style_NumberFormat::toFormattedString($value, $mask); return Style_NumberFormat::toFormattedString($value, $mask);
} // function DOLLAR() } // function DOLLAR()
@ -231,17 +223,17 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function SEARCHSENSITIVE($needle,$haystack,$offset=1) { public static function SEARCHSENSITIVE($needle,$haystack,$offset=1) {
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle); $needle = Calculation_Functions::flattenSingleValue($needle);
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack); $haystack = Calculation_Functions::flattenSingleValue($haystack);
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset); $offset = Calculation_Functions::flattenSingleValue($offset);
if (!is_bool($needle)) { if (!is_bool($needle)) {
if (is_bool($haystack)) { if (is_bool($haystack)) {
$haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $haystack = ($haystack) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) { if (($offset > 0) && (Shared_String::CountCharacters($haystack) > $offset)) {
if (PHPExcel_Shared_String::CountCharacters($needle) == 0) { if (Shared_String::CountCharacters($needle) == 0) {
return $offset; return $offset;
} }
if (function_exists('mb_strpos')) { if (function_exists('mb_strpos')) {
@ -254,7 +246,7 @@ class PHPExcel_Calculation_TextData {
} }
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function SEARCHSENSITIVE() } // function SEARCHSENSITIVE()
@ -267,17 +259,17 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function SEARCHINSENSITIVE($needle,$haystack,$offset=1) { public static function SEARCHINSENSITIVE($needle,$haystack,$offset=1) {
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle); $needle = Calculation_Functions::flattenSingleValue($needle);
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack); $haystack = Calculation_Functions::flattenSingleValue($haystack);
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset); $offset = Calculation_Functions::flattenSingleValue($offset);
if (!is_bool($needle)) { if (!is_bool($needle)) {
if (is_bool($haystack)) { if (is_bool($haystack)) {
$haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $haystack = ($haystack) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) { if (($offset > 0) && (Shared_String::CountCharacters($haystack) > $offset)) {
if (PHPExcel_Shared_String::CountCharacters($needle) == 0) { if (Shared_String::CountCharacters($needle) == 0) {
return $offset; return $offset;
} }
if (function_exists('mb_stripos')) { if (function_exists('mb_stripos')) {
@ -290,7 +282,7 @@ class PHPExcel_Calculation_TextData {
} }
} }
} }
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} // function SEARCHINSENSITIVE() } // function SEARCHINSENSITIVE()
@ -303,13 +295,13 @@ class PHPExcel_Calculation_TextData {
* @return boolean * @return boolean
*/ */
public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = FALSE) { public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = FALSE) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value); $value = Calculation_Functions::flattenSingleValue($value);
$decimals = PHPExcel_Calculation_Functions::flattenSingleValue($decimals); $decimals = Calculation_Functions::flattenSingleValue($decimals);
$no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas); $no_commas = Calculation_Functions::flattenSingleValue($no_commas);
// Validate parameters // Validate parameters
if (!is_numeric($value) || !is_numeric($decimals)) { if (!is_numeric($value) || !is_numeric($decimals)) {
return PHPExcel_Calculation_Functions::NaN(); return Calculation_Functions::NaN();
} }
$decimals = floor($decimals); $decimals = floor($decimals);
@ -331,15 +323,15 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function LEFT($value = '', $chars = 1) { public static function LEFT($value = '', $chars = 1) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value); $value = Calculation_Functions::flattenSingleValue($value);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars); $chars = Calculation_Functions::flattenSingleValue($chars);
if ($chars < 0) { if ($chars < 0) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (is_bool($value)) { if (is_bool($value)) {
$value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $value = ($value) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
if (function_exists('mb_substr')) { if (function_exists('mb_substr')) {
@ -359,16 +351,16 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function MID($value = '', $start = 1, $chars = null) { public static function MID($value = '', $start = 1, $chars = null) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value); $value = Calculation_Functions::flattenSingleValue($value);
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start); $start = Calculation_Functions::flattenSingleValue($start);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars); $chars = Calculation_Functions::flattenSingleValue($chars);
if (($start < 1) || ($chars < 0)) { if (($start < 1) || ($chars < 0)) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (is_bool($value)) { if (is_bool($value)) {
$value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $value = ($value) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
if (function_exists('mb_substr')) { if (function_exists('mb_substr')) {
@ -387,15 +379,15 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function RIGHT($value = '', $chars = 1) { public static function RIGHT($value = '', $chars = 1) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value); $value = Calculation_Functions::flattenSingleValue($value);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars); $chars = Calculation_Functions::flattenSingleValue($chars);
if ($chars < 0) { if ($chars < 0) {
return PHPExcel_Calculation_Functions::VALUE(); return Calculation_Functions::VALUE();
} }
if (is_bool($value)) { if (is_bool($value)) {
$value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $value = ($value) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
if ((function_exists('mb_substr')) && (function_exists('mb_strlen'))) { if ((function_exists('mb_substr')) && (function_exists('mb_strlen'))) {
@ -413,10 +405,10 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function STRINGLENGTH($value = '') { public static function STRINGLENGTH($value = '') {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value); $value = Calculation_Functions::flattenSingleValue($value);
if (is_bool($value)) { if (is_bool($value)) {
$value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $value = ($value) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
if (function_exists('mb_strlen')) { if (function_exists('mb_strlen')) {
@ -436,13 +428,13 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function LOWERCASE($mixedCaseString) { public static function LOWERCASE($mixedCaseString) {
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString); $mixedCaseString = Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) { if (is_bool($mixedCaseString)) {
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $mixedCaseString = ($mixedCaseString) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
return PHPExcel_Shared_String::StrToLower($mixedCaseString); return Shared_String::StrToLower($mixedCaseString);
} // function LOWERCASE() } // function LOWERCASE()
@ -455,13 +447,13 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function UPPERCASE($mixedCaseString) { public static function UPPERCASE($mixedCaseString) {
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString); $mixedCaseString = Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) { if (is_bool($mixedCaseString)) {
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $mixedCaseString = ($mixedCaseString) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
return PHPExcel_Shared_String::StrToUpper($mixedCaseString); return Shared_String::StrToUpper($mixedCaseString);
} // function UPPERCASE() } // function UPPERCASE()
@ -474,13 +466,13 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function PROPERCASE($mixedCaseString) { public static function PROPERCASE($mixedCaseString) {
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString); $mixedCaseString = Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) { if (is_bool($mixedCaseString)) {
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $mixedCaseString = ($mixedCaseString) ? Calculation::getTRUE() : Calculation::getFALSE();
} }
return PHPExcel_Shared_String::StrToTitle($mixedCaseString); return Shared_String::StrToTitle($mixedCaseString);
} // function PROPERCASE() } // function PROPERCASE()
@ -494,10 +486,10 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function REPLACE($oldText = '', $start = 1, $chars = null, $newText) { public static function REPLACE($oldText = '', $start = 1, $chars = null, $newText) {
$oldText = PHPExcel_Calculation_Functions::flattenSingleValue($oldText); $oldText = Calculation_Functions::flattenSingleValue($oldText);
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start); $start = Calculation_Functions::flattenSingleValue($start);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars); $chars = Calculation_Functions::flattenSingleValue($chars);
$newText = PHPExcel_Calculation_Functions::flattenSingleValue($newText); $newText = Calculation_Functions::flattenSingleValue($newText);
$left = self::LEFT($oldText,$start-1); $left = self::LEFT($oldText,$start-1);
$right = self::RIGHT($oldText,self::STRINGLENGTH($oldText)-($start+$chars)+1); $right = self::RIGHT($oldText,self::STRINGLENGTH($oldText)-($start+$chars)+1);
@ -516,10 +508,10 @@ class PHPExcel_Calculation_TextData {
* @return string * @return string
*/ */
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) { public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) {
$text = PHPExcel_Calculation_Functions::flattenSingleValue($text); $text = Calculation_Functions::flattenSingleValue($text);
$fromText = PHPExcel_Calculation_Functions::flattenSingleValue($fromText); $fromText = Calculation_Functions::flattenSingleValue($fromText);
$toText = PHPExcel_Calculation_Functions::flattenSingleValue($toText); $toText = Calculation_Functions::flattenSingleValue($toText);
$instance = floor(PHPExcel_Calculation_Functions::flattenSingleValue($instance)); $instance = floor(Calculation_Functions::flattenSingleValue($instance));
if ($instance == 0) { if ($instance == 0) {
if(function_exists('mb_str_replace')) { if(function_exists('mb_str_replace')) {
@ -560,7 +552,7 @@ class PHPExcel_Calculation_TextData {
* @return boolean * @return boolean
*/ */
public static function RETURNSTRING($testValue = '') { public static function RETURNSTRING($testValue = '') {
$testValue = PHPExcel_Calculation_Functions::flattenSingleValue($testValue); $testValue = Calculation_Functions::flattenSingleValue($testValue);
if (is_string($testValue)) { if (is_string($testValue)) {
return $testValue; return $testValue;
@ -577,14 +569,14 @@ class PHPExcel_Calculation_TextData {
* @return boolean * @return boolean
*/ */
public static function TEXTFORMAT($value,$format) { public static function TEXTFORMAT($value,$format) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value); $value = Calculation_Functions::flattenSingleValue($value);
$format = PHPExcel_Calculation_Functions::flattenSingleValue($format); $format = Calculation_Functions::flattenSingleValue($format);
if ((is_string($value)) && (!is_numeric($value)) && PHPExcel_Shared_Date::isDateTimeFormatCode($format)) { if ((is_string($value)) && (!is_numeric($value)) && Shared_Date::isDateTimeFormatCode($format)) {
$value = PHPExcel_Calculation_DateTime::DATEVALUE($value); $value = Calculation_DateTime::DATEVALUE($value);
} }
return (string) PHPExcel_Style_NumberFormat::toFormattedString($value,$format); return (string) Style_NumberFormat::toFormattedString($value,$format);
} // function TEXTFORMAT() } // function TEXTFORMAT()
} // class PHPExcel_Calculation_TextData }

View File

@ -19,21 +19,23 @@
* 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_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Calculation_Token_Stack * PHPExcel\Calculation_Token_Stack
* *
* @category PHPExcel_Calculation_Token_Stack * @category PHPExcel\Calculation_Token_Stack
* @package PHPExcel_Calculation * @package PHPExcel\Calculation
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation_Token_Stack { class Calculation_Token_Stack {
/** /**
* The parser stack for formulae * The parser stack for formulae
@ -72,7 +74,7 @@ class PHPExcel_Calculation_Token_Stack {
'reference' => $reference 'reference' => $reference
); );
if ($type == 'Function') { if ($type == 'Function') {
$localeFunction = PHPExcel_Calculation::_localeFunc($value); $localeFunction = Calculation::_localeFunc($value);
if ($localeFunction != $value) { if ($localeFunction != $value) {
$this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction; $this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction;
} }
@ -112,4 +114,4 @@ class PHPExcel_Calculation_Token_Stack {
$this->_count = 0; $this->_count = 0;
} }
} // class PHPExcel_Calculation_Token_Stack }

View File

@ -19,21 +19,23 @@
* 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_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Cell * PHPExcel\Cell
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Cell class Cell
{ {
/** /**
@ -46,7 +48,7 @@ class PHPExcel_Cell
/** /**
* Value binder to use * Value binder to use
* *
* @var PHPExcel_Cell_IValueBinder * @var PHPExcel\Cell_IValueBinder
*/ */
private static $_valueBinder = NULL; private static $_valueBinder = NULL;
@ -79,7 +81,7 @@ class PHPExcel_Cell
/** /**
* Parent worksheet * Parent worksheet
* *
* @var PHPExcel_CachedObjectStorage_CacheBase * @var PHPExcel\CachedObjectStorage_CacheBase
*/ */
private $_parent; private $_parent;
@ -112,7 +114,7 @@ class PHPExcel_Cell
$this->_parent = NULL; $this->_parent = NULL;
} }
public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) { public function attach(CachedObjectStorage_CacheBase $parent) {
$this->_parent = $parent; $this->_parent = $parent;
@ -124,10 +126,10 @@ class PHPExcel_Cell
* *
* @param mixed $pValue * @param mixed $pValue
* @param string $pDataType * @param string $pDataType
* @param PHPExcel_Worksheet $pSheet * @param PHPExcel\Worksheet $pSheet
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function __construct($pValue = NULL, $pDataType = NULL, PHPExcel_Worksheet $pSheet = NULL) public function __construct($pValue = NULL, $pDataType = NULL, Worksheet $pSheet = NULL)
{ {
// Initialise cell value // Initialise cell value
$this->_value = $pValue; $this->_value = $pValue;
@ -137,12 +139,12 @@ class PHPExcel_Cell
// Set datatype? // Set datatype?
if ($pDataType !== NULL) { if ($pDataType !== NULL) {
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) if ($pDataType == Cell_DataType::TYPE_STRING2)
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING; $pDataType = Cell_DataType::TYPE_STRING;
$this->_dataType = $pDataType; $this->_dataType = $pDataType;
} else { } else {
if (!self::getValueBinder()->bindValue($this, $pValue)) { if (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new PHPExcel_Exception("Value could not be bound to cell."); throw new Exception("Value could not be bound to cell.");
} }
} }
@ -197,7 +199,7 @@ class PHPExcel_Cell
*/ */
public function getFormattedValue() public function getFormattedValue()
{ {
return (string) PHPExcel_Style_NumberFormat::toFormattedString( return (string) Style_NumberFormat::toFormattedString(
$this->getCalculatedValue(), $this->getCalculatedValue(),
$this->getWorksheet()->getParent()->getCellXfByIndex($this->getXfIndex()) $this->getWorksheet()->getParent()->getCellXfByIndex($this->getXfIndex())
->getNumberFormat()->getFormatCode() ->getNumberFormat()->getFormatCode()
@ -210,13 +212,13 @@ class PHPExcel_Cell
* Sets the value for a cell, automatically determining the datatype using the value binder * Sets the value for a cell, automatically determining the datatype using the value binder
* *
* @param mixed $pValue Value * @param mixed $pValue Value
* @return PHPExcel_Cell * @return PHPExcel\Cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function setValue($pValue = NULL) public function setValue($pValue = NULL)
{ {
if (!self::getValueBinder()->bindValue($this, $pValue)) { if (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new PHPExcel_Exception("Value could not be bound to cell."); throw new Exception("Value could not be bound to cell.");
} }
return $this; return $this;
} }
@ -226,34 +228,34 @@ class PHPExcel_Cell
* *
* @param mixed $pValue Value * @param mixed $pValue Value
* @param string $pDataType Explicit data type * @param string $pDataType Explicit data type
* @return PHPExcel_Cell * @return PHPExcel\Cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function setValueExplicit($pValue = NULL, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING) public function setValueExplicit($pValue = NULL, $pDataType = Cell_DataType::TYPE_STRING)
{ {
// set the value according to data type // set the value according to data type
switch ($pDataType) { switch ($pDataType) {
case PHPExcel_Cell_DataType::TYPE_STRING2: case Cell_DataType::TYPE_STRING2:
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING; $pDataType = Cell_DataType::TYPE_STRING;
case PHPExcel_Cell_DataType::TYPE_STRING: case Cell_DataType::TYPE_STRING:
case PHPExcel_Cell_DataType::TYPE_NULL: case Cell_DataType::TYPE_NULL:
case PHPExcel_Cell_DataType::TYPE_INLINE: case Cell_DataType::TYPE_INLINE:
$this->_value = PHPExcel_Cell_DataType::checkString($pValue); $this->_value = Cell_DataType::checkString($pValue);
break; break;
case PHPExcel_Cell_DataType::TYPE_NUMERIC: case Cell_DataType::TYPE_NUMERIC:
$this->_value = (float)$pValue; $this->_value = (float)$pValue;
break; break;
case PHPExcel_Cell_DataType::TYPE_FORMULA: case Cell_DataType::TYPE_FORMULA:
$this->_value = (string)$pValue; $this->_value = (string)$pValue;
break; break;
case PHPExcel_Cell_DataType::TYPE_BOOL: case Cell_DataType::TYPE_BOOL:
$this->_value = (bool)$pValue; $this->_value = (bool)$pValue;
break; break;
case PHPExcel_Cell_DataType::TYPE_ERROR: case Cell_DataType::TYPE_ERROR:
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue); $this->_value = Cell_DataType::checkErrorCode($pValue);
break; break;
default: default:
throw new PHPExcel_Exception('Invalid datatype: ' . $pDataType); throw new Exception('Invalid datatype: ' . $pDataType);
break; break;
} }
@ -270,15 +272,15 @@ class PHPExcel_Cell
* *
* @param boolean $resetLog Whether the calculation engine logger should be reset or not * @param boolean $resetLog Whether the calculation engine logger should be reset or not
* @return mixed * @return mixed
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function getCalculatedValue($resetLog = TRUE) public function getCalculatedValue($resetLog = TRUE)
{ {
//echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().PHP_EOL; //echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().PHP_EOL;
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) { if ($this->_dataType == Cell_DataType::TYPE_FORMULA) {
try { try {
//echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL; //echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL;
$result = PHPExcel_Calculation::getInstance( $result = Calculation::getInstance(
$this->getWorksheet()->getParent() $this->getWorksheet()->getParent()
)->calculateCellValue($this,$resetLog); )->calculateCellValue($this,$resetLog);
//echo $this->getCoordinate().' calculation result is '.$result.PHP_EOL; //echo $this->getCoordinate().' calculation result is '.$result.PHP_EOL;
@ -288,14 +290,14 @@ class PHPExcel_Cell
$result = array_pop($result); $result = array_pop($result);
} }
} }
} catch ( PHPExcel_Exception $ex ) { } catch ( Exception $ex ) {
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) { if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) {
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL; //echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
return $this->_calculatedValue; // Fallback for calculations referencing external files. return $this->_calculatedValue; // Fallback for calculations referencing external files.
} }
//echo 'Calculation Exception: '.$ex->getMessage().PHP_EOL; //echo 'Calculation Exception: '.$ex->getMessage().PHP_EOL;
$result = '#N/A'; $result = '#N/A';
throw new PHPExcel_Calculation_Exception( throw new Calculation_Exception(
$this->getWorksheet()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage() $this->getWorksheet()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()
); );
} }
@ -306,7 +308,7 @@ class PHPExcel_Cell
} }
//echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL; //echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL;
return $result; return $result;
} elseif($this->_value instanceof PHPExcel_RichText) { } elseif($this->_value instanceof RichText) {
// echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->_value.'<br />'; // echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->_value.'<br />';
return $this->_value->getPlainText(); return $this->_value->getPlainText();
} }
@ -318,7 +320,7 @@ class PHPExcel_Cell
* Set old calculated value (cached) * Set old calculated value (cached)
* *
* @param mixed $pValue Value * @param mixed $pValue Value
* @return PHPExcel_Cell * @return PHPExcel\Cell
*/ */
public function setCalculatedValue($pValue = NULL) public function setCalculatedValue($pValue = NULL)
{ {
@ -358,12 +360,12 @@ class PHPExcel_Cell
* Set cell data type * Set cell data type
* *
* @param string $pDataType * @param string $pDataType
* @return PHPExcel_Cell * @return PHPExcel\Cell
*/ */
public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING) public function setDataType($pDataType = Cell_DataType::TYPE_STRING)
{ {
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) if ($pDataType == Cell_DataType::TYPE_STRING2)
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING; $pDataType = Cell_DataType::TYPE_STRING;
$this->_dataType = $pDataType; $this->_dataType = $pDataType;
@ -374,12 +376,12 @@ class PHPExcel_Cell
* Does this cell contain Data validation rules? * Does this cell contain Data validation rules?
* *
* @return boolean * @return boolean
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function hasDataValidation() public function hasDataValidation()
{ {
if (!isset($this->_parent)) { if (!isset($this->_parent)) {
throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet'); throw new Exception('Cannot check for data validation when cell is not bound to a worksheet');
} }
return $this->getWorksheet()->dataValidationExists($this->getCoordinate()); return $this->getWorksheet()->dataValidationExists($this->getCoordinate());
@ -388,13 +390,13 @@ class PHPExcel_Cell
/** /**
* Get Data validation rules * Get Data validation rules
* *
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function getDataValidation() public function getDataValidation()
{ {
if (!isset($this->_parent)) { if (!isset($this->_parent)) {
throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet'); throw new Exception('Cannot get data validation for cell that is not bound to a worksheet');
} }
return $this->getWorksheet()->getDataValidation($this->getCoordinate()); return $this->getWorksheet()->getDataValidation($this->getCoordinate());
@ -403,14 +405,14 @@ class PHPExcel_Cell
/** /**
* Set Data validation rules * Set Data validation rules
* *
* @param PHPExcel_Cell_DataValidation $pDataValidation * @param PHPExcel\Cell_DataValidation $pDataValidation
* @return PHPExcel_Cell * @return PHPExcel\Cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = NULL) public function setDataValidation(Cell_DataValidation $pDataValidation = NULL)
{ {
if (!isset($this->_parent)) { if (!isset($this->_parent)) {
throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet'); throw new Exception('Cannot set data validation for cell that is not bound to a worksheet');
} }
$this->getWorksheet()->setDataValidation($this->getCoordinate(), $pDataValidation); $this->getWorksheet()->setDataValidation($this->getCoordinate(), $pDataValidation);
@ -422,12 +424,12 @@ class PHPExcel_Cell
* Does this cell contain a Hyperlink? * Does this cell contain a Hyperlink?
* *
* @return boolean * @return boolean
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function hasHyperlink() public function hasHyperlink()
{ {
if (!isset($this->_parent)) { if (!isset($this->_parent)) {
throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet'); throw new Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
} }
return $this->getWorksheet()->hyperlinkExists($this->getCoordinate()); return $this->getWorksheet()->hyperlinkExists($this->getCoordinate());
@ -436,13 +438,13 @@ class PHPExcel_Cell
/** /**
* Get Hyperlink * Get Hyperlink
* *
* @return PHPExcel_Cell_Hyperlink * @return PHPExcel\Cell_Hyperlink
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function getHyperlink() public function getHyperlink()
{ {
if (!isset($this->_parent)) { if (!isset($this->_parent)) {
throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet'); throw new Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
} }
return $this->getWorksheet()->getHyperlink($this->getCoordinate()); return $this->getWorksheet()->getHyperlink($this->getCoordinate());
@ -451,14 +453,14 @@ class PHPExcel_Cell
/** /**
* Set Hyperlink * Set Hyperlink
* *
* @param PHPExcel_Cell_Hyperlink $pHyperlink * @param PHPExcel\Cell_Hyperlink $pHyperlink
* @return PHPExcel_Cell * @return PHPExcel\Cell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = NULL) public function setHyperlink(Cell_Hyperlink $pHyperlink = NULL)
{ {
if (!isset($this->_parent)) { if (!isset($this->_parent)) {
throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet'); throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
} }
$this->getWorksheet()->setHyperlink($this->getCoordinate(), $pHyperlink); $this->getWorksheet()->setHyperlink($this->getCoordinate(), $pHyperlink);
@ -469,7 +471,7 @@ class PHPExcel_Cell
/** /**
* Get parent worksheet * Get parent worksheet
* *
* @return PHPExcel_Worksheet * @return PHPExcel\Worksheet
*/ */
public function getParent() { public function getParent() {
return $this->_parent; return $this->_parent;
@ -478,7 +480,7 @@ class PHPExcel_Cell
/** /**
* Get parent worksheet * Get parent worksheet
* *
* @return PHPExcel_Worksheet * @return PHPExcel\Worksheet
*/ */
public function getWorksheet() { public function getWorksheet() {
return $this->_parent->getParent(); return $this->_parent->getParent();
@ -487,7 +489,7 @@ class PHPExcel_Cell
/** /**
* Get cell style * Get cell style
* *
* @return PHPExcel_Style * @return PHPExcel\Style
*/ */
public function getStyle() public function getStyle()
{ {
@ -497,10 +499,10 @@ class PHPExcel_Cell
/** /**
* Re-bind parent * Re-bind parent
* *
* @param PHPExcel_Worksheet $parent * @param PHPExcel\Worksheet $parent
* @return PHPExcel_Cell * @return PHPExcel\Cell
*/ */
public function rebindParent(PHPExcel_Worksheet $parent) { public function rebindParent(Worksheet $parent) {
$this->_parent = $parent->getCellCacheController(); $this->_parent = $parent->getCellCacheController();
return $this->notifyCacheController(); return $this->notifyCacheController();
@ -531,19 +533,19 @@ class PHPExcel_Cell
* *
* @param string $pCoordinateString * @param string $pCoordinateString
* @return array Array containing column and row (indexes 0 and 1) * @return array Array containing column and row (indexes 0 and 1)
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public static function coordinateFromString($pCoordinateString = 'A1') public static function coordinateFromString($pCoordinateString = 'A1')
{ {
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) { if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
return array($matches[1],$matches[2]); return array($matches[1],$matches[2]);
} elseif ((strpos($pCoordinateString,':') !== FALSE) || (strpos($pCoordinateString,',') !== FALSE)) { } elseif ((strpos($pCoordinateString,':') !== FALSE) || (strpos($pCoordinateString,',') !== FALSE)) {
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells'); throw new Exception('Cell coordinate string can not be a range of cells');
} elseif ($pCoordinateString == '') { } elseif ($pCoordinateString == '') {
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string'); throw new Exception('Cell coordinate can not be zero-length string');
} }
throw new PHPExcel_Exception('Invalid cell coordinate '.$pCoordinateString); throw new Exception('Invalid cell coordinate '.$pCoordinateString);
} }
/** /**
@ -552,7 +554,7 @@ class PHPExcel_Cell
* @param string $pCoordinateString e.g. 'A' or '1' or 'A1' * @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
* Note that this value can be a row or column reference as well as a cell reference * Note that this value can be a row or column reference as well as a cell reference
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1' * @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public static function absoluteReference($pCoordinateString = 'A1') public static function absoluteReference($pCoordinateString = 'A1')
{ {
@ -574,7 +576,7 @@ class PHPExcel_Cell
return $worksheet . self::absoluteCoordinate($pCoordinateString); return $worksheet . self::absoluteCoordinate($pCoordinateString);
} }
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells'); throw new Exception('Cell coordinate string can not be a range of cells');
} }
/** /**
@ -582,7 +584,7 @@ class PHPExcel_Cell
* *
* @param string $pCoordinateString e.g. 'A1' * @param string $pCoordinateString e.g. 'A1'
* @return string Absolute coordinate e.g. '$A$1' * @return string Absolute coordinate e.g. '$A$1'
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public static function absoluteCoordinate($pCoordinateString = 'A1') public static function absoluteCoordinate($pCoordinateString = 'A1')
{ {
@ -602,7 +604,7 @@ class PHPExcel_Cell
return $worksheet . '$' . $column . '$' . $row; return $worksheet . '$' . $column . '$' . $row;
} }
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells'); throw new Exception('Cell coordinate string can not be a range of cells');
} }
/** /**
@ -633,13 +635,13 @@ class PHPExcel_Cell
* *
* @param array $pRange Array containg one or more arrays containing one or two coordinate strings * @param array $pRange Array containg one or more arrays containing one or two coordinate strings
* @return string String representation of $pRange * @return string String representation of $pRange
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public static function buildRange($pRange) public static function buildRange($pRange)
{ {
// Verify range // Verify range
if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) { if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) {
throw new PHPExcel_Exception('Range does not contain any information'); throw new Exception('Range does not contain any information');
} }
// Build range // Build range
@ -734,6 +736,7 @@ class PHPExcel_Cell
* *
* @param string $pString * @param string $pString
* @return int Column index (base 1 !!!) * @return int Column index (base 1 !!!)
* @throws PHPExcel\Exception
*/ */
public static function columnIndexFromString($pString = 'A') public static function columnIndexFromString($pString = 'A')
{ {
@ -769,7 +772,7 @@ class PHPExcel_Cell
return $_indexCache[$pString]; return $_indexCache[$pString];
} }
} }
throw new PHPExcel_Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty")); throw new Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty"));
} }
/** /**
@ -866,11 +869,11 @@ class PHPExcel_Cell
/** /**
* Compare 2 cells * Compare 2 cells
* *
* @param PHPExcel_Cell $a Cell a * @param PHPExcel\Cell $a Cell a
* @param PHPExcel_Cell $b Cell b * @param PHPExcel\Cell $b Cell b
* @return int Result of comparison (always -1 or 1, never zero!) * @return int Result of comparison (always -1 or 1, never zero!)
*/ */
public static function compareCells(PHPExcel_Cell $a, PHPExcel_Cell $b) public static function compareCells(Cell $a, Cell $b)
{ {
if ($a->getRow() < $b->getRow()) { if ($a->getRow() < $b->getRow()) {
return -1; return -1;
@ -886,11 +889,11 @@ class PHPExcel_Cell
/** /**
* Get value binder to use * Get value binder to use
* *
* @return PHPExcel_Cell_IValueBinder * @return PHPExcel\Cell_IValueBinder
*/ */
public static function getValueBinder() { public static function getValueBinder() {
if (self::$_valueBinder === NULL) { if (self::$_valueBinder === NULL) {
self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder(); self::$_valueBinder = new Cell_DefaultValueBinder();
} }
return self::$_valueBinder; return self::$_valueBinder;
@ -899,12 +902,12 @@ class PHPExcel_Cell
/** /**
* Set value binder to use * Set value binder to use
* *
* @param PHPExcel_Cell_IValueBinder $binder * @param PHPExcel\Cell_IValueBinder $binder
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = NULL) { public static function setValueBinder(Cell_IValueBinder $binder = NULL) {
if ($binder === NULL) { if ($binder === NULL) {
throw new PHPExcel_Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly."); throw new Exception("A PHPExcel\Cell_IValueBinder is required for PHPExcel to function correctly.");
} }
self::$_valueBinder = $binder; self::$_valueBinder = $binder;
@ -938,7 +941,7 @@ class PHPExcel_Cell
* Set index to cellXf * Set index to cellXf
* *
* @param int $pValue * @param int $pValue
* @return PHPExcel_Cell * @return PHPExcel\Cell
*/ */
public function setXfIndex($pValue = 0) public function setXfIndex($pValue = 0)
{ {

View File

@ -19,63 +19,55 @@
* 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_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Cell_AdvancedValueBinder * PHPExcel\Cell_AdvancedValueBinder
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder class Cell_AdvancedValueBinder extends Cell_DefaultValueBinder implements Cell_IValueBinder
{ {
/** /**
* Bind value to a cell * Bind value to a cell
* *
* @param PHPExcel_Cell $cell Cell to bind value to * @param PHPExcel\Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
* @return boolean * @return boolean
*/ */
public function bindValue(PHPExcel_Cell $cell, $value = null) public function bindValue(Cell $cell, $value = null)
{ {
// sanitize UTF-8 strings // sanitize UTF-8 strings
if (is_string($value)) { if (is_string($value)) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value); $value = Shared_String::SanitizeUTF8($value);
} }
// Find out data type // Find out data type
$dataType = parent::dataTypeForValue($value); $dataType = parent::dataTypeForValue($value);
// Style logic - strings // Style logic - strings
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) { if ($dataType === Cell_DataType::TYPE_STRING && !$value instanceof RichText) {
// Test for booleans using locale-setting // Test for booleans using locale-setting
if ($value == PHPExcel_Calculation::getTRUE()) { if ($value == Calculation::getTRUE()) {
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL); $cell->setValueExplicit( TRUE, Cell_DataType::TYPE_BOOL);
return true; return true;
} elseif($value == PHPExcel_Calculation::getFALSE()) { } elseif($value == Calculation::getFALSE()) {
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL); $cell->setValueExplicit( FALSE, Cell_DataType::TYPE_BOOL);
return true; return true;
} }
// Check for number in scientific format // Check for number in scientific format
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) { if (preg_match('/^'.Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( (float) $value, Cell_DataType::TYPE_NUMERIC);
return true; return true;
} }
@ -84,7 +76,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Convert value to number // Convert value to number
$value = $matches[2] / $matches[3]; $value = $matches[2] / $matches[3];
if ($matches[1] == '-') $value = 0 - $value; if ($matches[1] == '-') $value = 0 - $value;
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( (float) $value, Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '??/??' ); ->getNumberFormat()->setFormatCode( '??/??' );
@ -93,7 +85,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Convert value to number // Convert value to number
$value = $matches[2] + ($matches[3] / $matches[4]); $value = $matches[2] + ($matches[3] / $matches[4]);
if ($matches[1] == '-') $value = 0 - $value; if ($matches[1] == '-') $value = 0 - $value;
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( (float) $value, Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '# ??/??' ); ->getNumberFormat()->setFormatCode( '# ??/??' );
@ -104,34 +96,34 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) { if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
// Convert value to number // Convert value to number
$value = (float) str_replace('%', '', $value) / 100; $value = (float) str_replace('%', '', $value) / 100;
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( $value, Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 ); ->getNumberFormat()->setFormatCode( Style_NumberFormat::FORMAT_PERCENTAGE_00 );
return true; return true;
} }
// Check for currency // Check for currency
$currencyCode = PHPExcel_Shared_String::getCurrencyCode(); $currencyCode = Shared_String::getCurrencyCode();
$decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator(); $decimalSeparator = Shared_String::getDecimalSeparator();
$thousandsSeparator = PHPExcel_Shared_String::getThousandsSeparator(); $thousandsSeparator = Shared_String::getThousandsSeparator();
if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) { if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) {
// Convert value to number // Convert value to number
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value)); $value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( $value, Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( ->getNumberFormat()->setFormatCode(
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ) str_replace('$', $currencyCode, Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
); );
return true; return true;
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) { } elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
// Convert value to number // Convert value to number
$value = (float) trim(str_replace(array('$',','), '', $value)); $value = (float) trim(str_replace(array('$',','), '', $value));
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( $value, Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ); ->getNumberFormat()->setFormatCode( Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
return true; return true;
} }
@ -140,10 +132,10 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Convert value to number // Convert value to number
list($h, $m) = explode(':', $value); list($h, $m) = explode(':', $value);
$days = $h / 24 + $m / 1440; $days = $h / 24 + $m / 1440;
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit($days, Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 ); ->getNumberFormat()->setFormatCode( Style_NumberFormat::FORMAT_DATE_TIME3 );
return true; return true;
} }
@ -153,17 +145,17 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
list($h, $m, $s) = explode(':', $value); list($h, $m, $s) = explode(':', $value);
$days = $h / 24 + $m / 1440 + $s / 86400; $days = $h / 24 + $m / 1440 + $s / 86400;
// Convert value to number // Convert value to number
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit($days, Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 ); ->getNumberFormat()->setFormatCode( Style_NumberFormat::FORMAT_DATE_TIME4 );
return true; return true;
} }
// Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10' // Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10'
if (($d = PHPExcel_Shared_Date::stringToExcel($value)) !== false) { if (($d = Shared_Date::stringToExcel($value)) !== false) {
// Convert value to number // Convert value to number
$cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit($d, Cell_DataType::TYPE_NUMERIC);
// Determine style. Either there is a time part or not. Look for ':' // Determine style. Either there is a time part or not. Look for ':'
if (strpos($value, ':') !== false) { if (strpos($value, ':') !== false) {
$formatCode = 'yyyy-mm-dd h:mm'; $formatCode = 'yyyy-mm-dd h:mm';
@ -177,8 +169,8 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Check for newline character "\n" // Check for newline character "\n"
if (strpos($value, "\n") !== FALSE) { if (strpos($value, "\n") !== FALSE) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value); $value = Shared_String::SanitizeUTF8($value);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING); $cell->setValueExplicit($value, Cell_DataType::TYPE_STRING);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getAlignment()->setWrapText(TRUE); ->getAlignment()->setWrapText(TRUE);

View File

@ -19,21 +19,23 @@
* 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_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Cell_DataType * PHPExcel\Cell_DataType
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Cell_DataType class Cell_DataType
{ {
/* Data types */ /* Data types */
const TYPE_STRING2 = 'str'; const TYPE_STRING2 = 'str';
@ -72,12 +74,12 @@ class PHPExcel_Cell_DataType
/** /**
* DataType for value * DataType for value
* *
* @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure, will be removed in version 1.8.0 * @deprecated Replaced by PHPExcel\Cell_IValueBinder infrastructure, will be removed in version 1.8.0
* @param mixed $pValue * @param mixed $pValue
* @return string * @return string
*/ */
public static function dataTypeForValue($pValue = null) { public static function dataTypeForValue($pValue = null) {
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue); return Cell_DefaultValueBinder::dataTypeForValue($pValue);
} }
/** /**
@ -88,13 +90,13 @@ class PHPExcel_Cell_DataType
*/ */
public static function checkString($pValue = null) public static function checkString($pValue = null)
{ {
if ($pValue instanceof PHPExcel_RichText) { if ($pValue instanceof RichText) {
// TODO: Sanitize Rich-Text string (max. character count is 32,767) // TODO: Sanitize Rich-Text string (max. character count is 32,767)
return $pValue; return $pValue;
} }
// string must never be longer than 32,767 characters, truncate if necessary // string must never be longer than 32,767 characters, truncate if necessary
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767); $pValue = Shared_String::Substring($pValue, 0, 32767);
// we require that newline is represented as "\n" in core, not as "\r\n" or "\r" // we require that newline is represented as "\n" in core, not as "\r\n" or "\r"
$pValue = str_replace(array("\r\n", "\r"), "\n", $pValue); $pValue = str_replace(array("\r\n", "\r"), "\n", $pValue);

View File

@ -19,21 +19,23 @@
* 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_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Cell_DataValidation * PHPExcel\Cell_DataValidation
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Cell_DataValidation class Cell_DataValidation
{ {
/* Data validation types */ /* Data validation types */
const TYPE_NONE = 'none'; const TYPE_NONE = 'none';
@ -79,14 +81,14 @@ class PHPExcel_Cell_DataValidation
* *
* @var string * @var string
*/ */
private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE; private $_type = Cell_DataValidation::TYPE_NONE;
/** /**
* Error style * Error style
* *
* @var string * @var string
*/ */
private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; private $_errorStyle = Cell_DataValidation::STYLE_STOP;
/** /**
* Operator * Operator
@ -152,15 +154,15 @@ class PHPExcel_Cell_DataValidation
private $_prompt; private $_prompt;
/** /**
* Create a new PHPExcel_Cell_DataValidation * Create a new PHPExcel\Cell_DataValidation
*/ */
public function __construct() public function __construct()
{ {
// Initialise member variables // Initialise member variables
$this->_formula1 = ''; $this->_formula1 = '';
$this->_formula2 = ''; $this->_formula2 = '';
$this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE; $this->_type = Cell_DataValidation::TYPE_NONE;
$this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; $this->_errorStyle = Cell_DataValidation::STYLE_STOP;
$this->_operator = ''; $this->_operator = '';
$this->_allowBlank = FALSE; $this->_allowBlank = FALSE;
$this->_showDropDown = FALSE; $this->_showDropDown = FALSE;
@ -185,7 +187,7 @@ class PHPExcel_Cell_DataValidation
* Set Formula 1 * Set Formula 1
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setFormula1($value = '') { public function setFormula1($value = '') {
$this->_formula1 = $value; $this->_formula1 = $value;
@ -205,7 +207,7 @@ class PHPExcel_Cell_DataValidation
* Set Formula 2 * Set Formula 2
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setFormula2($value = '') { public function setFormula2($value = '') {
$this->_formula2 = $value; $this->_formula2 = $value;
@ -225,9 +227,9 @@ class PHPExcel_Cell_DataValidation
* Set Type * Set Type
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) { public function setType($value = Cell_DataValidation::TYPE_NONE) {
$this->_type = $value; $this->_type = $value;
return $this; return $this;
} }
@ -245,9 +247,9 @@ class PHPExcel_Cell_DataValidation
* Set Error style * Set Error style
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) { public function setErrorStyle($value = Cell_DataValidation::STYLE_STOP) {
$this->_errorStyle = $value; $this->_errorStyle = $value;
return $this; return $this;
} }
@ -265,7 +267,7 @@ class PHPExcel_Cell_DataValidation
* Set Operator * Set Operator
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setOperator($value = '') { public function setOperator($value = '') {
$this->_operator = $value; $this->_operator = $value;
@ -285,7 +287,7 @@ class PHPExcel_Cell_DataValidation
* Set Allow Blank * Set Allow Blank
* *
* @param boolean $value * @param boolean $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setAllowBlank($value = false) { public function setAllowBlank($value = false) {
$this->_allowBlank = $value; $this->_allowBlank = $value;
@ -305,7 +307,7 @@ class PHPExcel_Cell_DataValidation
* Set Show DropDown * Set Show DropDown
* *
* @param boolean $value * @param boolean $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setShowDropDown($value = false) { public function setShowDropDown($value = false) {
$this->_showDropDown = $value; $this->_showDropDown = $value;
@ -325,7 +327,7 @@ class PHPExcel_Cell_DataValidation
* Set Show InputMessage * Set Show InputMessage
* *
* @param boolean $value * @param boolean $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setShowInputMessage($value = false) { public function setShowInputMessage($value = false) {
$this->_showInputMessage = $value; $this->_showInputMessage = $value;
@ -345,7 +347,7 @@ class PHPExcel_Cell_DataValidation
* Set Show ErrorMessage * Set Show ErrorMessage
* *
* @param boolean $value * @param boolean $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setShowErrorMessage($value = false) { public function setShowErrorMessage($value = false) {
$this->_showErrorMessage = $value; $this->_showErrorMessage = $value;
@ -365,7 +367,7 @@ class PHPExcel_Cell_DataValidation
* Set Error title * Set Error title
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setErrorTitle($value = '') { public function setErrorTitle($value = '') {
$this->_errorTitle = $value; $this->_errorTitle = $value;
@ -385,7 +387,7 @@ class PHPExcel_Cell_DataValidation
* Set Error * Set Error
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setError($value = '') { public function setError($value = '') {
$this->_error = $value; $this->_error = $value;
@ -405,7 +407,7 @@ class PHPExcel_Cell_DataValidation
* Set Prompt title * Set Prompt title
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setPromptTitle($value = '') { public function setPromptTitle($value = '') {
$this->_promptTitle = $value; $this->_promptTitle = $value;
@ -425,7 +427,7 @@ class PHPExcel_Cell_DataValidation
* Set Prompt * Set Prompt
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel\Cell_DataValidation
*/ */
public function setPrompt($value = '') { public function setPrompt($value = '') {
$this->_prompt = $value; $this->_prompt = $value;
@ -441,8 +443,8 @@ class PHPExcel_Cell_DataValidation
return md5( return md5(
$this->_formula1 $this->_formula1
. $this->_formula2 . $this->_formula2
. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE . $this->_type = Cell_DataValidation::TYPE_NONE
. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP . $this->_errorStyle = Cell_DataValidation::STYLE_STOP
. $this->_operator . $this->_operator
. ($this->_allowBlank ? 't' : 'f') . ($this->_allowBlank ? 't' : 'f')
. ($this->_showDropDown ? 't' : 'f') . ($this->_showDropDown ? 't' : 'f')

View File

@ -19,44 +19,36 @@
* 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_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Cell_DefaultValueBinder * PHPExcel\Cell_DefaultValueBinder
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder class Cell_DefaultValueBinder implements Cell_IValueBinder
{ {
/** /**
* Bind value to a cell * Bind value to a cell
* *
* @param PHPExcel_Cell $cell Cell to bind value to * @param PHPExcel\Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
* @return boolean * @return boolean
*/ */
public function bindValue(PHPExcel_Cell $cell, $value = null) public function bindValue(Cell $cell, $value = null)
{ {
// sanitize UTF-8 strings // sanitize UTF-8 strings
if (is_string($value)) { if (is_string($value)) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value); $value = Shared_String::SanitizeUTF8($value);
} }
// Set value explicit // Set value explicit
@ -75,31 +67,31 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
public static function dataTypeForValue($pValue = null) { public static function dataTypeForValue($pValue = null) {
// Match the value against a few data types // Match the value against a few data types
if (is_null($pValue)) { if (is_null($pValue)) {
return PHPExcel_Cell_DataType::TYPE_NULL; return Cell_DataType::TYPE_NULL;
} elseif ($pValue === '') { } elseif ($pValue === '') {
return PHPExcel_Cell_DataType::TYPE_STRING; return Cell_DataType::TYPE_STRING;
} elseif ($pValue instanceof PHPExcel_RichText) { } elseif ($pValue instanceof RichText) {
return PHPExcel_Cell_DataType::TYPE_INLINE; return Cell_DataType::TYPE_INLINE;
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) { } elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
return PHPExcel_Cell_DataType::TYPE_FORMULA; return Cell_DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) { } elseif (is_bool($pValue)) {
return PHPExcel_Cell_DataType::TYPE_BOOL; return Cell_DataType::TYPE_BOOL;
} elseif (is_float($pValue) || is_int($pValue)) { } elseif (is_float($pValue) || is_int($pValue)) {
return PHPExcel_Cell_DataType::TYPE_NUMERIC; return Cell_DataType::TYPE_NUMERIC;
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) { } elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
return PHPExcel_Cell_DataType::TYPE_NUMERIC; return Cell_DataType::TYPE_NUMERIC;
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) { } elseif (is_string($pValue) && array_key_exists($pValue, Cell_DataType::getErrorCodes())) {
return PHPExcel_Cell_DataType::TYPE_ERROR; return Cell_DataType::TYPE_ERROR;
} else { } else {
return PHPExcel_Cell_DataType::TYPE_STRING; return Cell_DataType::TYPE_STRING;
} }
} }

View File

@ -19,21 +19,23 @@
* 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_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Cell_Hyperlink * PHPExcel\Cell_Hyperlink
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Cell_Hyperlink class Cell_Hyperlink
{ {
/** /**
* URL to link the cell to * URL to link the cell to
@ -50,7 +52,7 @@ class PHPExcel_Cell_Hyperlink
private $_tooltip; private $_tooltip;
/** /**
* Create a new PHPExcel_Cell_Hyperlink * Create a new PHPExcel\Cell_Hyperlink
* *
* @param string $pUrl Url to link the cell to * @param string $pUrl Url to link the cell to
* @param string $pTooltip Tooltip to display on the hyperlink * @param string $pTooltip Tooltip to display on the hyperlink
@ -75,7 +77,7 @@ class PHPExcel_Cell_Hyperlink
* Set URL * Set URL
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_Hyperlink * @return PHPExcel\Cell_Hyperlink
*/ */
public function setUrl($value = '') { public function setUrl($value = '') {
$this->_url = $value; $this->_url = $value;
@ -95,7 +97,7 @@ class PHPExcel_Cell_Hyperlink
* Set tooltip * Set tooltip
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_Hyperlink * @return PHPExcel\Cell_Hyperlink
*/ */
public function setTooltip($value = '') { public function setTooltip($value = '') {
$this->_tooltip = $value; $this->_tooltip = $value;

View File

@ -19,28 +19,30 @@
* 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_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Cell_IValueBinder * PHPExcel\Cell_IValueBinder
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel\Cell
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
interface PHPExcel_Cell_IValueBinder interface Cell_IValueBinder
{ {
/** /**
* Bind value to a cell * Bind value to a cell
* *
* @param PHPExcel_Cell $cell Cell to bind value to * @param PHPExcel\Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
* @return boolean * @return boolean
*/ */
public function bindValue(PHPExcel_Cell $cell, $value = NULL); public function bindValue(Cell $cell, $value = NULL);
} }

View File

@ -19,21 +19,23 @@
* 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_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Chart * PHPExcel\Chart
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart class Chart
{ {
/** /**
* Chart Name * Chart Name
@ -45,42 +47,42 @@ class PHPExcel_Chart
/** /**
* Worksheet * Worksheet
* *
* @var PHPExcel_Worksheet * @var PHPExcel\Worksheet
*/ */
private $_worksheet = null; private $_worksheet = null;
/** /**
* Chart Title * Chart Title
* *
* @var PHPExcel_Chart_Title * @var PHPExcel\Chart_Title
*/ */
private $_title = null; private $_title = null;
/** /**
* Chart Legend * Chart Legend
* *
* @var PHPExcel_Chart_Legend * @var PHPExcel\Chart_Legend
*/ */
private $_legend = null; private $_legend = null;
/** /**
* X-Axis Label * X-Axis Label
* *
* @var PHPExcel_Chart_Title * @var PHPExcel\Chart_Title
*/ */
private $_xAxisLabel = null; private $_xAxisLabel = null;
/** /**
* Y-Axis Label * Y-Axis Label
* *
* @var PHPExcel_Chart_Title * @var PHPExcel\Chart_Title
*/ */
private $_yAxisLabel = null; private $_yAxisLabel = null;
/** /**
* Chart Plot Area * Chart Plot Area
* *
* @var PHPExcel_Chart_PlotArea * @var PHPExcel\Chart_PlotArea
*/ */
private $_plotArea = null; private $_plotArea = null;
@ -148,9 +150,9 @@ class PHPExcel_Chart
/** /**
* Create a new PHPExcel_Chart * Create a new PHPExcel\Chart
*/ */
public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null) public function __construct($name, Chart_Title $title = null, Chart_Legend $legend = null, Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', Chart_Title $xAxisLabel = null, Chart_Title $yAxisLabel = null)
{ {
$this->_name = $name; $this->_name = $name;
$this->_title = $title; $this->_title = $title;
@ -174,7 +176,7 @@ class PHPExcel_Chart
/** /**
* Get Worksheet * Get Worksheet
* *
* @return PHPExcel_Worksheet * @return PHPExcel\Worksheet
*/ */
public function getWorksheet() { public function getWorksheet() {
return $this->_worksheet; return $this->_worksheet;
@ -183,11 +185,11 @@ class PHPExcel_Chart
/** /**
* Set Worksheet * Set Worksheet
* *
* @param PHPExcel_Worksheet $pValue * @param PHPExcel\Worksheet $pValue
* @throws PHPExcel_Chart_Exception * @throws PHPExcel\Chart_Exception
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setWorksheet(PHPExcel_Worksheet $pValue = null) { public function setWorksheet(Worksheet $pValue = null) {
$this->_worksheet = $pValue; $this->_worksheet = $pValue;
return $this; return $this;
@ -196,7 +198,7 @@ class PHPExcel_Chart
/** /**
* Get Title * Get Title
* *
* @return PHPExcel_Chart_Title * @return PHPExcel\Chart_Title
*/ */
public function getTitle() { public function getTitle() {
return $this->_title; return $this->_title;
@ -205,10 +207,10 @@ class PHPExcel_Chart
/** /**
* Set Title * Set Title
* *
* @param PHPExcel_Chart_Title $title * @param PHPExcel\Chart_Title $title
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setTitle(PHPExcel_Chart_Title $title) { public function setTitle(Chart_Title $title) {
$this->_title = $title; $this->_title = $title;
return $this; return $this;
@ -217,7 +219,7 @@ class PHPExcel_Chart
/** /**
* Get Legend * Get Legend
* *
* @return PHPExcel_Chart_Legend * @return PHPExcel\Chart_Legend
*/ */
public function getLegend() { public function getLegend() {
return $this->_legend; return $this->_legend;
@ -226,10 +228,10 @@ class PHPExcel_Chart
/** /**
* Set Legend * Set Legend
* *
* @param PHPExcel_Chart_Legend $legend * @param PHPExcel\Chart_Legend $legend
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setLegend(PHPExcel_Chart_Legend $legend) { public function setLegend(Chart_Legend $legend) {
$this->_legend = $legend; $this->_legend = $legend;
return $this; return $this;
@ -238,7 +240,7 @@ class PHPExcel_Chart
/** /**
* Get X-Axis Label * Get X-Axis Label
* *
* @return PHPExcel_Chart_Title * @return PHPExcel\Chart_Title
*/ */
public function getXAxisLabel() { public function getXAxisLabel() {
return $this->_xAxisLabel; return $this->_xAxisLabel;
@ -247,10 +249,10 @@ class PHPExcel_Chart
/** /**
* Set X-Axis Label * Set X-Axis Label
* *
* @param PHPExcel_Chart_Title $label * @param PHPExcel\Chart_Title $label
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setXAxisLabel(PHPExcel_Chart_Title $label) { public function setXAxisLabel(Chart_Title $label) {
$this->_xAxisLabel = $label; $this->_xAxisLabel = $label;
return $this; return $this;
@ -259,7 +261,7 @@ class PHPExcel_Chart
/** /**
* Get Y-Axis Label * Get Y-Axis Label
* *
* @return PHPExcel_Chart_Title * @return PHPExcel\Chart_Title
*/ */
public function getYAxisLabel() { public function getYAxisLabel() {
return $this->_yAxisLabel; return $this->_yAxisLabel;
@ -268,10 +270,10 @@ class PHPExcel_Chart
/** /**
* Set Y-Axis Label * Set Y-Axis Label
* *
* @param PHPExcel_Chart_Title $label * @param PHPExcel\Chart_Title $label
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setYAxisLabel(PHPExcel_Chart_Title $label) { public function setYAxisLabel(Chart_Title $label) {
$this->_yAxisLabel = $label; $this->_yAxisLabel = $label;
return $this; return $this;
@ -280,7 +282,7 @@ class PHPExcel_Chart
/** /**
* Get Plot Area * Get Plot Area
* *
* @return PHPExcel_Chart_PlotArea * @return PHPExcel\Chart_PlotArea
*/ */
public function getPlotArea() { public function getPlotArea() {
return $this->_plotArea; return $this->_plotArea;
@ -299,7 +301,7 @@ class PHPExcel_Chart
* Set Plot Visible Only * Set Plot Visible Only
* *
* @param boolean $plotVisibleOnly * @param boolean $plotVisibleOnly
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setPlotVisibleOnly($plotVisibleOnly = true) { public function setPlotVisibleOnly($plotVisibleOnly = true) {
$this->_plotVisibleOnly = $plotVisibleOnly; $this->_plotVisibleOnly = $plotVisibleOnly;
@ -320,7 +322,7 @@ class PHPExcel_Chart
* Set Display Blanks as * Set Display Blanks as
* *
* @param string $displayBlanksAs * @param string $displayBlanksAs
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setDisplayBlanksAs($displayBlanksAs = '0') { public function setDisplayBlanksAs($displayBlanksAs = '0') {
$this->_displayBlanksAs = $displayBlanksAs; $this->_displayBlanksAs = $displayBlanksAs;
@ -333,7 +335,7 @@ class PHPExcel_Chart
* @param string $cell * @param string $cell
* @param integer $xOffset * @param integer $xOffset
* @param integer $yOffset * @param integer $yOffset
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) { public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) {
$this->_topLeftCellRef = $cell; $this->_topLeftCellRef = $cell;
@ -370,7 +372,7 @@ class PHPExcel_Chart
* Set the Top Left cell position for the chart * Set the Top Left cell position for the chart
* *
* @param string $cell * @param string $cell
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setTopLeftCell($cell) { public function setTopLeftCell($cell) {
$this->_topLeftCellRef = $cell; $this->_topLeftCellRef = $cell;
@ -383,7 +385,7 @@ class PHPExcel_Chart
* *
* @param integer $xOffset * @param integer $xOffset
* @param integer $yOffset * @param integer $yOffset
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setTopLeftOffset($xOffset=null,$yOffset=null) { public function setTopLeftOffset($xOffset=null,$yOffset=null) {
if (!is_null($xOffset)) if (!is_null($xOffset))
@ -431,7 +433,7 @@ class PHPExcel_Chart
* @param string $cell * @param string $cell
* @param integer $xOffset * @param integer $xOffset
* @param integer $yOffset * @param integer $yOffset
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setBottomRightPosition($cell, $xOffset=null, $yOffset=null) { public function setBottomRightPosition($cell, $xOffset=null, $yOffset=null) {
$this->_bottomRightCellRef = $cell; $this->_bottomRightCellRef = $cell;
@ -475,7 +477,7 @@ class PHPExcel_Chart
* *
* @param integer $xOffset * @param integer $xOffset
* @param integer $yOffset * @param integer $yOffset
* @return PHPExcel_Chart * @return PHPExcel\Chart
*/ */
public function setBottomRightOffset($xOffset=null,$yOffset=null) { public function setBottomRightOffset($xOffset=null,$yOffset=null) {
if (!is_null($xOffset)) if (!is_null($xOffset))
@ -525,21 +527,21 @@ class PHPExcel_Chart
} }
public function render($outputDestination = null) { public function render($outputDestination = null) {
$libraryName = PHPExcel_Settings::getChartRendererName(); $libraryName = Settings::getChartRendererName();
if (is_null($libraryName)) { if (is_null($libraryName)) {
return false; return false;
} }
// Ensure that data series values are up-to-date before we render // Ensure that data series values are up-to-date before we render
$this->refresh(); $this->refresh();
$libraryPath = PHPExcel_Settings::getChartRendererPath(); $libraryPath = Settings::getChartRendererPath();
$includePath = str_replace('\\','/',get_include_path()); $includePath = str_replace('\\','/',get_include_path());
$rendererPath = str_replace('\\','/',$libraryPath); $rendererPath = str_replace('\\','/',$libraryPath);
if (strpos($rendererPath,$includePath) === false) { if (strpos($rendererPath,$includePath) === false) {
set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath); set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
} }
$rendererName = 'PHPExcel_Chart_Renderer_'.$libraryName; $rendererName = __NAMESPACE__ . '\Chart_Renderer_'.$libraryName;
$renderer = new $rendererName($this); $renderer = new $rendererName($this);
if ($outputDestination == 'php://output') { if ($outputDestination == 'php://output') {

View File

@ -19,21 +19,23 @@
* 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_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Chart_DataSeries * PHPExcel\Chart_DataSeries
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_DataSeries class Chart_DataSeries
{ {
const TYPE_BARCHART = 'barChart'; const TYPE_BARCHART = 'barChart';
@ -108,14 +110,14 @@ class PHPExcel_Chart_DataSeries
/** /**
* Plot Label * Plot Label
* *
* @var array of PHPExcel_Chart_DataSeriesValues * @var array of PHPExcel\Chart_DataSeriesValues
*/ */
private $_plotLabel = array(); private $_plotLabel = array();
/** /**
* Plot Category * Plot Category
* *
* @var array of PHPExcel_Chart_DataSeriesValues * @var array of PHPExcel\Chart_DataSeriesValues
*/ */
private $_plotCategory = array(); private $_plotCategory = array();
@ -129,12 +131,12 @@ class PHPExcel_Chart_DataSeries
/** /**
* Plot Values * Plot Values
* *
* @var array of PHPExcel_Chart_DataSeriesValues * @var array of PHPExcel\Chart_DataSeriesValues
*/ */
private $_plotValues = array(); private $_plotValues = array();
/** /**
* Create a new PHPExcel_Chart_DataSeries * Create a new PHPExcel\Chart_DataSeries
*/ */
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $smoothLine = null, $plotStyle = null) public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $smoothLine = null, $plotStyle = null)
{ {
@ -144,12 +146,12 @@ class PHPExcel_Chart_DataSeries
$keys = array_keys($plotValues); $keys = array_keys($plotValues);
$this->_plotValues = $plotValues; $this->_plotValues = $plotValues;
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) { if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); $plotLabel[$keys[0]] = new Chart_DataSeriesValues();
} }
$this->_plotLabel = $plotLabel; $this->_plotLabel = $plotLabel;
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) { if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); $plotCategory[$keys[0]] = new Chart_DataSeriesValues();
} }
$this->_plotCategory = $plotCategory; $this->_plotCategory = $plotCategory;
$this->_smoothLine = $smoothLine; $this->_smoothLine = $smoothLine;
@ -222,7 +224,7 @@ class PHPExcel_Chart_DataSeries
/** /**
* Get Plot Labels * Get Plot Labels
* *
* @return array of PHPExcel_Chart_DataSeriesValues * @return array of PHPExcel\Chart_DataSeriesValues
*/ */
public function getPlotLabels() { public function getPlotLabels() {
return $this->_plotLabel; return $this->_plotLabel;
@ -231,7 +233,7 @@ class PHPExcel_Chart_DataSeries
/** /**
* Get Plot Label by Index * Get Plot Label by Index
* *
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel\Chart_DataSeriesValues
*/ */
public function getPlotLabelByIndex($index) { public function getPlotLabelByIndex($index) {
$keys = array_keys($this->_plotLabel); $keys = array_keys($this->_plotLabel);
@ -246,7 +248,7 @@ class PHPExcel_Chart_DataSeries
/** /**
* Get Plot Categories * Get Plot Categories
* *
* @return array of PHPExcel_Chart_DataSeriesValues * @return array of PHPExcel\Chart_DataSeriesValues
*/ */
public function getPlotCategories() { public function getPlotCategories() {
return $this->_plotCategory; return $this->_plotCategory;
@ -255,7 +257,7 @@ class PHPExcel_Chart_DataSeries
/** /**
* Get Plot Category by Index * Get Plot Category by Index
* *
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel\Chart_DataSeriesValues
*/ */
public function getPlotCategoryByIndex($index) { public function getPlotCategoryByIndex($index) {
$keys = array_keys($this->_plotCategory); $keys = array_keys($this->_plotCategory);
@ -288,7 +290,7 @@ class PHPExcel_Chart_DataSeries
/** /**
* Get Plot Values * Get Plot Values
* *
* @return array of PHPExcel_Chart_DataSeriesValues * @return array of PHPExcel\Chart_DataSeriesValues
*/ */
public function getPlotValues() { public function getPlotValues() {
return $this->_plotValues; return $this->_plotValues;
@ -297,7 +299,7 @@ class PHPExcel_Chart_DataSeries
/** /**
* Get Plot Values by Index * Get Plot Values by Index
* *
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel\Chart_DataSeriesValues
*/ */
public function getPlotValuesByIndex($index) { public function getPlotValuesByIndex($index) {
$keys = array_keys($this->_plotValues); $keys = array_keys($this->_plotValues);
@ -336,7 +338,7 @@ class PHPExcel_Chart_DataSeries
$this->_smoothLine = $smoothLine; $this->_smoothLine = $smoothLine;
} }
public function refresh(PHPExcel_Worksheet $worksheet) { public function refresh(Worksheet $worksheet) {
foreach($this->_plotValues as $plotValues) { foreach($this->_plotValues as $plotValues) {
if ($plotValues !== NULL) if ($plotValues !== NULL)
$plotValues->refresh($worksheet, TRUE); $plotValues->refresh($worksheet, TRUE);

View File

@ -19,21 +19,23 @@
* 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_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Chart_DataSeriesValues * PHPExcel\Chart_DataSeriesValues
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_DataSeriesValues class Chart_DataSeriesValues
{ {
const DATASERIES_TYPE_STRING = 'String'; const DATASERIES_TYPE_STRING = 'String';
@ -87,7 +89,7 @@ class PHPExcel_Chart_DataSeriesValues
private $_dataValues = array(); private $_dataValues = array();
/** /**
* Create a new PHPExcel_Chart_DataSeriesValues object * Create a new PHPExcel\Chart_DataSeriesValues object
*/ */
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null) public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
{ {
@ -113,15 +115,15 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @param string $dataType Datatype of this data series * @param string $dataType Datatype of this data series
* Typical values are: * Typical values are:
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING * PHPExcel\Chart_DataSeriesValues::DATASERIES_TYPE_STRING
* Normally used for axis point values * Normally used for axis point values
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER * PHPExcel\Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
* Normally used for chart data values * Normally used for chart data values
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel\Chart_DataSeriesValues
*/ */
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) { public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) {
if (!in_array($dataType, self::$_dataTypeValues)) { if (!in_array($dataType, self::$_dataTypeValues)) {
throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values'); throw new Chart_Exception('Invalid datatype for chart data series values');
} }
$this->_dataType = $dataType; $this->_dataType = $dataType;
@ -141,7 +143,7 @@ class PHPExcel_Chart_DataSeriesValues
* Set Series Data Source (formula) * Set Series Data Source (formula)
* *
* @param string $dataSource * @param string $dataSource
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel\Chart_DataSeriesValues
*/ */
public function setDataSource($dataSource = null, $refreshDataValues = true) { public function setDataSource($dataSource = null, $refreshDataValues = true) {
$this->_dataSource = $dataSource; $this->_dataSource = $dataSource;
@ -166,7 +168,7 @@ class PHPExcel_Chart_DataSeriesValues
* Set Point Marker * Set Point Marker
* *
* @param string $marker * @param string $marker
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel\Chart_DataSeriesValues
*/ */
public function setPointMarker($marker = null) { public function setPointMarker($marker = null) {
$this->_marker = $marker; $this->_marker = $marker;
@ -187,7 +189,7 @@ class PHPExcel_Chart_DataSeriesValues
* Set Series Format Code * Set Series Format Code
* *
* @param string $formatCode * @param string $formatCode
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel\Chart_DataSeriesValues
*/ */
public function setFormatCode($formatCode = null) { public function setFormatCode($formatCode = null) {
$this->_formatCode = $formatCode; $this->_formatCode = $formatCode;
@ -260,10 +262,10 @@ class PHPExcel_Chart_DataSeriesValues
* @param boolean $refreshDataSource * @param boolean $refreshDataSource
* TRUE - refresh the value of _dataSource based on the values of $dataValues * TRUE - refresh the value of _dataSource based on the values of $dataValues
* FALSE - don't change the value of _dataSource * FALSE - don't change the value of _dataSource
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel\Chart_DataSeriesValues
*/ */
public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) { public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues); $this->_dataValues = Calculation_Functions::flattenArray($dataValues);
$this->_pointCount = count($dataValues); $this->_pointCount = count($dataValues);
if ($refreshDataSource) { if ($refreshDataSource) {
@ -277,10 +279,10 @@ class PHPExcel_Chart_DataSeriesValues
return $var !== NULL; return $var !== NULL;
} }
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) { public function refresh(Worksheet $worksheet, $flatten = TRUE) {
if ($this->_dataSource !== NULL) { if ($this->_dataSource !== NULL) {
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent()); $calcEngine = Calculation::getInstance($worksheet->getParent());
$newDataValues = PHPExcel_Calculation::_unwrapResult( $newDataValues = Calculation::_unwrapResult(
$calcEngine->_calculateFormulaValue( $calcEngine->_calculateFormulaValue(
'='.$this->_dataSource, '='.$this->_dataSource,
NULL, NULL,
@ -288,7 +290,7 @@ class PHPExcel_Chart_DataSeriesValues
) )
); );
if ($flatten) { if ($flatten) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); $this->_dataValues = Calculation_Functions::flattenArray($newDataValues);
foreach($this->_dataValues as &$dataValue) { foreach($this->_dataValues as &$dataValue) {
if ((!empty($dataValue)) && ($dataValue[0] == '#')) { if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
$dataValue = 0.0; $dataValue = 0.0;
@ -301,9 +303,9 @@ class PHPExcel_Chart_DataSeriesValues
list(,$cellRange) = $cellRange; list(,$cellRange) = $cellRange;
} }
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange)); $dimensions = Cell::rangeDimension(str_replace('$','',$cellRange));
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) { if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); $this->_dataValues = Calculation_Functions::flattenArray($newDataValues);
} else { } else {
$newArray = array_values(array_shift($newDataValues)); $newArray = array_values(array_shift($newDataValues));
foreach($newArray as $i => $newDataSet) { foreach($newArray as $i => $newDataSet) {

View File

@ -19,21 +19,23 @@
* 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_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Chart_Exception * PHPExcel\Chart_Exception
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_Exception extends PHPExcel_Exception { class Chart_Exception extends Exception {
/** /**
* Error handler callback * Error handler callback
* *

View File

@ -19,21 +19,23 @@
* 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_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Chart_Layout * PHPExcel\Chart_Layout
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_Layout class Chart_Layout
{ {
/** /**
* layoutTarget * layoutTarget
@ -141,7 +143,7 @@ class PHPExcel_Chart_Layout
/** /**
* Create a new PHPExcel_Chart_Layout * Create a new PHPExcel\Chart_Layout
*/ */
public function __construct($layout=array()) public function __construct($layout=array())
{ {

View File

@ -19,21 +19,23 @@
* 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_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Chart_Legend * PHPExcel\Chart_Legend
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_Legend class Chart_Legend
{ {
/** Legend positions */ /** Legend positions */
const xlLegendPositionBottom = -4107; // Below the chart. const xlLegendPositionBottom = -4107; // Below the chart.
@ -74,15 +76,15 @@ class PHPExcel_Chart_Legend
/** /**
* Legend Layout * Legend Layout
* *
* @var PHPExcel_Chart_Layout * @var PHPExcel\Chart_Layout
*/ */
private $_layout = NULL; private $_layout = NULL;
/** /**
* Create a new PHPExcel_Chart_Legend * Create a new PHPExcel\Chart_Legend
*/ */
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE) public function __construct($position = self::POSITION_RIGHT, Chart_Layout $layout = NULL, $overlay = FALSE)
{ {
$this->setPosition($position); $this->setPosition($position);
$this->_layout = $layout; $this->_layout = $layout;
@ -162,7 +164,7 @@ class PHPExcel_Chart_Legend
/** /**
* Get Layout * Get Layout
* *
* @return PHPExcel_Chart_Layout * @return PHPExcel\Chart_Layout
*/ */
public function getLayout() { public function getLayout() {
return $this->_layout; return $this->_layout;

View File

@ -19,40 +19,42 @@
* 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_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Chart_PlotArea * PHPExcel\Chart_PlotArea
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_PlotArea class Chart_PlotArea
{ {
/** /**
* PlotArea Layout * PlotArea Layout
* *
* @var PHPExcel_Chart_Layout * @var PHPExcel\Chart_Layout
*/ */
private $_layout = null; private $_layout = null;
/** /**
* Plot Series * Plot Series
* *
* @var array of PHPExcel_Chart_DataSeries * @var array of PHPExcel\Chart_DataSeries
*/ */
private $_plotSeries = array(); private $_plotSeries = array();
/** /**
* Create a new PHPExcel_Chart_PlotArea * Create a new PHPExcel\Chart_PlotArea
*/ */
public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array()) public function __construct(Chart_Layout $layout = null, $plotSeries = array())
{ {
$this->_layout = $layout; $this->_layout = $layout;
$this->_plotSeries = $plotSeries; $this->_plotSeries = $plotSeries;
@ -61,7 +63,7 @@ class PHPExcel_Chart_PlotArea
/** /**
* Get Layout * Get Layout
* *
* @return PHPExcel_Chart_Layout * @return PHPExcel\Chart_Layout
*/ */
public function getLayout() { public function getLayout() {
return $this->_layout; return $this->_layout;
@ -70,7 +72,7 @@ class PHPExcel_Chart_PlotArea
/** /**
* Get Number of Plot Groups * Get Number of Plot Groups
* *
* @return array of PHPExcel_Chart_DataSeries * @return array of PHPExcel\Chart_DataSeries
*/ */
public function getPlotGroupCount() { public function getPlotGroupCount() {
return count($this->_plotSeries); return count($this->_plotSeries);
@ -92,7 +94,7 @@ class PHPExcel_Chart_PlotArea
/** /**
* Get Plot Series * Get Plot Series
* *
* @return array of PHPExcel_Chart_DataSeries * @return array of PHPExcel\Chart_DataSeries
*/ */
public function getPlotGroup() { public function getPlotGroup() {
return $this->_plotSeries; return $this->_plotSeries;
@ -101,7 +103,7 @@ class PHPExcel_Chart_PlotArea
/** /**
* Get Plot Series by Index * Get Plot Series by Index
* *
* @return PHPExcel_Chart_DataSeries * @return PHPExcel\Chart_DataSeries
*/ */
public function getPlotGroupByIndex($index) { public function getPlotGroupByIndex($index) {
return $this->_plotSeries[$index]; return $this->_plotSeries[$index];
@ -110,13 +112,13 @@ class PHPExcel_Chart_PlotArea
/** /**
* Set Plot Series * Set Plot Series
* *
* @param [PHPExcel_Chart_DataSeries] * @param [PHPExcel\Chart_DataSeries]
*/ */
public function setPlotSeries($plotSeries = array()) { public function setPlotSeries($plotSeries = array()) {
$this->_plotSeries = $plotSeries; $this->_plotSeries = $plotSeries;
} }
public function refresh(PHPExcel_Worksheet $worksheet) { public function refresh(Worksheet $worksheet) {
foreach($this->_plotSeries as $plotSeries) { foreach($this->_plotSeries as $plotSeries) {
$plotSeries->refresh($worksheet); $plotSeries->refresh($worksheet);
} }

View File

@ -20,24 +20,25 @@
* 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_Chart_Renderer * @package PHPExcel\Chart_Renderer
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
require_once(PHPExcel_Settings::getChartRendererPath().'/jpgraph.php'); require_once(Settings::getChartRendererPath() . '/jpgraph.php');
/** /**
* PHPExcel_Chart_Renderer_jpgraph * PHPExcel\Chart_Renderer_jpgraph
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart_Renderer * @package PHPExcel\Chart_Renderer
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_Renderer_jpgraph class Chart_Renderer_jpgraph
{ {
private static $_width = 640; private static $_width = 640;
@ -117,7 +118,7 @@ class PHPExcel_Chart_Renderer_jpgraph
} else { } else {
// Format labels according to any formatting code // Format labels according to any formatting code
if (!is_null($datasetLabelFormatCode)) { if (!is_null($datasetLabelFormatCode)) {
$datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel,$datasetLabelFormatCode); $datasetLabels[$i] = Style_NumberFormat::toFormattedString($datasetLabel,$datasetLabelFormatCode);
} }
} }
++$testCurrentIndex; ++$testCurrentIndex;
@ -826,12 +827,12 @@ class PHPExcel_Chart_Renderer_jpgraph
/** /**
* Create a new PHPExcel_Chart_Renderer_jpgraph * Create a new PHPExcel\Chart_Renderer_jpgraph
*/ */
public function __construct(PHPExcel_Chart $chart) public function __construct(Chart $chart)
{ {
$this->_graph = null; $this->_graph = null;
$this->_chart = $chart; $this->_chart = $chart;
} // function __construct() } // function __construct()
} // PHPExcel_Chart_Renderer_jpgraph }

View File

@ -19,21 +19,23 @@
* 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_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Chart_Title * PHPExcel\Chart_Title
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel\Chart
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_Title class Chart_Title
{ {
/** /**
@ -46,14 +48,14 @@ class PHPExcel_Chart_Title
/** /**
* Title Layout * Title Layout
* *
* @var PHPExcel_Chart_Layout * @var PHPExcel\Chart_Layout
*/ */
private $_layout = null; private $_layout = null;
/** /**
* Create a new PHPExcel_Chart_Title * Create a new PHPExcel\Chart_Title
*/ */
public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null) public function __construct($caption = null, Chart_Layout $layout = null)
{ {
$this->_caption = $caption; $this->_caption = $caption;
$this->_layout = $layout; $this->_layout = $layout;
@ -80,7 +82,7 @@ class PHPExcel_Chart_Title
/** /**
* Get Layout * Get Layout
* *
* @return PHPExcel_Chart_Layout * @return PHPExcel\Chart_Layout
*/ */
public function getLayout() { public function getLayout() {
return $this->_layout; return $this->_layout;

View File

@ -26,14 +26,16 @@
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Comment * PHPExcel\Comment
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Comment implements PHPExcel_IComparable class Comment implements IComparable
{ {
/** /**
* Author * Author
@ -45,7 +47,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
/** /**
* Rich text comment * Rich text comment
* *
* @var PHPExcel_RichText * @var PHPExcel\RichText
*/ */
private $_text; private $_text;
@ -87,7 +89,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
/** /**
* Comment fill color * Comment fill color
* *
* @var PHPExcel_Style_Color * @var PHPExcel\Style_Color
*/ */
private $_fillColor; private $_fillColor;
@ -99,17 +101,17 @@ class PHPExcel_Comment implements PHPExcel_IComparable
private $_alignment; private $_alignment;
/** /**
* Create a new PHPExcel_Comment * Create a new PHPExcel\Comment
* *
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function __construct() public function __construct()
{ {
// Initialise variables // Initialise variables
$this->_author = 'Author'; $this->_author = 'Author';
$this->_text = new PHPExcel_RichText(); $this->_text = new RichText();
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1'); $this->_fillColor = new Style_Color('FFFFFFE1');
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; $this->_alignment = Style_Alignment::HORIZONTAL_GENERAL;
} }
/** /**
@ -125,7 +127,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* Set Author * Set Author
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_Comment * @return PHPExcel\Comment
*/ */
public function setAuthor($pValue = '') { public function setAuthor($pValue = '') {
$this->_author = $pValue; $this->_author = $pValue;
@ -135,7 +137,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
/** /**
* Get Rich text comment * Get Rich text comment
* *
* @return PHPExcel_RichText * @return PHPExcel\RichText
*/ */
public function getText() { public function getText() {
return $this->_text; return $this->_text;
@ -144,10 +146,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
/** /**
* Set Rich text comment * Set Rich text comment
* *
* @param PHPExcel_RichText $pValue * @param PHPExcel\RichText $pValue
* @return PHPExcel_Comment * @return PHPExcel\Comment
*/ */
public function setText(PHPExcel_RichText $pValue) { public function setText(RichText $pValue) {
$this->_text = $pValue; $this->_text = $pValue;
return $this; return $this;
} }
@ -165,7 +167,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* Set comment width (CSS style, i.e. XXpx or YYpt) * Set comment width (CSS style, i.e. XXpx or YYpt)
* *
* @param string $value * @param string $value
* @return PHPExcel_Comment * @return PHPExcel\Comment
*/ */
public function setWidth($value = '96pt') { public function setWidth($value = '96pt') {
$this->_width = $value; $this->_width = $value;
@ -185,7 +187,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* Set comment height (CSS style, i.e. XXpx or YYpt) * Set comment height (CSS style, i.e. XXpx or YYpt)
* *
* @param string $value * @param string $value
* @return PHPExcel_Comment * @return PHPExcel\Comment
*/ */
public function setHeight($value = '55.5pt') { public function setHeight($value = '55.5pt') {
$this->_height = $value; $this->_height = $value;
@ -205,7 +207,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* Set left margin (CSS style, i.e. XXpx or YYpt) * Set left margin (CSS style, i.e. XXpx or YYpt)
* *
* @param string $value * @param string $value
* @return PHPExcel_Comment * @return PHPExcel\Comment
*/ */
public function setMarginLeft($value = '59.25pt') { public function setMarginLeft($value = '59.25pt') {
$this->_marginLeft = $value; $this->_marginLeft = $value;
@ -225,7 +227,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* Set top margin (CSS style, i.e. XXpx or YYpt) * Set top margin (CSS style, i.e. XXpx or YYpt)
* *
* @param string $value * @param string $value
* @return PHPExcel_Comment * @return PHPExcel\Comment
*/ */
public function setMarginTop($value = '1.5pt') { public function setMarginTop($value = '1.5pt') {
$this->_marginTop = $value; $this->_marginTop = $value;
@ -245,7 +247,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* Set comment default visibility * Set comment default visibility
* *
* @param boolean $value * @param boolean $value
* @return PHPExcel_Comment * @return PHPExcel\Comment
*/ */
public function setVisible($value = false) { public function setVisible($value = false) {
$this->_visible = $value; $this->_visible = $value;
@ -255,7 +257,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
/** /**
* Get fill color * Get fill color
* *
* @return PHPExcel_Style_Color * @return PHPExcel\Style_Color
*/ */
public function getFillColor() { public function getFillColor() {
return $this->_fillColor; return $this->_fillColor;
@ -265,9 +267,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* Set Alignment * Set Alignment
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_Comment * @return PHPExcel\Comment
*/ */
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) { public function setAlignment($pValue = Style_Alignment::HORIZONTAL_GENERAL) {
$this->_alignment = $pValue; $this->_alignment = $pValue;
return $this; return $this;
} }

View File

@ -26,14 +26,16 @@
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_DocumentProperties * PHPExcel\DocumentProperties
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_DocumentProperties class DocumentProperties
{ {
/** constants */ /** constants */
const PROPERTY_TYPE_BOOLEAN = 'b'; const PROPERTY_TYPE_BOOLEAN = 'b';
@ -129,7 +131,7 @@ class PHPExcel_DocumentProperties
/** /**
* Create a new PHPExcel_DocumentProperties * Create a new PHPExcel\DocumentProperties
*/ */
public function __construct() public function __construct()
{ {
@ -152,7 +154,7 @@ class PHPExcel_DocumentProperties
* Set Creator * Set Creator
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setCreator($pValue = '') { public function setCreator($pValue = '') {
$this->_creator = $pValue; $this->_creator = $pValue;
@ -172,7 +174,7 @@ class PHPExcel_DocumentProperties
* Set Last Modified By * Set Last Modified By
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setLastModifiedBy($pValue = '') { public function setLastModifiedBy($pValue = '') {
$this->_lastModifiedBy = $pValue; $this->_lastModifiedBy = $pValue;
@ -192,7 +194,7 @@ class PHPExcel_DocumentProperties
* Set Created * Set Created
* *
* @param datetime $pValue * @param datetime $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setCreated($pValue = null) { public function setCreated($pValue = null) {
if ($pValue === NULL) { if ($pValue === NULL) {
@ -222,7 +224,7 @@ class PHPExcel_DocumentProperties
* Set Modified * Set Modified
* *
* @param datetime $pValue * @param datetime $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setModified($pValue = null) { public function setModified($pValue = null) {
if ($pValue === NULL) { if ($pValue === NULL) {
@ -252,7 +254,7 @@ class PHPExcel_DocumentProperties
* Set Title * Set Title
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setTitle($pValue = '') { public function setTitle($pValue = '') {
$this->_title = $pValue; $this->_title = $pValue;
@ -272,7 +274,7 @@ class PHPExcel_DocumentProperties
* Set Description * Set Description
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setDescription($pValue = '') { public function setDescription($pValue = '') {
$this->_description = $pValue; $this->_description = $pValue;
@ -292,7 +294,7 @@ class PHPExcel_DocumentProperties
* Set Subject * Set Subject
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setSubject($pValue = '') { public function setSubject($pValue = '') {
$this->_subject = $pValue; $this->_subject = $pValue;
@ -312,7 +314,7 @@ class PHPExcel_DocumentProperties
* Set Keywords * Set Keywords
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setKeywords($pValue = '') { public function setKeywords($pValue = '') {
$this->_keywords = $pValue; $this->_keywords = $pValue;
@ -332,7 +334,7 @@ class PHPExcel_DocumentProperties
* Set Category * Set Category
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setCategory($pValue = '') { public function setCategory($pValue = '') {
$this->_category = $pValue; $this->_category = $pValue;
@ -352,7 +354,7 @@ class PHPExcel_DocumentProperties
* Set Company * Set Company
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setCompany($pValue = '') { public function setCompany($pValue = '') {
$this->_company = $pValue; $this->_company = $pValue;
@ -372,7 +374,7 @@ class PHPExcel_DocumentProperties
* Set Manager * Set Manager
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setManager($pValue = '') { public function setManager($pValue = '') {
$this->_manager = $pValue; $this->_manager = $pValue;
@ -435,7 +437,7 @@ class PHPExcel_DocumentProperties
* 's' : String * 's' : String
* 'd' : Date/Time * 'd' : Date/Time
* 'b' : Boolean * 'b' : Boolean
* @return PHPExcel_DocumentProperties * @return PHPExcel\DocumentProperties
*/ */
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) { public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER, if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,

View File

@ -26,14 +26,16 @@
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_DocumentSecurity * PHPExcel\DocumentSecurity
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_DocumentSecurity class DocumentSecurity
{ {
/** /**
* LockRevision * LockRevision
@ -71,7 +73,7 @@ class PHPExcel_DocumentSecurity
private $_workbookPassword; private $_workbookPassword;
/** /**
* Create a new PHPExcel_DocumentSecurity * Create a new PHPExcel\DocumentSecurity
*/ */
public function __construct() public function __construct()
{ {
@ -107,7 +109,7 @@ class PHPExcel_DocumentSecurity
* Set LockRevision * Set LockRevision
* *
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_DocumentSecurity * @return PHPExcel\DocumentSecurity
*/ */
function setLockRevision($pValue = false) { function setLockRevision($pValue = false) {
$this->_lockRevision = $pValue; $this->_lockRevision = $pValue;
@ -127,7 +129,7 @@ class PHPExcel_DocumentSecurity
* Set LockStructure * Set LockStructure
* *
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_DocumentSecurity * @return PHPExcel\DocumentSecurity
*/ */
function setLockStructure($pValue = false) { function setLockStructure($pValue = false) {
$this->_lockStructure = $pValue; $this->_lockStructure = $pValue;
@ -147,7 +149,7 @@ class PHPExcel_DocumentSecurity
* Set LockWindows * Set LockWindows
* *
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_DocumentSecurity * @return PHPExcel\DocumentSecurity
*/ */
function setLockWindows($pValue = false) { function setLockWindows($pValue = false) {
$this->_lockWindows = $pValue; $this->_lockWindows = $pValue;
@ -168,11 +170,11 @@ class PHPExcel_DocumentSecurity
* *
* @param string $pValue * @param string $pValue
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @return PHPExcel_DocumentSecurity * @return PHPExcel\DocumentSecurity
*/ */
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) { function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
if (!$pAlreadyHashed) { if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue); $pValue = Shared_PasswordHasher::hashPassword($pValue);
} }
$this->_revisionsPassword = $pValue; $this->_revisionsPassword = $pValue;
return $this; return $this;
@ -192,11 +194,11 @@ class PHPExcel_DocumentSecurity
* *
* @param string $pValue * @param string $pValue
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @return PHPExcel_DocumentSecurity * @return PHPExcel\DocumentSecurity
*/ */
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) { function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
if (!$pAlreadyHashed) { if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue); $pValue = Shared_PasswordHasher::hashPassword($pValue);
} }
$this->_workbookPassword = $pValue; $this->_workbookPassword = $pValue;
return $this; return $this;

View File

@ -26,14 +26,16 @@
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Exception * PHPExcel\Exception
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Exception extends Exception { class Exception extends \Exception {
/** /**
* Error handler callback * Error handler callback
* *

View File

@ -26,14 +26,16 @@
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_HashTable * PHPExcel\HashTable
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_HashTable class HashTable
{ {
/** /**
* HashTable elements * HashTable elements
@ -50,10 +52,10 @@ class PHPExcel_HashTable
public $_keyMap = array(); public $_keyMap = array();
/** /**
* Create a new PHPExcel_HashTable * Create a new PHPExcel\HashTable
* *
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from * @param PHPExcel\IComparable[] $pSource Optional source array to create HashTable from
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function __construct($pSource = null) public function __construct($pSource = null)
{ {
@ -66,15 +68,15 @@ class PHPExcel_HashTable
/** /**
* Add HashTable items from source * Add HashTable items from source
* *
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from * @param PHPExcel\IComparable[] $pSource Source array to create HashTable from
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function addFromSource($pSource = null) { public function addFromSource($pSource = null) {
// Check if an array was passed // Check if an array was passed
if ($pSource == null) { if ($pSource == null) {
return; return;
} else if (!is_array($pSource)) { } else if (!is_array($pSource)) {
throw new PHPExcel_Exception('Invalid array parameter passed.'); throw new Exception('Invalid array parameter passed.');
} }
foreach ($pSource as $item) { foreach ($pSource as $item) {
@ -85,10 +87,10 @@ class PHPExcel_HashTable
/** /**
* Add HashTable item * Add HashTable item
* *
* @param PHPExcel_IComparable $pSource Item to add * @param PHPExcel\IComparable $pSource Item to add
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function add(PHPExcel_IComparable $pSource = null) { public function add(IComparable $pSource = null) {
$hash = $pSource->getHashCode(); $hash = $pSource->getHashCode();
if (!isset($this->_items[$hash])) { if (!isset($this->_items[$hash])) {
$this->_items[$hash] = $pSource; $this->_items[$hash] = $pSource;
@ -99,10 +101,10 @@ class PHPExcel_HashTable
/** /**
* Remove HashTable item * Remove HashTable item
* *
* @param PHPExcel_IComparable $pSource Item to remove * @param PHPExcel\IComparable $pSource Item to remove
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function remove(PHPExcel_IComparable $pSource = null) { public function remove(IComparable $pSource = null) {
$hash = $pSource->getHashCode(); $hash = $pSource->getHashCode();
if (isset($this->_items[$hash])) { if (isset($this->_items[$hash])) {
unset($this->_items[$hash]); unset($this->_items[$hash]);
@ -153,7 +155,7 @@ class PHPExcel_HashTable
* Get by index * Get by index
* *
* @param int $pIndex * @param int $pIndex
* @return PHPExcel_IComparable * @return PHPExcel\IComparable
* *
*/ */
public function getByIndex($pIndex = 0) { public function getByIndex($pIndex = 0) {
@ -168,7 +170,7 @@ class PHPExcel_HashTable
* Get by hashcode * Get by hashcode
* *
* @param string $pHashCode * @param string $pHashCode
* @return PHPExcel_IComparable * @return PHPExcel\IComparable
* *
*/ */
public function getByHashCode($pHashCode = '') { public function getByHashCode($pHashCode = '') {
@ -182,7 +184,7 @@ class PHPExcel_HashTable
/** /**
* HashTable to array * HashTable to array
* *
* @return PHPExcel_IComparable[] * @return PHPExcel\IComparable[]
*/ */
public function toArray() { public function toArray() {
return $this->_items; return $this->_items;

View File

@ -24,14 +24,16 @@
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_IComparable * PHPExcel\IComparable
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
interface PHPExcel_IComparable interface IComparable
{ {
/** /**
* Get hash code * Get hash code

View File

@ -26,23 +26,16 @@
*/ */
/** PHPExcel root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_IOFactory * PHPExcel\IOFactory
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_IOFactory class IOFactory
{ {
/** /**
* Search locations * Search locations
@ -52,8 +45,8 @@ class PHPExcel_IOFactory
* @static * @static
*/ */
private static $_searchLocations = array( private static $_searchLocations = array(
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ), array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'Writer_{0}' ),
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' ) array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'Reader_{0}' )
); );
/** /**
@ -75,7 +68,7 @@ class PHPExcel_IOFactory
); );
/** /**
* Private constructor for PHPExcel_IOFactory * Private constructor for PHPExcel\IOFactory
*/ */
private function __construct() { } private function __construct() { }
@ -96,13 +89,13 @@ class PHPExcel_IOFactory
* @static * @static
* @access public * @access public
* @param array $value * @param array $value
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public static function setSearchLocations($value) { public static function setSearchLocations($value) {
if (is_array($value)) { if (is_array($value)) {
self::$_searchLocations = $value; self::$_searchLocations = $value;
} else { } else {
throw new PHPExcel_Reader_Exception('Invalid parameter passed.'); throw new Reader_Exception('Invalid parameter passed.');
} }
} // function setSearchLocations() } // function setSearchLocations()
@ -113,30 +106,31 @@ class PHPExcel_IOFactory
* @access public * @access public
* @param string $type Example: IWriter * @param string $type Example: IWriter
* @param string $location Example: PHPExcel/Writer/{0}.php * @param string $location Example: PHPExcel/Writer/{0}.php
* @param string $classname Example: PHPExcel_Writer_{0} * @param string $classname Example: PHPExcel\Writer_{0}
*/ */
public static function addSearchLocation($type = '', $location = '', $classname = '') { public static function addSearchLocation($type = '', $location = '', $classname = '') {
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname ); self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
} // function addSearchLocation() } // function addSearchLocation()
/** /**
* Create PHPExcel_Writer_IWriter * Create PHPExcel\Writer_IWriter
* *
* @static * @static
* @access public * @access public
* @param PHPExcel $phpExcel * @param PHPExcel $phpExcel
* @param string $writerType Example: Excel2007 * @param string $writerType Example: Excel2007
* @return PHPExcel_Writer_IWriter * @return PHPExcel\Writer_IWriter
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public static function createWriter(PHPExcel $phpExcel, $writerType = '') { public static function createWriter(Workbook $phpExcel, $writerType = '') {
// Search type // Search type
$searchType = 'IWriter'; $searchType = 'IWriter';
// Include class // Include class
foreach (self::$_searchLocations as $searchLocation) { foreach (self::$_searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) { if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $writerType, $searchLocation['class']); $className = __NAMESPACE__ . '\\' . str_replace('{0}', $writerType, $searchLocation['class']);
$instance = new $className($phpExcel); $instance = new $className($phpExcel);
if ($instance !== NULL) { if ($instance !== NULL) {
@ -146,17 +140,17 @@ class PHPExcel_IOFactory
} }
// Nothing found... // Nothing found...
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType"); throw new Reader_Exception("No $searchType found for type $writerType");
} // function createWriter() } // function createWriter()
/** /**
* Create PHPExcel_Reader_IReader * Create PHPExcel\Reader_IReader
* *
* @static * @static
* @access public * @access public
* @param string $readerType Example: Excel2007 * @param string $readerType Example: Excel2007
* @return PHPExcel_Reader_IReader * @return PHPExcel\Reader_IReader
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public static function createReader($readerType = '') { public static function createReader($readerType = '') {
// Search type // Search type
@ -175,17 +169,17 @@ class PHPExcel_IOFactory
} }
// Nothing found... // Nothing found...
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType"); throw new Reader_Exception("No $searchType found for type $readerType");
} // function createReader() } // function createReader()
/** /**
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution * Loads PHPExcel from file using automatic PHPExcel\Reader_IReader resolution
* *
* @static * @static
* @access public * @access public
* @param string $pFilename The name of the spreadsheet file * @param string $pFilename The name of the spreadsheet file
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public static function load($pFilename) { public static function load($pFilename) {
$reader = self::createReaderForFile($pFilename); $reader = self::createReaderForFile($pFilename);
@ -193,13 +187,13 @@ class PHPExcel_IOFactory
} // function load() } // function load()
/** /**
* Identify file type using automatic PHPExcel_Reader_IReader resolution * Identify file type using automatic PHPExcel\Reader_IReader resolution
* *
* @static * @static
* @access public * @access public
* @param string $pFilename The name of the spreadsheet file to identify * @param string $pFilename The name of the spreadsheet file to identify
* @return string * @return string
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public static function identify($pFilename) { public static function identify($pFilename) {
$reader = self::createReaderForFile($pFilename); $reader = self::createReaderForFile($pFilename);
@ -210,13 +204,13 @@ class PHPExcel_IOFactory
} // function identify() } // function identify()
/** /**
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution * Create PHPExcel\Reader_IReader for file using automatic PHPExcel\Reader_IReader resolution
* *
* @static * @static
* @access public * @access public
* @param string $pFilename The name of the spreadsheet file * @param string $pFilename The name of the spreadsheet file
* @return PHPExcel_Reader_IReader * @return PHPExcel\Reader_IReader
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public static function createReaderForFile($pFilename) { public static function createReaderForFile($pFilename) {
@ -283,6 +277,6 @@ class PHPExcel_IOFactory
} }
} }
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file'); throw new Reader_Exception('Unable to identify a reader for this file');
} // function createReaderForFile() } // function createReaderForFile()
} }

View File

@ -26,14 +26,16 @@
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_NamedRange * PHPExcel\NamedRange
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_NamedRange class NamedRange
{ {
/** /**
* Range name * Range name
@ -45,7 +47,7 @@ class PHPExcel_NamedRange
/** /**
* Worksheet on which the named range can be resolved * Worksheet on which the named range can be resolved
* *
* @var PHPExcel_Worksheet * @var PHPExcel\Worksheet
*/ */
private $_worksheet; private $_worksheet;
@ -66,7 +68,7 @@ class PHPExcel_NamedRange
/** /**
* Scope * Scope
* *
* @var PHPExcel_Worksheet * @var PHPExcel\Worksheet
*/ */
private $_scope; private $_scope;
@ -74,17 +76,17 @@ class PHPExcel_NamedRange
* Create a new NamedRange * Create a new NamedRange
* *
* @param string $pName * @param string $pName
* @param PHPExcel_Worksheet $pWorksheet * @param PHPExcel\Worksheet $pWorksheet
* @param string $pRange * @param string $pRange
* @param bool $pLocalOnly * @param bool $pLocalOnly
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope. * @param PHPExcel\Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null) public function __construct($pName = null, Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
{ {
// Validate data // Validate data
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) { if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
throw new PHPExcel_Exception('Parameters can not be null.'); throw new Exception('Parameters can not be null.');
} }
// Set local members // Set local members
@ -109,7 +111,7 @@ class PHPExcel_NamedRange
* Set name * Set name
* *
* @param string $value * @param string $value
* @return PHPExcel_NamedRange * @return PHPExcel\NamedRange
*/ */
public function setName($value = null) { public function setName($value = null) {
if ($value !== NULL) { if ($value !== NULL) {
@ -128,7 +130,7 @@ class PHPExcel_NamedRange
// New title // New title
$newTitle = $this->_name; $newTitle = $this->_name;
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle); ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle);
} }
return $this; return $this;
} }
@ -136,7 +138,7 @@ class PHPExcel_NamedRange
/** /**
* Get worksheet * Get worksheet
* *
* @return PHPExcel_Worksheet * @return PHPExcel\Worksheet
*/ */
public function getWorksheet() { public function getWorksheet() {
return $this->_worksheet; return $this->_worksheet;
@ -145,12 +147,12 @@ class PHPExcel_NamedRange
/** /**
* Set worksheet * Set worksheet
* *
* @param PHPExcel_Worksheet $value * @param PHPExcel\Worksheet $worksheet
* @return PHPExcel_NamedRange * @return PHPExcel\NamedRange
*/ */
public function setWorksheet(PHPExcel_Worksheet $value = null) { public function setWorksheet(Worksheet $worksheet = null) {
if ($value !== NULL) { if ($worksheet !== NULL) {
$this->_worksheet = $value; $this->_worksheet = $worksheet;
} }
return $this; return $this;
} }
@ -168,7 +170,7 @@ class PHPExcel_NamedRange
* Set range * Set range
* *
* @param string $value * @param string $value
* @return PHPExcel_NamedRange * @return PHPExcel\NamedRange
*/ */
public function setRange($value = null) { public function setRange($value = null) {
if ($value !== NULL) { if ($value !== NULL) {
@ -190,7 +192,7 @@ class PHPExcel_NamedRange
* Set localOnly * Set localOnly
* *
* @param bool $value * @param bool $value
* @return PHPExcel_NamedRange * @return PHPExcel\NamedRange
*/ */
public function setLocalOnly($value = false) { public function setLocalOnly($value = false) {
$this->_localOnly = $value; $this->_localOnly = $value;
@ -201,7 +203,7 @@ class PHPExcel_NamedRange
/** /**
* Get scope * Get scope
* *
* @return PHPExcel_Worksheet|null * @return PHPExcel\Worksheet|NULL
*/ */
public function getScope() { public function getScope() {
return $this->_scope; return $this->_scope;
@ -210,12 +212,12 @@ class PHPExcel_NamedRange
/** /**
* Set scope * Set scope
* *
* @param PHPExcel_Worksheet|null $value * @param PHPExcel\Worksheet|NULL $worksheet
* @return PHPExcel_NamedRange * @return PHPExcel\NamedRange
*/ */
public function setScope(PHPExcel_Worksheet $value = null) { public function setScope(Worksheet $worksheet = null) {
$this->_scope = $value; $this->_scope = $worksheet;
$this->_localOnly = ($value == null) ? false : true; $this->_localOnly = ($worksheet == null) ? false : true;
return $this; return $this;
} }
@ -223,10 +225,10 @@ class PHPExcel_NamedRange
* Resolve a named range to a regular cell range * Resolve a named range to a regular cell range
* *
* @param string $pNamedRange Named range * @param string $pNamedRange Named range
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope * @param PHPExcel\Worksheet|null $pSheet Scope. Use null for global scope
* @return PHPExcel_NamedRange * @return PHPExcel\NamedRange
*/ */
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) { public static function resolveRange($pNamedRange = '', Worksheet $pSheet) {
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet); return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
} }

View File

@ -19,21 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Reader_Abstract * PHPExcel\Reader_Abstract
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader abstract class Reader_Abstract implements Reader_IReader
{ {
/** /**
* Read data only? * Read data only?
@ -61,9 +63,9 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
protected $_loadSheetsOnly = NULL; protected $_loadSheetsOnly = NULL;
/** /**
* PHPExcel_Reader_IReadFilter instance * PHPExcel\Reader_IReadFilter instance
* *
* @var PHPExcel_Reader_IReadFilter * @var PHPExcel\Reader_IReadFilter
*/ */
protected $_readFilter = NULL; protected $_readFilter = NULL;
@ -88,7 +90,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @param boolean $pValue * @param boolean $pValue
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel\Reader_IReader
*/ */
public function setReadDataOnly($pValue = FALSE) { public function setReadDataOnly($pValue = FALSE) {
$this->_readDataOnly = $pValue; $this->_readDataOnly = $pValue;
@ -115,7 +117,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @param boolean $pValue * @param boolean $pValue
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel\Reader_IReader
*/ */
public function setIncludeCharts($pValue = FALSE) { public function setIncludeCharts($pValue = FALSE) {
$this->_includeCharts = (boolean) $pValue; $this->_includeCharts = (boolean) $pValue;
@ -141,7 +143,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
* If NULL, then it tells the Reader to read all worksheets in the workbook * If NULL, then it tells the Reader to read all worksheets in the workbook
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel\Reader_IReader
*/ */
public function setLoadSheetsOnly($value = NULL) public function setLoadSheetsOnly($value = NULL)
{ {
@ -154,7 +156,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* Set all sheets to load * Set all sheets to load
* Tells the Reader to load all worksheets from the workbook. * Tells the Reader to load all worksheets from the workbook.
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel\Reader_IReader
*/ */
public function setLoadAllSheets() public function setLoadAllSheets()
{ {
@ -165,7 +167,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
/** /**
* Read filter * Read filter
* *
* @return PHPExcel_Reader_IReadFilter * @return PHPExcel\Reader_IReadFilter
*/ */
public function getReadFilter() { public function getReadFilter() {
return $this->_readFilter; return $this->_readFilter;
@ -174,10 +176,10 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
/** /**
* Set read filter * Set read filter
* *
* @param PHPExcel_Reader_IReadFilter $pValue * @param PHPExcel\Reader_IReadFilter $pValue
* @return PHPExcel_Reader_IReader * @return PHPExcel\Reader_IReader
*/ */
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { public function setReadFilter(Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue; $this->_readFilter = $pValue;
return $this; return $this;
} }
@ -186,29 +188,29 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* Open file for reading * Open file for reading
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
* @return resource * @return resource
*/ */
protected function _openFile($pFilename) protected function _openFile($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename) || !is_readable($pFilename)) { if (!file_exists($pFilename) || !is_readable($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
// Open file // Open file
$this->_fileHandle = fopen($pFilename, 'r'); $this->_fileHandle = fopen($pFilename, 'r');
if ($this->_fileHandle === FALSE) { if ($this->_fileHandle === FALSE) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading."); throw new Reader_Exception("Could not open file " . $pFilename . " for reading.");
} }
} }
/** /**
* Can the current PHPExcel_Reader_IReader read the file? * Can the current PHPExcel\Reader_IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return boolean * @return boolean
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function canRead($pFilename) public function canRead($pFilename)
{ {

View File

@ -19,30 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Reader_CSV * PHPExcel\Reader_CSV
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class Reader_CSV extends Reader_Abstract implements Reader_IReader
{ {
/** /**
* Input encoding * Input encoding
@ -101,10 +94,10 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
/** /**
* Create a new PHPExcel_Reader_CSV * Create a new PHPExcel\Reader_CSV
*/ */
public function __construct() { public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new Reader_DefaultReadFilter();
} }
/** /**
@ -176,7 +169,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
{ {
@ -184,7 +177,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
$this->_openFile($pFilename); $this->_openFile($pFilename);
if (!$this->_isValidFormat()) { if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle); fclose ($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$fileHandle = $this->_fileHandle; $fileHandle = $this->_fileHandle;
@ -206,7 +199,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1); $worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
} }
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']); $worksheetInfo[0]['lastColumnLetter'] = Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1; $worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
// Close file // Close file
@ -220,12 +213,12 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* *
* @param string $pFilename * @param string $pFilename
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function load($pFilename) public function load($pFilename)
{ {
// Create new PHPExcel // Create new PHPExcel Workbook
$objPHPExcel = new PHPExcel(); $objPHPExcel = new Workbook();
// Load into this instance // Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
@ -237,7 +230,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @param string $pFilename * @param string $pFilename
* @param PHPExcel $objPHPExcel * @param PHPExcel $objPHPExcel
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{ {
@ -248,7 +241,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
$this->_openFile($pFilename); $this->_openFile($pFilename);
if (!$this->_isValidFormat()) { if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle); fclose ($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$fileHandle = $this->_fileHandle; $fileHandle = $this->_fileHandle;
@ -281,7 +274,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
// Convert encoding if necessary // Convert encoding if necessary
if ($this->_inputEncoding !== 'UTF-8') { if ($this->_inputEncoding !== 'UTF-8') {
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding); $rowDatum = Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
} }
// Set cell value // Set cell value
@ -318,7 +311,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Set delimiter * Set delimiter
* *
* @param string $pValue Delimiter, defaults to , * @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Reader_CSV * @return PHPExcel\Reader_CSV
*/ */
public function setDelimiter($pValue = ',') { public function setDelimiter($pValue = ',') {
$this->_delimiter = $pValue; $this->_delimiter = $pValue;
@ -338,7 +331,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Set enclosure * Set enclosure
* *
* @param string $pValue Enclosure, defaults to " * @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV * @return PHPExcel\Reader_CSV
*/ */
public function setEnclosure($pValue = '"') { public function setEnclosure($pValue = '"') {
if ($pValue == '') { if ($pValue == '') {
@ -361,7 +354,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Set line ending * Set line ending
* *
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL) * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* @return PHPExcel_Reader_CSV * @return PHPExcel\Reader_CSV
*/ */
public function setLineEnding($pValue = PHP_EOL) { public function setLineEnding($pValue = PHP_EOL) {
$this->_lineEnding = $pValue; $this->_lineEnding = $pValue;
@ -381,7 +374,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Set sheet index * Set sheet index
* *
* @param integer $pValue Sheet index * @param integer $pValue Sheet index
* @return PHPExcel_Reader_CSV * @return PHPExcel\Reader_CSV
*/ */
public function setSheetIndex($pValue = 0) { public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue; $this->_sheetIndex = $pValue;

View File

@ -19,30 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Reader_DefaultReadFilter * PHPExcel\Reader_DefaultReadFilter
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter class Reader_DefaultReadFilter implements Reader_IReadFilter
{ {
/** /**
* Should this cell be read? * Should this cell be read?

View File

@ -19,30 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Reader_Excel2003XML * PHPExcel\Reader_Excel2003XML
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class Reader_Excel2003XML extends Reader_Abstract implements Reader_IReader
{ {
/** /**
* Formats * Formats
@ -60,19 +53,19 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
/** /**
* Create a new PHPExcel_Reader_Excel2003XML * Create a new PHPExcel\Reader_Excel2003XML
*/ */
public function __construct() { public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new Reader_DefaultReadFilter();
} }
/** /**
* Can the current PHPExcel_Reader_IReader read the file? * Can the current PHPExcel\Reader_IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return boolean * @return boolean
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function canRead($pFilename) public function canRead($pFilename)
{ {
@ -123,16 +116,16 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetNames($pFilename) public function listWorksheetNames($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
if (!$this->canRead($pFilename)) { if (!$this->canRead($pFilename)) {
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$worksheetNames = array(); $worksheetNames = array();
@ -154,13 +147,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$worksheetInfo = array(); $worksheetInfo = array();
@ -210,7 +203,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
} }
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $tmpInfo['lastColumnLetter'] = Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1; $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
$worksheetInfo[] = $tmpInfo; $worksheetInfo[] = $tmpInfo;
@ -226,12 +219,12 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
* *
* @param string $pFilename * @param string $pFilename
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function load($pFilename) public function load($pFilename)
{ {
// Create new PHPExcel // Create new PHPExcel Workbook
$objPHPExcel = new PHPExcel(); $objPHPExcel = new Workbook();
// Load into this instance // Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
@ -288,7 +281,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
* @param string $pFilename * @param string $pFilename
* @param PHPExcel $objPHPExcel * @param PHPExcel $objPHPExcel
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{ {
@ -296,25 +289,25 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$toFormats = array('-', ' '); $toFormats = array('-', ' ');
$underlineStyles = array ( $underlineStyles = array (
PHPExcel_Style_Font::UNDERLINE_NONE, Style_Font::UNDERLINE_NONE,
PHPExcel_Style_Font::UNDERLINE_DOUBLE, Style_Font::UNDERLINE_DOUBLE,
PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING, Style_Font::UNDERLINE_DOUBLEACCOUNTING,
PHPExcel_Style_Font::UNDERLINE_SINGLE, Style_Font::UNDERLINE_SINGLE,
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING Style_Font::UNDERLINE_SINGLEACCOUNTING
); );
$verticalAlignmentStyles = array ( $verticalAlignmentStyles = array (
PHPExcel_Style_Alignment::VERTICAL_BOTTOM, Style_Alignment::VERTICAL_BOTTOM,
PHPExcel_Style_Alignment::VERTICAL_TOP, Style_Alignment::VERTICAL_TOP,
PHPExcel_Style_Alignment::VERTICAL_CENTER, Style_Alignment::VERTICAL_CENTER,
PHPExcel_Style_Alignment::VERTICAL_JUSTIFY Style_Alignment::VERTICAL_JUSTIFY
); );
$horizontalAlignmentStyles = array ( $horizontalAlignmentStyles = array (
PHPExcel_Style_Alignment::HORIZONTAL_GENERAL, Style_Alignment::HORIZONTAL_GENERAL,
PHPExcel_Style_Alignment::HORIZONTAL_LEFT, Style_Alignment::HORIZONTAL_LEFT,
PHPExcel_Style_Alignment::HORIZONTAL_RIGHT, Style_Alignment::HORIZONTAL_RIGHT,
PHPExcel_Style_Alignment::HORIZONTAL_CENTER, Style_Alignment::HORIZONTAL_CENTER,
PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS, Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS,
PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY Style_Alignment::HORIZONTAL_JUSTIFY
); );
$timezoneObj = new DateTimeZone('Europe/London'); $timezoneObj = new DateTimeZone('Europe/London');
@ -323,11 +316,11 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
if (!$this->canRead($pFilename)) { if (!$this->canRead($pFilename)) {
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$xml = simplexml_load_file($pFilename); $xml = simplexml_load_file($pFilename);
@ -378,27 +371,27 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
if (isset($xml->CustomDocumentProperties)) { if (isset($xml->CustomDocumentProperties)) {
foreach($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) { foreach($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
$propertyAttributes = $propertyValue->attributes($namespaces['dt']); $propertyAttributes = $propertyValue->attributes($namespaces['dt']);
$propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str',$propertyName); $propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/', __NAMESPACE__ . '\Reader_Excel2003XML::_hex2str', $propertyName);
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN; $propertyType = DocumentProperties::PROPERTY_TYPE_UNKNOWN;
switch((string) $propertyAttributes) { switch((string) $propertyAttributes) {
case 'string' : case 'string' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $propertyType = DocumentProperties::PROPERTY_TYPE_STRING;
$propertyValue = trim($propertyValue); $propertyValue = trim($propertyValue);
break; break;
case 'boolean' : case 'boolean' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; $propertyType = DocumentProperties::PROPERTY_TYPE_BOOLEAN;
$propertyValue = (bool) $propertyValue; $propertyValue = (bool) $propertyValue;
break; break;
case 'integer' : case 'integer' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_INTEGER; $propertyType = DocumentProperties::PROPERTY_TYPE_INTEGER;
$propertyValue = intval($propertyValue); $propertyValue = intval($propertyValue);
break; break;
case 'float' : case 'float' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; $propertyType = DocumentProperties::PROPERTY_TYPE_FLOAT;
$propertyValue = floatval($propertyValue); $propertyValue = floatval($propertyValue);
break; break;
case 'dateTime.tz' : case 'dateTime.tz' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; $propertyType = DocumentProperties::PROPERTY_TYPE_DATE;
$propertyValue = strtotime(trim($propertyValue)); $propertyValue = strtotime(trim($propertyValue));
break; break;
} }
@ -448,7 +441,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />'; // echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
switch ($borderStyleKey) { switch ($borderStyleKey) {
case 'LineStyle' : case 'LineStyle' :
$thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; $thisBorder['style'] = Style_Border::BORDER_MEDIUM;
// $thisBorder['style'] = $borderStyleValue; // $thisBorder['style'] = $borderStyleValue;
break; break;
case 'Weight' : case 'Weight' :
@ -563,7 +556,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
foreach($worksheet->Table->Column as $columnData) { foreach($worksheet->Table->Column as $columnData) {
$columnData_ss = $columnData->attributes($namespaces['ss']); $columnData_ss = $columnData->attributes($namespaces['ss']);
if (isset($columnData_ss['Index'])) { if (isset($columnData_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($columnData_ss['Index']-1); $columnID = Cell::stringFromColumnIndex($columnData_ss['Index']-1);
} }
if (isset($columnData_ss['Width'])) { if (isset($columnData_ss['Width'])) {
$columnWidth = $columnData_ss['Width']; $columnWidth = $columnData_ss['Width'];
@ -589,7 +582,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$cell_ss = $cell->attributes($namespaces['ss']); $cell_ss = $cell->attributes($namespaces['ss']);
if (isset($cell_ss['Index'])) { if (isset($cell_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1); $columnID = Cell::stringFromColumnIndex($cell_ss['Index']-1);
} }
$cellRange = $columnID.$rowID; $cellRange = $columnID.$rowID;
@ -602,7 +595,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
if ((isset($cell_ss['MergeAcross'])) || (isset($cell_ss['MergeDown']))) { if ((isset($cell_ss['MergeAcross'])) || (isset($cell_ss['MergeDown']))) {
$columnTo = $columnID; $columnTo = $columnID;
if (isset($cell_ss['MergeAcross'])) { if (isset($cell_ss['MergeAcross'])) {
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cell_ss['MergeAcross'] -1); $columnTo = Cell::stringFromColumnIndex(Cell::columnIndexFromString($columnID) + $cell_ss['MergeAcross'] -1);
} }
$rowTo = $rowID; $rowTo = $rowID;
if (isset($cell_ss['MergeDown'])) { if (isset($cell_ss['MergeDown'])) {
@ -625,7 +618,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
if (isset($cell->Data)) { if (isset($cell->Data)) {
$cellValue = $cellData = $cell->Data; $cellValue = $cellData = $cell->Data;
$type = PHPExcel_Cell_DataType::TYPE_NULL; $type = Cell_DataType::TYPE_NULL;
$cellData_ss = $cellData->attributes($namespaces['ss']); $cellData_ss = $cellData->attributes($namespaces['ss']);
if (isset($cellData_ss['Type'])) { if (isset($cellData_ss['Type'])) {
$cellDataType = $cellData_ss['Type']; $cellDataType = $cellData_ss['Type'];
@ -641,33 +634,33 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
*/ */
case 'String' : case 'String' :
$cellValue = self::_convertStringEncoding($cellValue,$this->_charSet); $cellValue = self::_convertStringEncoding($cellValue,$this->_charSet);
$type = PHPExcel_Cell_DataType::TYPE_STRING; $type = Cell_DataType::TYPE_STRING;
break; break;
case 'Number' : case 'Number' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = Cell_DataType::TYPE_NUMERIC;
$cellValue = (float) $cellValue; $cellValue = (float) $cellValue;
if (floor($cellValue) == $cellValue) { if (floor($cellValue) == $cellValue) {
$cellValue = (integer) $cellValue; $cellValue = (integer) $cellValue;
} }
break; break;
case 'Boolean' : case 'Boolean' :
$type = PHPExcel_Cell_DataType::TYPE_BOOL; $type = Cell_DataType::TYPE_BOOL;
$cellValue = ($cellValue != 0); $cellValue = ($cellValue != 0);
break; break;
case 'DateTime' : case 'DateTime' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = Cell_DataType::TYPE_NUMERIC;
$cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue)); $cellValue = Shared_Date::PHPToExcel(strtotime($cellValue));
break; break;
case 'Error' : case 'Error' :
$type = PHPExcel_Cell_DataType::TYPE_ERROR; $type = Cell_DataType::TYPE_ERROR;
break; break;
} }
} }
if ($hasCalculatedValue) { if ($hasCalculatedValue) {
// echo 'FORMULA<br />'; // echo 'FORMULA<br />';
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = Cell_DataType::TYPE_FORMULA;
$columnNumber = PHPExcel_Cell::columnIndexFromString($columnID); $columnNumber = Cell::columnIndexFromString($columnID);
if (substr($cellDataFormula,0,3) == 'of:') { if (substr($cellDataFormula,0,3) == 'of:') {
$cellDataFormula = substr($cellDataFormula,3); $cellDataFormula = substr($cellDataFormula,3);
// echo 'Before: ',$cellDataFormula,'<br />'; // echo 'Before: ',$cellDataFormula,'<br />';
@ -705,7 +698,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
if ($columnReference == '') $columnReference = $columnNumber; if ($columnReference == '') $columnReference = $columnNumber;
// Bracketed C references are relative to the current column // Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]'); if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]');
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; $A1CellReference = Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0])); $value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
} }
} }
@ -785,14 +778,14 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
private static function _convertStringEncoding($string,$charset) { private static function _convertStringEncoding($string,$charset) {
if ($charset != 'UTF-8') { if ($charset != 'UTF-8') {
return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8',$charset); return Shared_String::ConvertEncoding($string,'UTF-8',$charset);
} }
return $string; return $string;
} }
private function _parseRichText($is = '') { private function _parseRichText($is = '') {
$value = new PHPExcel_RichText(); $value = new RichText();
$value->createText(self::_convertStringEncoding($is,$this->_charSet)); $value->createText(self::_convertStringEncoding($is,$this->_charSet));

View File

@ -19,72 +19,65 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Reader_Excel2007 * PHPExcel\Reader_Excel2007
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class Reader_Excel2007 extends Reader_Abstract implements Reader_IReader
{ {
/** /**
* PHPExcel_ReferenceHelper instance * PHPExcel\ReferenceHelper instance
* *
* @var PHPExcel_ReferenceHelper * @var PHPExcel\ReferenceHelper
*/ */
private $_referenceHelper = NULL; private $_referenceHelper = NULL;
/** /**
* PHPExcel_Reader_Excel2007_Theme instance * PHPExcel\Reader_Excel2007_Theme instance
* *
* @var PHPExcel_Reader_Excel2007_Theme * @var PHPExcel\Reader_Excel2007_Theme
*/ */
private static $_theme = NULL; private static $_theme = NULL;
/** /**
* Create a new PHPExcel_Reader_Excel2007 instance * Create a new PHPExcel\Reader_Excel2007 instance
*/ */
public function __construct() { public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new Reader_DefaultReadFilter();
$this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance(); $this->_referenceHelper = ReferenceHelper::getInstance();
} }
/** /**
* Can the current PHPExcel_Reader_IReader read the file? * Can the current PHPExcel\Reader_IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return boolean * @return boolean
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function canRead($pFilename) public function canRead($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
// Check if zip class exists // Check if zip class exists
if (!class_exists('ZipArchive',FALSE)) { if (!class_exists('ZipArchive',FALSE)) {
throw new PHPExcel_Reader_Exception("ZipArchive library is not enabled"); throw new Reader_Exception("ZipArchive library is not enabled");
} }
$xl = false; $xl = false;
@ -116,13 +109,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetNames($pFilename) public function listWorksheetNames($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$worksheetNames = array(); $worksheetNames = array();
@ -160,13 +153,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$worksheetInfo = array(); $worksheetInfo = array();
@ -203,7 +196,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$xml = new XMLReader(); $xml = new XMLReader();
$res = $xml->open('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet"); $res = $xml->open('zip://' . Shared_File::realpath($pFilename) . '#' . "$dir/$fileWorksheet");
$xml->setParserProperty(2,true); $xml->setParserProperty(2,true);
$currCells = 0; $currCells = 0;
@ -221,7 +214,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$xml->close(); $xml->close();
$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1; $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $tmpInfo['lastColumnLetter'] = Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$worksheetInfo[] = $tmpInfo; $worksheetInfo[] = $tmpInfo;
} }
@ -292,11 +285,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// echo 'GETTING SHARED FORMULA<br />'; // echo 'GETTING SHARED FORMULA<br />';
// echo 'Master is '.$sharedFormulas[$instance]['master'].'<br />'; // echo 'Master is '.$sharedFormulas[$instance]['master'].'<br />';
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].'<br />'; // echo 'Formula is '.$sharedFormulas[$instance]['formula'].'<br />';
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']); $master = Cell::coordinateFromString($sharedFormulas[$instance]['master']);
$current = PHPExcel_Cell::coordinateFromString($r); $current = Cell::coordinateFromString($r);
$difference = array(0, 0); $difference = array(0, 0);
$difference[0] = PHPExcel_Cell::columnIndexFromString($current[0]) - PHPExcel_Cell::columnIndexFromString($master[0]); $difference[0] = Cell::columnIndexFromString($current[0]) - Cell::columnIndexFromString($master[0]);
$difference[1] = $current[1] - $master[1]; $difference[1] = $current[1] - $master[1];
$value = $this->_referenceHelper->updateFormulaReferences( $sharedFormulas[$instance]['formula'], $value = $this->_referenceHelper->updateFormulaReferences( $sharedFormulas[$instance]['formula'],
@ -317,7 +310,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
{ {
$fileName = substr($fileName, strpos($fileName, '//') + 1); $fileName = substr($fileName, strpos($fileName, '//') + 1);
} }
$fileName = PHPExcel_Shared_File::realpath($fileName); $fileName = Shared_File::realpath($fileName);
// Apache POI fixes // Apache POI fixes
$contents = $archive->getFromName($fileName); $contents = $archive->getFromName($fileName);
@ -334,17 +327,17 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
* Loads PHPExcel from file * Loads PHPExcel from file
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function load($pFilename) public function load($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
// Initialisations // Initialisations
$excel = new PHPExcel; $excel = new Workbook();
$excel->removeSheetByIndex(0); $excel->removeSheetByIndex(0);
if (!$this->_readDataOnly) { if (!$this->_readDataOnly) {
$excel->removeCellStyleXfByIndex(0); // remove the default style $excel->removeCellStyleXfByIndex(0); // remove the default style
@ -385,7 +378,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$themeColours[$themePos] = $xmlColourData['val']; $themeColours[$themePos] = $xmlColourData['val'];
} }
} }
self::$_theme = new PHPExcel_Reader_Excel2007_Theme($themeName,$colourSchemeName,$themeColours); self::$_theme = new Reader_Excel2007_Theme($themeName,$colourSchemeName,$themeColours);
} }
break; break;
} }
@ -435,8 +428,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); $cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
$attributeType = $cellDataOfficeChildren->getName(); $attributeType = $cellDataOfficeChildren->getName();
$attributeValue = (string) $cellDataOfficeChildren->{$attributeType}; $attributeValue = (string) $cellDataOfficeChildren->{$attributeType};
$attributeValue = PHPExcel_DocumentProperties::convertProperty($attributeValue,$attributeType); $attributeValue = DocumentProperties::convertProperty($attributeValue,$attributeType);
$attributeType = PHPExcel_DocumentProperties::convertPropertyType($attributeType); $attributeType = DocumentProperties::convertPropertyType($attributeType);
$docProps->setCustomProperty($propertyName,$attributeValue,$attributeType); $docProps->setCustomProperty($propertyName,$attributeValue,$attributeType);
} }
} }
@ -454,7 +447,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($xmlStrings) && isset($xmlStrings->si)) { if (isset($xmlStrings) && isset($xmlStrings->si)) {
foreach ($xmlStrings->si as $val) { foreach ($xmlStrings->si as $val) {
if (isset($val->t)) { if (isset($val->t)) {
$sharedStrings[] = PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $val->t ); $sharedStrings[] = Shared_String::ControlCharacterOOXML2PHP( (string) $val->t );
} elseif (isset($val->r)) { } elseif (isset($val->r)) {
$sharedStrings[] = $this->_parseRichText($val); $sharedStrings[] = $this->_parseRichText($val);
} }
@ -481,7 +474,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
if (!$this->_readDataOnly && $xmlStyles) { if (!$this->_readDataOnly && $xmlStyles) {
foreach ($xmlStyles->cellXfs->xf as $xf) { foreach ($xmlStyles->cellXfs->xf as $xf) {
$numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; $numFmt = Style_NumberFormat::FORMAT_GENERAL;
if ($xf["numFmtId"]) { if ($xf["numFmtId"]) {
if (isset($numFmts)) { if (isset($numFmts)) {
@ -493,7 +486,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
if ((int)$xf["numFmtId"] < 164) { if ((int)$xf["numFmtId"] < 164) {
$numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]); $numFmt = Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
} }
} }
//$numFmt = str_replace('mm', 'i', $numFmt); //$numFmt = str_replace('mm', 'i', $numFmt);
@ -510,19 +503,19 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$styles[] = $style; $styles[] = $style;
// add style to cellXf collection // add style to cellXf collection
$objStyle = new PHPExcel_Style; $objStyle = new Style;
self::_readStyle($objStyle, $style); self::_readStyle($objStyle, $style);
$excel->addCellXf($objStyle); $excel->addCellXf($objStyle);
} }
foreach ($xmlStyles->cellStyleXfs->xf as $xf) { foreach ($xmlStyles->cellStyleXfs->xf as $xf) {
$numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; $numFmt = Style_NumberFormat::FORMAT_GENERAL;
if ($numFmts && $xf["numFmtId"]) { if ($numFmts && $xf["numFmtId"]) {
$tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]")); $tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]"));
if (isset($tmpNumFmt["formatCode"])) { if (isset($tmpNumFmt["formatCode"])) {
$numFmt = (string) $tmpNumFmt["formatCode"]; $numFmt = (string) $tmpNumFmt["formatCode"];
} else if ((int)$xf["numFmtId"] < 165) { } else if ((int)$xf["numFmtId"] < 165) {
$numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]); $numFmt = Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
} }
} }
@ -537,7 +530,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$cellStyles[] = $cellStyle; $cellStyles[] = $cellStyle;
// add style to cellStyleXf collection // add style to cellStyleXf collection
$objStyle = new PHPExcel_Style; $objStyle = new Style;
self::_readStyle($objStyle, $cellStyle); self::_readStyle($objStyle, $cellStyle);
$excel->addCellStyleXf($objStyle); $excel->addCellStyleXf($objStyle);
} }
@ -548,7 +541,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Conditional Styles // Conditional Styles
if ($xmlStyles->dxfs) { if ($xmlStyles->dxfs) {
foreach ($xmlStyles->dxfs->dxf as $dxf) { foreach ($xmlStyles->dxfs->dxf as $dxf) {
$style = new PHPExcel_Style(FALSE, TRUE); $style = new Style(FALSE, TRUE);
self::_readStyle($style, $dxf); self::_readStyle($style, $dxf);
$dxfs[] = $style; $dxfs[] = $style;
} }
@ -559,7 +552,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (intval($cellStyle['builtinId']) == 0) { if (intval($cellStyle['builtinId']) == 0) {
if (isset($cellStyles[intval($cellStyle['xfId'])])) { if (isset($cellStyles[intval($cellStyle['xfId'])])) {
// Set default style // Set default style
$style = new PHPExcel_Style; $style = new Style;
self::_readStyle($style, $cellStyles[intval($cellStyle['xfId'])]); self::_readStyle($style, $cellStyles[intval($cellStyle['xfId'])]);
// normal style, currently not using it for anything // normal style, currently not using it for anything
@ -573,10 +566,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Set base date // Set base date
if ($xmlWorkbook->workbookPr) { if ($xmlWorkbook->workbookPr) {
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); Shared_Date::setExcelCalendar(Shared_Date::CALENDAR_WINDOWS_1900);
if (isset($xmlWorkbook->workbookPr['date1904'])) { if (isset($xmlWorkbook->workbookPr['date1904'])) {
if (self::boolean((string) $xmlWorkbook->workbookPr['date1904'])) { if (self::boolean((string) $xmlWorkbook->workbookPr['date1904'])) {
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); Shared_Date::setExcelCalendar(Shared_Date::CALENDAR_MAC_1904);
} }
} }
} }
@ -725,21 +718,21 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
foreach ($xmlSheet->cols->col as $col) { foreach ($xmlSheet->cols->col as $col) {
for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) { for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) {
if ($col["style"] && !$this->_readDataOnly) { if ($col["style"] && !$this->_readDataOnly) {
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"])); $docSheet->getColumnDimension(Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"]));
} }
if (self::boolean($col["bestFit"])) { if (self::boolean($col["bestFit"])) {
//$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(TRUE); //$docSheet->getColumnDimension(Cell::stringFromColumnIndex($i))->setAutoSize(TRUE);
} }
if (self::boolean($col["hidden"])) { if (self::boolean($col["hidden"])) {
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE); $docSheet->getColumnDimension(Cell::stringFromColumnIndex($i))->setVisible(FALSE);
} }
if (self::boolean($col["collapsed"])) { if (self::boolean($col["collapsed"])) {
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(TRUE); $docSheet->getColumnDimension(Cell::stringFromColumnIndex($i))->setCollapsed(TRUE);
} }
if ($col["outlineLevel"] > 0) { if ($col["outlineLevel"] > 0) {
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"])); $docSheet->getColumnDimension(Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));
} }
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"])); $docSheet->getColumnDimension(Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"]));
if (intval($col["max"]) == 16384) { if (intval($col["max"]) == 16384) {
break; break;
@ -791,7 +784,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Read cell? // Read cell?
if ($this->getReadFilter() !== NULL) { if ($this->getReadFilter() !== NULL) {
$coordinates = PHPExcel_Cell::coordinateFromString($r); $coordinates = Cell::coordinateFromString($r);
if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) { if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) {
continue; continue;
@ -810,7 +803,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ((string)$c->v != '') { if ((string)$c->v != '') {
$value = $sharedStrings[intval($c->v)]; $value = $sharedStrings[intval($c->v)];
if ($value instanceof PHPExcel_RichText) { if ($value instanceof RichText) {
$value = clone $value; $value = clone $value;
} }
} else { } else {
@ -874,7 +867,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
// Rich text? // Rich text?
if ($value instanceof PHPExcel_RichText && $this->_readDataOnly) { if ($value instanceof RichText && $this->_readDataOnly) {
$value = $value->getPlainText(); $value = $value->getPlainText();
} }
@ -905,10 +898,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
foreach ($conditional->cfRule as $cfRule) { foreach ($conditional->cfRule as $cfRule) {
if ( if (
( (
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE || (string)$cfRule["type"] == Style_Conditional::CONDITION_NONE ||
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS || (string)$cfRule["type"] == Style_Conditional::CONDITION_CELLIS ||
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || (string)$cfRule["type"] == Style_Conditional::CONDITION_CONTAINSTEXT ||
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION (string)$cfRule["type"] == Style_Conditional::CONDITION_EXPRESSION
) && isset($dxfs[intval($cfRule["dxfId"])]) ) && isset($dxfs[intval($cfRule["dxfId"])])
) { ) {
$conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])] = $cfRule; $conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])] = $cfRule;
@ -920,7 +913,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
ksort($cfRules); ksort($cfRules);
$conditionalStyles = array(); $conditionalStyles = array();
foreach ($cfRules as $cfRule) { foreach ($cfRules as $cfRule) {
$objConditional = new PHPExcel_Style_Conditional(); $objConditional = new Style_Conditional();
$objConditional->setConditionType((string)$cfRule["type"]); $objConditional->setConditionType((string)$cfRule["type"]);
$objConditional->setOperatorType((string)$cfRule["operator"]); $objConditional->setOperatorType((string)$cfRule["operator"]);
@ -940,7 +933,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
// Extract all cell references in $ref // Extract all cell references in $ref
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($ref); $aReferences = Cell::extractAllCellReferencesInRange($ref);
foreach ($aReferences as $reference) { foreach ($aReferences as $reference) {
$docSheet->getStyle($reference)->setConditionalStyles($conditionalStyles); $docSheet->getStyle($reference)->setConditionalStyles($conditionalStyles);
} }
@ -971,14 +964,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$column = $autoFilter->getColumnByOffset((integer) $filterColumn["colId"]); $column = $autoFilter->getColumnByOffset((integer) $filterColumn["colId"]);
// Check for standard filters // Check for standard filters
if ($filterColumn->filters) { if ($filterColumn->filters) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER); $column->setFilterType(Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER);
$filters = $filterColumn->filters; $filters = $filterColumn->filters;
if ((isset($filters["blank"])) && ($filters["blank"] == 1)) { if ((isset($filters["blank"])) && ($filters["blank"] == 1)) {
$column->createRule()->setRule( $column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL NULL, // Operator is undefined, but always treated as EQUAL
'' ''
) )
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); ->setRuleType(Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
} }
// Standard filters are always an OR join, so no join rule needs to be set // Standard filters are always an OR join, so no join rule needs to be set
// Entries can be either filter elements // Entries can be either filter elements
@ -987,7 +980,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
NULL, // Operator is undefined, but always treated as EQUAL NULL, // Operator is undefined, but always treated as EQUAL
(string) $filterRule["val"] (string) $filterRule["val"]
) )
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); ->setRuleType(Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
} }
// Or Date Group elements // Or Date Group elements
foreach ($filters->dateGroupItem as $dateGroupItem) { foreach ($filters->dateGroupItem as $dateGroupItem) {
@ -1003,29 +996,29 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
), ),
(string) $dateGroupItem["dateTimeGrouping"] (string) $dateGroupItem["dateTimeGrouping"]
) )
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP); ->setRuleType(Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP);
} }
} }
// Check for custom filters // Check for custom filters
if ($filterColumn->customFilters) { if ($filterColumn->customFilters) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); $column->setFilterType(Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER);
$customFilters = $filterColumn->customFilters; $customFilters = $filterColumn->customFilters;
// Custom filters can an AND or an OR join; // Custom filters can an AND or an OR join;
// and there should only ever be one or two entries // and there should only ever be one or two entries
if ((isset($customFilters["and"])) && ($customFilters["and"] == 1)) { if ((isset($customFilters["and"])) && ($customFilters["and"] == 1)) {
$column->setJoin(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND); $column->setJoin(Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND);
} }
foreach ($customFilters->customFilter as $filterRule) { foreach ($customFilters->customFilter as $filterRule) {
$column->createRule()->setRule( $column->createRule()->setRule(
(string) $filterRule["operator"], (string) $filterRule["operator"],
(string) $filterRule["val"] (string) $filterRule["val"]
) )
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); ->setRuleType(Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
} }
} }
// Check for dynamic filters // Check for dynamic filters
if ($filterColumn->dynamicFilter) { if ($filterColumn->dynamicFilter) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); $column->setFilterType(Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
// We should only ever have one dynamic filter // We should only ever have one dynamic filter
foreach ($filterColumn->dynamicFilter as $filterRule) { foreach ($filterColumn->dynamicFilter as $filterRule) {
$column->createRule()->setRule( $column->createRule()->setRule(
@ -1033,7 +1026,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
(string) $filterRule["val"], (string) $filterRule["val"],
(string) $filterRule["type"] (string) $filterRule["type"]
) )
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); ->setRuleType(Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER);
if (isset($filterRule["val"])) { if (isset($filterRule["val"])) {
$column->setAttribute('val',(string) $filterRule["val"]); $column->setAttribute('val',(string) $filterRule["val"]);
} }
@ -1044,21 +1037,21 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
// Check for dynamic filters // Check for dynamic filters
if ($filterColumn->top10) { if ($filterColumn->top10) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); $column->setFilterType(Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER);
// We should only ever have one top10 filter // We should only ever have one top10 filter
foreach ($filterColumn->top10 as $filterRule) { foreach ($filterColumn->top10 as $filterRule) {
$column->createRule()->setRule( $column->createRule()->setRule(
(((isset($filterRule["percent"])) && ($filterRule["percent"] == 1)) (((isset($filterRule["percent"])) && ($filterRule["percent"] == 1))
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT ? Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT
: PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE : Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE
), ),
(string) $filterRule["val"], (string) $filterRule["val"],
(((isset($filterRule["top"])) && ($filterRule["top"] == 1)) (((isset($filterRule["top"])) && ($filterRule["top"] == 1))
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP ? Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP
: PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM : Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM
) )
) )
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER); ->setRuleType(Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER);
} }
} }
} }
@ -1146,14 +1139,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->_readDataOnly) {
foreach ($xmlSheet->rowBreaks->brk as $brk) { foreach ($xmlSheet->rowBreaks->brk as $brk) {
if ($brk["man"]) { if ($brk["man"]) {
$docSheet->setBreak("A$brk[id]", PHPExcel_Worksheet::BREAK_ROW); $docSheet->setBreak("A$brk[id]", Worksheet::BREAK_ROW);
} }
} }
} }
if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->_readDataOnly) {
foreach ($xmlSheet->colBreaks->brk as $brk) { foreach ($xmlSheet->colBreaks->brk as $brk) {
if ($brk["man"]) { if ($brk["man"]) {
$docSheet->setBreak(PHPExcel_Cell::stringFromColumnIndex((string) $brk["id"]) . "1", PHPExcel_Worksheet::BREAK_COLUMN); $docSheet->setBreak(Cell::stringFromColumnIndex((string) $brk["id"]) . "1", Worksheet::BREAK_COLUMN);
} }
} }
} }
@ -1167,7 +1160,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$stRange = $docSheet->shrinkRangeToFit($range); $stRange = $docSheet->shrinkRangeToFit($range);
// Extract all cell references in $range // Extract all cell references in $range
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($stRange); $aReferences = Cell::extractAllCellReferencesInRange($stRange);
foreach ($aReferences as $reference) { foreach ($aReferences as $reference) {
// Create validation // Create validation
$docValidation = $docSheet->getCell($reference)->getDataValidation(); $docValidation = $docSheet->getCell($reference)->getDataValidation();
@ -1208,7 +1201,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Link url // Link url
$linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships');
foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { foreach (Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) {
$cell = $docSheet->getCell( $cellReference ); $cell = $docSheet->getCell( $cellReference );
if (isset($linkRel['id'])) { if (isset($linkRel['id'])) {
$hyperlinkUrl = $hyperlinks[ (string)$linkRel['id'] ]; $hyperlinkUrl = $hyperlinks[ (string)$linkRel['id'] ];
@ -1249,7 +1242,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Loop through comments // Loop through comments
foreach ($comments as $relName => $relPath) { foreach ($comments as $relName => $relPath) {
// Load comments file // Load comments file
$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); $relPath = Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath);
$commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath) ); $commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath) );
// Utility variables // Utility variables
@ -1270,7 +1263,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Loop through VML comments // Loop through VML comments
foreach ($vmlComments as $relName => $relPath) { foreach ($vmlComments as $relName => $relPath) {
// Load VML comments file // Load VML comments file
$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); $relPath = Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath);
$vmlCommentsFile = simplexml_load_string( $this->_getFromZipArchive($zip, $relPath) ); $vmlCommentsFile = simplexml_load_string( $this->_getFromZipArchive($zip, $relPath) );
$vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
@ -1356,12 +1349,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office'); $imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office');
$style = self::toCSSArray( (string)$shape['style'] ); $style = self::toCSSArray( (string)$shape['style'] );
$hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing(); $hfImages[ (string)$shape['id'] ] = new Worksheet_HeaderFooterDrawing();
if (isset($imageData['title'])) { if (isset($imageData['title'])) {
$hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] ); $hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] );
} }
$hfImages[ (string)$shape['id'] ]->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false); $hfImages[ (string)$shape['id'] ]->setPath("zip://".Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false);
$hfImages[ (string)$shape['id'] ]->setResizeProportional(false); $hfImages[ (string)$shape['id'] ]->setResizeProportional(false);
$hfImages[ (string)$shape['id'] ]->setWidth($style['width']); $hfImages[ (string)$shape['id'] ]->setWidth($style['width']);
$hfImages[ (string)$shape['id'] ]->setHeight($style['height']); $hfImages[ (string)$shape['id'] ]->setHeight($style['height']);
@ -1413,25 +1406,25 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$blip = $oneCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip; $blip = $oneCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
$xfrm = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm; $xfrm = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
$outerShdw = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw; $outerShdw = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
$objDrawing = new PHPExcel_Worksheet_Drawing; $objDrawing = new Worksheet_Drawing;
$objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name")); $objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr")); $objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
$objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setPath("zip://".Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1)); $objDrawing->setCoordinates(Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1));
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff)); $objDrawing->setOffsetX(Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff)); $objDrawing->setOffsetY(Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff));
$objDrawing->setResizeProportional(false); $objDrawing->setResizeProportional(false);
$objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx"))); $objDrawing->setWidth(Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx")));
$objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy"))); $objDrawing->setHeight(Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy")));
if ($xfrm) { if ($xfrm) {
$objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot"))); $objDrawing->setRotation(Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot")));
} }
if ($outerShdw) { if ($outerShdw) {
$shadow = $objDrawing->getShadow(); $shadow = $objDrawing->getShadow();
$shadow->setVisible(true); $shadow->setVisible(true);
$shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "blurRad"))); $shadow->setBlurRadius(Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "blurRad")));
$shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "dist"))); $shadow->setDistance(Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "dist")));
$shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes(), "dir"))); $shadow->setDirection(Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes(), "dir")));
$shadow->setAlignment((string) self::array_item($outerShdw->attributes(), "algn")); $shadow->setAlignment((string) self::array_item($outerShdw->attributes(), "algn"));
$shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(), "val")); $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(), "val"));
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000); $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
@ -1439,11 +1432,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$objDrawing->setWorksheet($docSheet); $objDrawing->setWorksheet($docSheet);
} else { } else {
// ? Can charts be positioned with a oneCellAnchor ? // ? Can charts be positioned with a oneCellAnchor ?
$coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1); $coordinates = Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1);
$offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff); $offsetX = Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff);
$offsetY = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff); $offsetY = Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff);
$width = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx")); $width = Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx"));
$height = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy")); $height = Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy"));
} }
} }
} }
@ -1453,39 +1446,39 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$blip = $twoCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip; $blip = $twoCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
$xfrm = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm; $xfrm = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
$outerShdw = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw; $outerShdw = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
$objDrawing = new PHPExcel_Worksheet_Drawing; $objDrawing = new Worksheet_Drawing;
$objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name")); $objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr")); $objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
$objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setPath("zip://".Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1)); $objDrawing->setCoordinates(Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1));
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff)); $objDrawing->setOffsetX(Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff)); $objDrawing->setOffsetY(Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff));
$objDrawing->setResizeProportional(false); $objDrawing->setResizeProportional(false);
$objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx"))); $objDrawing->setWidth(Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx")));
$objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cy"))); $objDrawing->setHeight(Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cy")));
if ($xfrm) { if ($xfrm) {
$objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot"))); $objDrawing->setRotation(Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot")));
} }
if ($outerShdw) { if ($outerShdw) {
$shadow = $objDrawing->getShadow(); $shadow = $objDrawing->getShadow();
$shadow->setVisible(true); $shadow->setVisible(true);
$shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "blurRad"))); $shadow->setBlurRadius(Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "blurRad")));
$shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "dist"))); $shadow->setDistance(Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "dist")));
$shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes(), "dir"))); $shadow->setDirection(Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes(), "dir")));
$shadow->setAlignment((string) self::array_item($outerShdw->attributes(), "algn")); $shadow->setAlignment((string) self::array_item($outerShdw->attributes(), "algn"));
$shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(), "val")); $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(), "val"));
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000); $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
} }
$objDrawing->setWorksheet($docSheet); $objDrawing->setWorksheet($docSheet);
} elseif(($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) { } elseif(($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) {
$fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1); $fromCoordinate = Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);
$fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff); $fromOffsetX = Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);
$fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff); $fromOffsetY = Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff);
$toCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->to->col) . ($twoCellAnchor->to->row + 1); $toCoordinate = Cell::stringFromColumnIndex((string) $twoCellAnchor->to->col) . ($twoCellAnchor->to->row + 1);
$toOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->to->colOff); $toOffsetX = Shared_Drawing::EMUToPixels($twoCellAnchor->to->colOff);
$toOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->to->rowOff); $toOffsetY = Shared_Drawing::EMUToPixels($twoCellAnchor->to->rowOff);
$graphic = $twoCellAnchor->graphicFrame->children("http://schemas.openxmlformats.org/drawingml/2006/main")->graphic; $graphic = $twoCellAnchor->graphicFrame->children("http://schemas.openxmlformats.org/drawingml/2006/main")->graphic;
$chartRef = $graphic->graphicData->children("http://schemas.openxmlformats.org/drawingml/2006/chart")->chart; $chartRef = $graphic->graphicData->children("http://schemas.openxmlformats.org/drawingml/2006/chart")->chart;
$thisChart = (string) $chartRef->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"); $thisChart = (string) $chartRef->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships");
@ -1617,7 +1610,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) { if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]); $extractedRange = str_replace('$', '', $range[1]);
$scope = $docSheet->getParent()->getSheet($mapSheetId[(integer) $definedName['localSheetId']]); $scope = $docSheet->getParent()->getSheet($mapSheetId[(integer) $definedName['localSheetId']]);
$excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) ); $excel->addNamedRange( new NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) );
} }
} }
} }
@ -1629,7 +1622,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$extractedSheetName = ''; $extractedSheetName = '';
if (strpos( (string)$definedName, '!' ) !== false) { if (strpos( (string)$definedName, '!' ) !== false) {
// Extract sheet name // Extract sheet name
$extractedSheetName = PHPExcel_Worksheet::extractSheetTitle( (string)$definedName, true ); $extractedSheetName = Worksheet::extractSheetTitle( (string)$definedName, true );
$extractedSheetName = $extractedSheetName[0]; $extractedSheetName = $extractedSheetName[0];
// Locate sheet // Locate sheet
@ -1641,7 +1634,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
if ($locatedSheet !== NULL) { if ($locatedSheet !== NULL) {
$excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) ); $excel->addNamedRange( new NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) );
} }
} }
} }
@ -1676,7 +1669,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($this->_includeCharts) { if ($this->_includeCharts) {
$chartEntryRef = ltrim($contentType['PartName'],'/'); $chartEntryRef = ltrim($contentType['PartName'],'/');
$chartElements = simplexml_load_string($this->_getFromZipArchive($zip, $chartEntryRef)); $chartElements = simplexml_load_string($this->_getFromZipArchive($zip, $chartEntryRef));
$objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml')); $objChart = Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml'));
// echo 'Chart ',$chartEntryRef,'<br />'; // echo 'Chart ',$chartEntryRef,'<br />';
// var_dump($charts[$chartEntryRef]); // var_dump($charts[$chartEntryRef]);
@ -1714,13 +1707,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($color["rgb"])) { if (isset($color["rgb"])) {
return (string)$color["rgb"]; return (string)$color["rgb"];
} else if (isset($color["indexed"])) { } else if (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB(); return Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB();
} else if (isset($color["theme"])) { } else if (isset($color["theme"])) {
if (self::$_theme !== NULL) { if (self::$_theme !== NULL) {
$returnColour = self::$_theme->getColourByIndex((int)$color["theme"]); $returnColour = self::$_theme->getColourByIndex((int)$color["theme"]);
if (isset($color["tint"])) { if (isset($color["tint"])) {
$tintAdjust = (float) $color["tint"]; $tintAdjust = (float) $color["tint"];
$returnColour = PHPExcel_Style_Color::changeBrightness($returnColour, $tintAdjust); $returnColour = Style_Color::changeBrightness($returnColour, $tintAdjust);
} }
return 'FF'.$returnColour; return 'FF'.$returnColour;
} }
@ -1759,7 +1752,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$docStyle->getFont()->getColor()->setARGB(self::_readColor($style->font->color)); $docStyle->getFont()->getColor()->setARGB(self::_readColor($style->font->color));
if (isset($style->font->u) && !isset($style->font->u["val"])) { if (isset($style->font->u) && !isset($style->font->u["val"])) {
$docStyle->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); $docStyle->getFont()->setUnderline(Style_Font::UNDERLINE_SINGLE);
} else if (isset($style->font->u) && isset($style->font->u["val"])) { } else if (isset($style->font->u) && isset($style->font->u["val"])) {
$docStyle->getFont()->setUnderline((string)$style->font->u["val"]); $docStyle->getFont()->setUnderline((string)$style->font->u["val"]);
} }
@ -1805,13 +1798,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$diagonalUp = self::boolean((string) $style->border["diagonalUp"]); $diagonalUp = self::boolean((string) $style->border["diagonalUp"]);
$diagonalDown = self::boolean((string) $style->border["diagonalDown"]); $diagonalDown = self::boolean((string) $style->border["diagonalDown"]);
if (!$diagonalUp && !$diagonalDown) { if (!$diagonalUp && !$diagonalDown) {
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_NONE); $docStyle->getBorders()->setDiagonalDirection(Style_Borders::DIAGONAL_NONE);
} elseif ($diagonalUp && !$diagonalDown) { } elseif ($diagonalUp && !$diagonalDown) {
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP); $docStyle->getBorders()->setDiagonalDirection(Style_Borders::DIAGONAL_UP);
} elseif (!$diagonalUp && $diagonalDown) { } elseif (!$diagonalUp && $diagonalDown) {
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN); $docStyle->getBorders()->setDiagonalDirection(Style_Borders::DIAGONAL_DOWN);
} else { } else {
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH); $docStyle->getBorders()->setDiagonalDirection(Style_Borders::DIAGONAL_BOTH);
} }
self::_readBorder($docStyle->getBorders()->getLeft(), $style->border->left); self::_readBorder($docStyle->getBorders()->getLeft(), $style->border->left);
self::_readBorder($docStyle->getBorders()->getRight(), $style->border->right); self::_readBorder($docStyle->getBorders()->getRight(), $style->border->right);
@ -1842,17 +1835,17 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($style->protection)) { if (isset($style->protection)) {
if (isset($style->protection['locked'])) { if (isset($style->protection['locked'])) {
if (self::boolean((string) $style->protection['locked'])) { if (self::boolean((string) $style->protection['locked'])) {
$docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_PROTECTED); $docStyle->getProtection()->setLocked(Style_Protection::PROTECTION_PROTECTED);
} else { } else {
$docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); $docStyle->getProtection()->setLocked(Style_Protection::PROTECTION_UNPROTECTED);
} }
} }
if (isset($style->protection['hidden'])) { if (isset($style->protection['hidden'])) {
if (self::boolean((string) $style->protection['hidden'])) { if (self::boolean((string) $style->protection['hidden'])) {
$docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_PROTECTED); $docStyle->getProtection()->setHidden(Style_Protection::PROTECTION_PROTECTED);
} else { } else {
$docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); $docStyle->getProtection()->setHidden(Style_Protection::PROTECTION_UNPROTECTED);
} }
} }
} }
@ -1870,17 +1863,17 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
private function _parseRichText($is = null) { private function _parseRichText($is = null) {
$value = new PHPExcel_RichText(); $value = new RichText();
if (isset($is->t)) { if (isset($is->t)) {
$value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) ); $value->createText( Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) );
} else { } else {
foreach ($is->r as $run) { foreach ($is->r as $run) {
if (!isset($run->rPr)) { if (!isset($run->rPr)) {
$objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); $objText = $value->createText( Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) );
} else { } else {
$objText = $value->createTextRun( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); $objText = $value->createTextRun( Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) );
if (isset($run->rPr->rFont["val"])) { if (isset($run->rPr->rFont["val"])) {
$objText->getFont()->setName((string) $run->rPr->rFont["val"]); $objText->getFont()->setName((string) $run->rPr->rFont["val"]);
@ -1891,7 +1884,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
if (isset($run->rPr->color)) { if (isset($run->rPr->color)) {
$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($run->rPr->color) ) ); $objText->getFont()->setColor( new Style_Color( self::_readColor($run->rPr->color) ) );
} }
if ((isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"])) || if ((isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"])) ||
@ -1915,7 +1908,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
if (isset($run->rPr->u) && !isset($run->rPr->u["val"])) { if (isset($run->rPr->u) && !isset($run->rPr->u["val"])) {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); $objText->getFont()->setUnderline(Style_Font::UNDERLINE_SINGLE);
} else if (isset($run->rPr->u) && isset($run->rPr->u["val"])) { } else if (isset($run->rPr->u) && isset($run->rPr->u["val"])) {
$objText->getFont()->setUnderline((string)$run->rPr->u["val"]); $objText->getFont()->setUnderline((string)$run->rPr->u["val"]);
} }
@ -1955,15 +1948,15 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
if (strpos($item[1], 'pt') !== false) { if (strpos($item[1], 'pt') !== false) {
$item[1] = str_replace('pt', '', $item[1]); $item[1] = str_replace('pt', '', $item[1]);
$item[1] = PHPExcel_Shared_Font::fontSizeToPixels($item[1]); $item[1] = Shared_Font::fontSizeToPixels($item[1]);
} }
if (strpos($item[1], 'in') !== false) { if (strpos($item[1], 'in') !== false) {
$item[1] = str_replace('in', '', $item[1]); $item[1] = str_replace('in', '', $item[1]);
$item[1] = PHPExcel_Shared_Font::inchSizeToPixels($item[1]); $item[1] = Shared_Font::inchSizeToPixels($item[1]);
} }
if (strpos($item[1], 'cm') !== false) { if (strpos($item[1], 'cm') !== false) {
$item[1] = str_replace('cm', '', $item[1]); $item[1] = str_replace('cm', '', $item[1]);
$item[1] = PHPExcel_Shared_Font::centimeterSizeToPixels($item[1]); $item[1] = Shared_Font::centimeterSizeToPixels($item[1]);
} }
$style[$item[0]] = $item[1]; $style[$item[0]] = $item[1];

View File

@ -19,20 +19,23 @@
* 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_Reader_Excel2007 * @package PHPExcel\Reader_Excel2007
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Reader_Excel2007_Chart * PHPExcel\Reader_Excel2007_Chart
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader_Excel2007 * @package PHPExcel\Reader_Excel2007
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_Excel2007_Chart class Reader_Excel2007_Chart
{ {
private static function _getAttribute($component, $name, $format) { private static function _getAttribute($component, $name, $format) {
$attributes = $component->attributes(); $attributes = $component->attributes();
@ -55,7 +58,7 @@ class PHPExcel_Reader_Excel2007_Chart
if (isset($color["rgb"])) { if (isset($color["rgb"])) {
return (string)$color["rgb"]; return (string)$color["rgb"];
} else if (isset($color["indexed"])) { } else if (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB(); return Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB();
} }
} }
@ -159,9 +162,9 @@ class PHPExcel_Reader_Excel2007_Chart
} }
} }
if ($plotAreaLayout == NULL) { if ($plotAreaLayout == NULL) {
$plotAreaLayout = new PHPExcel_Chart_Layout(); $plotAreaLayout = new Chart_Layout();
} }
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout,$plotSeries); $plotArea = new Chart_PlotArea($plotAreaLayout,$plotSeries);
self::_setChartAttributes($plotAreaLayout,$plotAttributes); self::_setChartAttributes($plotAreaLayout,$plotAttributes);
break; break;
case "plotVisOnly": case "plotVisOnly":
@ -190,13 +193,13 @@ class PHPExcel_Reader_Excel2007_Chart
break; break;
} }
} }
$legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay); $legend = new Chart_Legend($legendPos, $legendLayout, $legendOverlay);
break; break;
} }
} }
} }
} }
$chart = new PHPExcel_Chart($chartName,$title,$legend,$plotArea,$plotVisOnly,$dispBlanksAs,$XaxisLabel,$YaxisLabel); $chart = new Chart($chartName,$title,$legend,$plotArea,$plotVisOnly,$dispBlanksAs,$XaxisLabel,$YaxisLabel);
return $chart; return $chart;
} // function readChart() } // function readChart()
@ -223,7 +226,7 @@ class PHPExcel_Reader_Excel2007_Chart
} }
} }
return new PHPExcel_Chart_Title($caption, $titleLayout); return new Chart_Title($caption, $titleLayout);
} // function _chartTitle() } // function _chartTitle()
@ -240,7 +243,7 @@ class PHPExcel_Reader_Excel2007_Chart
// echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL; // echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL;
$layout[$detailKey] = self::_getAttribute($detail, 'val', 'string'); $layout[$detailKey] = self::_getAttribute($detail, 'val', 'string');
} }
return new PHPExcel_Chart_Layout($layout); return new Chart_Layout($layout);
} // function _chartLayoutDetails() } // function _chartLayoutDetails()
@ -291,7 +294,7 @@ class PHPExcel_Reader_Excel2007_Chart
} }
} }
} }
return new PHPExcel_Chart_DataSeries($plotType,$multiSeriesType,$plotOrder,$seriesLabel,$seriesCategory,$seriesValues,$smoothLine); return new Chart_DataSeries($plotType,$multiSeriesType,$plotOrder,$seriesLabel,$seriesCategory,$seriesValues,$smoothLine);
} // function _chartDataSeries() } // function _chartDataSeries()
@ -300,24 +303,24 @@ class PHPExcel_Reader_Excel2007_Chart
$seriesSource = (string) $seriesDetail->strRef->f; $seriesSource = (string) $seriesDetail->strRef->f;
$seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s');
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
} elseif (isset($seriesDetail->numRef)) { } elseif (isset($seriesDetail->numRef)) {
$seriesSource = (string) $seriesDetail->numRef->f; $seriesSource = (string) $seriesDetail->numRef->f;
$seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c'])); $seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
return new PHPExcel_Chart_DataSeriesValues('Number',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new Chart_DataSeriesValues('Number',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
} elseif (isset($seriesDetail->multiLvlStrRef)) { } elseif (isset($seriesDetail->multiLvlStrRef)) {
$seriesSource = (string) $seriesDetail->multiLvlStrRef->f; $seriesSource = (string) $seriesDetail->multiLvlStrRef->f;
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s');
$seriesData['pointCount'] = count($seriesData['dataValues']); $seriesData['pointCount'] = count($seriesData['dataValues']);
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
} elseif (isset($seriesDetail->multiLvlNumRef)) { } elseif (isset($seriesDetail->multiLvlNumRef)) {
$seriesSource = (string) $seriesDetail->multiLvlNumRef->f; $seriesSource = (string) $seriesDetail->multiLvlNumRef->f;
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s');
$seriesData['pointCount'] = count($seriesData['dataValues']); $seriesData['pointCount'] = count($seriesData['dataValues']);
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
} }
return null; return null;
} // function _chartDataSeriesValueSet() } // function _chartDataSeriesValueSet()
@ -391,7 +394,7 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _chartDataSeriesValuesMultiLevel() } // function _chartDataSeriesValuesMultiLevel()
private static function _parseRichText($titleDetailPart = null) { private static function _parseRichText($titleDetailPart = null) {
$value = new PHPExcel_RichText(); $value = new RichText();
foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) { foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
if (isset($titleDetailElement->t)) { if (isset($titleDetailElement->t)) {
@ -409,7 +412,7 @@ class PHPExcel_Reader_Excel2007_Chart
$fontColor = (self::_getAttribute($titleDetailElement->rPr, 'color', 'string')); $fontColor = (self::_getAttribute($titleDetailElement->rPr, 'color', 'string'));
if (!is_null($fontColor)) { if (!is_null($fontColor)) {
$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($fontColor) ) ); $objText->getFont()->setColor( new Style_Color( self::_readColor($fontColor) ) );
} }
$bold = self::_getAttribute($titleDetailElement->rPr, 'b', 'boolean'); $bold = self::_getAttribute($titleDetailElement->rPr, 'b', 'boolean');
@ -434,11 +437,11 @@ class PHPExcel_Reader_Excel2007_Chart
$underscore = (self::_getAttribute($titleDetailElement->rPr, 'u', 'string')); $underscore = (self::_getAttribute($titleDetailElement->rPr, 'u', 'string'));
if (!is_null($underscore)) { if (!is_null($underscore)) {
if ($underscore == 'sng') { if ($underscore == 'sng') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); $objText->getFont()->setUnderline(Style_Font::UNDERLINE_SINGLE);
} elseif($underscore == 'dbl') { } elseif($underscore == 'dbl') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE); $objText->getFont()->setUnderline(Style_Font::UNDERLINE_DOUBLE);
} else { } else {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE); $objText->getFont()->setUnderline(Style_Font::UNDERLINE_NONE);
} }
} }

View File

@ -19,21 +19,23 @@
* 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_Reader_Excel2007 * @package PHPExcel\Reader_Excel2007
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Reader_Excel2007_Theme * PHPExcel\Reader_Excel2007_Theme
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader_Excel2007 * @package PHPExcel\Reader_Excel2007
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_Excel2007_Theme class Reader_Excel2007_Theme
{ {
/** /**
* Theme Name * Theme Name
@ -66,7 +68,7 @@ class PHPExcel_Reader_Excel2007_Theme
/** /**
* Create a new PHPExcel_Theme * Create a new PHPExcel\Theme
* *
*/ */
public function __construct($themeName,$colourSchemeName,$colourMap) public function __construct($themeName,$colourSchemeName,$colourMap)

File diff suppressed because it is too large Load Diff

View File

@ -19,20 +19,23 @@
* 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_Reader_Excel5 * @package PHPExcel\Reader_Excel5
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Reader_Excel5_Escher * PHPExcel\Reader_Excel5_Escher
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader_Excel5 * @package PHPExcel\Reader_Excel5
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_Excel5_Escher class Reader_Excel5_Escher
{ {
const DGGCONTAINER = 0xF000; const DGGCONTAINER = 0xF000;
const BSTORECONTAINER = 0xF001; const BSTORECONTAINER = 0xF001;
@ -82,7 +85,7 @@ class PHPExcel_Reader_Excel5_Escher
private $_object; private $_object;
/** /**
* Create a new PHPExcel_Reader_Excel5_Escher instance * Create a new PHPExcel\Reader_Excel5_Escher instance
* *
* @param mixed $object * @param mixed $object
*/ */
@ -109,7 +112,7 @@ class PHPExcel_Reader_Excel5_Escher
while ($this->_pos < $this->_dataSize) { while ($this->_pos < $this->_dataSize) {
// offset: 2; size: 2: Record Type // offset: 2; size: 2: Record Type
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2); $fbt = Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
switch ($fbt) { switch ($fbt) {
case self::DGGCONTAINER: $this->_readDggContainer(); break; case self::DGGCONTAINER: $this->_readDggContainer(); break;
@ -143,15 +146,15 @@ class PHPExcel_Reader_Excel5_Escher
private function _readDefault() private function _readDefault()
{ {
// offset 0; size: 2; recVer and recInstance // offset 0; size: 2; recVer and recInstance
$verInstance = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos); $verInstance = Reader_Excel5::_GetInt2d($this->_data, $this->_pos);
// offset: 2; size: 2: Record Type // offset: 2; size: 2: Record Type
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2); $fbt = Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
// bit: 0-3; mask: 0x000F; recVer // bit: 0-3; mask: 0x000F; recVer
$recVer = (0x000F & $verInstance) >> 0; $recVer = (0x000F & $verInstance) >> 0;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -163,16 +166,16 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readDggContainer() private function _readDggContainer()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
$this->_pos += 8 + $length; $this->_pos += 8 + $length;
// record is a container, read contents // record is a container, read contents
$dggContainer = new PHPExcel_Shared_Escher_DggContainer(); $dggContainer = new Shared_Escher_DggContainer();
$this->_object->setDggContainer($dggContainer); $this->_object->setDggContainer($dggContainer);
$reader = new PHPExcel_Reader_Excel5_Escher($dggContainer); $reader = new Reader_Excel5_Escher($dggContainer);
$reader->load($recordData); $reader->load($recordData);
} }
@ -181,7 +184,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readDgg() private function _readDgg()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -193,16 +196,16 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readBstoreContainer() private function _readBstoreContainer()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
$this->_pos += 8 + $length; $this->_pos += 8 + $length;
// record is a container, read contents // record is a container, read contents
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer(); $bstoreContainer = new Shared_Escher_DggContainer_BstoreContainer();
$this->_object->setBstoreContainer($bstoreContainer); $this->_object->setBstoreContainer($bstoreContainer);
$reader = new PHPExcel_Reader_Excel5_Escher($bstoreContainer); $reader = new Reader_Excel5_Escher($bstoreContainer);
$reader->load($recordData); $reader->load($recordData);
} }
@ -214,16 +217,16 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; $recInstance = (0xFFF0 & Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
$this->_pos += 8 + $length; $this->_pos += 8 + $length;
// add BSE to BstoreContainer // add BSE to BstoreContainer
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE(); $BSE = new Shared_Escher_DggContainer_BstoreContainer_BSE();
$this->_object->addBSE($BSE); $this->_object->addBSE($BSE);
$BSE->setBLIPType($recInstance); $BSE->setBLIPType($recInstance);
@ -238,16 +241,16 @@ class PHPExcel_Reader_Excel5_Escher
$rgbUid = substr($recordData, 2, 16); $rgbUid = substr($recordData, 2, 16);
// offset: 18; size: 2; tag // offset: 18; size: 2; tag
$tag = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 18); $tag = Reader_Excel5::_GetInt2d($recordData, 18);
// offset: 20; size: 4; size of BLIP in bytes // offset: 20; size: 4; size of BLIP in bytes
$size = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 20); $size = Reader_Excel5::_GetInt4d($recordData, 20);
// offset: 24; size: 4; number of references to this BLIP // offset: 24; size: 4; number of references to this BLIP
$cRef = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 24); $cRef = Reader_Excel5::_GetInt4d($recordData, 24);
// offset: 28; size: 4; MSOFO file offset // offset: 28; size: 4; MSOFO file offset
$foDelay = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 28); $foDelay = Reader_Excel5::_GetInt4d($recordData, 28);
// offset: 32; size: 1; unused1 // offset: 32; size: 1; unused1
$unused1 = ord($recordData{32}); $unused1 = ord($recordData{32});
@ -268,7 +271,7 @@ class PHPExcel_Reader_Excel5_Escher
$blipData = substr($recordData, 36 + $cbName); $blipData = substr($recordData, 36 + $cbName);
// record is a container, read contents // record is a container, read contents
$reader = new PHPExcel_Reader_Excel5_Escher($BSE); $reader = new Reader_Excel5_Escher($BSE);
$reader->load($blipData); $reader->load($blipData);
} }
@ -280,9 +283,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; $recInstance = (0xFFF0 & Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -307,7 +310,7 @@ class PHPExcel_Reader_Excel5_Escher
// offset: var; size: var; the raw image data // offset: var; size: var; the raw image data
$data = substr($recordData, $pos); $data = substr($recordData, $pos);
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip(); $blip = new Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data); $blip->setData($data);
$this->_object->setBlip($blip); $this->_object->setBlip($blip);
@ -321,9 +324,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; $recInstance = (0xFFF0 & Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -348,7 +351,7 @@ class PHPExcel_Reader_Excel5_Escher
// offset: var; size: var; the raw image data // offset: var; size: var; the raw image data
$data = substr($recordData, $pos); $data = substr($recordData, $pos);
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip(); $blip = new Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data); $blip->setData($data);
$this->_object->setBlip($blip); $this->_object->setBlip($blip);
@ -362,9 +365,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; $recInstance = (0xFFF0 & Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -381,9 +384,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; $recInstance = (0xFFF0 & Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -395,7 +398,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readSplitMenuColors() private function _readSplitMenuColors()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -407,16 +410,16 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readDgContainer() private function _readDgContainer()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
$this->_pos += 8 + $length; $this->_pos += 8 + $length;
// record is a container, read contents // record is a container, read contents
$dgContainer = new PHPExcel_Shared_Escher_DgContainer(); $dgContainer = new Shared_Escher_DgContainer();
$this->_object->setDgContainer($dgContainer); $this->_object->setDgContainer($dgContainer);
$reader = new PHPExcel_Reader_Excel5_Escher($dgContainer); $reader = new Reader_Excel5_Escher($dgContainer);
$escher = $reader->load($recordData); $escher = $reader->load($recordData);
} }
@ -425,7 +428,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readDg() private function _readDg()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -439,16 +442,16 @@ class PHPExcel_Reader_Excel5_Escher
{ {
// context is either context DgContainer or SpgrContainer // context is either context DgContainer or SpgrContainer
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
$this->_pos += 8 + $length; $this->_pos += 8 + $length;
// record is a container, read contents // record is a container, read contents
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer(); $spgrContainer = new Shared_Escher_DgContainer_SpgrContainer();
if ($this->_object instanceof PHPExcel_Shared_Escher_DgContainer) { if ($this->_object instanceof Shared_Escher_DgContainer) {
// DgContainer // DgContainer
$this->_object->setSpgrContainer($spgrContainer); $this->_object->setSpgrContainer($spgrContainer);
} else { } else {
@ -456,7 +459,7 @@ class PHPExcel_Reader_Excel5_Escher
$this->_object->addChild($spgrContainer); $this->_object->addChild($spgrContainer);
} }
$reader = new PHPExcel_Reader_Excel5_Escher($spgrContainer); $reader = new Reader_Excel5_Escher($spgrContainer);
$escher = $reader->load($recordData); $escher = $reader->load($recordData);
} }
@ -465,18 +468,18 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readSpContainer() private function _readSpContainer()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// add spContainer to spgrContainer // add spContainer to spgrContainer
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer(); $spContainer = new Shared_Escher_DgContainer_SpgrContainer_SpContainer();
$this->_object->addChild($spContainer); $this->_object->addChild($spContainer);
// move stream pointer to next record // move stream pointer to next record
$this->_pos += 8 + $length; $this->_pos += 8 + $length;
// record is a container, read contents // record is a container, read contents
$reader = new PHPExcel_Reader_Excel5_Escher($spContainer); $reader = new Reader_Excel5_Escher($spContainer);
$escher = $reader->load($recordData); $escher = $reader->load($recordData);
} }
@ -485,7 +488,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readSpgr() private function _readSpgr()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -500,9 +503,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; $recInstance = (0xFFF0 & Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -517,9 +520,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; $recInstance = (0xFFF0 & Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -531,38 +534,38 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readClientAnchor() private function _readClientAnchor()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
$this->_pos += 8 + $length; $this->_pos += 8 + $length;
// offset: 2; size: 2; upper-left corner column index (0-based) // offset: 2; size: 2; upper-left corner column index (0-based)
$c1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 2); $c1 = Reader_Excel5::_GetInt2d($recordData, 2);
// offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width // offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width
$startOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 4); $startOffsetX = Reader_Excel5::_GetInt2d($recordData, 4);
// offset: 6; size: 2; upper-left corner row index (0-based) // offset: 6; size: 2; upper-left corner row index (0-based)
$r1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 6); $r1 = Reader_Excel5::_GetInt2d($recordData, 6);
// offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height // offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height
$startOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 8); $startOffsetY = Reader_Excel5::_GetInt2d($recordData, 8);
// offset: 10; size: 2; bottom-right corner column index (0-based) // offset: 10; size: 2; bottom-right corner column index (0-based)
$c2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 10); $c2 = Reader_Excel5::_GetInt2d($recordData, 10);
// offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width // offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width
$endOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 12); $endOffsetX = Reader_Excel5::_GetInt2d($recordData, 12);
// offset: 14; size: 2; bottom-right corner row index (0-based) // offset: 14; size: 2; bottom-right corner row index (0-based)
$r2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 14); $r2 = Reader_Excel5::_GetInt2d($recordData, 14);
// offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height // offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height
$endOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 16); $endOffsetY = Reader_Excel5::_GetInt2d($recordData, 16);
// set the start coordinates // set the start coordinates
$this->_object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1)); $this->_object->setStartCoordinates(Cell::stringFromColumnIndex($c1) . ($r1 + 1));
// set the start offsetX // set the start offsetX
$this->_object->setStartOffsetX($startOffsetX); $this->_object->setStartOffsetX($startOffsetX);
@ -571,7 +574,7 @@ class PHPExcel_Reader_Excel5_Escher
$this->_object->setStartOffsetY($startOffsetY); $this->_object->setStartOffsetY($startOffsetY);
// set the end coordinates // set the end coordinates
$this->_object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1)); $this->_object->setEndCoordinates(Cell::stringFromColumnIndex($c2) . ($r2 + 1));
// set the end offsetX // set the end offsetX
$this->_object->setEndOffsetX($endOffsetX); $this->_object->setEndOffsetX($endOffsetX);
@ -585,7 +588,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function _readClientData() private function _readClientData()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); $length = Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length); $recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -608,7 +611,7 @@ class PHPExcel_Reader_Excel5_Escher
$fopte = substr($data, 6 * $i, 6); $fopte = substr($data, 6 * $i, 6);
// offset: 0; size: 2; opid // offset: 0; size: 2; opid
$opid = PHPExcel_Reader_Excel5::_GetInt2d($fopte, 0); $opid = Reader_Excel5::_GetInt2d($fopte, 0);
// bit: 0-13; mask: 0x3FFF; opid.opid // bit: 0-13; mask: 0x3FFF; opid.opid
$opidOpid = (0x3FFF & $opid) >> 0; $opidOpid = (0x3FFF & $opid) >> 0;
@ -620,7 +623,7 @@ class PHPExcel_Reader_Excel5_Escher
$opidFComplex = (0x8000 & $opid) >> 15; $opidFComplex = (0x8000 & $opid) >> 15;
// offset: 2; size: 4; the value for this property // offset: 2; size: 4; the value for this property
$op = PHPExcel_Reader_Excel5::_GetInt4d($fopte, 2); $op = Reader_Excel5::_GetInt4d($fopte, 2);
if ($opidFComplex) { if ($opidFComplex) {
$complexData = substr($splicedComplexData, 0, $op); $complexData = substr($splicedComplexData, 0, $op);

View File

@ -19,21 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Reader_Exception * PHPExcel\Reader_Exception
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_Exception extends PHPExcel_Exception { class Reader_Exception extends Exception {
/** /**
* Error handler callback * Error handler callback
* *

View File

@ -19,30 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Reader_Gnumeric * PHPExcel\Reader_Gnumeric
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class Reader_Gnumeric extends Reader_Abstract implements Reader_IReader
{ {
/** /**
* Formats * Formats
@ -62,31 +55,31 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
/** /**
* Create a new PHPExcel_Reader_Gnumeric * Create a new PHPExcel\Reader_Gnumeric
*/ */
public function __construct() { public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new Reader_DefaultReadFilter();
$this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance(); $this->_referenceHelper = ReferenceHelper::getInstance();
} }
/** /**
* Can the current PHPExcel_Reader_IReader read the file? * Can the current PHPExcel\Reader_IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return boolean * @return boolean
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function canRead($pFilename) public function canRead($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
// Check if gzlib functions are available // Check if gzlib functions are available
if (!function_exists('gzread')) { if (!function_exists('gzread')) {
throw new PHPExcel_Reader_Exception("gzlib library is not enabled"); throw new Reader_Exception("gzlib library is not enabled");
} }
// Read signature data (first 3 bytes) // Read signature data (first 3 bytes)
@ -106,13 +99,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetNames($pFilename) public function listWorksheetNames($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$xml = new XMLReader(); $xml = new XMLReader();
@ -140,13 +133,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$xml = new XMLReader(); $xml = new XMLReader();
@ -180,7 +173,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
break; break;
} }
} }
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $tmpInfo['lastColumnLetter'] = Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$worksheetInfo[] = $tmpInfo; $worksheetInfo[] = $tmpInfo;
} }
} }
@ -207,12 +200,12 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
* *
* @param string $pFilename * @param string $pFilename
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function load($pFilename) public function load($pFilename)
{ {
// Create new PHPExcel // Create new PHPExcel Workbook
$objPHPExcel = new PHPExcel(); $objPHPExcel = new Workbook();
// Load into this instance // Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
@ -220,18 +213,18 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
/** /**
* Loads PHPExcel from file into PHPExcel instance * Loads Workbook from file into PHPExcel Workbook instance
* *
* @param string $pFilename * @param string $pFilename
* @param PHPExcel $objPHPExcel * @param PHPExcel $objPHPExcel
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$timezoneObj = new DateTimeZone('Europe/London'); $timezoneObj = new DateTimeZone('Europe/London');
@ -414,7 +407,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
if ($row > $maxRow) $maxRow = $row; if ($row > $maxRow) $maxRow = $row;
if ($column > $maxCol) $maxCol = $column; if ($column > $maxCol) $maxCol = $column;
$column = PHPExcel_Cell::stringFromColumnIndex($column); $column = Cell::stringFromColumnIndex($column);
// Read cell? // Read cell?
if ($this->getReadFilter() !== NULL) { if ($this->getReadFilter() !== NULL) {
@ -428,7 +421,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// echo 'Cell ',$column,$row,'<br />'; // echo 'Cell ',$column,$row,'<br />';
// echo 'Type is ',$ValueType,'<br />'; // echo 'Type is ',$ValueType,'<br />';
// echo 'Value is ',$cell,'<br />'; // echo 'Value is ',$cell,'<br />';
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = Cell_DataType::TYPE_FORMULA;
if ($ExprID > '') { if ($ExprID > '') {
if (((string) $cell) > '') { if (((string) $cell) > '') {
@ -449,26 +442,26 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// echo 'SHARED EXPRESSION ',$ExprID,'<br />'; // echo 'SHARED EXPRESSION ',$ExprID,'<br />';
// echo 'New Value is ',$cell,'<br />'; // echo 'New Value is ',$cell,'<br />';
} }
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = Cell_DataType::TYPE_FORMULA;
} else { } else {
switch($ValueType) { switch($ValueType) {
case '10' : // NULL case '10' : // NULL
$type = PHPExcel_Cell_DataType::TYPE_NULL; $type = Cell_DataType::TYPE_NULL;
break; break;
case '20' : // Boolean case '20' : // Boolean
$type = PHPExcel_Cell_DataType::TYPE_BOOL; $type = Cell_DataType::TYPE_BOOL;
$cell = ($cell == 'TRUE') ? True : False; $cell = ($cell == 'TRUE') ? True : False;
break; break;
case '30' : // Integer case '30' : // Integer
$cell = intval($cell); $cell = intval($cell);
case '40' : // Float case '40' : // Float
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = Cell_DataType::TYPE_NUMERIC;
break; break;
case '50' : // Error case '50' : // Error
$type = PHPExcel_Cell_DataType::TYPE_ERROR; $type = Cell_DataType::TYPE_ERROR;
break; break;
case '60' : // String case '60' : // String
$type = PHPExcel_Cell_DataType::TYPE_STRING; $type = Cell_DataType::TYPE_STRING;
break; break;
case '70' : // Cell Range case '70' : // Cell Range
case '80' : // Array case '80' : // Array
@ -495,11 +488,11 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
if (($styleAttributes['startRow'] <= $maxRow) && if (($styleAttributes['startRow'] <= $maxRow) &&
($styleAttributes['startCol'] <= $maxCol)) { ($styleAttributes['startCol'] <= $maxCol)) {
$startColumn = PHPExcel_Cell::stringFromColumnIndex((int) $styleAttributes['startCol']); $startColumn = Cell::stringFromColumnIndex((int) $styleAttributes['startCol']);
$startRow = $styleAttributes['startRow'] + 1; $startRow = $styleAttributes['startRow'] + 1;
$endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol']; $endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol'];
$endColumn = PHPExcel_Cell::stringFromColumnIndex($endColumn); $endColumn = Cell::stringFromColumnIndex($endColumn);
$endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow']; $endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow'];
$endRow += 1; $endRow += 1;
$cellRange = $startColumn.$startRow.':'.$endColumn.$endRow; $cellRange = $startColumn.$startRow.':'.$endColumn.$endRow;
@ -511,45 +504,45 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// We still set the number format mask for date/time values, even if _readDataOnly is true // We still set the number format mask for date/time values, even if _readDataOnly is true
if ((!$this->_readDataOnly) || if ((!$this->_readDataOnly) ||
(PHPExcel_Shared_Date::isDateTimeFormatCode($styleArray['numberformat']['code']))) { (Shared_Date::isDateTimeFormatCode($styleArray['numberformat']['code']))) {
$styleArray = array(); $styleArray = array();
$styleArray['numberformat']['code'] = (string) $styleAttributes['Format']; $styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
// If _readDataOnly is false, we set all formatting information // If _readDataOnly is false, we set all formatting information
if (!$this->_readDataOnly) { if (!$this->_readDataOnly) {
switch($styleAttributes['HAlign']) { switch($styleAttributes['HAlign']) {
case '1' : case '1' :
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; $styleArray['alignment']['horizontal'] = Style_Alignment::HORIZONTAL_GENERAL;
break; break;
case '2' : case '2' :
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT; $styleArray['alignment']['horizontal'] = Style_Alignment::HORIZONTAL_LEFT;
break; break;
case '4' : case '4' :
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT; $styleArray['alignment']['horizontal'] = Style_Alignment::HORIZONTAL_RIGHT;
break; break;
case '8' : case '8' :
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER; $styleArray['alignment']['horizontal'] = Style_Alignment::HORIZONTAL_CENTER;
break; break;
case '16' : case '16' :
case '64' : case '64' :
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS; $styleArray['alignment']['horizontal'] = Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS;
break; break;
case '32' : case '32' :
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY; $styleArray['alignment']['horizontal'] = Style_Alignment::HORIZONTAL_JUSTIFY;
break; break;
} }
switch($styleAttributes['VAlign']) { switch($styleAttributes['VAlign']) {
case '1' : case '1' :
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP; $styleArray['alignment']['vertical'] = Style_Alignment::VERTICAL_TOP;
break; break;
case '2' : case '2' :
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; $styleArray['alignment']['vertical'] = Style_Alignment::VERTICAL_BOTTOM;
break; break;
case '4' : case '4' :
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER; $styleArray['alignment']['vertical'] = Style_Alignment::VERTICAL_CENTER;
break; break;
case '8' : case '8' :
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY; $styleArray['alignment']['vertical'] = Style_Alignment::VERTICAL_JUSTIFY;
break; break;
} }
@ -567,64 +560,64 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['fill']['endcolor']['rgb'] = $RGB2; $styleArray['fill']['endcolor']['rgb'] = $RGB2;
switch($shade) { switch($shade) {
case '1' : case '1' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID; $styleArray['fill']['type'] = Style_Fill::FILL_SOLID;
break; break;
case '2' : case '2' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR; $styleArray['fill']['type'] = Style_Fill::FILL_GRADIENT_LINEAR;
break; break;
case '3' : case '3' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_PATH; $styleArray['fill']['type'] = Style_Fill::FILL_GRADIENT_PATH;
break; break;
case '4' : case '4' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_DARKDOWN;
break; break;
case '5' : case '5' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_DARKGRAY;
break; break;
case '6' : case '6' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_DARKGRID;
break; break;
case '7' : case '7' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_DARKHORIZONTAL;
break; break;
case '8' : case '8' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_DARKTRELLIS;
break; break;
case '9' : case '9' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKUP; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_DARKUP;
break; break;
case '10' : case '10' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_DARKVERTICAL;
break; break;
case '11' : case '11' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_GRAY0625;
break; break;
case '12' : case '12' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY125; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_GRAY125;
break; break;
case '13' : case '13' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_LIGHTDOWN;
break; break;
case '14' : case '14' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_LIGHTGRAY;
break; break;
case '15' : case '15' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_LIGHTGRID;
break; break;
case '16' : case '16' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL;
break; break;
case '17' : case '17' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_LIGHTTRELLIS;
break; break;
case '18' : case '18' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_LIGHTUP;
break; break;
case '19' : case '19' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_LIGHTVERTICAL;
break; break;
case '20' : case '20' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY; $styleArray['fill']['type'] = Style_Fill::FILL_PATTERN_MEDIUMGRAY;
break; break;
} }
} }
@ -639,19 +632,19 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False; $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False;
switch($fontAttributes['Underline']) { switch($fontAttributes['Underline']) {
case '1' : case '1' :
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE; $styleArray['font']['underline'] = Style_Font::UNDERLINE_SINGLE;
break; break;
case '2' : case '2' :
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE; $styleArray['font']['underline'] = Style_Font::UNDERLINE_DOUBLE;
break; break;
case '3' : case '3' :
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING; $styleArray['font']['underline'] = Style_Font::UNDERLINE_SINGLEACCOUNTING;
break; break;
case '4' : case '4' :
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING; $styleArray['font']['underline'] = Style_Font::UNDERLINE_DOUBLEACCOUNTING;
break; break;
default : default :
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE; $styleArray['font']['underline'] = Style_Font::UNDERLINE_NONE;
break; break;
} }
switch($fontAttributes['Script']) { switch($fontAttributes['Script']) {
@ -678,13 +671,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) { if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) {
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); $styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_BOTH; $styleArray['borders']['diagonaldirection'] = Style_Borders::DIAGONAL_BOTH;
} elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) { } elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) {
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); $styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_UP; $styleArray['borders']['diagonaldirection'] = Style_Borders::DIAGONAL_UP;
} elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) { } elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) {
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes()); $styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_DOWN; $styleArray['borders']['diagonaldirection'] = Style_Borders::DIAGONAL_DOWN;
} }
} }
if (isset($styleRegion->Style->HyperLink)) { if (isset($styleRegion->Style->HyperLink)) {
@ -711,19 +704,19 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$hidden = ((isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1')) ? true : false; $hidden = ((isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1')) ? true : false;
$columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1; $columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1;
while ($c < $column) { while ($c < $column) {
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($defaultWidth); $objPHPExcel->getActiveSheet()->getColumnDimension(Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
++$c; ++$c;
} }
while (($c < ($column+$columnCount)) && ($c <= $maxCol)) { while (($c < ($column+$columnCount)) && ($c <= $maxCol)) {
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($columnWidth); $objPHPExcel->getActiveSheet()->getColumnDimension(Cell::stringFromColumnIndex($c))->setWidth($columnWidth);
if ($hidden) { if ($hidden) {
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setVisible(false); $objPHPExcel->getActiveSheet()->getColumnDimension(Cell::stringFromColumnIndex($c))->setVisible(false);
} }
++$c; ++$c;
} }
} }
while ($c <= $maxCol) { while ($c <= $maxCol) {
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($defaultWidth); $objPHPExcel->getActiveSheet()->getColumnDimension(Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
++$c; ++$c;
} }
} }
@ -783,7 +776,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$range[0] = trim($range[0],"'");; $range[0] = trim($range[0],"'");;
if ($worksheet = $objPHPExcel->getSheetByName($range[0])) { if ($worksheet = $objPHPExcel->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]); $extractedRange = str_replace('$', '', $range[1]);
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange($name, $worksheet, $extractedRange) ); $objPHPExcel->addNamedRange( new NamedRange($name, $worksheet, $extractedRange) );
} }
} }
} }
@ -805,46 +798,46 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
switch ($borderAttributes["Style"]) { switch ($borderAttributes["Style"]) {
case '0' : case '0' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_NONE; $styleArray['style'] = Style_Border::BORDER_NONE;
break; break;
case '1' : case '1' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THIN; $styleArray['style'] = Style_Border::BORDER_THIN;
break; break;
case '2' : case '2' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; $styleArray['style'] = Style_Border::BORDER_MEDIUM;
break; break;
case '4' : case '4' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED; $styleArray['style'] = Style_Border::BORDER_DASHED;
break; break;
case '5' : case '5' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK; $styleArray['style'] = Style_Border::BORDER_THICK;
break; break;
case '6' : case '6' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE; $styleArray['style'] = Style_Border::BORDER_DOUBLE;
break; break;
case '7' : case '7' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED; $styleArray['style'] = Style_Border::BORDER_DOTTED;
break; break;
case '9' : case '9' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT; $styleArray['style'] = Style_Border::BORDER_DASHDOT;
break; break;
case '10' : case '10' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT; $styleArray['style'] = Style_Border::BORDER_MEDIUMDASHDOT;
break; break;
case '11' : case '11' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT; $styleArray['style'] = Style_Border::BORDER_DASHDOTDOT;
break; break;
case '12' : case '12' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; $styleArray['style'] = Style_Border::BORDER_MEDIUMDASHDOTDOT;
break; break;
case '13' : case '13' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; $styleArray['style'] = Style_Border::BORDER_MEDIUMDASHDOTDOT;
break; break;
case '3' : case '3' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT; $styleArray['style'] = Style_Border::BORDER_SLANTDASHDOT;
break; break;
case '8' : case '8' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED; $styleArray['style'] = Style_Border::BORDER_MEDIUMDASHED;
break; break;
} }
return $styleArray; return $styleArray;
@ -852,7 +845,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
private function _parseRichText($is = '') { private function _parseRichText($is = '') {
$value = new PHPExcel_RichText(); $value = new RichText();
$value->createText($is); $value->createText($is);

View File

@ -19,30 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Reader_HTML * PHPExcel\Reader_HTML
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class Reader_HTML extends Reader_Abstract implements Reader_IReader
{ {
/** /**
* Input encoding * Input encoding
@ -88,12 +81,12 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
), ),
), // Bold, 7.5pt ), // Bold, 7.5pt
'a' => array( 'font' => array( 'underline' => true, 'a' => array( 'font' => array( 'underline' => true,
'color' => array( 'argb' => PHPExcel_Style_Color::COLOR_BLUE, 'color' => array( 'argb' => Style_Color::COLOR_BLUE,
), ),
), ),
), // Blue underlined ), // Blue underlined
'hr' => array( 'borders' => array( 'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN, 'hr' => array( 'borders' => array( 'bottom' => array( 'style' => Style_Border::BORDER_THIN,
'color' => array( PHPExcel_Style_Color::COLOR_BLACK, 'color' => array( Style_Color::COLOR_BLACK,
), ),
), ),
), ),
@ -102,10 +95,10 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
/** /**
* Create a new PHPExcel_Reader_HTML * Create a new PHPExcel\Reader_HTML
*/ */
public function __construct() { public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new Reader_DefaultReadFilter();
} }
/** /**
@ -130,12 +123,12 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
* *
* @param string $pFilename * @param string $pFilename
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function load($pFilename) public function load($pFilename)
{ {
// Create new PHPExcel // Create new PHPExcel Workbook
$objPHPExcel = new PHPExcel(); $objPHPExcel = new Workbook();
// Load into this instance // Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
@ -402,7 +395,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
* @param string $pFilename * @param string $pFilename
* @param PHPExcel $objPHPExcel * @param PHPExcel $objPHPExcel
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{ {
@ -410,7 +403,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$this->_openFile($pFilename); $this->_openFile($pFilename);
if (!$this->_isValidFormat()) { if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle); fclose ($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file."); throw new Reader_Exception($pFilename . " is an Invalid HTML file.");
} }
// Close after validating // Close after validating
fclose ($this->_fileHandle); fclose ($this->_fileHandle);
@ -426,7 +419,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
// Reload the HTML file into the DOM object // Reload the HTML file into the DOM object
$loaded = $dom->loadHTMLFile($pFilename); $loaded = $dom->loadHTMLFile($pFilename);
if ($loaded === FALSE) { if ($loaded === FALSE) {
throw new PHPExcel_Reader_Exception('Failed to load ',$pFilename,' as a DOM Document'); throw new Reader_Exception('Failed to load ',$pFilename,' as a DOM Document');
} }
// Discard white space // Discard white space
@ -458,7 +451,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
* Set sheet index * Set sheet index
* *
* @param int $pValue Sheet index * @param int $pValue Sheet index
* @return PHPExcel_Reader_HTML * @return PHPExcel\Reader_HTML
*/ */
public function setSheetIndex($pValue = 0) { public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue; $this->_sheetIndex = $pValue;

View File

@ -19,21 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Reader_IReadFilter * PHPExcel\Reader_IReadFilter
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
interface PHPExcel_Reader_IReadFilter interface Reader_IReadFilter
{ {
/** /**
* Should this cell be read? * Should this cell be read?

View File

@ -19,24 +19,26 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Reader_IReader * PHPExcel\Reader_IReader
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
interface PHPExcel_Reader_IReader interface Reader_IReader
{ {
/** /**
* Can the current PHPExcel_Reader_IReader read the file? * Can the current PHPExcel\Reader_IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return boolean * @return boolean
@ -47,7 +49,7 @@ interface PHPExcel_Reader_IReader
* Loads PHPExcel from file * Loads PHPExcel from file
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function load($pFilename); public function load($pFilename);
} }

View File

@ -19,30 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Reader_OOCalc * PHPExcel\Reader_OOCalc
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class Reader_OOCalc extends Reader_Abstract implements Reader_IReader
{ {
/** /**
* Formats * Formats
@ -53,30 +46,30 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
/** /**
* Create a new PHPExcel_Reader_OOCalc * Create a new PHPExcel\Reader_OOCalc
*/ */
public function __construct() { public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new Reader_DefaultReadFilter();
} }
/** /**
* Can the current PHPExcel_Reader_IReader read the file? * Can the current PHPExcel\Reader_IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return boolean * @return boolean
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function canRead($pFilename) public function canRead($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
// Check if zip class exists // Check if zip class exists
if (!class_exists('ZipArchive',FALSE)) { if (!class_exists('ZipArchive',FALSE)) {
throw new PHPExcel_Reader_Exception("ZipArchive library is not enabled"); throw new Reader_Exception("ZipArchive library is not enabled");
} }
$mimeType = 'UNKNOWN'; $mimeType = 'UNKNOWN';
@ -115,18 +108,18 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetNames($pFilename) public function listWorksheetNames($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$zip = new ZipArchive; $zip = new ZipArchive;
if (!$zip->open($pFilename)) { if (!$zip->open($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
} }
$worksheetNames = array(); $worksheetNames = array();
@ -165,20 +158,20 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$worksheetInfo = array(); $worksheetInfo = array();
$zip = new ZipArchive; $zip = new ZipArchive;
if (!$zip->open($pFilename)) { if (!$zip->open($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
} }
$xml = new XMLReader(); $xml = new XMLReader();
@ -239,7 +232,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells);
$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1; $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $tmpInfo['lastColumnLetter'] = Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$worksheetInfo[] = $tmpInfo; $worksheetInfo[] = $tmpInfo;
} }
} }
@ -273,7 +266,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// } // }
// } // }
// //
// $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); // $tmpInfo['lastColumnLetter'] = Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
// $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1; // $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
// //
// } // }
@ -289,7 +282,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
* *
* @param string $pFilename * @param string $pFilename
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function load($pFilename) public function load($pFilename)
{ {
@ -319,13 +312,13 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
* @param string $pFilename * @param string $pFilename
* @param PHPExcel $objPHPExcel * @param PHPExcel $objPHPExcel
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$timezoneObj = new DateTimeZone('Europe/London'); $timezoneObj = new DateTimeZone('Europe/London');
@ -333,7 +326,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$zip = new ZipArchive; $zip = new ZipArchive;
if (!$zip->open($pFilename)) { if (!$zip->open($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
} }
// echo '<h1>Meta Information</h1>'; // echo '<h1>Meta Information</h1>';
@ -390,26 +383,26 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
break; break;
case 'user-defined' : case 'user-defined' :
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING;
foreach ($propertyValueAttributes as $key => $value) { foreach ($propertyValueAttributes as $key => $value) {
if ($key == 'name') { if ($key == 'name') {
$propertyValueName = (string) $value; $propertyValueName = (string) $value;
} elseif($key == 'value-type') { } elseif($key == 'value-type') {
switch ($value) { switch ($value) {
case 'date' : case 'date' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date'); $propertyValue = DocumentProperties::convertProperty($propertyValue,'date');
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; $propertyValueType = DocumentProperties::PROPERTY_TYPE_DATE;
break; break;
case 'boolean' : case 'boolean' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool'); $propertyValue = DocumentProperties::convertProperty($propertyValue,'bool');
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; $propertyValueType = DocumentProperties::PROPERTY_TYPE_BOOLEAN;
break; break;
case 'float' : case 'float' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4'); $propertyValue = DocumentProperties::convertProperty($propertyValue,'r4');
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; $propertyValueType = DocumentProperties::PROPERTY_TYPE_FLOAT;
break; break;
default : default :
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING;
} }
} }
} }
@ -540,7 +533,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />'; // echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />';
switch ($cellDataOfficeAttributes['value-type']) { switch ($cellDataOfficeAttributes['value-type']) {
case 'string' : case 'string' :
$type = PHPExcel_Cell_DataType::TYPE_STRING; $type = Cell_DataType::TYPE_STRING;
$dataValue = $allCellDataText; $dataValue = $allCellDataText;
if (isset($dataValue->a)) { if (isset($dataValue->a)) {
$dataValue = $dataValue->a; $dataValue = $dataValue->a;
@ -549,27 +542,27 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
} }
break; break;
case 'boolean' : case 'boolean' :
$type = PHPExcel_Cell_DataType::TYPE_BOOL; $type = Cell_DataType::TYPE_BOOL;
$dataValue = ($allCellDataText == 'TRUE') ? True : False; $dataValue = ($allCellDataText == 'TRUE') ? True : False;
break; break;
case 'percentage' : case 'percentage' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value']; $dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) { if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue; $dataValue = (integer) $dataValue;
} }
$formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00; $formatting = Style_NumberFormat::FORMAT_PERCENTAGE_00;
break; break;
case 'currency' : case 'currency' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value']; $dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) { if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue; $dataValue = (integer) $dataValue;
} }
$formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; $formatting = Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
break; break;
case 'float' : case 'float' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value']; $dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) { if (floor($dataValue) == $dataValue) {
if ($dataValue = (integer) $dataValue) if ($dataValue = (integer) $dataValue)
@ -579,21 +572,21 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
} }
break; break;
case 'date' : case 'date' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = Cell_DataType::TYPE_NUMERIC;
$dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT);
$dateObj->setTimeZone($timezoneObj); $dateObj->setTimeZone($timezoneObj);
list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s')); list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s'));
$dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second); $dataValue = Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second);
if ($dataValue != floor($dataValue)) { if ($dataValue != floor($dataValue)) {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; $formatting = Style_NumberFormat::FORMAT_DATE_XLSX15.' '.Style_NumberFormat::FORMAT_DATE_TIME4;
} else { } else {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15; $formatting = Style_NumberFormat::FORMAT_DATE_XLSX15;
} }
break; break;
case 'time' : case 'time' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = Cell_DataType::TYPE_NUMERIC;
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS')))); $dataValue = Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS'))));
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; $formatting = Style_NumberFormat::FORMAT_DATE_TIME4;
break; break;
} }
// echo 'Data value is '.$dataValue.'<br />'; // echo 'Data value is '.$dataValue.'<br />';
@ -601,12 +594,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo 'Hyperlink is '.$hyperlink.'<br />'; // echo 'Hyperlink is '.$hyperlink.'<br />';
// } // }
} else { } else {
$type = PHPExcel_Cell_DataType::TYPE_NULL; $type = Cell_DataType::TYPE_NULL;
$dataValue = NULL; $dataValue = NULL;
} }
if ($hasCalculatedValue) { if ($hasCalculatedValue) {
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = Cell_DataType::TYPE_FORMULA;
// echo 'Formula: '.$cellDataFormula.'<br />'; // echo 'Formula: '.$cellDataFormula.'<br />';
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1);
$temp = explode('"',$cellDataFormula); $temp = explode('"',$cellDataFormula);
@ -616,7 +609,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if ($tKey = !$tKey) { if ($tKey = !$tKey) {
$value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value); $value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value);
$value = preg_replace('/\[\.(.*)\]/Ui','$1',$value); $value = preg_replace('/\[\.(.*)\]/Ui','$1',$value);
$value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces); $value = Calculation::_translateSeparator(';',',',$value,$inBraces);
} }
} }
unset($value); unset($value);
@ -632,7 +625,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if ($i > 0) { if ($i > 0) {
++$columnID; ++$columnID;
} }
if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) { if ($type !== Cell_DataType::TYPE_NULL) {
for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) { for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
$rID = $rowID + $rowAdjust; $rID = $rowID + $rowAdjust;
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type); $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
@ -643,7 +636,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if ($formatting !== NULL) { if ($formatting !== NULL) {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting); $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
} else { } else {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL); $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(Style_NumberFormat::FORMAT_GENERAL);
} }
if ($hyperlink !== NULL) { if ($hyperlink !== NULL) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink); $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink);
@ -655,10 +648,10 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// Merged cells // Merged cells
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) { if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) { if (($type !== Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) {
$columnTo = $columnID; $columnTo = $columnID;
if (isset($cellDataTableAttributes['number-columns-spanned'])) { if (isset($cellDataTableAttributes['number-columns-spanned'])) {
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2); $columnTo = Cell::stringFromColumnIndex(Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
} }
$rowTo = $rowID; $rowTo = $rowID;
if (isset($cellDataTableAttributes['number-rows-spanned'])) { if (isset($cellDataTableAttributes['number-rows-spanned'])) {
@ -685,7 +678,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
private function _parseRichText($is = '') { private function _parseRichText($is = '') {
$value = new PHPExcel_RichText(); $value = new RichText();
$value->createText($is); $value->createText($is);

View File

@ -19,30 +19,23 @@
* 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_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */ namespace PHPExcel;
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel_Reader_SYLK * PHPExcel\Reader_SYLK
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Reader * @package PHPExcel\Reader
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class Reader_SYLK extends Reader_Abstract implements Reader_IReader
{ {
/** /**
* Input encoding * Input encoding
@ -73,10 +66,10 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
private $_format = 0; private $_format = 0;
/** /**
* Create a new PHPExcel_Reader_SYLK * Create a new PHPExcel\Reader_SYLK
*/ */
public function __construct() { public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new Reader_DefaultReadFilter();
} }
/** /**
@ -129,7 +122,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
* *
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
{ {
@ -137,7 +130,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
$this->_openFile($pFilename); $this->_openFile($pFilename);
if (!$this->_isValidFormat()) { if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle); fclose ($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$fileHandle = $this->_fileHandle; $fileHandle = $this->_fileHandle;
rewind($fileHandle); rewind($fileHandle);
@ -158,7 +151,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
$columnIndex = 0; $columnIndex = 0;
// convert SYLK encoded $rowData to UTF-8 // convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData); $rowData = Shared_String::SYLKtoUTF8($rowData);
// explode each row at semicolons while taking into account that literal semicolon (;) // explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;) // is escaped like this (;;)
@ -185,7 +178,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
} }
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']); $worksheetInfo[0]['lastColumnLetter'] = Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1; $worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
// Close file // Close file
@ -199,12 +192,12 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
* *
* @param string $pFilename * @param string $pFilename
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function load($pFilename) public function load($pFilename)
{ {
// Create new PHPExcel // Create new PHPExcel Workbook
$objPHPExcel = new PHPExcel(); $objPHPExcel = new Workbook();
// Load into this instance // Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
@ -216,7 +209,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
* @param string $pFilename * @param string $pFilename
* @param PHPExcel $objPHPExcel * @param PHPExcel $objPHPExcel
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Reader_Exception * @throws PHPExcel\Reader_Exception
*/ */
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{ {
@ -224,7 +217,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
$this->_openFile($pFilename); $this->_openFile($pFilename);
if (!$this->_isValidFormat()) { if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle); fclose ($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$fileHandle = $this->_fileHandle; $fileHandle = $this->_fileHandle;
rewind($fileHandle); rewind($fileHandle);
@ -246,7 +239,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
while (($rowData = fgets($fileHandle)) !== FALSE) { while (($rowData = fgets($fileHandle)) !== FALSE) {
// convert SYLK encoded $rowData to UTF-8 // convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData); $rowData = Shared_String::SYLKtoUTF8($rowData);
// explode each row at semicolons while taking into account that literal semicolon (;) // explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;) // is escaped like this (;;)
@ -272,13 +265,13 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
case 'D' : $formatArray['font']['bold'] = true; case 'D' : $formatArray['font']['bold'] = true;
break; break;
case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN; case 'T' : $formatArray['borders']['top']['style'] = Style_Border::BORDER_THIN;
break; break;
case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN; case 'B' : $formatArray['borders']['bottom']['style'] = Style_Border::BORDER_THIN;
break; break;
case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN; case 'L' : $formatArray['borders']['left']['style'] = Style_Border::BORDER_THIN;
break; break;
case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN; case 'R' : $formatArray['borders']['right']['style'] = Style_Border::BORDER_THIN;
break; break;
} }
} }
@ -325,7 +318,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
if ($columnReference == '') $columnReference = $column; if ($columnReference == '') $columnReference = $column;
// Bracketed C references are relative to the current column // Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]'); if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; $A1CellReference = Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0])); $value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
} }
@ -338,13 +331,13 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
} }
} }
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); $columnLetter = Cell::stringFromColumnIndex($column-1);
$cellData = PHPExcel_Calculation::_unwrapResult($cellData); $cellData = Calculation::_unwrapResult($cellData);
// Set cell value // Set cell value
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData); $objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
if ($hasCalculatedValue) { if ($hasCalculatedValue) {
$cellData = PHPExcel_Calculation::_unwrapResult($cellData); $cellData = Calculation::_unwrapResult($cellData);
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData); $objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
} }
// Read cell formatting // Read cell formatting
@ -370,13 +363,13 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
case 'D' : $styleData['font']['bold'] = true; case 'D' : $styleData['font']['bold'] = true;
break; break;
case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN; case 'T' : $styleData['borders']['top']['style'] = Style_Border::BORDER_THIN;
break; break;
case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN; case 'B' : $styleData['borders']['bottom']['style'] = Style_Border::BORDER_THIN;
break; break;
case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN; case 'L' : $styleData['borders']['left']['style'] = Style_Border::BORDER_THIN;
break; break;
case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN; case 'R' : $styleData['borders']['right']['style'] = Style_Border::BORDER_THIN;
break; break;
} }
} }
@ -384,22 +377,22 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
} }
if (($formatStyle > '') && ($column > '') && ($row > '')) { if (($formatStyle > '') && ($column > '') && ($row > '')) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); $columnLetter = Cell::stringFromColumnIndex($column-1);
if (isset($this->_formats[$formatStyle])) { if (isset($this->_formats[$formatStyle])) {
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]); $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]);
} }
} }
if ((!empty($styleData)) && ($column > '') && ($row > '')) { if ((!empty($styleData)) && ($column > '') && ($row > '')) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); $columnLetter = Cell::stringFromColumnIndex($column-1);
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData); $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
} }
if ($columnWidth > '') { if ($columnWidth > '') {
if ($startCol == $endCol) { if ($startCol == $endCol) {
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1); $startCol = Cell::stringFromColumnIndex($startCol-1);
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); $objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
} else { } else {
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1); $startCol = Cell::stringFromColumnIndex($startCol-1);
$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1); $endCol = Cell::stringFromColumnIndex($endCol-1);
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); $objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
do { do {
$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth); $objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
@ -440,7 +433,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
* Set sheet index * Set sheet index
* *
* @param int $pValue Sheet index * @param int $pValue Sheet index
* @return PHPExcel_Reader_SYLK * @return PHPExcel\Reader_SYLK
*/ */
public function setSheetIndex($pValue = 0) { public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue; $this->_sheetIndex = $pValue;

View File

@ -26,14 +26,16 @@
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_ReferenceHelper (Singleton) * PHPExcel\ReferenceHelper (Singleton)
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_ReferenceHelper class ReferenceHelper
{ {
/** Constants */ /** Constants */
/** Regular Expressions */ /** Regular Expressions */
@ -45,25 +47,25 @@ class PHPExcel_ReferenceHelper
/** /**
* Instance of this class * Instance of this class
* *
* @var PHPExcel_ReferenceHelper * @var PHPExcel\ReferenceHelper
*/ */
private static $_instance; private static $_instance;
/** /**
* Get an instance of this class * Get an instance of this class
* *
* @return PHPExcel_ReferenceHelper * @return PHPExcel\ReferenceHelper
*/ */
public static function getInstance() { public static function getInstance() {
if (!isset(self::$_instance) || (self::$_instance === NULL)) { if (!isset(self::$_instance) || (self::$_instance === NULL)) {
self::$_instance = new PHPExcel_ReferenceHelper(); self::$_instance = new ReferenceHelper();
} }
return self::$_instance; return self::$_instance;
} }
/** /**
* Create a new PHPExcel_ReferenceHelper * Create a new PHPExcel\ReferenceHelper
*/ */
protected function __construct() { protected function __construct() {
} }
@ -139,8 +141,8 @@ class PHPExcel_ReferenceHelper
* @return boolean * @return boolean
*/ */
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) { private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) {
list($cellColumn, $cellRow) = PHPExcel_Cell::coordinateFromString($cellAddress); list($cellColumn, $cellRow) = Cell::coordinateFromString($cellAddress);
$cellColumnIndex = PHPExcel_Cell::columnIndexFromString($cellColumn); $cellColumnIndex = Cell::columnIndexFromString($cellColumn);
// Is cell within the range of rows/columns if we're deleting // Is cell within the range of rows/columns if we're deleting
if ($pNumRows < 0 && if ($pNumRows < 0 &&
($cellRow >= ($beforeRow + $pNumRows)) && ($cellRow >= ($beforeRow + $pNumRows)) &&
@ -157,32 +159,32 @@ class PHPExcel_ReferenceHelper
/** /**
* Update page breaks when inserting/deleting rows/columns * Update page breaks when inserting/deleting rows/columns
* *
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel\Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
* @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $beforeRow Number of the row we're inserting/deleting before
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/ */
protected function _adjustPageBreaks(PHPExcel_Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function _adjustPageBreaks(Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{ {
$aBreaks = $pSheet->getBreaks(); $aBreaks = $pSheet->getBreaks();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aBreaks, array(__NAMESPACE__ . '\ReferenceHelper','cellReverseSort')) :
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellSort')); uksort($aBreaks, array(__NAMESPACE__ . '\ReferenceHelper','cellSort'));
foreach ($aBreaks as $key => $value) { foreach ($aBreaks as $key => $value) {
if (self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) { if (self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {
// If we're deleting, then clear any defined breaks that are within the range // If we're deleting, then clear any defined breaks that are within the range
// of rows/columns that we're deleting // of rows/columns that we're deleting
$pSheet->setBreak($key, PHPExcel_Worksheet::BREAK_NONE); $pSheet->setBreak($key, Worksheet::BREAK_NONE);
} else { } else {
// Otherwise update any affected breaks by inserting a new break at the appropriate point // Otherwise update any affected breaks by inserting a new break at the appropriate point
// and removing the old affected break // and removing the old affected break
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) { if ($key != $newReference) {
$pSheet->setBreak($newReference, $value) $pSheet->setBreak($newReference, $value)
->setBreak($key, PHPExcel_Worksheet::BREAK_NONE); ->setBreak($key, Worksheet::BREAK_NONE);
} }
} }
} }
@ -191,7 +193,7 @@ class PHPExcel_ReferenceHelper
/** /**
* Update cell comments when inserting/deleting rows/columns * Update cell comments when inserting/deleting rows/columns
* *
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel\Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
@ -218,7 +220,7 @@ class PHPExcel_ReferenceHelper
/** /**
* Update hyperlinks when inserting/deleting rows/columns * Update hyperlinks when inserting/deleting rows/columns
* *
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel\Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
@ -229,8 +231,8 @@ class PHPExcel_ReferenceHelper
{ {
$aHyperlinkCollection = $pSheet->getHyperlinkCollection(); $aHyperlinkCollection = $pSheet->getHyperlinkCollection();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aHyperlinkCollection, array(__NAMESPACE__ . '\ReferenceHelper','cellReverseSort')) :
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort')); uksort($aHyperlinkCollection, array(__NAMESPACE__ . '\ReferenceHelper','cellSort'));
foreach ($aHyperlinkCollection as $key => $value) { foreach ($aHyperlinkCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
@ -244,7 +246,7 @@ class PHPExcel_ReferenceHelper
/** /**
* Update data validations when inserting/deleting rows/columns * Update data validations when inserting/deleting rows/columns
* *
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel\Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
@ -255,8 +257,8 @@ class PHPExcel_ReferenceHelper
{ {
$aDataValidationCollection = $pSheet->getDataValidationCollection(); $aDataValidationCollection = $pSheet->getDataValidationCollection();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aDataValidationCollection, array(__NAMESPACE__ . '\ReferenceHelper','cellReverseSort')) :
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort')); uksort($aDataValidationCollection, array(__NAMESPACE__ . '\ReferenceHelper','cellSort'));
foreach ($aDataValidationCollection as $key => $value) { foreach ($aDataValidationCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) { if ($key != $newReference) {
@ -269,7 +271,7 @@ class PHPExcel_ReferenceHelper
/** /**
* Update merged cells when inserting/deleting rows/columns * Update merged cells when inserting/deleting rows/columns
* *
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel\Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
@ -290,7 +292,7 @@ class PHPExcel_ReferenceHelper
/** /**
* Update protected cells when inserting/deleting rows/columns * Update protected cells when inserting/deleting rows/columns
* *
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel\Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
@ -301,8 +303,8 @@ class PHPExcel_ReferenceHelper
{ {
$aProtectedCells = $pSheet->getProtectedCells(); $aProtectedCells = $pSheet->getProtectedCells();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aProtectedCells, array(__NAMESPACE__ . '\ReferenceHelper','cellReverseSort')) :
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellSort')); uksort($aProtectedCells, array(__NAMESPACE__ . '\ReferenceHelper','cellSort'));
foreach ($aProtectedCells as $key => $value) { foreach ($aProtectedCells as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) { if ($key != $newReference) {
@ -315,7 +317,7 @@ class PHPExcel_ReferenceHelper
/** /**
* Update column dimensions when inserting/deleting rows/columns * Update column dimensions when inserting/deleting rows/columns
* *
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel\Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
@ -328,7 +330,7 @@ class PHPExcel_ReferenceHelper
if (!empty($aColumnDimensions)) { if (!empty($aColumnDimensions)) {
foreach ($aColumnDimensions as $objColumnDimension) { foreach ($aColumnDimensions as $objColumnDimension) {
$newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows);
list($newReference) = PHPExcel_Cell::coordinateFromString($newReference); list($newReference) = Cell::coordinateFromString($newReference);
if ($objColumnDimension->getColumnIndex() != $newReference) { if ($objColumnDimension->getColumnIndex() != $newReference) {
$objColumnDimension->setColumnIndex($newReference); $objColumnDimension->setColumnIndex($newReference);
} }
@ -340,7 +342,7 @@ class PHPExcel_ReferenceHelper
/** /**
* Update row dimensions when inserting/deleting rows/columns * Update row dimensions when inserting/deleting rows/columns
* *
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel\Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
@ -353,7 +355,7 @@ class PHPExcel_ReferenceHelper
if (!empty($aRowDimensions)) { if (!empty($aRowDimensions)) {
foreach ($aRowDimensions as $objRowDimension) { foreach ($aRowDimensions as $objRowDimension) {
$newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference); list(, $newReference) = Cell::coordinateFromString($newReference);
if ($objRowDimension->getRowIndex() != $newReference) { if ($objRowDimension->getRowIndex() != $newReference) {
$objRowDimension->setRowIndex($newReference); $objRowDimension->setRowIndex($newReference);
} }
@ -377,10 +379,10 @@ class PHPExcel_ReferenceHelper
* @param string $pBefore Insert before this cell address (e.g. 'A1') * @param string $pBefore Insert before this cell address (e.g. 'A1')
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel\Worksheet $pSheet The worksheet that we're editing
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = NULL) public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, Worksheet $pSheet = NULL)
{ {
$remove = ($pNumCols < 0 || $pNumRows < 0); $remove = ($pNumCols < 0 || $pNumRows < 0);
$aCellCollection = $pSheet->getCellCollection(); $aCellCollection = $pSheet->getCellCollection();
@ -388,8 +390,8 @@ class PHPExcel_ReferenceHelper
// Get coordinates of $pBefore // Get coordinates of $pBefore
$beforeColumn = 'A'; $beforeColumn = 'A';
$beforeRow = 1; $beforeRow = 1;
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString($pBefore); list($beforeColumn, $beforeRow) = Cell::coordinateFromString($pBefore);
$beforeColumnIndex = PHPExcel_Cell::columnIndexFromString($beforeColumn); $beforeColumnIndex = Cell::columnIndexFromString($beforeColumn);
// Clear cells if we are removing columns or rows // Clear cells if we are removing columns or rows
$highestColumn = $pSheet->getHighestColumn(); $highestColumn = $pSheet->getHighestColumn();
@ -399,10 +401,10 @@ class PHPExcel_ReferenceHelper
if ($pNumCols < 0 && $beforeColumnIndex - 2 + $pNumCols > 0) { if ($pNumCols < 0 && $beforeColumnIndex - 2 + $pNumCols > 0) {
for ($i = 1; $i <= $highestRow - 1; ++$i) { for ($i = 1; $i <= $highestRow - 1; ++$i) {
for ($j = $beforeColumnIndex - 1 + $pNumCols; $j <= $beforeColumnIndex - 2; ++$j) { for ($j = $beforeColumnIndex - 1 + $pNumCols; $j <= $beforeColumnIndex - 2; ++$j) {
$coordinate = PHPExcel_Cell::stringFromColumnIndex($j) . $i; $coordinate = Cell::stringFromColumnIndex($j) . $i;
$pSheet->removeConditionalStyles($coordinate); $pSheet->removeConditionalStyles($coordinate);
if ($pSheet->cellExists($coordinate)) { if ($pSheet->cellExists($coordinate)) {
$pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL); $pSheet->getCell($coordinate)->setValueExplicit('', Cell_DataType::TYPE_NULL);
$pSheet->getCell($coordinate)->setXfIndex(0); $pSheet->getCell($coordinate)->setXfIndex(0);
} }
} }
@ -411,12 +413,12 @@ class PHPExcel_ReferenceHelper
// 2. Clear row strips if we are removing rows // 2. Clear row strips if we are removing rows
if ($pNumRows < 0 && $beforeRow - 1 + $pNumRows > 0) { if ($pNumRows < 0 && $beforeRow - 1 + $pNumRows > 0) {
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) { for ($i = $beforeColumnIndex - 1; $i <= Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
for ($j = $beforeRow + $pNumRows; $j <= $beforeRow - 1; ++$j) { for ($j = $beforeRow + $pNumRows; $j <= $beforeRow - 1; ++$j) {
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . $j; $coordinate = Cell::stringFromColumnIndex($i) . $j;
$pSheet->removeConditionalStyles($coordinate); $pSheet->removeConditionalStyles($coordinate);
if ($pSheet->cellExists($coordinate)) { if ($pSheet->cellExists($coordinate)) {
$pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL); $pSheet->getCell($coordinate)->setValueExplicit('', Cell_DataType::TYPE_NULL);
$pSheet->getCell($coordinate)->setXfIndex(0); $pSheet->getCell($coordinate)->setXfIndex(0);
} }
} }
@ -426,13 +428,13 @@ class PHPExcel_ReferenceHelper
// Loop through cells, bottom-up, and change cell coordinates // Loop through cells, bottom-up, and change cell coordinates
while (($cellID = $remove ? array_shift($aCellCollection) : array_pop($aCellCollection))) { while (($cellID = $remove ? array_shift($aCellCollection) : array_pop($aCellCollection))) {
$cell = $pSheet->getCell($cellID); $cell = $pSheet->getCell($cellID);
$cellIndex = PHPExcel_Cell::columnIndexFromString($cell->getColumn()); $cellIndex = Cell::columnIndexFromString($cell->getColumn());
if ($cellIndex-1 + $pNumCols < 0) { if ($cellIndex-1 + $pNumCols < 0) {
continue; continue;
} }
// New coordinates // New coordinates
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows); $newCoordinates = Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows);
// Should the cell be updated? Move value and cellXf index from one cell to another. // Should the cell be updated? Move value and cellXf index from one cell to another.
if (($cellIndex >= $beforeColumnIndex) && if (($cellIndex >= $beforeColumnIndex) &&
@ -442,7 +444,7 @@ class PHPExcel_ReferenceHelper
$pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex()); $pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex());
// Insert this cell at its new location // Insert this cell at its new location
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) { if ($cell->getDataType() == Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted // Formula should be adjusted
$pSheet->getCell($newCoordinates) $pSheet->getCell($newCoordinates)
->setValue($this->updateFormulaReferences($cell->getValue(), ->setValue($this->updateFormulaReferences($cell->getValue(),
@ -458,7 +460,7 @@ class PHPExcel_ReferenceHelper
} else { } else {
/* We don't need to update styles for rows/columns before our insertion position, /* We don't need to update styles for rows/columns before our insertion position,
but we do still need to adjust any formulae in those cells */ but we do still need to adjust any formulae in those cells */
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) { if ($cell->getDataType() == Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted // Formula should be adjusted
$cell->setValue($this->updateFormulaReferences($cell->getValue(), $cell->setValue($this->updateFormulaReferences($cell->getValue(),
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle())); $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
@ -475,7 +477,7 @@ class PHPExcel_ReferenceHelper
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) { for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
// Style // Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex( $beforeColumnIndex - 2 ) . $i; $coordinate = Cell::stringFromColumnIndex( $beforeColumnIndex - 2 ) . $i;
if ($pSheet->cellExists($coordinate)) { if ($pSheet->cellExists($coordinate)) {
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex(); $xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ? $conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
@ -487,7 +489,7 @@ class PHPExcel_ReferenceHelper
foreach ($conditionalStyles as $conditionalStyle) { foreach ($conditionalStyles as $conditionalStyle) {
$cloned[] = clone $conditionalStyle; $cloned[] = clone $conditionalStyle;
} }
$pSheet->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($j) . $i, $cloned); $pSheet->setConditionalStyles(Cell::stringFromColumnIndex($j) . $i, $cloned);
} }
} }
} }
@ -496,22 +498,22 @@ class PHPExcel_ReferenceHelper
} }
if ($pNumRows > 0 && $beforeRow - 1 > 0) { if ($pNumRows > 0 && $beforeRow - 1 > 0) {
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) { for ($i = $beforeColumnIndex - 1; $i <= Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
// Style // Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1); $coordinate = Cell::stringFromColumnIndex($i) . ($beforeRow - 1);
if ($pSheet->cellExists($coordinate)) { if ($pSheet->cellExists($coordinate)) {
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex(); $xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ? $conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
$pSheet->getConditionalStyles($coordinate) : false; $pSheet->getConditionalStyles($coordinate) : false;
for ($j = $beforeRow; $j <= $beforeRow - 1 + $pNumRows; ++$j) { for ($j = $beforeRow; $j <= $beforeRow - 1 + $pNumRows; ++$j) {
$pSheet->getCell(PHPExcel_Cell::stringFromColumnIndex($i) . $j)->setXfIndex($xfIndex); $pSheet->getCell(Cell::stringFromColumnIndex($i) . $j)->setXfIndex($xfIndex);
if ($conditionalStyles) { if ($conditionalStyles) {
$cloned = array(); $cloned = array();
foreach ($conditionalStyles as $conditionalStyle) { foreach ($conditionalStyles as $conditionalStyle) {
$cloned[] = clone $conditionalStyle; $cloned[] = clone $conditionalStyle;
} }
$pSheet->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($i) . $j, $cloned); $pSheet->setConditionalStyles(Cell::stringFromColumnIndex($i) . $j, $cloned);
} }
} }
} }
@ -550,8 +552,8 @@ class PHPExcel_ReferenceHelper
$autoFilterColumns = array_keys($autoFilter->getColumns()); $autoFilterColumns = array_keys($autoFilter->getColumns());
if (count($autoFilterColumns) > 0) { if (count($autoFilterColumns) > 0) {
sscanf($pBefore,'%[A-Z]%d', $column, $row); sscanf($pBefore,'%[A-Z]%d', $column, $row);
$columnIndex = PHPExcel_Cell::columnIndexFromString($column); $columnIndex = Cell::columnIndexFromString($column);
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange); list($rangeStart,$rangeEnd) = Cell::rangeBoundaries($autoFilterRange);
if ($columnIndex <= $rangeEnd[0]) { if ($columnIndex <= $rangeEnd[0]) {
if ($pNumCols < 0) { if ($pNumCols < 0) {
// If we're actually deleting any columns that fall within the autofilter range, // If we're actually deleting any columns that fall within the autofilter range,
@ -559,8 +561,8 @@ class PHPExcel_ReferenceHelper
$deleteColumn = $columnIndex + $pNumCols - 1; $deleteColumn = $columnIndex + $pNumCols - 1;
$deleteCount = abs($pNumCols); $deleteCount = abs($pNumCols);
for ($i = 1; $i <= $deleteCount; ++$i) { for ($i = 1; $i <= $deleteCount; ++$i) {
if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn),$autoFilterColumns)) { if (in_array(Cell::stringFromColumnIndex($deleteColumn),$autoFilterColumns)) {
$autoFilter->clearColumn(PHPExcel_Cell::stringFromColumnIndex($deleteColumn)); $autoFilter->clearColumn(Cell::stringFromColumnIndex($deleteColumn));
} }
++$deleteColumn; ++$deleteColumn;
} }
@ -570,24 +572,24 @@ class PHPExcel_ReferenceHelper
// Shuffle columns in autofilter range // Shuffle columns in autofilter range
if ($pNumCols > 0) { if ($pNumCols > 0) {
// For insert, we shuffle from end to beginning to avoid overwriting // For insert, we shuffle from end to beginning to avoid overwriting
$startColID = PHPExcel_Cell::stringFromColumnIndex($startCol-1); $startColID = Cell::stringFromColumnIndex($startCol-1);
$toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1); $toColID = Cell::stringFromColumnIndex($startCol+$pNumCols-1);
$endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]); $endColID = Cell::stringFromColumnIndex($rangeEnd[0]);
$startColRef = $startCol; $startColRef = $startCol;
$endColRef = $rangeEnd[0]; $endColRef = $rangeEnd[0];
$toColRef = $rangeEnd[0]+$pNumCols; $toColRef = $rangeEnd[0]+$pNumCols;
do { do {
$autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1),PHPExcel_Cell::stringFromColumnIndex($toColRef-1)); $autoFilter->shiftColumn(Cell::stringFromColumnIndex($endColRef-1),Cell::stringFromColumnIndex($toColRef-1));
--$endColRef; --$endColRef;
--$toColRef; --$toColRef;
} while ($startColRef <= $endColRef); } while ($startColRef <= $endColRef);
} else { } else {
// For delete, we shuffle from beginning to end to avoid overwriting // For delete, we shuffle from beginning to end to avoid overwriting
$startColID = PHPExcel_Cell::stringFromColumnIndex($startCol-1); $startColID = Cell::stringFromColumnIndex($startCol-1);
$toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1); $toColID = Cell::stringFromColumnIndex($startCol+$pNumCols-1);
$endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]); $endColID = Cell::stringFromColumnIndex($rangeEnd[0]);
do { do {
$autoFilter->shiftColumn($startColID,$toColID); $autoFilter->shiftColumn($startColID,$toColID);
++$startColID; ++$startColID;
@ -643,7 +645,7 @@ class PHPExcel_ReferenceHelper
* @param int $pNumRows Number of rows to insert * @param int $pNumRows Number of rows to insert
* @param string $sheetName Worksheet name/title * @param string $sheetName Worksheet name/title
* @return string Updated formula * @return string Updated formula
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') { public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') {
// Update cell references in the formula // Update cell references in the formula
@ -693,7 +695,7 @@ class PHPExcel_ReferenceHelper
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4; $toString .= $modified3.':'.$modified4;
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($match[3],'$')) + 100000; $column = Cell::columnIndexFromString(trim($match[3],'$')) + 100000;
$row = 10000000; $row = 10000000;
$cellIndex = $column.$row; $cellIndex = $column.$row;
@ -717,9 +719,9 @@ class PHPExcel_ReferenceHelper
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4; $toString .= $modified3.':'.$modified4;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]); list($column,$row) = Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000; $column = Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000; $row = trim($row,'$') + 10000000;
$cellIndex = $column.$row; $cellIndex = $column.$row;
@ -742,9 +744,9 @@ class PHPExcel_ReferenceHelper
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3; $toString .= $modified3;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]); list($column,$row) = Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000; $column = Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000; $row = trim($row,'$') + 10000000;
$cellIndex = $column.$row; $cellIndex = $column.$row;
@ -782,7 +784,7 @@ class PHPExcel_ReferenceHelper
* @param int $pNumCols Number of columns to increment * @param int $pNumCols Number of columns to increment
* @param int $pNumRows Number of rows to increment * @param int $pNumRows Number of rows to increment
* @return string Updated cell range * @return string Updated cell range
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
// Is it in another worksheet? Will not have to update anything. // Is it in another worksheet? Will not have to update anything.
@ -808,7 +810,7 @@ class PHPExcel_ReferenceHelper
* @param string $oldName Old name (name to replace) * @param string $oldName Old name (name to replace)
* @param string $newName New name * @param string $newName New name
*/ */
public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '') { public function updateNamedFormulas(Workbook $pPhpExcel, $oldName = '', $newName = '') {
if ($oldName == '') { if ($oldName == '') {
return; return;
} }
@ -816,12 +818,12 @@ class PHPExcel_ReferenceHelper
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) { foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
foreach ($sheet->getCellCollection(false) as $cellID) { foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID); $cell = $sheet->getCell($cellID);
if (($cell !== NULL) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA)) { if (($cell !== NULL) && ($cell->getDataType() == Cell_DataType::TYPE_FORMULA)) {
$formula = $cell->getValue(); $formula = $cell->getValue();
if (strpos($formula, $oldName) !== false) { if (strpos($formula, $oldName) !== false) {
$formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula); $formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
$formula = str_replace($oldName . "!", $newName . "!", $formula); $formula = str_replace($oldName . "!", $newName . "!", $formula);
$cell->setValueExplicit($formula, PHPExcel_Cell_DataType::TYPE_FORMULA); $cell->setValueExplicit($formula, Cell_DataType::TYPE_FORMULA);
} }
} }
} }
@ -836,21 +838,21 @@ class PHPExcel_ReferenceHelper
* @param int $pNumCols Number of columns to increment * @param int $pNumCols Number of columns to increment
* @param int $pNumRows Number of rows to increment * @param int $pNumRows Number of rows to increment
* @return string Updated cell range * @return string Updated cell range
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) { if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) {
// Update range // Update range
$range = PHPExcel_Cell::splitRange($pCellRange); $range = Cell::splitRange($pCellRange);
$ic = count($range); $ic = count($range);
for ($i = 0; $i < $ic; ++$i) { for ($i = 0; $i < $ic; ++$i) {
$jc = count($range[$i]); $jc = count($range[$i]);
for ($j = 0; $j < $jc; ++$j) { for ($j = 0; $j < $jc; ++$j) {
if (ctype_alpha($range[$i][$j])) { if (ctype_alpha($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows)); $r = Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[0]; $range[$i][$j] = $r[0];
} elseif(ctype_digit($range[$i][$j])) { } elseif(ctype_digit($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows)); $r = Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[1]; $range[$i][$j] = $r[1];
} else { } else {
$range[$i][$j] = $this->_updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows); $range[$i][$j] = $this->_updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows);
@ -859,9 +861,9 @@ class PHPExcel_ReferenceHelper
} }
// Recreate range string // Recreate range string
return PHPExcel_Cell::buildRange($range); return Cell::buildRange($range);
} else { } else {
throw new PHPExcel_Exception("Only cell ranges may be passed to this method."); throw new Exception("Only cell ranges may be passed to this method.");
} }
} }
@ -873,26 +875,26 @@ class PHPExcel_ReferenceHelper
* @param int $pNumCols Number of columns to increment * @param int $pNumCols Number of columns to increment
* @param int $pNumRows Number of rows to increment * @param int $pNumRows Number of rows to increment
* @return string Updated cell reference * @return string Updated cell reference
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) { if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
// Get coordinates of $pBefore // Get coordinates of $pBefore
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore ); list($beforeColumn, $beforeRow) = Cell::coordinateFromString( $pBefore );
// Get coordinates of $pCellReference // Get coordinates of $pCellReference
list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString( $pCellReference ); list($newColumn, $newRow) = Cell::coordinateFromString( $pCellReference );
// Verify which parts should be updated // Verify which parts should be updated
$updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') && $updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') &&
PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn)); Cell::columnIndexFromString($newColumn) >= Cell::columnIndexFromString($beforeColumn));
$updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') && $updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') &&
$newRow >= $beforeRow); $newRow >= $beforeRow);
// Create new column reference // Create new column reference
if ($updateColumn) { if ($updateColumn) {
$newColumn = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols ); $newColumn = Cell::stringFromColumnIndex( Cell::columnIndexFromString($newColumn) - 1 + $pNumCols );
} }
// Create new row reference // Create new row reference
@ -903,16 +905,16 @@ class PHPExcel_ReferenceHelper
// Return new reference // Return new reference
return $newColumn . $newRow; return $newColumn . $newRow;
} else { } else {
throw new PHPExcel_Exception("Only single cell references may be passed to this method."); throw new Exception("Only single cell references may be passed to this method.");
} }
} }
/** /**
* __clone implementation. Cloning should not be allowed in a Singleton! * __clone implementation. Cloning should not be allowed in a Singleton!
* *
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public final function __clone() { public final function __clone() {
throw new PHPExcel_Exception("Cloning a Singleton is not allowed!"); throw new Exception("Cloning a Singleton is not allowed!");
} }
} }

View File

@ -19,36 +19,38 @@
* 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_RichText * @package PHPExcel\RichText
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_RichText * PHPExcel\RichText
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_RichText * @package PHPExcel\RichText
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_RichText implements PHPExcel_IComparable class RichText implements IComparable
{ {
/** /**
* Rich text elements * Rich text elements
* *
* @var PHPExcel_RichText_ITextElement[] * @var PHPExcel\RichText_ITextElement[]
*/ */
private $_richTextElements; private $_richTextElements;
/** /**
* Create a new PHPExcel_RichText instance * Create a new PHPExcel\RichText instance
* *
* @param PHPExcel_Cell $pCell * @param PHPExcel\Cell $pCell
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function __construct(PHPExcel_Cell $pCell = null) public function __construct(Cell $pCell = null)
{ {
// Initialise variables // Initialise variables
$this->_richTextElements = array(); $this->_richTextElements = array();
@ -57,24 +59,24 @@ class PHPExcel_RichText implements PHPExcel_IComparable
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 RichText_Run($pCell->getValue());
$objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
$this->addText($objRun); $this->addText($objRun);
} }
// Set parent value // Set parent value
$pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING); $pCell->setValueExplicit($this, Cell_DataType::TYPE_STRING);
} }
} }
/** /**
* Add text * Add text
* *
* @param PHPExcel_RichText_ITextElement $pText Rich text element * @param PHPExcel\RichText_ITextElement $pText Rich text element
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_RichText * @return PHPExcel\RichText
*/ */
public function addText(PHPExcel_RichText_ITextElement $pText = null) public function addText(RichText_ITextElement $pText = null)
{ {
$this->_richTextElements[] = $pText; $this->_richTextElements[] = $pText;
return $this; return $this;
@ -84,12 +86,12 @@ class PHPExcel_RichText implements PHPExcel_IComparable
* Create text * Create text
* *
* @param string $pText Text * @param string $pText Text
* @return PHPExcel_RichText_TextElement * @return PHPExcel\RichText_TextElement
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function createText($pText = '') public function createText($pText = '')
{ {
$objText = new PHPExcel_RichText_TextElement($pText); $objText = new RichText_TextElement($pText);
$this->addText($objText); $this->addText($objText);
return $objText; return $objText;
} }
@ -98,12 +100,12 @@ class PHPExcel_RichText implements PHPExcel_IComparable
* Create text run * Create text run
* *
* @param string $pText Text * @param string $pText Text
* @return PHPExcel_RichText_Run * @return PHPExcel\RichText_Run
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public function createTextRun($pText = '') public function createTextRun($pText = '')
{ {
$objText = new PHPExcel_RichText_Run($pText); $objText = new RichText_Run($pText);
$this->addText($objText); $this->addText($objText);
return $objText; return $objText;
} }
@ -118,7 +120,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
// Return value // Return value
$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();
} }
@ -140,7 +142,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
/** /**
* Get Rich Text elements * Get Rich Text elements
* *
* @return PHPExcel_RichText_ITextElement[] * @return PHPExcel\RichText_ITextElement[]
*/ */
public function getRichTextElements() public function getRichTextElements()
{ {
@ -150,16 +152,16 @@ class PHPExcel_RichText implements PHPExcel_IComparable
/** /**
* Set Rich Text elements * Set Rich Text elements
* *
* @param PHPExcel_RichText_ITextElement[] $pElements Array of elements * @param PHPExcel\RichText_ITextElement[] $pElements Array of elements
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_RichText * @return PHPExcel\RichText
*/ */
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 Exception("Invalid PHPExcel\RichText_ITextElement[] array passed.");
} }
return $this; return $this;
} }

View File

@ -17,21 +17,23 @@
* 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_RichText * @package PHPExcel\RichText
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_RichText_ITextElement * PHPExcel\RichText_ITextElement
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_RichText * @package PHPExcel\RichText
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
interface PHPExcel_RichText_ITextElement interface RichText_ITextElement
{ {
/** /**
* Get text * Get text
@ -44,14 +46,14 @@ interface PHPExcel_RichText_ITextElement
* 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();

View File

@ -17,31 +17,33 @@
* 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_RichText * @package PHPExcel\RichText
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_RichText_Run * PHPExcel\RichText_Run
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_RichText * @package PHPExcel\RichText
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement class RichText_Run extends RichText_TextElement implements 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
*/ */
@ -49,13 +51,13 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
{ {
// Initialise variables // Initialise variables
$this->setText($pText); $this->setText($pText);
$this->_font = new PHPExcel_Style_Font(); $this->_font = new 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;
@ -64,11 +66,11 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
/** /**
* Set font * Set font
* *
* @param PHPExcel_Style_Font $pFont Font * @param PHPExcel\Style_Font $pFont Font
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
* @return PHPExcel_RichText_ITextElement * @return PHPExcel\RichText_ITextElement
*/ */
public function setFont(PHPExcel_Style_Font $pFont = null) { public function setFont(Style_Font $pFont = null) {
$this->_font = $pFont; $this->_font = $pFont;
return $this; return $this;
} }

View File

@ -17,21 +17,23 @@
* 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_RichText * @package PHPExcel\RichText
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_RichText_TextElement * PHPExcel\RichText_TextElement
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_RichText * @package PHPExcel\RichText
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement class RichText_TextElement implements RichText_ITextElement
{ {
/** /**
* Text * Text
@ -41,7 +43,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
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
*/ */
@ -64,7 +66,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* 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 = '') {
$this->_text = $pText; $this->_text = $pText;
@ -74,7 +76,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
/** /**
* Get font * Get font
* *
* @return PHPExcel_Style_Font * @return PHPExcel\Style_Font
*/ */
public function getFont() { public function getFont() {
return null; return null;

View File

@ -19,23 +19,16 @@
* 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_Settings * @package PHPExcel\Settings
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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 root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
namespace PHPExcel;
class PHPExcel_Settings class Settings
{ {
/** constants */ /** constants */
/** Available Zip library classes */ /** Available Zip library classes */
@ -110,7 +103,7 @@ class PHPExcel_Settings
* 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)
@ -130,7 +123,7 @@ class PHPExcel_Settings
* *
* @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()
{ {
@ -145,7 +138,7 @@ class PHPExcel_Settings
*/ */
public static function getCacheStorageMethod() public static function getCacheStorageMethod()
{ {
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod(); return CachedObjectStorageFactory::getCacheStorageMethod();
} // function getCacheStorageMethod() } // function getCacheStorageMethod()
@ -156,7 +149,7 @@ class PHPExcel_Settings
*/ */
public static function getCacheStorageClass() public static function getCacheStorageClass()
{ {
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass(); return CachedObjectStorageFactory::getCacheStorageClass();
} // function getCacheStorageClass() } // function getCacheStorageClass()
@ -168,11 +161,11 @@ class PHPExcel_Settings
* @return boolean Success or failure * @return boolean Success or failure
*/ */
public static function setCacheStorageMethod( public static function setCacheStorageMethod(
$method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $method = CachedObjectStorageFactory::cache_in_memory,
$arguments = array() $arguments = array()
) )
{ {
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments); return CachedObjectStorageFactory::initialize($method, $arguments);
} // function setCacheStorageMethod() } // function setCacheStorageMethod()
@ -184,7 +177,7 @@ class PHPExcel_Settings
*/ */
public static function setLocale($locale='en_us') public static function setLocale($locale='en_us')
{ {
return PHPExcel_Calculation::getInstance()->setLocale($locale); return Calculation::getInstance()->setLocale($locale);
} // function setLocale() } // function setLocale()
@ -192,7 +185,7 @@ class PHPExcel_Settings
* 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
@ -209,7 +202,7 @@ class PHPExcel_Settings
* 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
*/ */
@ -247,7 +240,7 @@ class PHPExcel_Settings
* *
* @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()
{ {
@ -271,9 +264,9 @@ class PHPExcel_Settings
* 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
* *
* @return boolean Success or failure * @return boolean Success or failure
@ -290,9 +283,9 @@ class PHPExcel_Settings
* 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
*/ */
@ -330,9 +323,9 @@ class PHPExcel_Settings
* *
* @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()
{ {

View File

@ -19,21 +19,23 @@
* 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_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_CodePage * PHPExcel\Shared_CodePage
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_CodePage class Shared_CodePage
{ {
/** /**
* Convert Microsoft Code Page Identifier to Code Page Name which iconv * Convert Microsoft Code Page Identifier to Code Page Name which iconv
@ -41,14 +43,14 @@ class PHPExcel_Shared_CodePage
* *
* @param integer $codePage Microsoft Code Page Indentifier * @param integer $codePage Microsoft Code Page Indentifier
* @return string Code Page Name * @return string Code Page Name
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public static function NumberToName($codePage = 1252) public static function NumberToName($codePage = 1252)
{ {
switch ($codePage) { switch ($codePage) {
case 367: return 'ASCII'; break; // ASCII case 367: return 'ASCII'; break; // ASCII
case 437: return 'CP437'; break; // OEM US case 437: return 'CP437'; break; // OEM US
case 720: throw new PHPExcel_Exception('Code page 720 not supported.'); case 720: throw new Exception('Code page 720 not supported.');
break; // OEM Arabic break; // OEM Arabic
case 737: return 'CP737'; break; // OEM Greek case 737: return 'CP737'; break; // OEM Greek
case 775: return 'CP775'; break; // OEM Baltic case 775: return 'CP775'; break; // OEM Baltic
@ -89,13 +91,13 @@ class PHPExcel_Shared_CodePage
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
case 32768: return 'MAC'; break; // Apple Roman case 32768: return 'MAC'; break; // Apple Roman
case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.'); case 32769: throw new Exception('Code page 32769 not supported.');
break; // ANSI Latin I (BIFF2-BIFF3) break; // ANSI Latin I (BIFF2-BIFF3)
case 65000: return 'UTF-7'; break; // Unicode (UTF-7) case 65000: return 'UTF-7'; break; // Unicode (UTF-7)
case 65001: return 'UTF-8'; break; // Unicode (UTF-8) case 65001: return 'UTF-8'; break; // Unicode (UTF-8)
} }
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage); throw new Exception('Unknown codepage: ' . $codePage);
} }
} }

View File

@ -20,21 +20,23 @@
* 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_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Date * PHPExcel\Shared_Date
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Date class Shared_Date
{ {
/** constants */ /** constants */
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0 const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
@ -143,7 +145,7 @@ class PHPExcel_Shared_Date
} }
$timezoneAdjustment = ($adjustToTimezone) ? $timezoneAdjustment = ($adjustToTimezone) ?
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) : Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) :
0; 0;
// Return // Return
@ -248,10 +250,10 @@ class PHPExcel_Shared_Date
/** /**
* Is a given cell a date/time? * Is a given cell a date/time?
* *
* @param PHPExcel_Cell $pCell * @param PHPExcel\Cell $pCell
* @return boolean * @return boolean
*/ */
public static function isDateTime(PHPExcel_Cell $pCell) { public static function isDateTime(Cell $pCell) {
return self::isDateTimeFormat( return self::isDateTimeFormat(
$pCell->getWorksheet()->getStyle( $pCell->getWorksheet()->getStyle(
$pCell->getCoordinate() $pCell->getCoordinate()
@ -263,10 +265,10 @@ class PHPExcel_Shared_Date
/** /**
* Is a given number format a date/time? * Is a given number format a date/time?
* *
* @param PHPExcel_Style_NumberFormat $pFormat * @param Style_NumberFormat $pFormat
* @return boolean * @return boolean
*/ */
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat) { public static function isDateTimeFormat(Style_NumberFormat $pFormat) {
return self::isDateTimeFormatCode($pFormat->getFormatCode()); return self::isDateTimeFormatCode($pFormat->getFormatCode());
} // function isDateTimeFormat() } // function isDateTimeFormat()
@ -283,31 +285,31 @@ class PHPExcel_Shared_Date
// Switch on formatcode // Switch on formatcode
switch ($pFormatCode) { switch ($pFormatCode) {
// General contains an epoch letter 'e', so we trap for it explicitly here // General contains an epoch letter 'e', so we trap for it explicitly here
case PHPExcel_Style_NumberFormat::FORMAT_GENERAL: case Style_NumberFormat::FORMAT_GENERAL:
return FALSE; return FALSE;
// Explicitly defined date formats // Explicitly defined date formats
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD: case Style_NumberFormat::FORMAT_DATE_YYYYMMDD:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2: case Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY: case Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH: case Style_NumberFormat::FORMAT_DATE_DMYSLASH:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS: case Style_NumberFormat::FORMAT_DATE_DMYMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS: case Style_NumberFormat::FORMAT_DATE_DMMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS: case Style_NumberFormat::FORMAT_DATE_MYMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME: case Style_NumberFormat::FORMAT_DATE_DATETIME:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1: case Style_NumberFormat::FORMAT_DATE_TIME1:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2: case Style_NumberFormat::FORMAT_DATE_TIME2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3: case Style_NumberFormat::FORMAT_DATE_TIME3:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4: case Style_NumberFormat::FORMAT_DATE_TIME4:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5: case Style_NumberFormat::FORMAT_DATE_TIME5:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6: case Style_NumberFormat::FORMAT_DATE_TIME6:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7: case Style_NumberFormat::FORMAT_DATE_TIME7:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8: case Style_NumberFormat::FORMAT_DATE_TIME8:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH: case Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14: case Style_NumberFormat::FORMAT_DATE_XLSX14:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15: case Style_NumberFormat::FORMAT_DATE_XLSX15:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16: case Style_NumberFormat::FORMAT_DATE_XLSX16:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17: case Style_NumberFormat::FORMAT_DATE_XLSX17:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22: case Style_NumberFormat::FORMAT_DATE_XLSX22:
return TRUE; return TRUE;
} }
@ -350,14 +352,14 @@ class PHPExcel_Shared_Date
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue))
return FALSE; return FALSE;
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue); $dateValueNew = Calculation_DateTime::DATEVALUE($dateValue);
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) { if ($dateValueNew === Calculation_Functions::VALUE()) {
return FALSE; return FALSE;
} else { } else {
if (strpos($dateValue, ':') !== FALSE) { if (strpos($dateValue, ':') !== FALSE) {
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue); $timeValue = Calculation_DateTime::TIMEVALUE($dateValue);
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) { if ($timeValue === Calculation_Functions::VALUE()) {
return FALSE; return FALSE;
} }
$dateValueNew += $timeValue; $dateValueNew += $timeValue;

View File

@ -19,21 +19,23 @@
* 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_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Drawing * PHPExcel\Shared_Drawing
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Drawing class Shared_Drawing
{ {
/** /**
* Convert pixels to EMU * Convert pixels to EMU
@ -65,25 +67,25 @@ class PHPExcel_Shared_Drawing
* This gives a conversion factor of 7. Also, we assume that pixels and font size are proportional. * This gives a conversion factor of 7. Also, we assume that pixels and font size are proportional.
* *
* @param int $pValue Value in pixels * @param int $pValue Value in pixels
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook * @param PHPExcel\Style_Font $pDefaultFont Default font of the workbook
* @return int Value in cell dimension * @return int Value in cell dimension
*/ */
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont) { public static function pixelsToCellDimension($pValue = 0, Style_Font $pDefaultFont) {
// Font name and size // Font name and size
$name = $pDefaultFont->getName(); $name = $pDefaultFont->getName();
$size = $pDefaultFont->getSize(); $size = $pDefaultFont->getSize();
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) { if (isset(Shared_Font::$defaultColumnWidths[$name][$size])) {
// Exact width can be determined // Exact width can be determined
$colWidth = $pValue $colWidth = $pValue
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'] * Shared_Font::$defaultColumnWidths[$name][$size]['width']
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px']; / Shared_Font::$defaultColumnWidths[$name][$size]['px'];
} else { } else {
// We don't have data for this particular font and size, use approximation by // We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11 // extrapolating from Calibri 11
$colWidth = $pValue * 11 $colWidth = $pValue * 11
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] * Shared_Font::$defaultColumnWidths['Calibri'][11]['width']
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size; / Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
} }
return $colWidth; return $colWidth;
@ -93,26 +95,26 @@ class PHPExcel_Shared_Drawing
* Convert column width from (intrinsic) Excel units to pixels * Convert column width from (intrinsic) Excel units to pixels
* *
* @param float $pValue Value in cell dimension * @param float $pValue Value in cell dimension
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook * @param PHPExcel\Style_Font $pDefaultFont Default font of the workbook
* @return int Value in pixels * @return int Value in pixels
*/ */
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) { public static function cellDimensionToPixels($pValue = 0, Style_Font $pDefaultFont) {
// Font name and size // Font name and size
$name = $pDefaultFont->getName(); $name = $pDefaultFont->getName();
$size = $pDefaultFont->getSize(); $size = $pDefaultFont->getSize();
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) { if (isset(Shared_Font::$defaultColumnWidths[$name][$size])) {
// Exact width can be determined // Exact width can be determined
$colWidth = $pValue $colWidth = $pValue
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'] * Shared_Font::$defaultColumnWidths[$name][$size]['px']
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width']; / Shared_Font::$defaultColumnWidths[$name][$size]['width'];
} else { } else {
// We don't have data for this particular font and size, use approximation by // We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11 // extrapolating from Calibri 11
$colWidth = $pValue * $size $colWidth = $pValue * $size
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] * Shared_Font::$defaultColumnWidths['Calibri'][11]['px']
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11; / Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
} }
// Round pixels to closest integer // Round pixels to closest integer

View File

@ -19,39 +19,42 @@
* 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_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Escher * PHPExcel\Shared_Escher
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Escher class Shared_Escher
{ {
/** /**
* Drawing Group Container * Drawing Group Container
* *
* @var PHPExcel_Shared_Escher_DggContainer * @var PHPExcel\Shared_Escher_DggContainer
*/ */
private $_dggContainer; private $_dggContainer;
/** /**
* Drawing Container * Drawing Container
* *
* @var PHPExcel_Shared_Escher_DgContainer * @var PHPExcel\Shared_Escher_DgContainer
*/ */
private $_dgContainer; private $_dgContainer;
/** /**
* Get Drawing Group Container * Get Drawing Group Container
* *
* @return PHPExcel_Shared_Escher_DgContainer * @return PHPExcel\Shared_Escher_DgContainer
*/ */
public function getDggContainer() public function getDggContainer()
{ {
@ -61,7 +64,7 @@ class PHPExcel_Shared_Escher
/** /**
* Set Drawing Group Container * Set Drawing Group Container
* *
* @param PHPExcel_Shared_Escher_DggContainer $dggContainer * @param PHPExcel\Shared_Escher_DggContainer $dggContainer
*/ */
public function setDggContainer($dggContainer) public function setDggContainer($dggContainer)
{ {
@ -71,7 +74,7 @@ class PHPExcel_Shared_Escher
/** /**
* Get Drawing Container * Get Drawing Container
* *
* @return PHPExcel_Shared_Escher_DgContainer * @return PHPExcel\Shared_Escher_DgContainer
*/ */
public function getDgContainer() public function getDgContainer()
{ {
@ -81,7 +84,7 @@ class PHPExcel_Shared_Escher
/** /**
* Set Drawing Container * Set Drawing Container
* *
* @param PHPExcel_Shared_Escher_DgContainer $dgContainer * @param PHPExcel\Shared_Escher_DgContainer $dgContainer
*/ */
public function setDgContainer($dgContainer) public function setDgContainer($dgContainer)
{ {

View File

@ -19,20 +19,23 @@
* 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_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Escher_DgContainer * PHPExcel\Shared_Escher_DgContainer
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Escher_DgContainer class Shared_Escher_DgContainer
{ {
/** /**
* Drawing index, 1-based. * Drawing index, 1-based.

View File

@ -19,25 +19,28 @@
* 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_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Escher_DgContainer_SpgrContainer * PHPExcel\Shared_Escher_DgContainer_SpgrContainer
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer class Shared_Escher_DgContainer_SpgrContainer
{ {
/** /**
* Parent Shape Group Container * Parent Shape Group Container
* *
* @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer * @var PHPExcel\Shared_Escher_DgContainer_SpgrContainer
*/ */
private $_parent; private $_parent;
@ -51,7 +54,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
/** /**
* Set parent Shape Group Container * Set parent Shape Group Container
* *
* @param PHPExcel_Shared_Escher_DgContainer_SpgrContainer $parent * @param PHPExcel\Shared_Escher_DgContainer_SpgrContainer $parent
*/ */
public function setParent($parent) public function setParent($parent)
{ {
@ -61,7 +64,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
/** /**
* Get the parent Shape Group Container if any * Get the parent Shape Group Container if any
* *
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer|null * @return PHPExcel\Shared_Escher_DgContainer_SpgrContainer|null
*/ */
public function getParent() public function getParent()
{ {
@ -90,14 +93,14 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
/** /**
* Recursively get all spContainers within this spgrContainer * Recursively get all spContainers within this spgrContainer
* *
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer[] * @return PHPExcel\Shared_Escher_DgContainer_SpgrContainer_SpContainer[]
*/ */
public function getAllSpContainers() public function getAllSpContainers()
{ {
$allSpContainers = array(); $allSpContainers = array();
foreach ($this->_children as $child) { foreach ($this->_children as $child) {
if ($child instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) { if ($child instanceof Shared_Escher_DgContainer_SpgrContainer) {
$allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers()); $allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers());
} else { } else {
$allSpContainers[] = $child; $allSpContainers[] = $child;

View File

@ -19,25 +19,28 @@
* 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_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer * PHPExcel\Shared_Escher_DgContainer_SpgrContainer_SpContainer
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer class Shared_Escher_DgContainer_SpgrContainer_SpContainer
{ {
/** /**
* Parent Shape Group Container * Parent Shape Group Container
* *
* @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer * @var PHPExcel\Shared_Escher_DgContainer_SpgrContainer
*/ */
private $_parent; private $_parent;
@ -121,7 +124,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
/** /**
* Set parent Shape Group Container * Set parent Shape Group Container
* *
* @param PHPExcel_Shared_Escher_DgContainer_SpgrContainer $parent * @param PHPExcel\Shared_Escher_DgContainer_SpgrContainer $parent
*/ */
public function setParent($parent) public function setParent($parent)
{ {
@ -131,7 +134,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
/** /**
* Get the parent Shape Group Container * Get the parent Shape Group Container
* *
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer * @return PHPExcel\Shared_Escher_DgContainer_SpgrContainer
*/ */
public function getParent() public function getParent()
{ {
@ -385,7 +388,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
$nestingLevel = 0; $nestingLevel = 0;
$parent = $this->getParent(); $parent = $this->getParent();
while ($parent instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) { while ($parent instanceof Shared_Escher_DgContainer_SpgrContainer) {
++$nestingLevel; ++$nestingLevel;
$parent = $parent->getParent(); $parent = $parent->getParent();
} }

View File

@ -19,20 +19,23 @@
* 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_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Escher_DggContainer * PHPExcel\Shared_Escher_DggContainer
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Escher_DggContainer class Shared_Escher_DggContainer
{ {
/** /**
* Maximum shape index of all shapes in all drawings increased by one * Maximum shape index of all shapes in all drawings increased by one
@ -58,7 +61,7 @@ class PHPExcel_Shared_Escher_DggContainer
/** /**
* BLIP Store Container * BLIP Store Container
* *
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer * @var PHPExcel\Shared_Escher_DggContainer_BstoreContainer
*/ */
private $_bstoreContainer; private $_bstoreContainer;
@ -139,7 +142,7 @@ class PHPExcel_Shared_Escher_DggContainer
/** /**
* Get BLIP Store Container * Get BLIP Store Container
* *
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer * @return PHPExcel\Shared_Escher_DggContainer_BstoreContainer
*/ */
public function getBstoreContainer() public function getBstoreContainer()
{ {
@ -149,7 +152,7 @@ class PHPExcel_Shared_Escher_DggContainer
/** /**
* Set BLIP Store Container * Set BLIP Store Container
* *
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer $bstoreContainer * @param PHPExcel\Shared_Escher_DggContainer_BstoreContainer $bstoreContainer
*/ */
public function setBstoreContainer($bstoreContainer) public function setBstoreContainer($bstoreContainer)
{ {

View File

@ -19,20 +19,23 @@
* 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_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer * PHPExcel\Shared_Escher_DggContainer_BstoreContainer
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer class Shared_Escher_DggContainer_BstoreContainer
{ {
/** /**
* BLIP Store Entries. Each of them holds one BLIP (Big Large Image or Picture) * BLIP Store Entries. Each of them holds one BLIP (Big Large Image or Picture)
@ -44,7 +47,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
/** /**
* Add a BLIP Store Entry * Add a BLIP Store Entry
* *
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $BSE * @param PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE $BSE
*/ */
public function addBSE($BSE) public function addBSE($BSE)
{ {
@ -55,7 +58,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
/** /**
* Get the collection of BLIP Store Entries * Get the collection of BLIP Store Entries
* *
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE[] * @return PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE[]
*/ */
public function getBSECollection() public function getBSECollection()
{ {

View File

@ -19,20 +19,23 @@
* 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_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE * PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE class Shared_Escher_DggContainer_BstoreContainer_BSE
{ {
const BLIPTYPE_ERROR = 0x00; const BLIPTYPE_ERROR = 0x00;
const BLIPTYPE_UNKNOWN = 0x01; const BLIPTYPE_UNKNOWN = 0x01;
@ -48,14 +51,14 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
/** /**
* The parent BLIP Store Entry Container * The parent BLIP Store Entry Container
* *
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer * @var PHPExcel\Shared_Escher_DggContainer_BstoreContainer
*/ */
private $_parent; private $_parent;
/** /**
* The BLIP (Big Large Image or Picture) * The BLIP (Big Large Image or Picture)
* *
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip * @var PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
*/ */
private $_blip; private $_blip;
@ -69,7 +72,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
/** /**
* Set parent BLIP Store Entry Container * Set parent BLIP Store Entry Container
* *
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer $parent * @param PHPExcel\Shared_Escher_DggContainer_BstoreContainer $parent
*/ */
public function setParent($parent) public function setParent($parent)
{ {
@ -79,7 +82,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
/** /**
* Get the BLIP * Get the BLIP
* *
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip * @return PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
*/ */
public function getBlip() public function getBlip()
{ {
@ -89,7 +92,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
/** /**
* Set the BLIP * Set the BLIP
* *
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip $blip * @param PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE_Blip $blip
*/ */
public function setBlip($blip) public function setBlip($blip)
{ {

View File

@ -19,25 +19,28 @@
* 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_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip * PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_Escher * @package PHPExcel\Shared_Escher
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip class Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
{ {
/** /**
* The parent BSE * The parent BSE
* *
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE * @var PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE
*/ */
private $_parent; private $_parent;
@ -71,7 +74,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
/** /**
* Set parent BSE * Set parent BSE
* *
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $parent * @param PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE $parent
*/ */
public function setParent($parent) public function setParent($parent)
{ {
@ -81,7 +84,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
/** /**
* Get parent BSE * Get parent BSE
* *
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $parent * @return PHPExcel\Shared_Escher_DggContainer_BstoreContainer_BSE $parent
*/ */
public function getParent() public function getParent()
{ {

View File

@ -19,27 +19,30 @@
* 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_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Excel5 * PHPExcel\Shared_Excel5
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Excel5 class Shared_Excel5
{ {
/** /**
* Get the width of a column in pixels. We use the relationship y = ceil(7x) where * Get the width of a column in pixels. We use the relationship y = ceil(7x) where
* x is the width in intrinsic Excel units (measuring width in number of normal characters) * x is the width in intrinsic Excel units (measuring width in number of normal characters)
* This holds for Arial 10 * This holds for Arial 10
* *
* @param PHPExcel_Worksheet $sheet The sheet * @param PHPExcel\Worksheet $sheet The sheet
* @param string $col The column * @param string $col The column
* @return integer The width in pixels * @return integer The width in pixels
*/ */
@ -56,19 +59,19 @@ class PHPExcel_Shared_Excel5
// then we have column dimension with explicit width // then we have column dimension with explicit width
$columnDimension = $columnDimensions[$col]; $columnDimension = $columnDimensions[$col];
$width = $columnDimension->getWidth(); $width = $columnDimension->getWidth();
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font); $pixelWidth = Shared_Drawing::cellDimensionToPixels($width, $font);
} else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) { } else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
// then we have default column dimension with explicit width // then we have default column dimension with explicit width
$defaultColumnDimension = $sheet->getDefaultColumnDimension(); $defaultColumnDimension = $sheet->getDefaultColumnDimension();
$width = $defaultColumnDimension->getWidth(); $width = $defaultColumnDimension->getWidth();
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font); $pixelWidth = Shared_Drawing::cellDimensionToPixels($width, $font);
} else { } else {
// we don't even have any default column dimension. Width depends on default font // we don't even have any default column dimension. Width depends on default font
$pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true); $pixelWidth = Shared_Font::getDefaultColumnWidthByFont($font, true);
} }
// now find the effective column width in pixels // now find the effective column width in pixels
@ -86,7 +89,7 @@ class PHPExcel_Shared_Excel5
* the relationship is: y = 4/3x. If the height hasn't been set by the user we * the relationship is: y = 4/3x. If the height hasn't been set by the user we
* use the default value. If the row is hidden we use a value of zero. * use the default value. If the row is hidden we use a value of zero.
* *
* @param PHPExcel_Worksheet $sheet The sheet * @param PHPExcel\Worksheet $sheet The sheet
* @param integer $row The row index (1-based) * @param integer $row The row index (1-based)
* @return integer The width in pixels * @return integer The width in pixels
*/ */
@ -110,13 +113,13 @@ class PHPExcel_Shared_Excel5
// then we have a default row dimension with explicit height // then we have a default row dimension with explicit height
$defaultRowDimension = $sheet->getDefaultRowDimension(); $defaultRowDimension = $sheet->getDefaultRowDimension();
$rowHeight = $defaultRowDimension->getRowHeight(); $rowHeight = $defaultRowDimension->getRowHeight();
$pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight); $pixelRowHeight = Shared_Drawing::pointsToPixels($rowHeight);
} else { } else {
// we don't even have any default row dimension. Height depends on default font // we don't even have any default row dimension. Height depends on default font
$pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font); $pointRowHeight = Shared_Font::getDefaultRowHeightByFont($font);
$pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight); $pixelRowHeight = Shared_Font::fontSizeToPixels($pointRowHeight);
} }
@ -134,22 +137,22 @@ class PHPExcel_Shared_Excel5
* Get the horizontal distance in pixels between two anchors * Get the horizontal distance in pixels between two anchors
* The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets * The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets
* *
* @param PHPExcel_Worksheet $sheet * @param PHPExcel\Worksheet $sheet
* @param string $startColumn * @param string $startColumn
* @param integer $startOffsetX Offset within start cell measured in 1/1024 of the cell width * @param integer $startOffsetX Offset within start cell measured in 1/1024 of the cell width
* @param string $endColumn * @param string $endColumn
* @param integer $endOffsetX Offset within end cell measured in 1/1024 of the cell width * @param integer $endOffsetX Offset within end cell measured in 1/1024 of the cell width
* @return integer Horizontal measured in pixels * @return integer Horizontal measured in pixels
*/ */
public static function getDistanceX(PHPExcel_Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0) public static function getDistanceX(Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0)
{ {
$distanceX = 0; $distanceX = 0;
// add the widths of the spanning columns // add the widths of the spanning columns
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; // 1-based $startColumnIndex = Cell::columnIndexFromString($startColumn) - 1; // 1-based
$endColumnIndex = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; // 1-based $endColumnIndex = Cell::columnIndexFromString($endColumn) - 1; // 1-based
for ($i = $startColumnIndex; $i <= $endColumnIndex; ++$i) { for ($i = $startColumnIndex; $i <= $endColumnIndex; ++$i) {
$distanceX += self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($i)); $distanceX += self::sizeCol($sheet, Cell::stringFromColumnIndex($i));
} }
// correct for offsetX in startcell // correct for offsetX in startcell
@ -165,14 +168,14 @@ class PHPExcel_Shared_Excel5
* Get the vertical distance in pixels between two anchors * Get the vertical distance in pixels between two anchors
* The distanceY is found as sum of all the spanning rows minus two offsets * The distanceY is found as sum of all the spanning rows minus two offsets
* *
* @param PHPExcel_Worksheet $sheet * @param PHPExcel\Worksheet $sheet
* @param integer $startRow (1-based) * @param integer $startRow (1-based)
* @param integer $startOffsetY Offset within start cell measured in 1/256 of the cell height * @param integer $startOffsetY Offset within start cell measured in 1/256 of the cell height
* @param integer $endRow (1-based) * @param integer $endRow (1-based)
* @param integer $endOffsetY Offset within end cell measured in 1/256 of the cell height * @param integer $endOffsetY Offset within end cell measured in 1/256 of the cell height
* @return integer Vertical distance measured in pixels * @return integer Vertical distance measured in pixels
*/ */
public static function getDistanceY(PHPExcel_Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0) public static function getDistanceY(Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0)
{ {
$distanceY = 0; $distanceY = 0;
@ -234,7 +237,7 @@ class PHPExcel_Shared_Excel5
* W is the width of the cell * W is the width of the cell
* H is the height of the cell * H is the height of the cell
* *
* @param PHPExcel_Worksheet $sheet * @param PHPExcel\Worksheet $sheet
* @param string $coordinates E.g. 'A1' * @param string $coordinates E.g. 'A1'
* @param integer $offsetX Horizontal offset in pixels * @param integer $offsetX Horizontal offset in pixels
* @param integer $offsetY Vertical offset in pixels * @param integer $offsetY Vertical offset in pixels
@ -244,8 +247,8 @@ class PHPExcel_Shared_Excel5
*/ */
public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height) public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height)
{ {
list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinates); list($column, $row) = Cell::coordinateFromString($coordinates);
$col_start = PHPExcel_Cell::columnIndexFromString($column) - 1; $col_start = Cell::columnIndexFromString($column) - 1;
$row_start = $row - 1; $row_start = $row - 1;
$x1 = $offsetX; $x1 = $offsetX;
@ -256,7 +259,7 @@ class PHPExcel_Shared_Excel5
$row_end = $row_start; // Row containing bottom right corner of object $row_end = $row_start; // Row containing bottom right corner of object
// Zero the specified offset if greater than the cell dimensions // Zero the specified offset if greater than the cell dimensions
if ($x1 >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start))) { if ($x1 >= self::sizeCol($sheet, Cell::stringFromColumnIndex($col_start))) {
$x1 = 0; $x1 = 0;
} }
if ($y1 >= self::sizeRow($sheet, $row_start + 1)) { if ($y1 >= self::sizeRow($sheet, $row_start + 1)) {
@ -267,8 +270,8 @@ class PHPExcel_Shared_Excel5
$height = $height + $y1 -1; $height = $height + $y1 -1;
// Subtract the underlying cell widths to find the end cell of the image // Subtract the underlying cell widths to find the end cell of the image
while ($width >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end))) { while ($width >= self::sizeCol($sheet, Cell::stringFromColumnIndex($col_end))) {
$width -= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)); $width -= self::sizeCol($sheet, Cell::stringFromColumnIndex($col_end));
++$col_end; ++$col_end;
} }
@ -280,10 +283,10 @@ class PHPExcel_Shared_Excel5
// Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell
// with zero height or width. // with zero height or width.
if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) == 0) { if (self::sizeCol($sheet, Cell::stringFromColumnIndex($col_start)) == 0) {
return; return;
} }
if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) == 0) { if (self::sizeCol($sheet, Cell::stringFromColumnIndex($col_end)) == 0) {
return; return;
} }
if (self::sizeRow($sheet, $row_start + 1) == 0) { if (self::sizeRow($sheet, $row_start + 1) == 0) {
@ -294,13 +297,13 @@ class PHPExcel_Shared_Excel5
} }
// Convert the pixel values to the percentage value expected by Excel // Convert the pixel values to the percentage value expected by Excel
$x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024; $x1 = $x1 / self::sizeCol($sheet, Cell::stringFromColumnIndex($col_start)) * 1024;
$y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256; $y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256;
$x2 = ($width + 1) / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object $x2 = ($width + 1) / self::sizeCol($sheet, Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
$y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object $y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object
$startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start) . ($row_start + 1); $startCoordinates = Cell::stringFromColumnIndex($col_start) . ($row_start + 1);
$endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end) . ($row_end + 1); $endCoordinates = Cell::stringFromColumnIndex($col_end) . ($row_end + 1);
$twoAnchor = array( $twoAnchor = array(
'startCoordinates' => $startCoordinates, 'startCoordinates' => $startCoordinates,

View File

@ -19,21 +19,23 @@
* 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_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_File * PHPExcel\Shared_File
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_File class Shared_File
{ {
/* /*
* Use Temp or File Upload Temp for temporary files * Use Temp or File Upload Temp for temporary files

View File

@ -19,21 +19,23 @@
* 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_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_Font * PHPExcel\Shared_Font
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared * @package PHPExcel\Shared
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_Font class Shared_Font
{ {
/* Methods for resolving autosize value */ /* Methods for resolving autosize value */
const AUTOSIZE_METHOD_APPROX = 'approx'; const AUTOSIZE_METHOD_APPROX = 'approx';
@ -244,16 +246,16 @@ class PHPExcel_Shared_Font
/** /**
* Calculate an (approximate) OpenXML column width, based on font size and text contained * Calculate an (approximate) OpenXML column width, based on font size and text contained
* *
* @param PHPExcel_Style_Font $font Font object * @param PHPExcel\Style_Font $font Font object
* @param PHPExcel_RichText|string $cellText Text to calculate width * @param PHPExcel\RichText|string $cellText Text to calculate width
* @param integer $rotation Rotation angle * @param integer $rotation Rotation angle
* @param PHPExcel_Style_Font|NULL $defaultFont Font object * @param PHPExcel\Style_Font|NULL $defaultFont Font object
* @return integer Column width * @return integer Column width
*/ */
public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) { public static function calculateColumnWidth(Style_Font $font, $cellText = '', $rotation = 0, Style_Font $defaultFont = null) {
// If it is rich text, use plain text // If it is rich text, use plain text
if ($cellText instanceof PHPExcel_RichText) { if ($cellText instanceof RichText) {
$cellText = $cellText->getPlainText(); $cellText = $cellText->getPlainText();
} }
@ -271,7 +273,7 @@ class PHPExcel_Shared_Font
try { try {
// If autosize method is set to 'approx', use approximation // If autosize method is set to 'approx', use approximation
if (self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX) { if (self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX) {
throw new PHPExcel_Exception('AutoSize method is set to approx'); throw new Exception('AutoSize method is set to approx');
} }
// Width of text in pixels excl. padding // Width of text in pixels excl. padding
@ -280,7 +282,7 @@ class PHPExcel_Shared_Font
// Excel adds some padding, use 1.07 of the width of an 'n' glyph // Excel adds some padding, use 1.07 of the width of an 'n' glyph
$columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding $columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding
} catch (PHPExcel_Exception $e) { } catch (Exception $e) {
// Width of text in pixels excl. padding, approximation // Width of text in pixels excl. padding, approximation
$columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation); $columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation);
@ -289,7 +291,7 @@ class PHPExcel_Shared_Font
} }
// Convert from pixel width to column width // Convert from pixel width to column width
$columnWidth = PHPExcel_Shared_Drawing::pixelsToCellDimension($columnWidth, $defaultFont); $columnWidth = Shared_Drawing::pixelsToCellDimension($columnWidth, $defaultFont);
// Return // Return
return round($columnWidth, 6); return round($columnWidth, 6);
@ -299,14 +301,14 @@ class PHPExcel_Shared_Font
* Get GD text width in pixels for a string of text in a certain font at a certain rotation angle * Get GD text width in pixels for a string of text in a certain font at a certain rotation angle
* *
* @param string $text * @param string $text
* @param PHPExcel_Style_Font * @param PHPExcel\Style_Font
* @param int $rotation * @param int $rotation
* @return int * @return int
* @throws PHPExcel_Exception * @throws PHPExcel\Exception
*/ */
public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0) { public static function getTextWidthPixelsExact($text, Style_Font $font, $rotation = 0) {
if (!function_exists('imagettfbbox')) { if (!function_exists('imagettfbbox')) {
throw new PHPExcel_Exception('GD library needs to be enabled'); throw new Exception('GD library needs to be enabled');
} }
// font size should really be supplied in pixels in GD2, // font size should really be supplied in pixels in GD2,
@ -334,11 +336,11 @@ class PHPExcel_Shared_Font
* Get approximate width in pixels for a string of text in a certain font at a certain rotation angle * Get approximate width in pixels for a string of text in a certain font at a certain rotation angle
* *
* @param string $columnText * @param string $columnText
* @param PHPExcel_Style_Font $font * @param PHPExcel\Style_Font $font
* @param int $rotation * @param int $rotation
* @return int Text width in pixels (no padding added) * @return int Text width in pixels (no padding added)
*/ */
public static function getTextWidthPixelsApprox($columnText, PHPExcel_Style_Font $font = null, $rotation = 0) public static function getTextWidthPixelsApprox($columnText, Style_Font $font = null, $rotation = 0)
{ {
$fontName = $font->getName(); $fontName = $font->getName();
$fontSize = $font->getSize(); $fontSize = $font->getSize();
@ -347,25 +349,25 @@ class PHPExcel_Shared_Font
switch ($fontName) { switch ($fontName) {
case 'Calibri': case 'Calibri':
// value 8.26 was found via interpolation by inspecting real Excel files with Calibri 11 font. // value 8.26 was found via interpolation by inspecting real Excel files with Calibri 11 font.
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText)); $columnWidth = (int) (8.26 * Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size $columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
break; break;
case 'Arial': case 'Arial':
// value 7 was found via interpolation by inspecting real Excel files with Arial 10 font. // value 7 was found via interpolation by inspecting real Excel files with Arial 10 font.
$columnWidth = (int) (7 * PHPExcel_Shared_String::CountCharacters($columnText)); $columnWidth = (int) (7 * Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size $columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
break; break;
case 'Verdana': case 'Verdana':
// value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font. // value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font.
$columnWidth = (int) (8 * PHPExcel_Shared_String::CountCharacters($columnText)); $columnWidth = (int) (8 * Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size $columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
break; break;
default: default:
// just assume Calibri // just assume Calibri
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText)); $columnWidth = (int) (8.26 * Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size $columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
break; break;
} }
@ -420,12 +422,12 @@ class PHPExcel_Shared_Font
/** /**
* Returns the font path given the font * Returns the font path given the font
* *
* @param PHPExcel_Style_Font * @param PHPExcel\Style_Font
* @return string Path to TrueType font file * @return string Path to TrueType font file
*/ */
public static function getTrueTypeFontFileFromFont($font) { public static function getTrueTypeFontFileFromFont($font) {
if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) { if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) {
throw new PHPExcel_Exception('Valid directory to TrueType Font files not specified'); throw new Exception('Valid directory to TrueType Font files not specified');
} }
$name = $font->getName(); $name = $font->getName();
@ -530,7 +532,7 @@ class PHPExcel_Shared_Font
break; break;
default: default:
throw new PHPExcel_Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file'); throw new Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file');
break; break;
} }
@ -538,7 +540,7 @@ class PHPExcel_Shared_Font
// Check if file actually exists // Check if file actually exists
if (!file_exists($fontFile)) { if (!file_exists($fontFile)) {
throw New PHPExcel_Exception('TrueType Font file not found'); throw New Exception('TrueType Font file not found');
} }
return $fontFile; return $fontFile;
@ -566,11 +568,11 @@ class PHPExcel_Shared_Font
* Get the effective column width for columns without a column dimension or column with width -1 * Get the effective column width for columns without a column dimension or column with width -1
* For example, for Calibri 11 this is 9.140625 (64 px) * For example, for Calibri 11 this is 9.140625 (64 px)
* *
* @param PHPExcel_Style_Font $font The workbooks default font * @param PHPExcel\Style_Font $font The workbooks default font
* @param boolean $pPixels true = return column width in pixels, false = return in OOXML units * @param boolean $pPixels true = return column width in pixels, false = return in OOXML units
* @return mixed Column width * @return mixed Column width
*/ */
public static function getDefaultColumnWidthByFont(PHPExcel_Style_Font $font, $pPixels = false) public static function getDefaultColumnWidthByFont(Style_Font $font, $pPixels = false)
{ {
if (isset(self::$defaultColumnWidths[$font->getName()][$font->getSize()])) { if (isset(self::$defaultColumnWidths[$font->getName()][$font->getSize()])) {
// Exact width can be determined // Exact width can be determined
@ -599,10 +601,10 @@ class PHPExcel_Shared_Font
* Get the effective row height for rows without a row dimension or rows with height -1 * Get the effective row height for rows without a row dimension or rows with height -1
* For example, for Calibri 11 this is 15 points * For example, for Calibri 11 this is 15 points
* *
* @param PHPExcel_Style_Font $font The workbooks default font * @param PHPExcel\Style_Font $font The workbooks default font
* @return float Row height in points * @return float Row height in points
*/ */
public static function getDefaultRowHeightByFont(PHPExcel_Style_Font $font) public static function getDefaultRowHeightByFont(Style_Font $font)
{ {
switch ($font->getName()) { switch ($font->getName()) {
case 'Arial': case 'Arial':

View File

@ -73,7 +73,7 @@ class CholeskyDecomposition {
} }
} }
} else { } else {
throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException)); throw new PHPExcel\Calculation_Exception(JAMAError(ArgumentTypeException));
} }
} // function __construct() } // function __construct()
@ -136,13 +136,13 @@ class CholeskyDecomposition {
return new Matrix($X, $this->m, $nx); return new Matrix($X, $this->m, $nx);
} else { } else {
throw new PHPExcel_Calculation_Exception(JAMAError(MatrixSPDException)); throw new PHPExcel\Calculation_Exception(JAMAError(MatrixSPDException));
} }
} else { } else {
throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionException)); throw new PHPExcel\Calculation_Exception(JAMAError(MatrixDimensionException));
} }
} else { } else {
throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException)); throw new PHPExcel\Calculation_Exception(JAMAError(ArgumentTypeException));
} }
} // function solve() } // function solve()

View File

@ -20,6 +20,8 @@
// $Id: OLE.php,v 1.13 2007/03/07 14:38:25 schmidt Exp $ // $Id: OLE.php,v 1.13 2007/03/07 14:38:25 schmidt Exp $
namespace PHPExcel;
/** /**
* Array for storing OLE instances that are accessed from * Array for storing OLE instances that are accessed from
* OLE_ChainedBlockStream::stream_open(). * OLE_ChainedBlockStream::stream_open().
@ -33,9 +35,9 @@ $GLOBALS['_OLE_INSTANCES'] = array();
* @author Xavier Noguer <xnoguer@php.net> * @author Xavier Noguer <xnoguer@php.net>
* @author Christian Schmidt <schmidt@php.net> * @author Christian Schmidt <schmidt@php.net>
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_OLE * @package PHPExcel\Shared_OLE
*/ */
class PHPExcel_Shared_OLE class Shared_OLE
{ {
const OLE_PPS_TYPE_ROOT = 5; const OLE_PPS_TYPE_ROOT = 5;
const OLE_PPS_TYPE_DIR = 1; const OLE_PPS_TYPE_DIR = 1;
@ -97,18 +99,18 @@ class PHPExcel_Shared_OLE
{ {
$fh = fopen($file, "r"); $fh = fopen($file, "r");
if (!$fh) { if (!$fh) {
throw new PHPExcel_Reader_Exception("Can't open file $file"); throw new Reader_Exception("Can't open file $file");
} }
$this->_file_handle = $fh; $this->_file_handle = $fh;
$signature = fread($fh, 8); $signature = fread($fh, 8);
if ("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" != $signature) { if ("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" != $signature) {
throw new PHPExcel_Reader_Exception("File doesn't seem to be an OLE container."); throw new Reader_Exception("File doesn't seem to be an OLE container.");
} }
fseek($fh, 28); fseek($fh, 28);
if (fread($fh, 2) != "\xFE\xFF") { if (fread($fh, 2) != "\xFE\xFF") {
// This shouldn't be a problem in practice // This shouldn't be a problem in practice
throw new PHPExcel_Reader_Exception("Only Little-Endian encoding is supported."); throw new Reader_Exception("Only Little-Endian encoding is supported.");
} }
// Size of blocks and short blocks in bytes // Size of blocks and short blocks in bytes
$this->bigBlockSize = pow(2, self::_readInt2($fh)); $this->bigBlockSize = pow(2, self::_readInt2($fh));
@ -190,7 +192,7 @@ class PHPExcel_Shared_OLE
/** /**
* Returns a stream for use with fread() etc. External callers should * Returns a stream for use with fread() etc. External callers should
* use PHPExcel_Shared_OLE_PPS_File::getStream(). * use PHPExcel\Shared_OLE_PPS_File::getStream().
* @param int|PPS block id or PPS * @param int|PPS block id or PPS
* @return resource read-only stream * @return resource read-only stream
*/ */
@ -199,7 +201,7 @@ class PHPExcel_Shared_OLE
static $isRegistered = false; static $isRegistered = false;
if (!$isRegistered) { if (!$isRegistered) {
stream_wrapper_register('ole-chainedblockstream', stream_wrapper_register('ole-chainedblockstream',
'PHPExcel_Shared_OLE_ChainedBlockStream'); __NAMESPACE__ . '\Shared_OLE_ChainedBlockStream');
$isRegistered = true; $isRegistered = true;
} }
@ -210,7 +212,7 @@ class PHPExcel_Shared_OLE
$instanceId = end(array_keys($GLOBALS['_OLE_INSTANCES'])); $instanceId = end(array_keys($GLOBALS['_OLE_INSTANCES']));
$path = 'ole-chainedblockstream://oleInstanceId=' . $instanceId; $path = 'ole-chainedblockstream://oleInstanceId=' . $instanceId;
if ($blockIdOrPps instanceof PHPExcel_Shared_OLE_PPS) { if ($blockIdOrPps instanceof Shared_OLE_PPS) {
$path .= '&blockId=' . $blockIdOrPps->_StartBlock; $path .= '&blockId=' . $blockIdOrPps->_StartBlock;
$path .= '&size=' . $blockIdOrPps->Size; $path .= '&size=' . $blockIdOrPps->Size;
} else { } else {
@ -276,15 +278,15 @@ class PHPExcel_Shared_OLE
$type = self::_readInt1($fh); $type = self::_readInt1($fh);
switch ($type) { switch ($type) {
case self::OLE_PPS_TYPE_ROOT: case self::OLE_PPS_TYPE_ROOT:
$pps = new PHPExcel_Shared_OLE_PPS_Root(null, null, array()); $pps = new Shared_OLE_PPS_Root(null, null, array());
$this->root = $pps; $this->root = $pps;
break; break;
case self::OLE_PPS_TYPE_DIR: case self::OLE_PPS_TYPE_DIR:
$pps = new PHPExcel_Shared_OLE_PPS(null, null, null, null, null, $pps = new Shared_OLE_PPS(null, null, null, null, null,
null, null, null, null, array()); null, null, null, null, array());
break; break;
case self::OLE_PPS_TYPE_FILE: case self::OLE_PPS_TYPE_FILE:
$pps = new PHPExcel_Shared_OLE_PPS_File($name); $pps = new Shared_OLE_PPS_File($name);
break; break;
default: default:
continue; continue;

View File

@ -19,23 +19,26 @@
* 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_Shared_OLE * @package PHPExcel\Shared_OLE
* @copyright Copyright (c) 2006 - 2007 Christian Schmidt * @copyright Copyright (c) 2006 - 2007 Christian Schmidt
* @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##
*/ */
namespace PHPExcel;
/** /**
* PHPExcel_Shared_OLE_ChainedBlockStream * PHPExcel\Shared_OLE_ChainedBlockStream
* *
* Stream wrapper for reading data stored in an OLE file. Implements methods * Stream wrapper for reading data stored in an OLE file. Implements methods
* for PHP's stream_wrapper_register(). For creating streams using this * for PHP's stream_wrapper_register(). For creating streams using this
* wrapper, use PHPExcel_Shared_OLE_PPS_File::getStream(). * wrapper, use PHPExcel\Shared_OLE_PPS_File::getStream().
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_OLE * @package PHPExcel\Shared_OLE
*/ */
class PHPExcel_Shared_OLE_ChainedBlockStream class Shared_OLE_ChainedBlockStream
{ {
/** /**
* The OLE container of the file that is being read. * The OLE container of the file that is being read.

View File

@ -20,14 +20,16 @@
// $Id: PPS.php,v 1.7 2007/02/13 21:00:42 schmidt Exp $ // $Id: PPS.php,v 1.7 2007/02/13 21:00:42 schmidt Exp $
namespace PHPExcel;
/** /**
* Class for creating PPS's for OLE containers * Class for creating PPS's for OLE containers
* *
* @author Xavier Noguer <xnoguer@php.net> * @author Xavier Noguer <xnoguer@php.net>
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Shared_OLE * @package PHPExcel\Shared_OLE
*/ */
class PHPExcel_Shared_OLE_PPS class Shared_OLE_PPS
{ {
/** /**
* The PPS index * The PPS index
@ -182,8 +184,8 @@ class PHPExcel_Shared_OLE_PPS
. "\xc0\x00\x00\x00" // 92 . "\xc0\x00\x00\x00" // 92
. "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
. "\x00\x00\x00\x00" // 100 . "\x00\x00\x00\x00" // 100
. PHPExcel_Shared_OLE::LocalDate2OLE($this->Time1st) // 108 . Shared_OLE::LocalDate2OLE($this->Time1st) // 108
. PHPExcel_Shared_OLE::LocalDate2OLE($this->Time2nd) // 116 . Shared_OLE::LocalDate2OLE($this->Time2nd) // 116
. pack("V", isset($this->_StartBlock)? . pack("V", isset($this->_StartBlock)?
$this->_StartBlock:0) // 120 $this->_StartBlock:0) // 120
. pack("V", $this->Size) // 124 . pack("V", $this->Size) // 124

Some files were not shown because too many files have changed in this diff Show More