first commit
This commit is contained in:
commit
8818450302
1139
PHPExcel.php
Normal file
1139
PHPExcel.php
Normal file
File diff suppressed because it is too large
Load Diff
85
PHPExcel/Autoloader.php
Normal file
85
PHPExcel/Autoloader.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
PHPExcel_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 - 2014 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()
|
||||
|
||||
}
|
295
PHPExcel/CachedObjectStorage/APC.php
Normal file
295
PHPExcel/CachedObjectStorage/APC.php
Normal file
@ -0,0 +1,295 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_APC
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @access private
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in apc
|
||||
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === FALSE) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($obj === FALSE) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from APC
|
||||
apc_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @access public
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @throws PHPExcel_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
if ($cellID != $this->_currentObjectID) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
|
||||
if ($obj === FALSE) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC');
|
||||
}
|
||||
if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_cachePrefix = $newCachePrefix;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if ($this->_currentObject !== NULL) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the APC cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if ($this->_cachePrefix === NULL) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
apc_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('apc_store')) {
|
||||
return FALSE;
|
||||
}
|
||||
if (apc_sma_info() === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
347
PHPExcel/CachedObjectStorage/CacheBase.php
Normal file
347
PHPExcel/CachedObjectStorage/CacheBase.php
Normal file
@ -0,0 +1,347 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_CacheBase
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
abstract class PHPExcel_CachedObjectStorage_CacheBase {
|
||||
|
||||
/**
|
||||
* Parent worksheet
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
protected $_parent;
|
||||
|
||||
/**
|
||||
* The currently active Cell
|
||||
*
|
||||
* @var PHPExcel_Cell
|
||||
*/
|
||||
protected $_currentObject = null;
|
||||
|
||||
/**
|
||||
* Coordinate address of the currently active Cell
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_currentObjectID = null;
|
||||
|
||||
|
||||
/**
|
||||
* Flag indicating whether the currently active Cell requires saving
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_currentCellIsDirty = true;
|
||||
|
||||
/**
|
||||
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
||||
* and indexed by their coordinate address within the worksheet
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
protected $_cellCache = array();
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent) {
|
||||
// Set our parent worksheet.
|
||||
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
|
||||
// they are woken from a serialized state
|
||||
$this->_parent = $parent;
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Return the parent worksheet for this cell collection
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry exists in the cache
|
||||
return isset($this->_cellCache[$pCoord]);
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another
|
||||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress) {
|
||||
if ($fromAddress === $this->_currentObjectID) {
|
||||
$this->_currentObjectID = $toAddress;
|
||||
}
|
||||
$this->_currentCellIsDirty = true;
|
||||
if (isset($this->_cellCache[$fromAddress])) {
|
||||
$this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress];
|
||||
unset($this->_cellCache[$fromAddress]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} // function moveCell()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function updateCacheData(PHPExcel_Cell $cell) {
|
||||
return $this->addCacheData($cell->getCoordinate(),$cell);
|
||||
} // function updateCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
}
|
||||
|
||||
if (is_object($this->_cellCache[$pCoord])) {
|
||||
$this->_cellCache[$pCoord]->detach();
|
||||
unset($this->_cellCache[$pCoord]);
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
return array_keys($this->_cellCache);
|
||||
} // function getCellList()
|
||||
|
||||
|
||||
/**
|
||||
* Sort the list of all cell addresses currently held in cache by row and column
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSortedCellList() {
|
||||
$sortKeys = array();
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord,'%[A-Z]%d', $column, $row);
|
||||
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
|
||||
}
|
||||
ksort($sortKeys);
|
||||
|
||||
return array_values($sortKeys);
|
||||
} // function sortCellList()
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get highest worksheet column and highest row that have cell records
|
||||
*
|
||||
* @return array Highest column name and highest row number
|
||||
*/
|
||||
public function getHighestRowAndColumn()
|
||||
{
|
||||
// Lookup highest column and highest row
|
||||
$col = array('A' => '1A');
|
||||
$row = array(1);
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord,'%[A-Z]%d', $c, $r);
|
||||
$row[$r] = $r;
|
||||
$col[$c] = strlen($c).$c;
|
||||
}
|
||||
if (!empty($row)) {
|
||||
// Determine highest column and row
|
||||
$highestRow = max($row);
|
||||
$highestColumn = substr(max($col),1);
|
||||
}
|
||||
|
||||
return array( 'row' => $highestRow,
|
||||
'column' => $highestColumn
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the cell address of the currently active cell object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentAddress()
|
||||
{
|
||||
return $this->_currentObjectID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the column address of the currently active cell object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentColumn()
|
||||
{
|
||||
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
return $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the row address of the currently active cell object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentRow()
|
||||
{
|
||||
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get highest worksheet column
|
||||
*
|
||||
* @param string $row Return the highest column for the specified row,
|
||||
* or the highest column of any row if no row number is passed
|
||||
* @return string Highest column name
|
||||
*/
|
||||
public function getHighestColumn($row = null)
|
||||
{
|
||||
if ($row == null) {
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
return $colRow['column'];
|
||||
}
|
||||
|
||||
$columnList = array(1);
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord,'%[A-Z]%d', $c, $r);
|
||||
if ($r != $row) {
|
||||
continue;
|
||||
}
|
||||
$columnList[] = PHPExcel_Cell::columnIndexFromString($c);
|
||||
}
|
||||
return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get highest worksheet row
|
||||
*
|
||||
* @param string $column Return the highest row for the specified column,
|
||||
* or the highest row of any column if no column letter is passed
|
||||
* @return int Highest row number
|
||||
*/
|
||||
public function getHighestRow($column = null)
|
||||
{
|
||||
if ($column == null) {
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
return $colRow['row'];
|
||||
}
|
||||
|
||||
$rowList = array(0);
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord,'%[A-Z]%d', $c, $r);
|
||||
if ($c != $column) {
|
||||
continue;
|
||||
}
|
||||
$rowList[] = $r;
|
||||
}
|
||||
|
||||
return max($rowList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a unique ID for cache referencing
|
||||
*
|
||||
* @return string Unique Reference
|
||||
*/
|
||||
protected function _getUniqueID() {
|
||||
if (function_exists('posix_getpid')) {
|
||||
$baseUnique = posix_getpid();
|
||||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
return uniqid($baseUnique,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
$this->_currentCellIsDirty;
|
||||
$this->_storeData();
|
||||
|
||||
$this->_parent = $parent;
|
||||
if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
|
||||
$this->_currentObject->attach($this);
|
||||
}
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
219
PHPExcel/CachedObjectStorage/DiscISAM.php
Normal file
219
PHPExcel/CachedObjectStorage/DiscISAM.php
Normal file
@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_DiscISAM
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Name of the file for this cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileName = NULL;
|
||||
|
||||
/**
|
||||
* File handle for this cache file
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_fileHandle = NULL;
|
||||
|
||||
/**
|
||||
* Directory/Folder where the cache file is located
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cacheDirectory = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
fseek($this->_fileHandle,0,SEEK_END);
|
||||
$offset = ftell($this->_fileHandle);
|
||||
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
||||
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
||||
'sz' => ftell($this->_fileHandle) - $offset
|
||||
);
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||
// Copy the existing cell cache file
|
||||
copy ($this->_fileName,$newFileName);
|
||||
$this->_fileName = $newFileName;
|
||||
// Open the copied cell cache file
|
||||
$this->_fileHandle = fopen($this->_fileName,'a+');
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
|
||||
? $arguments['dir']
|
||||
: PHPExcel_Shared_File::sys_get_temp_dir();
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_fileHandle)) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||
$this->_fileHandle = fopen($this->_fileName,'a+');
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_fileHandle)) {
|
||||
fclose($this->_fileHandle);
|
||||
unlink($this->_fileName);
|
||||
}
|
||||
$this->_fileHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
}
|
112
PHPExcel/CachedObjectStorage/ICache.php
Normal file
112
PHPExcel/CachedObjectStorage/ICache.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_ICache
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell);
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function updateCacheData(PHPExcel_Cell $cell);
|
||||
|
||||
/**
|
||||
* Fetch a cell from cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to retrieve
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function getCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord);
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList();
|
||||
|
||||
/**
|
||||
* Get the list of all cell addresses currently held in cache sorted by column and row
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSortedCellList();
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent);
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable();
|
||||
|
||||
}
|
152
PHPExcel/CachedObjectStorage/Igbinary.php
Normal file
152
PHPExcel/CachedObjectStorage/Igbinary.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Igbinary
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('igbinary_serialize')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
312
PHPExcel/CachedObjectStorage/Memcache.php
Normal file
312
PHPExcel/CachedObjectStorage/Memcache.php
Normal file
@ -0,0 +1,312 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Memcache
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
|
||||
/**
|
||||
* Memcache interface
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_memcache = null;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$obj = serialize($this->_currentObject);
|
||||
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)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
|
||||
}
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in Memcache
|
||||
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from Memcache
|
||||
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
if ($cellID != $this->_currentObjectID) {
|
||||
$obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in MemCache');
|
||||
}
|
||||
if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in MemCache');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_cachePrefix = $newCachePrefix;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the Memcache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
||||
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->_cachePrefix)) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
|
||||
// Set a new Memcache object and connect to the Memcache server
|
||||
$this->_memcache = new Memcache();
|
||||
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);
|
||||
}
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Memcache error handler
|
||||
*
|
||||
* @param string $host Memcache server
|
||||
* @param integer $port Memcache port
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function failureCallback($host, $port) {
|
||||
throw new PHPExcel_Exception('memcache '.$host.':'.$port.' failed');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('memcache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
125
PHPExcel/CachedObjectStorage/Memory.php
Normal file
125
PHPExcel/CachedObjectStorage/Memory.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Memory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Dummy method callable from CacheBase, but unused by Memory cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _storeData() {
|
||||
} // function _storeData()
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
$this->_cellCache[$pCoord] = $cell;
|
||||
|
||||
// Set current entry to the new/updated entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
$this->_currentObjectID = NULL;
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
|
||||
// Return requested entry
|
||||
return $this->_cellCache[$pCoord];
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
|
||||
$newCollection = array();
|
||||
foreach($this->_cellCache as $k => &$cell) {
|
||||
$newCollection[$k] = clone $cell;
|
||||
$newCollection[$k]->attach($this);
|
||||
}
|
||||
|
||||
$this->_cellCache = $newCollection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
|
||||
foreach($this->_cellCache as $k => &$cell) {
|
||||
$cell->detach();
|
||||
$this->_cellCache[$k] = null;
|
||||
}
|
||||
unset($cell);
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
137
PHPExcel/CachedObjectStorage/MemoryGZip.php
Normal file
137
PHPExcel/CachedObjectStorage/MemoryGZip.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_MemoryGZip
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
137
PHPExcel/CachedObjectStorage/MemorySerialized.php
Normal file
137
PHPExcel/CachedObjectStorage/MemorySerialized.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_MemorySerialized
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
206
PHPExcel/CachedObjectStorage/PHPTemp.php
Normal file
206
PHPExcel/CachedObjectStorage/PHPTemp.php
Normal file
@ -0,0 +1,206 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_PHPTemp
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Name of the file for this cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileHandle = null;
|
||||
|
||||
/**
|
||||
* Memory limit to use before reverting to file cache
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_memoryCacheSize = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
fseek($this->_fileHandle,0,SEEK_END);
|
||||
$offset = ftell($this->_fileHandle);
|
||||
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
||||
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
||||
'sz' => ftell($this->_fileHandle) - $offset
|
||||
);
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Open a new stream for the cell cache data
|
||||
$newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
|
||||
// Copy the existing cell cache data to the new stream
|
||||
fseek($this->_fileHandle,0);
|
||||
while (!feof($this->_fileHandle)) {
|
||||
fwrite($newFileHandle,fread($this->_fileHandle, 1024));
|
||||
}
|
||||
$this->_fileHandle = $newFileHandle;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the php://temp file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_fileHandle)) {
|
||||
$this->_fileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_fileHandle)) {
|
||||
fclose($this->_fileHandle);
|
||||
}
|
||||
$this->_fileHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
}
|
306
PHPExcel/CachedObjectStorage/SQLite.php
Normal file
306
PHPExcel/CachedObjectStorage/SQLite.php
Normal file
@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_SQLite
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Database table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_TableName = null;
|
||||
|
||||
/**
|
||||
* Database handle
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_DBHandle = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
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()));
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
} elseif ($cellResultSet->numRows() == 0) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
|
||||
$cellResult = $cellResultSet->fetchSingle();
|
||||
$this->_currentObject = unserialize($cellResult);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
} elseif ($cellResultSet->numRows() == 0) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
if (!$this->_DBHandle->queryExec($query))
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
|
||||
$this->_currentCellIsDirty = false;
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another
|
||||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress) {
|
||||
if ($fromAddress === $this->_currentObjectID) {
|
||||
$this->_currentObjectID = $toAddress;
|
||||
}
|
||||
|
||||
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
|
||||
$result = $this->_DBHandle->exec($query);
|
||||
if ($result === false)
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
$query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
||||
$result = $this->_DBHandle->exec($query);
|
||||
if ($result === false)
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
return TRUE;
|
||||
} // function moveCell()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$query = "SELECT id FROM kvp_".$this->_TableName;
|
||||
$cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
|
||||
if ($cellIdsResult === false)
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
|
||||
$cellKeys = array();
|
||||
foreach($cellIdsResult as $row) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
||||
return $cellKeys;
|
||||
} // function getCellList()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
$this->_currentCellIsDirty;
|
||||
$this->_storeData();
|
||||
|
||||
// Get a new id for the new table name
|
||||
$tableName = str_replace('.','_',$this->_getUniqueID());
|
||||
if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||
AS SELECT * FROM kvp_'.$this->_TableName))
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
|
||||
// Copy the existing cell cache file
|
||||
$this->_TableName = $tableName;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent) {
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_DBHandle)) {
|
||||
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
|
||||
$_DBName = ':memory:';
|
||||
|
||||
$this->_DBHandle = new SQLiteDatabase($_DBName);
|
||||
if ($this->_DBHandle === false)
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
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()));
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_DBHandle)) {
|
||||
$this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);
|
||||
}
|
||||
$this->_DBHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('sqlite_open')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
345
PHPExcel/CachedObjectStorage/SQLite3.php
Normal file
345
PHPExcel/CachedObjectStorage/SQLite3.php
Normal file
@ -0,0 +1,345 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_SQLite3
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Database table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_TableName = null;
|
||||
|
||||
/**
|
||||
* Database handle
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_DBHandle = null;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 select query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $_selectQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 insert query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $_insertQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 update query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $_updateQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 delete query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $_deleteQuery;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
|
||||
$this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
|
||||
$result = $this->_insertQuery->execute();
|
||||
if ($result === false)
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
||||
$cellResult = $this->_selectQuery->execute();
|
||||
if ($cellResult === FALSE) {
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
}
|
||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||
if ($cellData === FALSE) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
|
||||
$this->_currentObject = unserialize($cellData['value']);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
||||
$cellResult = $this->_selectQuery->execute();
|
||||
if ($cellResult === FALSE) {
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
}
|
||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
return ($cellData === FALSE) ? FALSE : TRUE;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = NULL;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
||||
$result = $this->_deleteQuery->execute();
|
||||
if ($result === FALSE)
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
$this->_currentCellIsDirty = FALSE;
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another
|
||||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress) {
|
||||
if ($fromAddress === $this->_currentObjectID) {
|
||||
$this->_currentObjectID = $toAddress;
|
||||
}
|
||||
|
||||
$this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);
|
||||
$result = $this->_deleteQuery->execute();
|
||||
if ($result === false)
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
$this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);
|
||||
$this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);
|
||||
$result = $this->_updateQuery->execute();
|
||||
if ($result === false)
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
return TRUE;
|
||||
} // function moveCell()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$query = "SELECT id FROM kvp_".$this->_TableName;
|
||||
$cellIdsResult = $this->_DBHandle->query($query);
|
||||
if ($cellIdsResult === false)
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
$cellKeys = array();
|
||||
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
||||
return $cellKeys;
|
||||
} // function getCellList()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
$this->_currentCellIsDirty;
|
||||
$this->_storeData();
|
||||
|
||||
// Get a new id for the new table name
|
||||
$tableName = str_replace('.','_',$this->_getUniqueID());
|
||||
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||
AS SELECT * FROM kvp_'.$this->_TableName))
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
// Copy the existing cell cache file
|
||||
$this->_TableName = $tableName;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent) {
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_DBHandle)) {
|
||||
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
|
||||
$_DBName = ':memory:';
|
||||
|
||||
$this->_DBHandle = new SQLite3($_DBName);
|
||||
if ($this->_DBHandle === false)
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
|
||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id");
|
||||
$this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
|
||||
$this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId");
|
||||
$this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id");
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_DBHandle)) {
|
||||
$this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName);
|
||||
$this->_DBHandle->close();
|
||||
}
|
||||
$this->_DBHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!class_exists('SQLite3',FALSE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
294
PHPExcel/CachedObjectStorage/Wincache.php
Normal file
294
PHPExcel/CachedObjectStorage/Wincache.php
Normal file
@ -0,0 +1,294 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Wincache
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$obj = serialize($this->_currentObject);
|
||||
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
|
||||
if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
|
||||
}
|
||||
} else {
|
||||
if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
|
||||
}
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in cache
|
||||
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Wincache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
$obj = null;
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from Wincache
|
||||
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
if ($cellID != $this->_currentObjectID) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success);
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache');
|
||||
}
|
||||
if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_cachePrefix = $newCachePrefix;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the WinCache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->_cachePrefix)) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('wincache_ucache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
251
PHPExcel/CachedObjectStorageFactory.php
Normal file
251
PHPExcel/CachedObjectStorageFactory.php
Normal file
@ -0,0 +1,251 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorageFactory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorageFactory
|
||||
{
|
||||
const cache_in_memory = 'Memory';
|
||||
const cache_in_memory_gzip = 'MemoryGZip';
|
||||
const cache_in_memory_serialized = 'MemorySerialized';
|
||||
const cache_igbinary = 'Igbinary';
|
||||
const cache_to_discISAM = 'DiscISAM';
|
||||
const cache_to_apc = 'APC';
|
||||
const cache_to_memcache = 'Memcache';
|
||||
const cache_to_phpTemp = 'PHPTemp';
|
||||
const cache_to_wincache = 'Wincache';
|
||||
const cache_to_sqlite = 'SQLite';
|
||||
const cache_to_sqlite3 = 'SQLite3';
|
||||
|
||||
|
||||
/**
|
||||
* Name of the method used for cell cacheing
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_cacheStorageMethod = NULL;
|
||||
|
||||
/**
|
||||
* Name of the class used for cell cacheing
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_cacheStorageClass = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* List of all possible cache storage methods
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $_storageMethods = array(
|
||||
self::cache_in_memory,
|
||||
self::cache_in_memory_gzip,
|
||||
self::cache_in_memory_serialized,
|
||||
self::cache_igbinary,
|
||||
self::cache_to_phpTemp,
|
||||
self::cache_to_discISAM,
|
||||
self::cache_to_apc,
|
||||
self::cache_to_memcache,
|
||||
self::cache_to_wincache,
|
||||
self::cache_to_sqlite,
|
||||
self::cache_to_sqlite3,
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Default arguments for each cache storage method
|
||||
*
|
||||
* @var array of mixed array
|
||||
*/
|
||||
private static $_storageMethodDefaultParameters = array(
|
||||
self::cache_in_memory => array(
|
||||
),
|
||||
self::cache_in_memory_gzip => array(
|
||||
),
|
||||
self::cache_in_memory_serialized => array(
|
||||
),
|
||||
self::cache_igbinary => array(
|
||||
),
|
||||
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
|
||||
),
|
||||
self::cache_to_discISAM => array( 'dir' => NULL
|
||||
),
|
||||
self::cache_to_apc => array( 'cacheTime' => 600
|
||||
),
|
||||
self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
|
||||
'memcachePort' => 11211,
|
||||
'cacheTime' => 600
|
||||
),
|
||||
self::cache_to_wincache => array( 'cacheTime' => 600
|
||||
),
|
||||
self::cache_to_sqlite => array(
|
||||
),
|
||||
self::cache_to_sqlite3 => array(
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Arguments for the active cache storage method
|
||||
*
|
||||
* @var array of mixed array
|
||||
*/
|
||||
private static $_storageMethodParameters = array();
|
||||
|
||||
|
||||
/**
|
||||
* Return the current cache storage method
|
||||
*
|
||||
* @return string|NULL
|
||||
**/
|
||||
public static function getCacheStorageMethod()
|
||||
{
|
||||
return self::$_cacheStorageMethod;
|
||||
} // function getCacheStorageMethod()
|
||||
|
||||
|
||||
/**
|
||||
* Return the current cache storage class
|
||||
*
|
||||
* @return PHPExcel_CachedObjectStorage_ICache|NULL
|
||||
**/
|
||||
public static function getCacheStorageClass()
|
||||
{
|
||||
return self::$_cacheStorageClass;
|
||||
} // function getCacheStorageClass()
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of all possible cache storage methods
|
||||
*
|
||||
* @return string[]
|
||||
**/
|
||||
public static function getAllCacheStorageMethods()
|
||||
{
|
||||
return self::$_storageMethods;
|
||||
} // function getCacheStorageMethods()
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of all available cache storage methods
|
||||
*
|
||||
* @return string[]
|
||||
**/
|
||||
public static function getCacheStorageMethods()
|
||||
{
|
||||
$activeMethods = array();
|
||||
foreach(self::$_storageMethods as $storageMethod) {
|
||||
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
|
||||
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
|
||||
$activeMethods[] = $storageMethod;
|
||||
}
|
||||
}
|
||||
return $activeMethods;
|
||||
} // function getCacheStorageMethods()
|
||||
|
||||
|
||||
/**
|
||||
* Identify the cache storage method to use
|
||||
*
|
||||
* @param string $method Name of the method to use for cell cacheing
|
||||
* @param array of mixed $arguments Additional arguments to pass to the cell caching class
|
||||
* when instantiating
|
||||
* @return boolean
|
||||
**/
|
||||
public static function initialize($method = self::cache_in_memory, $arguments = array())
|
||||
{
|
||||
if (!in_array($method,self::$_storageMethods)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
||||
if (!call_user_func(array( $cacheStorageClass,
|
||||
'cacheMethodIsAvailable'))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
|
||||
foreach($arguments as $k => $v) {
|
||||
if (array_key_exists($k, self::$_storageMethodParameters[$method])) {
|
||||
self::$_storageMethodParameters[$method][$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$_cacheStorageMethod === NULL) {
|
||||
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
|
||||
self::$_cacheStorageMethod = $method;
|
||||
}
|
||||
return TRUE;
|
||||
} // function initialize()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the cache storage
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet
|
||||
* @return PHPExcel_CachedObjectStorage_ICache
|
||||
**/
|
||||
public static function getInstance(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
$cacheMethodIsAvailable = TRUE;
|
||||
if (self::$_cacheStorageMethod === NULL) {
|
||||
$cacheMethodIsAvailable = self::initialize();
|
||||
}
|
||||
|
||||
if ($cacheMethodIsAvailable) {
|
||||
$instance = new self::$_cacheStorageClass( $parent,
|
||||
self::$_storageMethodParameters[self::$_cacheStorageMethod]
|
||||
);
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
} // function getInstance()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cache storage
|
||||
*
|
||||
**/
|
||||
public static function finalize()
|
||||
{
|
||||
self::$_cacheStorageMethod = NULL;
|
||||
self::$_cacheStorageClass = NULL;
|
||||
self::$_storageMethodParameters = array();
|
||||
}
|
||||
|
||||
}
|
98
PHPExcel/CalcEngine/CyclicReferenceStack.php
Normal file
98
PHPExcel/CalcEngine/CyclicReferenceStack.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CalcEngine_CyclicReferenceStack
|
||||
*
|
||||
* @category PHPExcel_CalcEngine_CyclicReferenceStack
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CalcEngine_CyclicReferenceStack {
|
||||
|
||||
/**
|
||||
* The call stack for calculated cells
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $_stack = array();
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of entries on the stack
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->_stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a new entry onto the stack
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function push($value) {
|
||||
$this->_stack[] = $value;
|
||||
} // function push()
|
||||
|
||||
/**
|
||||
* Pop the last entry from the stack
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function pop() {
|
||||
return array_pop($this->_stack);
|
||||
} // function pop()
|
||||
|
||||
/**
|
||||
* Test to see if a specified entry exists on the stack
|
||||
*
|
||||
* @param mixed $value The value to test
|
||||
*/
|
||||
public function onStack($value) {
|
||||
return in_array($value, $this->_stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the stack
|
||||
*/
|
||||
public function clear() {
|
||||
$this->_stack = array();
|
||||
} // function push()
|
||||
|
||||
/**
|
||||
* Return an array of all entries on the stack
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function showStack() {
|
||||
return $this->_stack;
|
||||
}
|
||||
|
||||
} // class PHPExcel_CalcEngine_CyclicReferenceStack
|
153
PHPExcel/CalcEngine/Logger.php
Normal file
153
PHPExcel/CalcEngine/Logger.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_CalcEngine_Logger
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CalcEngine_Logger {
|
||||
|
||||
/**
|
||||
* Flag to determine whether a debug log should be generated by the calculation engine
|
||||
* If true, then a debug log will be generated
|
||||
* If false, then a debug log will not be generated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_writeDebugLog = FALSE;
|
||||
|
||||
/**
|
||||
* Flag to determine whether a debug log should be echoed by the calculation engine
|
||||
* If true, then a debug log will be echoed
|
||||
* If false, then a debug log will not be echoed
|
||||
* A debug log can only be echoed if it is generated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_echoDebugLog = FALSE;
|
||||
|
||||
/**
|
||||
* The debug log generated by the calculation engine
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $_debugLog = array();
|
||||
|
||||
/**
|
||||
* The calculation engine cell reference stack
|
||||
*
|
||||
* @var PHPExcel_CalcEngine_CyclicReferenceStack
|
||||
*/
|
||||
private $_cellStack;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiate a Calculation engine logger
|
||||
*
|
||||
* @param PHPExcel_CalcEngine_CyclicReferenceStack $stack
|
||||
*/
|
||||
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack) {
|
||||
$this->_cellStack = $stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable Calculation engine logging
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setWriteDebugLog($pValue = FALSE) {
|
||||
$this->_writeDebugLog = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether calculation engine logging is enabled or disabled
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getWriteDebugLog() {
|
||||
return $this->_writeDebugLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable echoing of debug log information
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setEchoDebugLog($pValue = FALSE) {
|
||||
$this->_echoDebugLog = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether echoing of debug log information is enabled or disabled
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getEchoDebugLog() {
|
||||
return $this->_echoDebugLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an entry to the calculation engine debug log
|
||||
*/
|
||||
public function writeDebugLog() {
|
||||
// Only write the debug log if logging is enabled
|
||||
if ($this->_writeDebugLog) {
|
||||
$message = implode(func_get_args());
|
||||
$cellReference = implode(' -> ', $this->_cellStack->showStack());
|
||||
if ($this->_echoDebugLog) {
|
||||
echo $cellReference,
|
||||
($this->_cellStack->count() > 0 ? ' => ' : ''),
|
||||
$message,
|
||||
PHP_EOL;
|
||||
}
|
||||
$this->_debugLog[] = $cellReference .
|
||||
($this->_cellStack->count() > 0 ? ' => ' : '') .
|
||||
$message;
|
||||
}
|
||||
} // function _writeDebug()
|
||||
|
||||
/**
|
||||
* Clear the calculation engine debug log
|
||||
*/
|
||||
public function clearLog() {
|
||||
$this->_debugLog = array();
|
||||
} // function flushLogger()
|
||||
|
||||
/**
|
||||
* Return the calculation engine debug log
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getLog() {
|
||||
return $this->_debugLog;
|
||||
} // function flushLogger()
|
||||
|
||||
} // class PHPExcel_CalcEngine_Logger
|
||||
|
3933
PHPExcel/Calculation.php
Normal file
3933
PHPExcel/Calculation.php
Normal file
File diff suppressed because it is too large
Load Diff
725
PHPExcel/Calculation/Database.php
Normal file
725
PHPExcel/Calculation/Database.php
Normal file
File diff suppressed because it is too large
Load Diff
1475
PHPExcel/Calculation/DateTime.php
Normal file
1475
PHPExcel/Calculation/DateTime.php
Normal file
File diff suppressed because it is too large
Load Diff
2505
PHPExcel/Calculation/Engineering.php
Normal file
2505
PHPExcel/Calculation/Engineering.php
Normal file
File diff suppressed because it is too large
Load Diff
52
PHPExcel/Calculation/Exception.php
Normal file
52
PHPExcel/Calculation/Exception.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Exception extends PHPExcel_Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
49
PHPExcel/Calculation/ExceptionHandler.php
Normal file
49
PHPExcel/Calculation/ExceptionHandler.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_ExceptionHandler
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_ExceptionHandler {
|
||||
/**
|
||||
* Register errorhandler
|
||||
*/
|
||||
public function __construct() {
|
||||
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister errorhandler
|
||||
*/
|
||||
public function __destruct() {
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
2292
PHPExcel/Calculation/Financial.php
Normal file
2292
PHPExcel/Calculation/Financial.php
Normal file
File diff suppressed because it is too large
Load Diff
614
PHPExcel/Calculation/FormulaParser.php
Normal file
614
PHPExcel/Calculation/FormulaParser.php
Normal file
File diff suppressed because it is too large
Load Diff
176
PHPExcel/Calculation/FormulaToken.php
Normal file
176
PHPExcel/Calculation/FormulaToken.php
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
PARTLY BASED ON:
|
||||
Copyright (c) 2007 E. W. Bachtal, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or implied, including but not
|
||||
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
|
||||
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
|
||||
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
|
||||
software or the use or other dealings in the software.
|
||||
|
||||
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
|
||||
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_FormulaToken
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_FormulaToken {
|
||||
/* Token types */
|
||||
const TOKEN_TYPE_NOOP = 'Noop';
|
||||
const TOKEN_TYPE_OPERAND = 'Operand';
|
||||
const TOKEN_TYPE_FUNCTION = 'Function';
|
||||
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
|
||||
const TOKEN_TYPE_ARGUMENT = 'Argument';
|
||||
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
|
||||
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
|
||||
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
|
||||
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
|
||||
const TOKEN_TYPE_UNKNOWN = 'Unknown';
|
||||
|
||||
/* Token subtypes */
|
||||
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
|
||||
const TOKEN_SUBTYPE_START = 'Start';
|
||||
const TOKEN_SUBTYPE_STOP = 'Stop';
|
||||
const TOKEN_SUBTYPE_TEXT = 'Text';
|
||||
const TOKEN_SUBTYPE_NUMBER = 'Number';
|
||||
const TOKEN_SUBTYPE_LOGICAL = 'Logical';
|
||||
const TOKEN_SUBTYPE_ERROR = 'Error';
|
||||
const TOKEN_SUBTYPE_RANGE = 'Range';
|
||||
const TOKEN_SUBTYPE_MATH = 'Math';
|
||||
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
|
||||
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
|
||||
const TOKEN_SUBTYPE_UNION = 'Union';
|
||||
|
||||
/**
|
||||
* Value
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_value;
|
||||
|
||||
/**
|
||||
* Token Type (represented by TOKEN_TYPE_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tokenType;
|
||||
|
||||
/**
|
||||
* Token SubType (represented by TOKEN_SUBTYPE_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tokenSubType;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_FormulaToken
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
|
||||
* @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)
|
||||
{
|
||||
// Initialise values
|
||||
$this->_value = $pValue;
|
||||
$this->_tokenType = $pTokenType;
|
||||
$this->_tokenSubType = $pTokenSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue() {
|
||||
return $this->_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Value
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value) {
|
||||
$this->_value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token Type (represented by TOKEN_TYPE_*)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenType() {
|
||||
return $this->_tokenType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Token Type
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) {
|
||||
$this->_tokenType = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token SubType (represented by TOKEN_SUBTYPE_*)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenSubType() {
|
||||
return $this->_tokenSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Token SubType
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
$this->_tokenSubType = $value;
|
||||
}
|
||||
}
|
149
PHPExcel/Calculation/Function.php
Normal file
149
PHPExcel/Calculation/Function.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Function
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Function {
|
||||
/* Function categories */
|
||||
const CATEGORY_CUBE = 'Cube';
|
||||
const CATEGORY_DATABASE = 'Database';
|
||||
const CATEGORY_DATE_AND_TIME = 'Date and Time';
|
||||
const CATEGORY_ENGINEERING = 'Engineering';
|
||||
const CATEGORY_FINANCIAL = 'Financial';
|
||||
const CATEGORY_INFORMATION = 'Information';
|
||||
const CATEGORY_LOGICAL = 'Logical';
|
||||
const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
|
||||
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
|
||||
const CATEGORY_STATISTICAL = 'Statistical';
|
||||
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
|
||||
|
||||
/**
|
||||
* Category (represented by CATEGORY_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_category;
|
||||
|
||||
/**
|
||||
* Excel name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_excelName;
|
||||
|
||||
/**
|
||||
* PHPExcel name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_phpExcelName;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_Function
|
||||
*
|
||||
* @param string $pCategory Category (represented by CATEGORY_*)
|
||||
* @param string $pExcelName Excel function name
|
||||
* @param string $pPHPExcelName PHPExcel function mapping
|
||||
* @throws PHPExcel_Calculation_Exception
|
||||
*/
|
||||
public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL)
|
||||
{
|
||||
if (($pCategory !== NULL) && ($pExcelName !== NULL) && ($pPHPExcelName !== NULL)) {
|
||||
// Initialise values
|
||||
$this->_category = $pCategory;
|
||||
$this->_excelName = $pExcelName;
|
||||
$this->_phpExcelName = $pPHPExcelName;
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category (represented by CATEGORY_*)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category (represented by CATEGORY_*)
|
||||
*
|
||||
* @param string $value
|
||||
* @throws PHPExcel_Calculation_Exception
|
||||
*/
|
||||
public function setCategory($value = null) {
|
||||
if (!is_null($value)) {
|
||||
$this->_category = $value;
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Excel name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExcelName() {
|
||||
return $this->_excelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Excel name
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setExcelName($value) {
|
||||
$this->_excelName = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPHPExcelName() {
|
||||
return $this->_phpExcelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set PHPExcel name
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setPHPExcelName($value) {
|
||||
$this->_phpExcelName = $value;
|
||||
}
|
||||
}
|
725
PHPExcel/Calculation/Functions.php
Normal file
725
PHPExcel/Calculation/Functions.php
Normal file
File diff suppressed because it is too large
Load Diff
288
PHPExcel/Calculation/Logical.php
Normal file
288
PHPExcel/Calculation/Logical.php
Normal file
@ -0,0 +1,288 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Logical
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Logical {
|
||||
|
||||
/**
|
||||
* TRUE
|
||||
*
|
||||
* Returns the boolean TRUE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =TRUE()
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return boolean True
|
||||
*/
|
||||
public static function TRUE() {
|
||||
return TRUE;
|
||||
} // function TRUE()
|
||||
|
||||
|
||||
/**
|
||||
* FALSE
|
||||
*
|
||||
* Returns the boolean FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =FALSE()
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return boolean False
|
||||
*/
|
||||
public static function FALSE() {
|
||||
return FALSE;
|
||||
} // function FALSE()
|
||||
|
||||
|
||||
/**
|
||||
* LOGICAL_AND
|
||||
*
|
||||
* Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =AND(logical1[,logical2[, ...]])
|
||||
*
|
||||
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
|
||||
* or references that contain logical values.
|
||||
*
|
||||
* Boolean arguments are treated as True or False as appropriate
|
||||
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
||||
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
|
||||
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return boolean The logical AND of the arguments.
|
||||
*/
|
||||
public static function LOGICAL_AND() {
|
||||
// Return value
|
||||
$returnValue = TRUE;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$argCount = -1;
|
||||
foreach ($aArgs as $argCount => $arg) {
|
||||
// Is it a boolean value?
|
||||
if (is_bool($arg)) {
|
||||
$returnValue = $returnValue && $arg;
|
||||
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
$returnValue = $returnValue && ($arg != 0);
|
||||
} elseif (is_string($arg)) {
|
||||
$arg = strtoupper($arg);
|
||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||
$arg = TRUE;
|
||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = FALSE;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$returnValue = $returnValue && ($arg != 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
if ($argCount < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
} // function LOGICAL_AND()
|
||||
|
||||
|
||||
/**
|
||||
* LOGICAL_OR
|
||||
*
|
||||
* Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =OR(logical1[,logical2[, ...]])
|
||||
*
|
||||
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
|
||||
* or references that contain logical values.
|
||||
*
|
||||
* Boolean arguments are treated as True or False as appropriate
|
||||
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
||||
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
|
||||
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return boolean The logical OR of the arguments.
|
||||
*/
|
||||
public static function LOGICAL_OR() {
|
||||
// Return value
|
||||
$returnValue = FALSE;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$argCount = -1;
|
||||
foreach ($aArgs as $argCount => $arg) {
|
||||
// Is it a boolean value?
|
||||
if (is_bool($arg)) {
|
||||
$returnValue = $returnValue || $arg;
|
||||
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
$returnValue = $returnValue || ($arg != 0);
|
||||
} elseif (is_string($arg)) {
|
||||
$arg = strtoupper($arg);
|
||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||
$arg = TRUE;
|
||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = FALSE;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$returnValue = $returnValue || ($arg != 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
if ($argCount < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
} // function LOGICAL_OR()
|
||||
|
||||
|
||||
/**
|
||||
* NOT
|
||||
*
|
||||
* Returns the boolean inverse of the argument.
|
||||
*
|
||||
* Excel Function:
|
||||
* =NOT(logical)
|
||||
*
|
||||
* The argument must evaluate to a logical value such as TRUE or FALSE
|
||||
*
|
||||
* Boolean arguments are treated as True or False as appropriate
|
||||
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
||||
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
|
||||
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
|
||||
* @return boolean The boolean inverse of the argument.
|
||||
*/
|
||||
public static function NOT($logical=FALSE) {
|
||||
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
|
||||
if (is_string($logical)) {
|
||||
$logical = strtoupper($logical);
|
||||
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
|
||||
return FALSE;
|
||||
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
return !$logical;
|
||||
} // function NOT()
|
||||
|
||||
/**
|
||||
* STATEMENT_IF
|
||||
*
|
||||
* Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =IF(condition[,returnIfTrue[,returnIfFalse]])
|
||||
*
|
||||
* Condition is any value or expression that can be evaluated to TRUE or FALSE.
|
||||
* For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100,
|
||||
* the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.
|
||||
* This argument can use any comparison calculation operator.
|
||||
* ReturnIfTrue is the value that is returned if condition evaluates to TRUE.
|
||||
* For example, if this argument is the text string "Within budget" and the condition argument evaluates to TRUE,
|
||||
* then the IF function returns the text "Within budget"
|
||||
* If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero). To display the word TRUE, use
|
||||
* the logical value TRUE for this argument.
|
||||
* ReturnIfTrue can be another formula.
|
||||
* ReturnIfFalse is the value that is returned if condition evaluates to FALSE.
|
||||
* For example, if this argument is the text string "Over budget" and the condition argument evaluates to FALSE,
|
||||
* then the IF function returns the text "Over budget".
|
||||
* If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned.
|
||||
* If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
|
||||
* ReturnIfFalse can be another formula.
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $condition Condition to evaluate
|
||||
* @param mixed $returnIfTrue Value to return when condition is true
|
||||
* @param mixed $returnIfFalse Optional value to return when condition is false
|
||||
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
|
||||
*/
|
||||
public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) {
|
||||
$condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
|
||||
$returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
|
||||
|
||||
return ($condition) ? $returnIfTrue : $returnIfFalse;
|
||||
} // function STATEMENT_IF()
|
||||
|
||||
|
||||
/**
|
||||
* IFERROR
|
||||
*
|
||||
* Excel Function:
|
||||
* =IFERROR(testValue,errorpart)
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $testValue Value to check, is also the value returned when no error
|
||||
* @param mixed $errorpart Value to return when testValue is an error condition
|
||||
* @return mixed The value of errorpart or testValue determined by error condition
|
||||
*/
|
||||
public static function IFERROR($testValue = '', $errorpart = '') {
|
||||
$testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
|
||||
$errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart);
|
||||
|
||||
return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
|
||||
} // function IFERROR()
|
||||
|
||||
} // class PHPExcel_Calculation_Logical
|
881
PHPExcel/Calculation/LookupRef.php
Normal file
881
PHPExcel/Calculation/LookupRef.php
Normal file
File diff suppressed because it is too large
Load Diff
1373
PHPExcel/Calculation/MathTrig.php
Normal file
1373
PHPExcel/Calculation/MathTrig.php
Normal file
File diff suppressed because it is too large
Load Diff
3651
PHPExcel/Calculation/Statistical.php
Normal file
3651
PHPExcel/Calculation/Statistical.php
Normal file
File diff suppressed because it is too large
Load Diff
590
PHPExcel/Calculation/TextData.php
Normal file
590
PHPExcel/Calculation/TextData.php
Normal file
File diff suppressed because it is too large
Load Diff
115
PHPExcel/Calculation/Token/Stack.php
Normal file
115
PHPExcel/Calculation/Token/Stack.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Token_Stack
|
||||
*
|
||||
* @category PHPExcel_Calculation_Token_Stack
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Token_Stack {
|
||||
|
||||
/**
|
||||
* The parser stack for formulae
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $_stack = array();
|
||||
|
||||
/**
|
||||
* Count of entries in the parser stack
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_count = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of entries on the stack
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function count() {
|
||||
return $this->_count;
|
||||
} // function count()
|
||||
|
||||
/**
|
||||
* Push a new entry onto the stack
|
||||
*
|
||||
* @param mixed $type
|
||||
* @param mixed $value
|
||||
* @param mixed $reference
|
||||
*/
|
||||
public function push($type, $value, $reference = NULL) {
|
||||
$this->_stack[$this->_count++] = array('type' => $type,
|
||||
'value' => $value,
|
||||
'reference' => $reference
|
||||
);
|
||||
if ($type == 'Function') {
|
||||
$localeFunction = PHPExcel_Calculation::_localeFunc($value);
|
||||
if ($localeFunction != $value) {
|
||||
$this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction;
|
||||
}
|
||||
}
|
||||
} // function push()
|
||||
|
||||
/**
|
||||
* Pop the last entry from the stack
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function pop() {
|
||||
if ($this->_count > 0) {
|
||||
return $this->_stack[--$this->_count];
|
||||
}
|
||||
return NULL;
|
||||
} // function pop()
|
||||
|
||||
/**
|
||||
* Return an entry from the stack without removing it
|
||||
*
|
||||
* @param integer $n number indicating how far back in the stack we want to look
|
||||
* @return mixed
|
||||
*/
|
||||
public function last($n = 1) {
|
||||
if ($this->_count - $n < 0) {
|
||||
return NULL;
|
||||
}
|
||||
return $this->_stack[$this->_count - $n];
|
||||
} // function last()
|
||||
|
||||
/**
|
||||
* Clear the stack
|
||||
*/
|
||||
function clear() {
|
||||
$this->_stack = array();
|
||||
$this->_count = 0;
|
||||
}
|
||||
|
||||
} // class PHPExcel_Calculation_Token_Stack
|
351
PHPExcel/Calculation/functionlist.txt
Normal file
351
PHPExcel/Calculation/functionlist.txt
Normal file
@ -0,0 +1,351 @@
|
||||
ABS
|
||||
ACCRINT
|
||||
ACCRINTM
|
||||
ACOS
|
||||
ACOSH
|
||||
ADDRESS
|
||||
AMORDEGRC
|
||||
AMORLINC
|
||||
AND
|
||||
AREAS
|
||||
ASC
|
||||
ASIN
|
||||
ASINH
|
||||
ATAN
|
||||
ATAN2
|
||||
ATANH
|
||||
AVEDEV
|
||||
AVERAGE
|
||||
AVERAGEA
|
||||
AVERAGEIF
|
||||
AVERAGEIFS
|
||||
BAHTTEXT
|
||||
BESSELI
|
||||
BESSELJ
|
||||
BESSELK
|
||||
BESSELY
|
||||
BETADIST
|
||||
BETAINV
|
||||
BIN2DEC
|
||||
BIN2HEX
|
||||
BIN2OCT
|
||||
BINOMDIST
|
||||
CEILING
|
||||
CELL
|
||||
CHAR
|
||||
CHIDIST
|
||||
CHIINV
|
||||
CHITEST
|
||||
CHOOSE
|
||||
CLEAN
|
||||
CODE
|
||||
COLUMN
|
||||
COLUMNS
|
||||
COMBIN
|
||||
COMPLEX
|
||||
CONCATENATE
|
||||
CONFIDENCE
|
||||
CONVERT
|
||||
CORREL
|
||||
COS
|
||||
COSH
|
||||
COUNT
|
||||
COUNTA
|
||||
COUNTBLANK
|
||||
COUNTIF
|
||||
COUNTIFS
|
||||
COUPDAYBS
|
||||
COUPDAYBS
|
||||
COUPDAYSNC
|
||||
COUPNCD
|
||||
COUPNUM
|
||||
COUPPCD
|
||||
COVAR
|
||||
CRITBINOM
|
||||
CUBEKPIMEMBER
|
||||
CUBEMEMBER
|
||||
CUBEMEMBERPROPERTY
|
||||
CUBERANKEDMEMBER
|
||||
CUBESET
|
||||
CUBESETCOUNT
|
||||
CUBEVALUE
|
||||
CUMIPMT
|
||||
CUMPRINC
|
||||
DATE
|
||||
DATEDIF
|
||||
DATEVALUE
|
||||
DAVERAGE
|
||||
DAY
|
||||
DAYS360
|
||||
DB
|
||||
DCOUNT
|
||||
DCOUNTA
|
||||
DDB
|
||||
DEC2BIN
|
||||
DEC2HEX
|
||||
DEC2OCT
|
||||
DEGREES
|
||||
DELTA
|
||||
DEVSQ
|
||||
DGET
|
||||
DISC
|
||||
DMAX
|
||||
DMIN
|
||||
DOLLAR
|
||||
DOLLARDE
|
||||
DOLLARFR
|
||||
DPRODUCT
|
||||
DSTDEV
|
||||
DSTDEVP
|
||||
DSUM
|
||||
DURATION
|
||||
DVAR
|
||||
DVARP
|
||||
EDATE
|
||||
EFFECT
|
||||
EOMONTH
|
||||
ERF
|
||||
ERFC
|
||||
ERROR.TYPE
|
||||
EVEN
|
||||
EXACT
|
||||
EXP
|
||||
EXPONDIST
|
||||
FACT
|
||||
FACTDOUBLE
|
||||
FALSE
|
||||
FDIST
|
||||
FIND
|
||||
FINDB
|
||||
FINV
|
||||
FISHER
|
||||
FISHERINV
|
||||
FIXED
|
||||
FLOOR
|
||||
FORECAST
|
||||
FREQUENCY
|
||||
FTEST
|
||||
FV
|
||||
FVSCHEDULE
|
||||
GAMAMDIST
|
||||
GAMMAINV
|
||||
GAMMALN
|
||||
GCD
|
||||
GEOMEAN
|
||||
GESTEP
|
||||
GETPIVOTDATA
|
||||
GROWTH
|
||||
HARMEAN
|
||||
HEX2BIN
|
||||
HEX2OCT
|
||||
HLOOKUP
|
||||
HOUR
|
||||
HYPERLINK
|
||||
HYPGEOMDIST
|
||||
IF
|
||||
IFERROR
|
||||
IMABS
|
||||
IMAGINARY
|
||||
IMARGUMENT
|
||||
IMCONJUGATE
|
||||
IMCOS
|
||||
IMEXP
|
||||
IMLN
|
||||
IMLOG10
|
||||
IMLOG2
|
||||
IMPOWER
|
||||
IMPRODUCT
|
||||
IMREAL
|
||||
IMSIN
|
||||
IMSQRT
|
||||
IMSUB
|
||||
IMSUM
|
||||
INDEX
|
||||
INDIRECT
|
||||
INFO
|
||||
INT
|
||||
INTERCEPT
|
||||
INTRATE
|
||||
IPMT
|
||||
IRR
|
||||
ISBLANK
|
||||
ISERR
|
||||
ISERROR
|
||||
ISEVEN
|
||||
ISLOGICAL
|
||||
ISNA
|
||||
ISNONTEXT
|
||||
ISNUMBER
|
||||
ISODD
|
||||
ISPMT
|
||||
ISREF
|
||||
ISTEXT
|
||||
JIS
|
||||
KURT
|
||||
LARGE
|
||||
LCM
|
||||
LEFT
|
||||
LEFTB
|
||||
LEN
|
||||
LENB
|
||||
LINEST
|
||||
LN
|
||||
LOG
|
||||
LOG10
|
||||
LOGEST
|
||||
LOGINV
|
||||
LOGNORMDIST
|
||||
LOOKUP
|
||||
LOWER
|
||||
MATCH
|
||||
MAX
|
||||
MAXA
|
||||
MDETERM
|
||||
MDURATION
|
||||
MEDIAN
|
||||
MID
|
||||
MIDB
|
||||
MIN
|
||||
MINA
|
||||
MINUTE
|
||||
MINVERSE
|
||||
MIRR
|
||||
MMULT
|
||||
MOD
|
||||
MODE
|
||||
MONTH
|
||||
MROUND
|
||||
MULTINOMIAL
|
||||
N
|
||||
NA
|
||||
NEGBINOMDIST
|
||||
NETWORKDAYS
|
||||
NOMINAL
|
||||
NORMDIST
|
||||
NORMINV
|
||||
NORMSDIST
|
||||
NORMSINV
|
||||
NOT
|
||||
NOW
|
||||
NPER
|
||||
NPV
|
||||
OCT2BIN
|
||||
OCT2DEC
|
||||
OCT2HEX
|
||||
ODD
|
||||
ODDFPRICE
|
||||
ODDFYIELD
|
||||
ODDLPRICE
|
||||
ODDLYIELD
|
||||
OFFSET
|
||||
OR
|
||||
PEARSON
|
||||
PERCENTILE
|
||||
PERCENTRANK
|
||||
PERMUT
|
||||
PHONETIC
|
||||
PI
|
||||
PMT
|
||||
POISSON
|
||||
POWER
|
||||
PPMT
|
||||
PRICE
|
||||
PRICEDISC
|
||||
PRICEMAT
|
||||
PROB
|
||||
PRODUCT
|
||||
PROPER
|
||||
PV
|
||||
QUARTILE
|
||||
QUOTIENT
|
||||
RADIANS
|
||||
RAND
|
||||
RANDBETWEEN
|
||||
RANK
|
||||
RATE
|
||||
RECEIVED
|
||||
REPLACE
|
||||
REPLACEB
|
||||
REPT
|
||||
RIGHT
|
||||
RIGHTB
|
||||
ROMAN
|
||||
ROUND
|
||||
ROUNDDOWN
|
||||
ROUNDUP
|
||||
ROW
|
||||
ROWS
|
||||
RSQ
|
||||
RTD
|
||||
SEARCH
|
||||
SEARCHB
|
||||
SECOND
|
||||
SERIESSUM
|
||||
SIGN
|
||||
SIN
|
||||
SINH
|
||||
SKEW
|
||||
SLN
|
||||
SLOPE
|
||||
SMALL
|
||||
SQRT
|
||||
SQRTPI
|
||||
STANDARDIZE
|
||||
STDEV
|
||||
STDEVA
|
||||
STDEVP
|
||||
STDEVPA
|
||||
STEYX
|
||||
SUBSTITUTE
|
||||
SUBTOTAL
|
||||
SUM
|
||||
SUMIF
|
||||
SUMIFS
|
||||
SUMPRODUCT
|
||||
SUMSQ
|
||||
SUMX2MY2
|
||||
SUMX2PY2
|
||||
SUMXMY2
|
||||
SYD
|
||||
T
|
||||
TAN
|
||||
TANH
|
||||
TBILLEQ
|
||||
TBILLPRICE
|
||||
TBILLYIELD
|
||||
TDIST
|
||||
TEXT
|
||||
TIME
|
||||
TIMEVALUE
|
||||
TINV
|
||||
TODAY
|
||||
TRANSPOSE
|
||||
TREND
|
||||
TRIM
|
||||
TRIMMEAN
|
||||
TRUE
|
||||
TRUNC
|
||||
TTEST
|
||||
TYPE
|
||||
UPPER
|
||||
USDOLLAR
|
||||
VALUE
|
||||
VAR
|
||||
VARA
|
||||
VARP
|
||||
VARPA
|
||||
VDB
|
||||
VERSION
|
||||
VLOOKUP
|
||||
WEEKDAY
|
||||
WEEKNUM
|
||||
WEIBULL
|
||||
WORKDAY
|
||||
XIRR
|
||||
XNPV
|
||||
YEAR
|
||||
YEARFRAC
|
||||
YIELD
|
||||
YIELDDISC
|
||||
YIELDMAT
|
||||
ZTEST
|
990
PHPExcel/Cell.php
Normal file
990
PHPExcel/Cell.php
Normal file
File diff suppressed because it is too large
Load Diff
192
PHPExcel/Cell/AdvancedValueBinder.php
Normal file
192
PHPExcel/Cell/AdvancedValueBinder.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_AdvancedValueBinder
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null)
|
||||
{
|
||||
// sanitize UTF-8 strings
|
||||
if (is_string($value)) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
}
|
||||
|
||||
// Find out data type
|
||||
$dataType = parent::dataTypeForValue($value);
|
||||
|
||||
// Style logic - strings
|
||||
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
|
||||
// Test for booleans using locale-setting
|
||||
if ($value == PHPExcel_Calculation::getTRUE()) {
|
||||
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||
return true;
|
||||
} elseif($value == PHPExcel_Calculation::getFALSE()) {
|
||||
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for number in scientific format
|
||||
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for fraction
|
||||
if (preg_match('/^([+-]?)\s*([0-9]+)\s?\/\s*([0-9]+)$/', $value, $matches)) {
|
||||
// Convert value to number
|
||||
$value = $matches[2] / $matches[3];
|
||||
if ($matches[1] == '-') $value = 0 - $value;
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( '??/??' );
|
||||
return true;
|
||||
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||
// Convert value to number
|
||||
$value = $matches[2] + ($matches[3] / $matches[4]);
|
||||
if ($matches[1] == '-') $value = 0 - $value;
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( '# ??/??' );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for percentage
|
||||
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) str_replace('%', '', $value) / 100;
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for currency
|
||||
$currencyCode = PHPExcel_Shared_String::getCurrencyCode();
|
||||
$decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator();
|
||||
$thousandsSeparator = PHPExcel_Shared_String::getThousandsSeparator();
|
||||
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
|
||||
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode(
|
||||
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
|
||||
);
|
||||
return true;
|
||||
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) trim(str_replace(array('$',','), '', $value));
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for time without seconds e.g. '9:45', '09:45'
|
||||
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
|
||||
// Convert value to number
|
||||
list($h, $m) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440;
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for time with seconds '9:45:59', '09:45:59'
|
||||
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) {
|
||||
// Convert value to number
|
||||
list($h, $m, $s) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440 + $s / 86400;
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Determine style. Either there is a time part or not. Look for ':'
|
||||
if (strpos($value, ':') !== false) {
|
||||
$formatCode = 'yyyy-mm-dd h:mm';
|
||||
} else {
|
||||
$formatCode = 'yyyy-mm-dd';
|
||||
}
|
||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode($formatCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for newline character "\n"
|
||||
if (strpos($value, "\n") !== FALSE) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||
->getAlignment()->setWrapText(TRUE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Not bound yet? Use parent...
|
||||
return parent::bindValue($cell, $value);
|
||||
}
|
||||
}
|
122
PHPExcel/Cell/DataType.php
Normal file
122
PHPExcel/Cell/DataType.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_DataType
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_DataType
|
||||
{
|
||||
/* Data types */
|
||||
const TYPE_STRING2 = 'str';
|
||||
const TYPE_STRING = 's';
|
||||
const TYPE_FORMULA = 'f';
|
||||
const TYPE_NUMERIC = 'n';
|
||||
const TYPE_BOOL = 'b';
|
||||
const TYPE_NULL = 'null';
|
||||
const TYPE_INLINE = 'inlineStr';
|
||||
const TYPE_ERROR = 'e';
|
||||
|
||||
/**
|
||||
* List of error codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_errorCodes = array(
|
||||
'#NULL!' => 0,
|
||||
'#DIV/0!' => 1,
|
||||
'#VALUE!' => 2,
|
||||
'#REF!' => 3,
|
||||
'#NAME?' => 4,
|
||||
'#NUM!' => 5,
|
||||
'#N/A' => 6
|
||||
);
|
||||
|
||||
/**
|
||||
* Get list of error codes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getErrorCodes() {
|
||||
return self::$_errorCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
* @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure, will be removed in version 1.8.0
|
||||
* @param mixed $pValue
|
||||
* @return string
|
||||
*/
|
||||
public static function dataTypeForValue($pValue = null) {
|
||||
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a string that it satisfies Excel requirements
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel string
|
||||
* @return mixed Sanitized value
|
||||
*/
|
||||
public static function checkString($pValue = null)
|
||||
{
|
||||
if ($pValue instanceof PHPExcel_RichText) {
|
||||
// TODO: Sanitize Rich-Text string (max. character count is 32,767)
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
// string must never be longer than 32,767 characters, truncate if necessary
|
||||
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767);
|
||||
|
||||
// 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);
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a value that it is a valid error code
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel error code
|
||||
* @return string Sanitized value
|
||||
*/
|
||||
public static function checkErrorCode($pValue = null)
|
||||
{
|
||||
$pValue = (string) $pValue;
|
||||
|
||||
if ( !array_key_exists($pValue, self::$_errorCodes) ) {
|
||||
$pValue = '#NULL!';
|
||||
}
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
}
|
472
PHPExcel/Cell/DataValidation.php
Normal file
472
PHPExcel/Cell/DataValidation.php
Normal file
@ -0,0 +1,472 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_DataValidation
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_DataValidation
|
||||
{
|
||||
/* Data validation types */
|
||||
const TYPE_NONE = 'none';
|
||||
const TYPE_CUSTOM = 'custom';
|
||||
const TYPE_DATE = 'date';
|
||||
const TYPE_DECIMAL = 'decimal';
|
||||
const TYPE_LIST = 'list';
|
||||
const TYPE_TEXTLENGTH = 'textLength';
|
||||
const TYPE_TIME = 'time';
|
||||
const TYPE_WHOLE = 'whole';
|
||||
|
||||
/* Data validation error styles */
|
||||
const STYLE_STOP = 'stop';
|
||||
const STYLE_WARNING = 'warning';
|
||||
const STYLE_INFORMATION = 'information';
|
||||
|
||||
/* Data validation operators */
|
||||
const OPERATOR_BETWEEN = 'between';
|
||||
const OPERATOR_EQUAL = 'equal';
|
||||
const OPERATOR_GREATERTHAN = 'greaterThan';
|
||||
const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
|
||||
const OPERATOR_LESSTHAN = 'lessThan';
|
||||
const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
|
||||
const OPERATOR_NOTBETWEEN = 'notBetween';
|
||||
const OPERATOR_NOTEQUAL = 'notEqual';
|
||||
|
||||
/**
|
||||
* Formula 1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formula1;
|
||||
|
||||
/**
|
||||
* Formula 2
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formula2;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
||||
|
||||
/**
|
||||
* Error style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
||||
|
||||
/**
|
||||
* Operator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_operator;
|
||||
|
||||
/**
|
||||
* Allow Blank
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_allowBlank;
|
||||
|
||||
/**
|
||||
* Show DropDown
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showDropDown;
|
||||
|
||||
/**
|
||||
* Show InputMessage
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showInputMessage;
|
||||
|
||||
/**
|
||||
* Show ErrorMessage
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showErrorMessage;
|
||||
|
||||
/**
|
||||
* Error title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_errorTitle;
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_error;
|
||||
|
||||
/**
|
||||
* Prompt title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_promptTitle;
|
||||
|
||||
/**
|
||||
* Prompt
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_prompt;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->_formula1 = '';
|
||||
$this->_formula2 = '';
|
||||
$this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
||||
$this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
||||
$this->_operator = '';
|
||||
$this->_allowBlank = FALSE;
|
||||
$this->_showDropDown = FALSE;
|
||||
$this->_showInputMessage = FALSE;
|
||||
$this->_showErrorMessage = FALSE;
|
||||
$this->_errorTitle = '';
|
||||
$this->_error = '';
|
||||
$this->_promptTitle = '';
|
||||
$this->_prompt = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Formula 1
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormula1() {
|
||||
return $this->_formula1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Formula 1
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setFormula1($value = '') {
|
||||
$this->_formula1 = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Formula 2
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormula2() {
|
||||
return $this->_formula2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Formula 2
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setFormula2($value = '') {
|
||||
$this->_formula2 = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType() {
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Type
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) {
|
||||
$this->_type = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Error style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorStyle() {
|
||||
return $this->_errorStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Error style
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) {
|
||||
$this->_errorStyle = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Operator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOperator() {
|
||||
return $this->_operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Operator
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setOperator($value = '') {
|
||||
$this->_operator = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Allow Blank
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getAllowBlank() {
|
||||
return $this->_allowBlank;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Allow Blank
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setAllowBlank($value = false) {
|
||||
$this->_allowBlank = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Show DropDown
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowDropDown() {
|
||||
return $this->_showDropDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Show DropDown
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setShowDropDown($value = false) {
|
||||
$this->_showDropDown = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Show InputMessage
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowInputMessage() {
|
||||
return $this->_showInputMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Show InputMessage
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setShowInputMessage($value = false) {
|
||||
$this->_showInputMessage = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Show ErrorMessage
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowErrorMessage() {
|
||||
return $this->_showErrorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Show ErrorMessage
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setShowErrorMessage($value = false) {
|
||||
$this->_showErrorMessage = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Error title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorTitle() {
|
||||
return $this->_errorTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Error title
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setErrorTitle($value = '') {
|
||||
$this->_errorTitle = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getError() {
|
||||
return $this->_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Error
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setError($value = '') {
|
||||
$this->_error = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Prompt title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPromptTitle() {
|
||||
return $this->_promptTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Prompt title
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setPromptTitle($value = '') {
|
||||
$this->_promptTitle = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Prompt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrompt() {
|
||||
return $this->_prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Prompt
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setPrompt($value = '') {
|
||||
$this->_prompt = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_formula1
|
||||
. $this->_formula2
|
||||
. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
|
||||
. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
|
||||
. $this->_operator
|
||||
. ($this->_allowBlank ? 't' : 'f')
|
||||
. ($this->_showDropDown ? 't' : 'f')
|
||||
. ($this->_showInputMessage ? 't' : 'f')
|
||||
. ($this->_showErrorMessage ? 't' : 'f')
|
||||
. $this->_errorTitle
|
||||
. $this->_error
|
||||
. $this->_promptTitle
|
||||
. $this->_prompt
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
106
PHPExcel/Cell/DefaultValueBinder.php
Normal file
106
PHPExcel/Cell/DefaultValueBinder.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_DefaultValueBinder
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null)
|
||||
{
|
||||
// sanitize UTF-8 strings
|
||||
if (is_string($value)) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
}
|
||||
|
||||
// Set value explicit
|
||||
$cell->setValueExplicit( $value, self::dataTypeForValue($value) );
|
||||
|
||||
// Done!
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
* @param mixed $pValue
|
||||
* @return string
|
||||
*/
|
||||
public static function dataTypeForValue($pValue = null) {
|
||||
// Match the value against a few data types
|
||||
if (is_null($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
|
||||
} elseif ($pValue === '') {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
|
||||
} elseif ($pValue instanceof PHPExcel_RichText) {
|
||||
return PHPExcel_Cell_DataType::TYPE_INLINE;
|
||||
|
||||
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
|
||||
return PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
|
||||
} elseif (is_bool($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
|
||||
} elseif (is_float($pValue) || is_int($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
|
||||
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
|
||||
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
|
||||
return PHPExcel_Cell_DataType::TYPE_ERROR;
|
||||
|
||||
} else {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
126
PHPExcel/Cell/Hyperlink.php
Normal file
126
PHPExcel/Cell/Hyperlink.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_Hyperlink
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_Hyperlink
|
||||
{
|
||||
/**
|
||||
* URL to link the cell to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_url;
|
||||
|
||||
/**
|
||||
* Tooltip to display on the hyperlink
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tooltip;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Cell_Hyperlink
|
||||
*
|
||||
* @param string $pUrl Url to link the cell to
|
||||
* @param string $pTooltip Tooltip to display on the hyperlink
|
||||
*/
|
||||
public function __construct($pUrl = '', $pTooltip = '')
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->_url = $pUrl;
|
||||
$this->_tooltip = $pTooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl() {
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set URL
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
*/
|
||||
public function setUrl($value = '') {
|
||||
$this->_url = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tooltip
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTooltip() {
|
||||
return $this->_tooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tooltip
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
*/
|
||||
public function setTooltip($value = '') {
|
||||
$this->_tooltip = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this hyperlink internal? (to another worksheet)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isInternal() {
|
||||
return strpos($this->_url, 'sheet://') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_url
|
||||
. $this->_tooltip
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
}
|
46
PHPExcel/Cell/IValueBinder.php
Normal file
46
PHPExcel/Cell/IValueBinder.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_IValueBinder
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = NULL);
|
||||
}
|
551
PHPExcel/Chart.php
Normal file
551
PHPExcel/Chart.php
Normal file
File diff suppressed because it is too large
Load Diff
365
PHPExcel/Chart/DataSeries.php
Normal file
365
PHPExcel/Chart/DataSeries.php
Normal file
@ -0,0 +1,365 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_DataSeries
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_DataSeries
|
||||
{
|
||||
|
||||
const TYPE_BARCHART = 'barChart';
|
||||
const TYPE_BARCHART_3D = 'bar3DChart';
|
||||
const TYPE_LINECHART = 'lineChart';
|
||||
const TYPE_LINECHART_3D = 'line3DChart';
|
||||
const TYPE_AREACHART = 'areaChart';
|
||||
const TYPE_AREACHART_3D = 'area3DChart';
|
||||
const TYPE_PIECHART = 'pieChart';
|
||||
const TYPE_PIECHART_3D = 'pie3DChart';
|
||||
const TYPE_DOUGHTNUTCHART = 'doughnutChart';
|
||||
const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym
|
||||
const TYPE_SCATTERCHART = 'scatterChart';
|
||||
const TYPE_SURFACECHART = 'surfaceChart';
|
||||
const TYPE_SURFACECHART_3D = 'surface3DChart';
|
||||
const TYPE_RADARCHART = 'radarChart';
|
||||
const TYPE_BUBBLECHART = 'bubbleChart';
|
||||
const TYPE_STOCKCHART = 'stockChart';
|
||||
const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym
|
||||
|
||||
const GROUPING_CLUSTERED = 'clustered';
|
||||
const GROUPING_STACKED = 'stacked';
|
||||
const GROUPING_PERCENT_STACKED = 'percentStacked';
|
||||
const GROUPING_STANDARD = 'standard';
|
||||
|
||||
const DIRECTION_BAR = 'bar';
|
||||
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
|
||||
const DIRECTION_COL = 'col';
|
||||
const DIRECTION_COLUMN = self::DIRECTION_COL;
|
||||
const DIRECTION_VERTICAL = self::DIRECTION_COL;
|
||||
|
||||
const STYLE_LINEMARKER = 'lineMarker';
|
||||
const STYLE_SMOOTHMARKER = 'smoothMarker';
|
||||
const STYLE_MARKER = 'marker';
|
||||
const STYLE_FILLED = 'filled';
|
||||
|
||||
|
||||
/**
|
||||
* Series Plot Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_plotType = null;
|
||||
|
||||
/**
|
||||
* Plot Grouping Type
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plotGrouping = null;
|
||||
|
||||
/**
|
||||
* Plot Direction
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plotDirection = null;
|
||||
|
||||
/**
|
||||
* Plot Style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_plotStyle = null;
|
||||
|
||||
/**
|
||||
* Order of plots in Series
|
||||
*
|
||||
* @var array of integer
|
||||
*/
|
||||
private $_plotOrder = array();
|
||||
|
||||
/**
|
||||
* Plot Label
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
private $_plotLabel = array();
|
||||
|
||||
/**
|
||||
* Plot Category
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
private $_plotCategory = array();
|
||||
|
||||
/**
|
||||
* Smooth Line
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_smoothLine = null;
|
||||
|
||||
/**
|
||||
* Plot Values
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
private $_plotValues = array();
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$this->_plotType = $plotType;
|
||||
$this->_plotGrouping = $plotGrouping;
|
||||
$this->_plotOrder = $plotOrder;
|
||||
$keys = array_keys($plotValues);
|
||||
$this->_plotValues = $plotValues;
|
||||
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
|
||||
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||
}
|
||||
|
||||
$this->_plotLabel = $plotLabel;
|
||||
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
|
||||
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||
}
|
||||
$this->_plotCategory = $plotCategory;
|
||||
$this->_smoothLine = $smoothLine;
|
||||
$this->_plotStyle = $plotStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotType() {
|
||||
return $this->_plotType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Type
|
||||
*
|
||||
* @param string $plotType
|
||||
* @return PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function setPlotType($plotType = '') {
|
||||
$this->_plotType = $plotType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Grouping Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotGrouping() {
|
||||
return $this->_plotGrouping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Grouping Type
|
||||
*
|
||||
* @param string $groupingType
|
||||
* @return PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function setPlotGrouping($groupingType = null) {
|
||||
$this->_plotGrouping = $groupingType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Direction
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotDirection() {
|
||||
return $this->_plotDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Direction
|
||||
*
|
||||
* @param string $plotDirection
|
||||
* @return PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function setPlotDirection($plotDirection = null) {
|
||||
$this->_plotDirection = $plotDirection;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Order
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotOrder() {
|
||||
return $this->_plotOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Labels
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotLabels() {
|
||||
return $this->_plotLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Label by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotLabelByIndex($index) {
|
||||
$keys = array_keys($this->_plotLabel);
|
||||
if (in_array($index,$keys)) {
|
||||
return $this->_plotLabel[$index];
|
||||
} elseif(isset($keys[$index])) {
|
||||
return $this->_plotLabel[$keys[$index]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Categories
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotCategories() {
|
||||
return $this->_plotCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Category by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotCategoryByIndex($index) {
|
||||
$keys = array_keys($this->_plotCategory);
|
||||
if (in_array($index,$keys)) {
|
||||
return $this->_plotCategory[$index];
|
||||
} elseif(isset($keys[$index])) {
|
||||
return $this->_plotCategory[$keys[$index]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotStyle() {
|
||||
return $this->_plotStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Style
|
||||
*
|
||||
* @param string $plotStyle
|
||||
* @return PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function setPlotStyle($plotStyle = null) {
|
||||
$this->_plotStyle = $plotStyle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Values
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotValues() {
|
||||
return $this->_plotValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Values by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotValuesByIndex($index) {
|
||||
$keys = array_keys($this->_plotValues);
|
||||
if (in_array($index,$keys)) {
|
||||
return $this->_plotValues[$index];
|
||||
} elseif(isset($keys[$index])) {
|
||||
return $this->_plotValues[$keys[$index]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Series
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPlotSeriesCount() {
|
||||
return count($this->_plotValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Smooth Line
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getSmoothLine() {
|
||||
return $this->_smoothLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Smooth Line
|
||||
*
|
||||
* @param boolean $smoothLine
|
||||
* @return PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function setSmoothLine($smoothLine = TRUE) {
|
||||
$this->_smoothLine = $smoothLine;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function refresh(PHPExcel_Worksheet $worksheet) {
|
||||
foreach($this->_plotValues as $plotValues) {
|
||||
if ($plotValues !== NULL)
|
||||
$plotValues->refresh($worksheet, TRUE);
|
||||
}
|
||||
foreach($this->_plotLabel as $plotValues) {
|
||||
if ($plotValues !== NULL)
|
||||
$plotValues->refresh($worksheet, TRUE);
|
||||
}
|
||||
foreach($this->_plotCategory as $plotValues) {
|
||||
if ($plotValues !== NULL)
|
||||
$plotValues->refresh($worksheet, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
327
PHPExcel/Chart/DataSeriesValues.php
Normal file
327
PHPExcel/Chart/DataSeriesValues.php
Normal file
@ -0,0 +1,327 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_DataSeriesValues
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_DataSeriesValues
|
||||
{
|
||||
|
||||
const DATASERIES_TYPE_STRING = 'String';
|
||||
const DATASERIES_TYPE_NUMBER = 'Number';
|
||||
|
||||
private static $_dataTypeValues = array(
|
||||
self::DATASERIES_TYPE_STRING,
|
||||
self::DATASERIES_TYPE_NUMBER,
|
||||
);
|
||||
|
||||
/**
|
||||
* Series Data Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dataType = null;
|
||||
|
||||
/**
|
||||
* Series Data Source
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dataSource = null;
|
||||
|
||||
/**
|
||||
* Format Code
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formatCode = null;
|
||||
|
||||
/**
|
||||
* Series Point Marker
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_marker = null;
|
||||
|
||||
/**
|
||||
* Point Count (The number of datapoints in the dataseries)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_pointCount = 0;
|
||||
|
||||
/**
|
||||
* Data Values
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $_dataValues = array();
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$this->setDataType($dataType);
|
||||
$this->_dataSource = $dataSource;
|
||||
$this->_formatCode = $formatCode;
|
||||
$this->_pointCount = $pointCount;
|
||||
$this->_dataValues = $dataValues;
|
||||
$this->_marker = $marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataType() {
|
||||
return $this->_dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Type
|
||||
*
|
||||
* @param string $dataType Datatype of this data series
|
||||
* Typical values are:
|
||||
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
|
||||
* Normally used for axis point values
|
||||
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
|
||||
* Normally used for chart data values
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) {
|
||||
if (!in_array($dataType, self::$_dataTypeValues)) {
|
||||
throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
|
||||
}
|
||||
$this->_dataType = $dataType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Source (formula)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataSource() {
|
||||
return $this->_dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Source (formula)
|
||||
*
|
||||
* @param string $dataSource
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setDataSource($dataSource = null, $refreshDataValues = true) {
|
||||
$this->_dataSource = $dataSource;
|
||||
|
||||
if ($refreshDataValues) {
|
||||
// TO DO
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Point Marker
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPointMarker() {
|
||||
return $this->_marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Point Marker
|
||||
*
|
||||
* @param string $marker
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setPointMarker($marker = null) {
|
||||
$this->_marker = $marker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Format Code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormatCode() {
|
||||
return $this->_formatCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Format Code
|
||||
*
|
||||
* @param string $formatCode
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setFormatCode($formatCode = null) {
|
||||
$this->_formatCode = $formatCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Point Count
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPointCount() {
|
||||
return $this->_pointCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify if the Data Series is a multi-level or a simple series
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isMultiLevelSeries() {
|
||||
if (count($this->_dataValues) > 0) {
|
||||
return is_array($this->_dataValues[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the level count of a multi-level Data Series
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function multiLevelCount() {
|
||||
$levelCount = 0;
|
||||
foreach($this->_dataValues as $dataValueSet) {
|
||||
$levelCount = max($levelCount,count($dataValueSet));
|
||||
}
|
||||
return $levelCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Values
|
||||
*
|
||||
* @return array of mixed
|
||||
*/
|
||||
public function getDataValues() {
|
||||
return $this->_dataValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first Series Data value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDataValue() {
|
||||
$count = count($this->_dataValues);
|
||||
if ($count == 0) {
|
||||
return null;
|
||||
} elseif ($count == 1) {
|
||||
return $this->_dataValues[0];
|
||||
}
|
||||
return $this->_dataValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Values
|
||||
*
|
||||
* @param array $dataValues
|
||||
* @param boolean $refreshDataSource
|
||||
* TRUE - refresh the value of _dataSource based on the values of $dataValues
|
||||
* FALSE - don't change the value of _dataSource
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) {
|
||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
|
||||
$this->_pointCount = count($dataValues);
|
||||
|
||||
if ($refreshDataSource) {
|
||||
// TO DO
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _stripNulls($var) {
|
||||
return $var !== NULL;
|
||||
}
|
||||
|
||||
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) {
|
||||
if ($this->_dataSource !== NULL) {
|
||||
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
|
||||
$newDataValues = PHPExcel_Calculation::_unwrapResult(
|
||||
$calcEngine->_calculateFormulaValue(
|
||||
'='.$this->_dataSource,
|
||||
NULL,
|
||||
$worksheet->getCell('A1')
|
||||
)
|
||||
);
|
||||
if ($flatten) {
|
||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
|
||||
foreach($this->_dataValues as &$dataValue) {
|
||||
if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
|
||||
$dataValue = 0.0;
|
||||
}
|
||||
}
|
||||
unset($dataValue);
|
||||
} else {
|
||||
$cellRange = explode('!',$this->_dataSource);
|
||||
if (count($cellRange) > 1) {
|
||||
list(,$cellRange) = $cellRange;
|
||||
}
|
||||
|
||||
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange));
|
||||
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
|
||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
|
||||
} else {
|
||||
$newArray = array_values(array_shift($newDataValues));
|
||||
foreach($newArray as $i => $newDataSet) {
|
||||
$newArray[$i] = array($newDataSet);
|
||||
}
|
||||
|
||||
foreach($newDataValues as $newDataSet) {
|
||||
$i = 0;
|
||||
foreach($newDataSet as $newDataVal) {
|
||||
array_unshift($newArray[$i++],$newDataVal);
|
||||
}
|
||||
}
|
||||
$this->_dataValues = $newArray;
|
||||
}
|
||||
}
|
||||
$this->_pointCount = count($this->_dataValues);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
52
PHPExcel/Chart/Exception.php
Normal file
52
PHPExcel/Chart/Exception.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Exception extends PHPExcel_Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
445
PHPExcel/Chart/Layout.php
Normal file
445
PHPExcel/Chart/Layout.php
Normal file
@ -0,0 +1,445 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Layout
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Layout
|
||||
{
|
||||
/**
|
||||
* layoutTarget
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_layoutTarget = NULL;
|
||||
|
||||
/**
|
||||
* X Mode
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_xMode = NULL;
|
||||
|
||||
/**
|
||||
* Y Mode
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_yMode = NULL;
|
||||
|
||||
/**
|
||||
* X-Position
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_xPos = NULL;
|
||||
|
||||
/**
|
||||
* Y-Position
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_yPos = NULL;
|
||||
|
||||
/**
|
||||
* width
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_width = NULL;
|
||||
|
||||
/**
|
||||
* height
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_height = NULL;
|
||||
|
||||
/**
|
||||
* show legend key
|
||||
* Specifies that legend keys should be shown in data labels
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showLegendKey = NULL;
|
||||
|
||||
/**
|
||||
* show value
|
||||
* Specifies that the value should be shown in a data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showVal = NULL;
|
||||
|
||||
/**
|
||||
* show category name
|
||||
* Specifies that the category name should be shown in the data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showCatName = NULL;
|
||||
|
||||
/**
|
||||
* show data series name
|
||||
* Specifies that the series name should be shown in the data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showSerName = NULL;
|
||||
|
||||
/**
|
||||
* show percentage
|
||||
* Specifies that the percentage should be shown in the data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showPercent = NULL;
|
||||
|
||||
/**
|
||||
* show bubble size
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showBubbleSize = NULL;
|
||||
|
||||
/**
|
||||
* show leader lines
|
||||
* Specifies that leader lines should be shown for the data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showLeaderLines = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function __construct($layout=array())
|
||||
{
|
||||
if (isset($layout['layoutTarget'])) { $this->_layoutTarget = $layout['layoutTarget']; }
|
||||
if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; }
|
||||
if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; }
|
||||
if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; }
|
||||
if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; }
|
||||
if (isset($layout['w'])) { $this->_width = (float) $layout['w']; }
|
||||
if (isset($layout['h'])) { $this->_height = (float) $layout['h']; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout Target
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLayoutTarget() {
|
||||
return $this->_layoutTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Layout Target
|
||||
*
|
||||
* @param Layout Target $value
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setLayoutTarget($value) {
|
||||
$this->_layoutTarget = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getXMode() {
|
||||
return $this->_xMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Mode
|
||||
*
|
||||
* @param X-Mode $value
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setXMode($value) {
|
||||
$this->_xMode = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getYMode() {
|
||||
return $this->_yMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Mode
|
||||
*
|
||||
* @param Y-Mode $value
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setYMode($value) {
|
||||
$this->_yMode = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Position
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getXPosition() {
|
||||
return $this->_xPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Position
|
||||
*
|
||||
* @param X-Position $value
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setXPosition($value) {
|
||||
$this->_xPos = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Position
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getYPosition() {
|
||||
return $this->_yPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Position
|
||||
*
|
||||
* @param Y-Position $value
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setYPosition($value) {
|
||||
$this->_yPos = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param Width $value
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setWidth($value) {
|
||||
$this->_width = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param Height $value
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setHeight($value) {
|
||||
$this->_height = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get show legend key
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowLegendKey() {
|
||||
return $this->_showLegendKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show legend key
|
||||
* Specifies that legend keys should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show legend key
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setShowLegendKey($value) {
|
||||
$this->_showLegendKey = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowVal() {
|
||||
return $this->_showVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show val
|
||||
* Specifies that the value should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show val
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setShowVal($value) {
|
||||
$this->_showVal = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show category name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowCatName() {
|
||||
return $this->_showCatName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show cat name
|
||||
* Specifies that the category name should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show cat name
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setShowCatName($value) {
|
||||
$this->_showCatName = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show data series name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowSerName() {
|
||||
return $this->_showSerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show ser name
|
||||
* Specifies that the series name should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show series name
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setShowSerName($value) {
|
||||
$this->_showSerName = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show percentage
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowPercent() {
|
||||
return $this->_showPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show percentage
|
||||
* Specifies that the percentage should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show percentage
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setShowPercent($value) {
|
||||
$this->_showPercent = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show bubble size
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowBubbleSize() {
|
||||
return $this->_showBubbleSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show bubble size
|
||||
* Specifies that the bubble size should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show bubble size
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setShowBubbleSize($value) {
|
||||
$this->_showBubbleSize = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show leader lines
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowLeaderLines() {
|
||||
return $this->_showLeaderLines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show leader lines
|
||||
* Specifies that leader lines should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show leader lines
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function setShowLeaderLines($value) {
|
||||
$this->_showLeaderLines = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
171
PHPExcel/Chart/Legend.php
Normal file
171
PHPExcel/Chart/Legend.php
Normal file
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Legend
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Legend
|
||||
{
|
||||
/** Legend positions */
|
||||
const xlLegendPositionBottom = -4107; // Below the chart.
|
||||
const xlLegendPositionCorner = 2; // In the upper right-hand corner of the chart border.
|
||||
const xlLegendPositionCustom = -4161; // A custom position.
|
||||
const xlLegendPositionLeft = -4131; // Left of the chart.
|
||||
const xlLegendPositionRight = -4152; // Right of the chart.
|
||||
const xlLegendPositionTop = -4160; // Above the chart.
|
||||
|
||||
const POSITION_RIGHT = 'r';
|
||||
const POSITION_LEFT = 'l';
|
||||
const POSITION_BOTTOM = 'b';
|
||||
const POSITION_TOP = 't';
|
||||
const POSITION_TOPRIGHT = 'tr';
|
||||
|
||||
private static $_positionXLref = array( self::xlLegendPositionBottom => self::POSITION_BOTTOM,
|
||||
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
|
||||
self::xlLegendPositionCustom => '??',
|
||||
self::xlLegendPositionLeft => self::POSITION_LEFT,
|
||||
self::xlLegendPositionRight => self::POSITION_RIGHT,
|
||||
self::xlLegendPositionTop => self::POSITION_TOP
|
||||
);
|
||||
|
||||
/**
|
||||
* Legend position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_position = self::POSITION_RIGHT;
|
||||
|
||||
/**
|
||||
* Allow overlay of other elements?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_overlay = TRUE;
|
||||
|
||||
/**
|
||||
* Legend Layout
|
||||
*
|
||||
* @var PHPExcel_Chart_Layout
|
||||
*/
|
||||
private $_layout = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Legend
|
||||
*/
|
||||
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE)
|
||||
{
|
||||
$this->setPosition($position);
|
||||
$this->_layout = $layout;
|
||||
$this->setOverlay($overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position as an excel string value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPosition() {
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position using an excel string value
|
||||
*
|
||||
* @param string $position
|
||||
*/
|
||||
public function setPosition($position = self::POSITION_RIGHT) {
|
||||
if (!in_array($position,self::$_positionXLref)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_position = $position;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position as an Excel internal numeric value
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getPositionXL() {
|
||||
return array_search($this->_position,self::$_positionXLref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set legend position using an Excel internal numeric value
|
||||
*
|
||||
* @param number $positionXL
|
||||
*/
|
||||
public function setPositionXL($positionXL = self::xlLegendPositionRight) {
|
||||
if (!array_key_exists($positionXL,self::$_positionXLref)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_position = self::$_positionXLref[$positionXL];
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allow overlay of other elements?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getOverlay() {
|
||||
return $this->_overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allow overlay of other elements?
|
||||
*
|
||||
* @param boolean $overlay
|
||||
* @return boolean
|
||||
*/
|
||||
public function setOverlay($overlay = FALSE) {
|
||||
if (!is_bool($overlay)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_overlay = $overlay;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout
|
||||
*
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function getLayout() {
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
}
|
128
PHPExcel/Chart/PlotArea.php
Normal file
128
PHPExcel/Chart/PlotArea.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_PlotArea
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_PlotArea
|
||||
{
|
||||
/**
|
||||
* PlotArea Layout
|
||||
*
|
||||
* @var PHPExcel_Chart_Layout
|
||||
*/
|
||||
private $_layout = null;
|
||||
|
||||
/**
|
||||
* Plot Series
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
private $_plotSeries = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array())
|
||||
{
|
||||
$this->_layout = $layout;
|
||||
$this->_plotSeries = $plotSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout
|
||||
*
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function getLayout() {
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Groups
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function getPlotGroupCount() {
|
||||
return count($this->_plotSeries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Series
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPlotSeriesCount() {
|
||||
$seriesCount = 0;
|
||||
foreach($this->_plotSeries as $plot) {
|
||||
$seriesCount += $plot->getPlotSeriesCount();
|
||||
}
|
||||
return $seriesCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Series
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function getPlotGroup() {
|
||||
return $this->_plotSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Series by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function getPlotGroupByIndex($index) {
|
||||
return $this->_plotSeries[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Series
|
||||
*
|
||||
* @param [PHPExcel_Chart_DataSeries]
|
||||
* @return PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
public function setPlotSeries($plotSeries = array()) {
|
||||
$this->_plotSeries = $plotSeries;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function refresh(PHPExcel_Worksheet $worksheet) {
|
||||
foreach($this->_plotSeries as $plotSeries) {
|
||||
$plotSeries->refresh($worksheet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
17
PHPExcel/Chart/Renderer/PHP Charting Libraries.txt
Normal file
17
PHPExcel/Chart/Renderer/PHP Charting Libraries.txt
Normal file
@ -0,0 +1,17 @@
|
||||
ChartDirector
|
||||
http://www.advsofteng.com/cdphp.html
|
||||
|
||||
GraPHPite
|
||||
http://graphpite.sourceforge.net/
|
||||
|
||||
JpGraph
|
||||
http://www.aditus.nu/jpgraph/
|
||||
|
||||
LibChart
|
||||
http://naku.dohcrew.com/libchart/pages/introduction/
|
||||
|
||||
pChart
|
||||
http://pchart.sourceforge.net/
|
||||
|
||||
TeeChart
|
||||
http://www.steema.com/products/teechart/overview.html
|
855
PHPExcel/Chart/Renderer/jpgraph.php
Normal file
855
PHPExcel/Chart/Renderer/jpgraph.php
Normal file
File diff suppressed because it is too large
Load Diff
92
PHPExcel/Chart/Title.php
Normal file
92
PHPExcel/Chart/Title.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Title
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Title
|
||||
{
|
||||
|
||||
/**
|
||||
* Title Caption
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_caption = null;
|
||||
|
||||
/**
|
||||
* Title Layout
|
||||
*
|
||||
* @var PHPExcel_Chart_Layout
|
||||
*/
|
||||
private $_layout = null;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Title
|
||||
*/
|
||||
public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null)
|
||||
{
|
||||
$this->_caption = $caption;
|
||||
$this->_layout = $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get caption
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCaption() {
|
||||
return $this->_caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set caption
|
||||
*
|
||||
* @param string $caption
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function setCaption($caption = null) {
|
||||
$this->_caption = $caption;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout
|
||||
*
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function getLayout() {
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
}
|
327
PHPExcel/Comment.php
Normal file
327
PHPExcel/Comment.php
Normal file
@ -0,0 +1,327 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Comment
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Author
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_author;
|
||||
|
||||
/**
|
||||
* Rich text comment
|
||||
*
|
||||
* @var PHPExcel_RichText
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_width = '96pt';
|
||||
|
||||
/**
|
||||
* Left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_marginLeft = '59.25pt';
|
||||
|
||||
/**
|
||||
* Top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_marginTop = '1.5pt';
|
||||
|
||||
/**
|
||||
* Visible
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_visible = false;
|
||||
|
||||
/**
|
||||
* Comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_height = '55.5pt';
|
||||
|
||||
/**
|
||||
* Comment fill color
|
||||
*
|
||||
* @var PHPExcel_Style_Color
|
||||
*/
|
||||
private $_fillColor;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_alignment;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Comment
|
||||
*
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_author = 'Author';
|
||||
$this->_text = new PHPExcel_RichText();
|
||||
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
||||
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor() {
|
||||
return $this->_author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Author
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setAuthor($pValue = '') {
|
||||
$this->_author = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rich text comment
|
||||
*
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich text comment
|
||||
*
|
||||
* @param PHPExcel_RichText $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setText(PHPExcel_RichText $pValue) {
|
||||
$this->_text = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setWidth($value = '96pt') {
|
||||
$this->_width = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setHeight($value = '55.5pt') {
|
||||
$this->_height = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMarginLeft() {
|
||||
return $this->_marginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setMarginLeft($value = '59.25pt') {
|
||||
$this->_marginLeft = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMarginTop() {
|
||||
return $this->_marginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setMarginTop($value = '1.5pt') {
|
||||
$this->_marginTop = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the comment visible by default?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getVisible() {
|
||||
return $this->_visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment default visibility
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setVisible($value = false) {
|
||||
$this->_visible = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fill color
|
||||
*
|
||||
* @return PHPExcel_Style_Color
|
||||
*/
|
||||
public function getFillColor() {
|
||||
return $this->_fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Alignment
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
|
||||
$this->_alignment = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alignment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlignment() {
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_author
|
||||
. $this->_text->getHashCode()
|
||||
. $this->_width
|
||||
. $this->_height
|
||||
. $this->_marginLeft
|
||||
. $this->_marginTop
|
||||
. ($this->_visible ? 1 : 0)
|
||||
. $this->_fillColor->getHashCode()
|
||||
. $this->_alignment
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->_text->getPlainText();
|
||||
}
|
||||
|
||||
}
|
587
PHPExcel/DocumentProperties.php
Normal file
587
PHPExcel/DocumentProperties.php
Normal file
File diff suppressed because it is too large
Load Diff
218
PHPExcel/DocumentSecurity.php
Normal file
218
PHPExcel/DocumentSecurity.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_DocumentSecurity
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_DocumentSecurity
|
||||
{
|
||||
/**
|
||||
* LockRevision
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_lockRevision;
|
||||
|
||||
/**
|
||||
* LockStructure
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_lockStructure;
|
||||
|
||||
/**
|
||||
* LockWindows
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_lockWindows;
|
||||
|
||||
/**
|
||||
* RevisionsPassword
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_revisionsPassword;
|
||||
|
||||
/**
|
||||
* WorkbookPassword
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_workbookPassword;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_DocumentSecurity
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_lockRevision = false;
|
||||
$this->_lockStructure = false;
|
||||
$this->_lockWindows = false;
|
||||
$this->_revisionsPassword = '';
|
||||
$this->_workbookPassword = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is some sort of dcument security enabled?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function isSecurityEnabled() {
|
||||
return $this->_lockRevision ||
|
||||
$this->_lockStructure ||
|
||||
$this->_lockWindows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockRevision
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLockRevision() {
|
||||
return $this->_lockRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LockRevision
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setLockRevision($pValue = false) {
|
||||
$this->_lockRevision = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockStructure
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLockStructure() {
|
||||
return $this->_lockStructure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LockStructure
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setLockStructure($pValue = false) {
|
||||
$this->_lockStructure = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockWindows
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLockWindows() {
|
||||
return $this->_lockWindows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LockWindows
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setLockWindows($pValue = false) {
|
||||
$this->_lockWindows = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get RevisionsPassword (hashed)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getRevisionsPassword() {
|
||||
return $this->_revisionsPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set RevisionsPassword
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
|
||||
if (!$pAlreadyHashed) {
|
||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||
}
|
||||
$this->_revisionsPassword = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WorkbookPassword (hashed)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getWorkbookPassword() {
|
||||
return $this->_workbookPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set WorkbookPassword
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
|
||||
if (!$pAlreadyHashed) {
|
||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||
}
|
||||
$this->_workbookPassword = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
52
PHPExcel/Exception.php
Normal file
52
PHPExcel/Exception.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Exception extends Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
202
PHPExcel/HashTable.php
Normal file
202
PHPExcel/HashTable.php
Normal file
@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_HashTable
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_HashTable
|
||||
{
|
||||
/**
|
||||
* HashTable elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_items = array();
|
||||
|
||||
/**
|
||||
* HashTable key map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_keyMap = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_HashTable
|
||||
*
|
||||
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function __construct($pSource = null)
|
||||
{
|
||||
if ($pSource !== NULL) {
|
||||
// Create HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable items from source
|
||||
*
|
||||
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addFromSource($pSource = null) {
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
} else if (!is_array($pSource)) {
|
||||
throw new PHPExcel_Exception('Invalid array parameter passed.');
|
||||
}
|
||||
|
||||
foreach ($pSource as $item) {
|
||||
$this->add($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable item
|
||||
*
|
||||
* @param PHPExcel_IComparable $pSource Item to add
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function add(PHPExcel_IComparable $pSource = null) {
|
||||
$hash = $pSource->getHashCode();
|
||||
if (!isset($this->_items[$hash])) {
|
||||
$this->_items[$hash] = $pSource;
|
||||
$this->_keyMap[count($this->_items) - 1] = $hash;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove HashTable item
|
||||
*
|
||||
* @param PHPExcel_IComparable $pSource Item to remove
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function remove(PHPExcel_IComparable $pSource = null) {
|
||||
$hash = $pSource->getHashCode();
|
||||
if (isset($this->_items[$hash])) {
|
||||
unset($this->_items[$hash]);
|
||||
|
||||
$deleteKey = -1;
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->_keyMap[$key - 1] = $value;
|
||||
}
|
||||
|
||||
if ($value == $hash) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear() {
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->_items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for hash code
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '') {
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return PHPExcel_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0) {
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by hashcode
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return PHPExcel_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '') {
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* HashTable to array
|
||||
*
|
||||
* @return PHPExcel_IComparable[]
|
||||
*/
|
||||
public function toArray() {
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
43
PHPExcel/IComparable.php
Normal file
43
PHPExcel/IComparable.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_IComparable
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
|
||||
}
|
288
PHPExcel/IOFactory.php
Normal file
288
PHPExcel/IOFactory.php
Normal file
@ -0,0 +1,288 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_IOFactory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_IOFactory
|
||||
{
|
||||
/**
|
||||
* Search locations
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
private static $_searchLocations = array(
|
||||
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
|
||||
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' )
|
||||
);
|
||||
|
||||
/**
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
private static $_autoResolveClasses = array(
|
||||
'Excel2007',
|
||||
'Excel5',
|
||||
'Excel2003XML',
|
||||
'OOCalc',
|
||||
'SYLK',
|
||||
'Gnumeric',
|
||||
'HTML',
|
||||
'CSV',
|
||||
);
|
||||
|
||||
/**
|
||||
* Private constructor for PHPExcel_IOFactory
|
||||
*/
|
||||
private function __construct() { }
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations() {
|
||||
return self::$_searchLocations;
|
||||
} // function getSearchLocations()
|
||||
|
||||
/**
|
||||
* Set search locations
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param array $value
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function setSearchLocations($value) {
|
||||
if (is_array($value)) {
|
||||
self::$_searchLocations = $value;
|
||||
} else {
|
||||
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
|
||||
}
|
||||
} // function setSearchLocations()
|
||||
|
||||
/**
|
||||
* Add search location
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PHPExcel/Writer/{0}.php
|
||||
* @param string $classname Example: PHPExcel_Writer_{0}
|
||||
*/
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '') {
|
||||
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||
} // function addSearchLocation()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Writer_IWriter
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param PHPExcel $phpExcel
|
||||
* @param string $writerType Example: Excel2007
|
||||
* @return PHPExcel_Writer_IWriter
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IWriter';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
||||
|
||||
$instance = new $className($phpExcel);
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
|
||||
} // function createWriter()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Reader_IReader
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $readerType Example: Excel2007
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function createReader($readerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IReader';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
||||
|
||||
$instance = new $className();
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
|
||||
} // function createReader()
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFilename The name of the spreadsheet file
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function load($pFilename) {
|
||||
$reader = self::createReaderForFile($pFilename);
|
||||
return $reader->load($pFilename);
|
||||
} // function load()
|
||||
|
||||
/**
|
||||
* Identify file type using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFilename The name of the spreadsheet file to identify
|
||||
* @return string
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function identify($pFilename) {
|
||||
$reader = self::createReaderForFile($pFilename);
|
||||
$className = get_class($reader);
|
||||
$classType = explode('_',$className);
|
||||
unset($reader);
|
||||
return array_pop($classType);
|
||||
} // function identify()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFilename The name of the spreadsheet file
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function createReaderForFile($pFilename) {
|
||||
|
||||
// First, lucky guess by inspecting file extension
|
||||
$pathinfo = pathinfo($pFilename);
|
||||
|
||||
$extensionType = NULL;
|
||||
if (isset($pathinfo['extension'])) {
|
||||
switch (strtolower($pathinfo['extension'])) {
|
||||
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
|
||||
case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
|
||||
case 'xltx': // Excel (OfficeOpenXML) Template
|
||||
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
|
||||
$extensionType = 'Excel2007';
|
||||
break;
|
||||
case 'xls': // Excel (BIFF) Spreadsheet
|
||||
case 'xlt': // Excel (BIFF) Template
|
||||
$extensionType = 'Excel5';
|
||||
break;
|
||||
case 'ods': // Open/Libre Offic Calc
|
||||
case 'ots': // Open/Libre Offic Calc Template
|
||||
$extensionType = 'OOCalc';
|
||||
break;
|
||||
case 'slk':
|
||||
$extensionType = 'SYLK';
|
||||
break;
|
||||
case 'xml': // Excel 2003 SpreadSheetML
|
||||
$extensionType = 'Excel2003XML';
|
||||
break;
|
||||
case 'gnumeric':
|
||||
$extensionType = 'Gnumeric';
|
||||
break;
|
||||
case 'htm':
|
||||
case 'html':
|
||||
$extensionType = 'HTML';
|
||||
break;
|
||||
case 'csv':
|
||||
// Do nothing
|
||||
// We must not try to use CSV reader since it loads
|
||||
// all files including Excel files etc.
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ($extensionType !== NULL) {
|
||||
$reader = self::createReader($extensionType);
|
||||
// Let's see if we are lucky
|
||||
if (isset($reader) && $reader->canRead($pFilename)) {
|
||||
return $reader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we reach here then "lucky guess" didn't give any result
|
||||
// Try walking through all the options in self::$_autoResolveClasses
|
||||
foreach (self::$_autoResolveClasses as $autoResolveClass) {
|
||||
// Ignore our original guess, we know that won't work
|
||||
if ($autoResolveClass !== $extensionType) {
|
||||
$reader = self::createReader($autoResolveClass);
|
||||
if ($reader->canRead($pFilename)) {
|
||||
return $reader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file');
|
||||
} // function createReaderForFile()
|
||||
}
|
246
PHPExcel/NamedRange.php
Normal file
246
PHPExcel/NamedRange.php
Normal file
@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_NamedRange
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_NamedRange
|
||||
{
|
||||
/**
|
||||
* Range name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_name;
|
||||
|
||||
/**
|
||||
* Worksheet on which the named range can be resolved
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_worksheet;
|
||||
|
||||
/**
|
||||
* Range of the referenced cells
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_range;
|
||||
|
||||
/**
|
||||
* Is the named range local? (i.e. can only be used on $this->_worksheet)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_localOnly;
|
||||
|
||||
/**
|
||||
* Scope
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_scope;
|
||||
|
||||
/**
|
||||
* Create a new NamedRange
|
||||
*
|
||||
* @param string $pName
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @param string $pRange
|
||||
* @param bool $pLocalOnly
|
||||
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
||||
{
|
||||
// Validate data
|
||||
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
|
||||
throw new PHPExcel_Exception('Parameters can not be null.');
|
||||
}
|
||||
|
||||
// Set local members
|
||||
$this->_name = $pName;
|
||||
$this->_worksheet = $pWorksheet;
|
||||
$this->_range = $pRange;
|
||||
$this->_localOnly = $pLocalOnly;
|
||||
$this->_scope = ($pLocalOnly == true) ?
|
||||
(($pScope == null) ? $pWorksheet : $pScope) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setName($value = null) {
|
||||
if ($value !== NULL) {
|
||||
// Old title
|
||||
$oldTitle = $this->_name;
|
||||
|
||||
// Re-attach
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
|
||||
}
|
||||
$this->_name = $value;
|
||||
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_worksheet->getParent()->addNamedRange($this);
|
||||
}
|
||||
|
||||
// New title
|
||||
$newTitle = $this->_name;
|
||||
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get worksheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getWorksheet() {
|
||||
return $this->_worksheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set worksheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setWorksheet(PHPExcel_Worksheet $value = null) {
|
||||
if ($value !== NULL) {
|
||||
$this->_worksheet = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get range
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRange() {
|
||||
return $this->_range;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set range
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setRange($value = null) {
|
||||
if ($value !== NULL) {
|
||||
$this->_range = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get localOnly
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getLocalOnly() {
|
||||
return $this->_localOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set localOnly
|
||||
*
|
||||
* @param bool $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setLocalOnly($value = false) {
|
||||
$this->_localOnly = $value;
|
||||
$this->_scope = $value ? $this->_worksheet : null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scope
|
||||
*
|
||||
* @return PHPExcel_Worksheet|null
|
||||
*/
|
||||
public function getScope() {
|
||||
return $this->_scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set scope
|
||||
*
|
||||
* @param PHPExcel_Worksheet|null $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setScope(PHPExcel_Worksheet $value = null) {
|
||||
$this->_scope = $value;
|
||||
$this->_localOnly = ($value == null) ? false : true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a named range to a regular cell range
|
||||
*
|
||||
* @param string $pNamedRange Named range
|
||||
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
|
||||
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
227
PHPExcel/Reader/Abstract.php
Normal file
227
PHPExcel/Reader/Abstract.php
Normal file
@ -0,0 +1,227 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Abstract
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Read data only?
|
||||
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
|
||||
* or whether it should read both data and formatting
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_readDataOnly = FALSE;
|
||||
|
||||
/**
|
||||
* Read charts that are defined in the workbook?
|
||||
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_includeCharts = FALSE;
|
||||
|
||||
/**
|
||||
* Restrict which sheets should be loaded?
|
||||
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
|
||||
*
|
||||
* @var array of string
|
||||
*/
|
||||
protected $_loadSheetsOnly = NULL;
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReadFilter instance
|
||||
*
|
||||
* @var PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
protected $_readFilter = NULL;
|
||||
|
||||
protected $_fileHandle = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Read data only?
|
||||
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
|
||||
* If false (the default) it will read data and formatting.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getReadDataOnly() {
|
||||
return $this->_readDataOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set read data only
|
||||
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
|
||||
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setReadDataOnly($pValue = FALSE) {
|
||||
$this->_readDataOnly = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read charts in workbook?
|
||||
* If this is true, then the Reader will include any charts that exist in the workbook.
|
||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||
* If false (the default) it will ignore any charts defined in the workbook file.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIncludeCharts() {
|
||||
return $this->_includeCharts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set read charts in workbook
|
||||
* Set to true, to advise the Reader to include any charts that exist in the workbook.
|
||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||
* Set to false (the default) to discard charts.
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setIncludeCharts($pValue = FALSE) {
|
||||
$this->_includeCharts = (boolean) $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get which sheets to load
|
||||
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
|
||||
* indicating that all worksheets in the workbook should be loaded.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLoadSheetsOnly()
|
||||
{
|
||||
return $this->_loadSheetsOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set which sheets to load
|
||||
*
|
||||
* @param mixed $value
|
||||
* 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
|
||||
*
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setLoadSheetsOnly($value = NULL)
|
||||
{
|
||||
$this->_loadSheetsOnly = is_array($value) ?
|
||||
$value : array($value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all sheets to load
|
||||
* Tells the Reader to load all worksheets from the workbook.
|
||||
*
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setLoadAllSheets()
|
||||
{
|
||||
$this->_loadSheetsOnly = NULL;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read filter
|
||||
*
|
||||
* @return PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
public function getReadFilter() {
|
||||
return $this->_readFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set read filter
|
||||
*
|
||||
* @param PHPExcel_Reader_IReadFilter $pValue
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
|
||||
$this->_readFilter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open file for reading
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
* @return resource
|
||||
*/
|
||||
protected function _openFile($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename) || !is_readable($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Open file
|
||||
$this->_fileHandle = fopen($pFilename, 'r');
|
||||
if ($this->_fileHandle === FALSE) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return boolean
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
try {
|
||||
$this->_openFile($pFilename);
|
||||
} catch (Exception $e) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$readable = $this->_isValidFormat();
|
||||
fclose ($this->_fileHandle);
|
||||
return $readable;
|
||||
}
|
||||
|
||||
}
|
415
PHPExcel/Reader/CSV.php
Normal file
415
PHPExcel/Reader/CSV.php
Normal file
@ -0,0 +1,415 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_CSV
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Input encoding
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_inputEncoding = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Delimiter
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_delimiter = ',';
|
||||
|
||||
/**
|
||||
* Enclosure
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_enclosure = '"';
|
||||
|
||||
/**
|
||||
* Line ending
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_lineEnding = PHP_EOL;
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex = 0;
|
||||
|
||||
/**
|
||||
* Load rows contiguously
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $_contiguous = false;
|
||||
|
||||
/**
|
||||
* Row counter for loading rows contiguously
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_contiguousRow = -1;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the current file is a CSV file
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _isValidFormat()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set input encoding
|
||||
*
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'UTF-8')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move filepointer past any BOM marker
|
||||
*
|
||||
*/
|
||||
protected function _skipBOM()
|
||||
{
|
||||
rewind($this->_fileHandle);
|
||||
|
||||
switch ($this->_inputEncoding) {
|
||||
case 'UTF-8':
|
||||
fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ?
|
||||
fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-16LE':
|
||||
fgets($this->_fileHandle, 3) == "\xFF\xFE" ?
|
||||
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-16BE':
|
||||
fgets($this->_fileHandle, 3) == "\xFE\xFF" ?
|
||||
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-32LE':
|
||||
fgets($this->_fileHandle, 5) == "\xFF\xFE\x00\x00" ?
|
||||
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-32BE':
|
||||
fgets($this->_fileHandle, 5) == "\x00\x00\xFE\xFF" ?
|
||||
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetInfo($pFilename)
|
||||
{
|
||||
// Open file
|
||||
$this->_openFile($pFilename);
|
||||
if (!$this->_isValidFormat()) {
|
||||
fclose ($this->_fileHandle);
|
||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
}
|
||||
$fileHandle = $this->_fileHandle;
|
||||
|
||||
// Skip BOM, if any
|
||||
$this->_skipBOM();
|
||||
|
||||
$escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure );
|
||||
|
||||
$worksheetInfo = array();
|
||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||
$worksheetInfo[0]['totalRows'] = 0;
|
||||
$worksheetInfo[0]['totalColumns'] = 0;
|
||||
|
||||
// Loop through each line of the file in turn
|
||||
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
||||
$worksheetInfo[0]['totalRows']++;
|
||||
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
|
||||
}
|
||||
|
||||
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
||||
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
$lineEnding = ini_get('auto_detect_line_endings');
|
||||
ini_set('auto_detect_line_endings', true);
|
||||
|
||||
// Open file
|
||||
$this->_openFile($pFilename);
|
||||
if (!$this->_isValidFormat()) {
|
||||
fclose ($this->_fileHandle);
|
||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
}
|
||||
$fileHandle = $this->_fileHandle;
|
||||
|
||||
// Skip BOM, if any
|
||||
$this->_skipBOM();
|
||||
|
||||
// Create new PHPExcel object
|
||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||
$objPHPExcel->createSheet();
|
||||
}
|
||||
$sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
|
||||
|
||||
$escapeEnclosures = array( "\\" . $this->_enclosure,
|
||||
$this->_enclosure . $this->_enclosure
|
||||
);
|
||||
|
||||
// Set our starting row based on whether we're in contiguous mode or not
|
||||
$currentRow = 1;
|
||||
if ($this->_contiguous) {
|
||||
$currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow;
|
||||
}
|
||||
|
||||
// Loop through each line of the file in turn
|
||||
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
||||
$columnLetter = 'A';
|
||||
foreach($rowData as $rowDatum) {
|
||||
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
|
||||
// Unescape enclosures
|
||||
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);
|
||||
|
||||
// Convert encoding if necessary
|
||||
if ($this->_inputEncoding !== 'UTF-8') {
|
||||
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
|
||||
}
|
||||
|
||||
// Set cell value
|
||||
$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
|
||||
}
|
||||
++$columnLetter;
|
||||
}
|
||||
++$currentRow;
|
||||
}
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
if ($this->_contiguous) {
|
||||
$this->_contiguousRow = $currentRow;
|
||||
}
|
||||
|
||||
ini_set('auto_detect_line_endings', $lineEnding);
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get delimiter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter() {
|
||||
return $this->_delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set delimiter
|
||||
*
|
||||
* @param string $pValue Delimiter, defaults to ,
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setDelimiter($pValue = ',') {
|
||||
$this->_delimiter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enclosure
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnclosure() {
|
||||
return $this->_enclosure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set enclosure
|
||||
*
|
||||
* @param string $pValue Enclosure, defaults to "
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setEnclosure($pValue = '"') {
|
||||
if ($pValue == '') {
|
||||
$pValue = '"';
|
||||
}
|
||||
$this->_enclosure = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get line ending
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLineEnding() {
|
||||
return $this->_lineEnding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line ending
|
||||
*
|
||||
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setLineEnding($pValue = PHP_EOL) {
|
||||
$this->_lineEnding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param integer $pValue Sheet index
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Contiguous
|
||||
*
|
||||
* @param boolean $contiguous
|
||||
*/
|
||||
public function setContiguous($contiguous = FALSE)
|
||||
{
|
||||
$this->_contiguous = (bool) $contiguous;
|
||||
if (!$contiguous) {
|
||||
$this->_contiguousRow = -1;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Contiguous
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getContiguous() {
|
||||
return $this->_contiguous;
|
||||
}
|
||||
|
||||
}
|
58
PHPExcel/Reader/DefaultReadFilter.php
Normal file
58
PHPExcel/Reader/DefaultReadFilter.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_DefaultReadFilter
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
/**
|
||||
* Should this cell be read?
|
||||
*
|
||||
* @param $column String column index
|
||||
* @param $row Row index
|
||||
* @param $worksheetName Optional worksheet name
|
||||
* @return boolean
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '') {
|
||||
return true;
|
||||
}
|
||||
}
|
802
PHPExcel/Reader/Excel2003XML.php
Normal file
802
PHPExcel/Reader/Excel2003XML.php
Normal file
File diff suppressed because it is too large
Load Diff
2069
PHPExcel/Reader/Excel2007.php
Normal file
2069
PHPExcel/Reader/Excel2007.php
Normal file
File diff suppressed because it is too large
Load Diff
517
PHPExcel/Reader/Excel2007/Chart.php
Normal file
517
PHPExcel/Reader/Excel2007/Chart.php
Normal file
File diff suppressed because it is too large
Load Diff
124
PHPExcel/Reader/Excel2007/Theme.php
Normal file
124
PHPExcel/Reader/Excel2007/Theme.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel2007_Theme
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Excel2007_Theme
|
||||
{
|
||||
/**
|
||||
* Theme Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_themeName;
|
||||
|
||||
/**
|
||||
* Colour Scheme Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_colourSchemeName;
|
||||
|
||||
/**
|
||||
* Colour Map indexed by position
|
||||
*
|
||||
* @var array of string
|
||||
*/
|
||||
private $_colourMapValues;
|
||||
|
||||
|
||||
/**
|
||||
* Colour Map
|
||||
*
|
||||
* @var array of string
|
||||
*/
|
||||
private $_colourMap;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Theme
|
||||
*
|
||||
*/
|
||||
public function __construct($themeName,$colourSchemeName,$colourMap)
|
||||
{
|
||||
// Initialise values
|
||||
$this->_themeName = $themeName;
|
||||
$this->_colourSchemeName = $colourSchemeName;
|
||||
$this->_colourMap = $colourMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Theme Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getThemeName()
|
||||
{
|
||||
return $this->_themeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colour Scheme Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColourSchemeName() {
|
||||
return $this->_colourSchemeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colour Map Value by Position
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColourByIndex($index=0) {
|
||||
if (isset($this->_colourMap[$index])) {
|
||||
return $this->_colourMap[$index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if ((is_object($value)) && ($key != '_parent')) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7084
PHPExcel/Reader/Excel5.php
Normal file
7084
PHPExcel/Reader/Excel5.php
Normal file
File diff suppressed because it is too large
Load Diff
640
PHPExcel/Reader/Excel5/Escher.php
Normal file
640
PHPExcel/Reader/Excel5/Escher.php
Normal file
File diff suppressed because it is too large
Load Diff
221
PHPExcel/Reader/Excel5/MD5.php
Normal file
221
PHPExcel/Reader/Excel5/MD5.php
Normal file
@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel5_MD5
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Excel5_MD5
|
||||
{
|
||||
// Context
|
||||
private $a;
|
||||
private $b;
|
||||
private $c;
|
||||
private $d;
|
||||
|
||||
|
||||
/**
|
||||
* MD5 stream constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the MD5 stream context
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->a = 0x67452301;
|
||||
$this->b = 0xEFCDAB89;
|
||||
$this->c = 0x98BADCFE;
|
||||
$this->d = 0x10325476;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get MD5 stream context
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContext()
|
||||
{
|
||||
$s = '';
|
||||
foreach (array('a', 'b', 'c', 'd') as $i) {
|
||||
$v = $this->{$i};
|
||||
$s .= chr($v & 0xff);
|
||||
$s .= chr(($v >> 8) & 0xff);
|
||||
$s .= chr(($v >> 16) & 0xff);
|
||||
$s .= chr(($v >> 24) & 0xff);
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add data to context
|
||||
*
|
||||
* @param string $data Data to add
|
||||
*/
|
||||
public function add($data)
|
||||
{
|
||||
$words = array_values(unpack('V16', $data));
|
||||
|
||||
$A = $this->a;
|
||||
$B = $this->b;
|
||||
$C = $this->c;
|
||||
$D = $this->d;
|
||||
|
||||
$F = array('PHPExcel_Reader_Excel5_MD5','F');
|
||||
$G = array('PHPExcel_Reader_Excel5_MD5','G');
|
||||
$H = array('PHPExcel_Reader_Excel5_MD5','H');
|
||||
$I = array('PHPExcel_Reader_Excel5_MD5','I');
|
||||
|
||||
/* ROUND 1 */
|
||||
self::step($F, $A, $B, $C, $D, $words[0], 7, 0xd76aa478);
|
||||
self::step($F, $D, $A, $B, $C, $words[1], 12, 0xe8c7b756);
|
||||
self::step($F, $C, $D, $A, $B, $words[2], 17, 0x242070db);
|
||||
self::step($F, $B, $C, $D, $A, $words[3], 22, 0xc1bdceee);
|
||||
self::step($F, $A, $B, $C, $D, $words[4], 7, 0xf57c0faf);
|
||||
self::step($F, $D, $A, $B, $C, $words[5], 12, 0x4787c62a);
|
||||
self::step($F, $C, $D, $A, $B, $words[6], 17, 0xa8304613);
|
||||
self::step($F, $B, $C, $D, $A, $words[7], 22, 0xfd469501);
|
||||
self::step($F, $A, $B, $C, $D, $words[8], 7, 0x698098d8);
|
||||
self::step($F, $D, $A, $B, $C, $words[9], 12, 0x8b44f7af);
|
||||
self::step($F, $C, $D, $A, $B, $words[10], 17, 0xffff5bb1);
|
||||
self::step($F, $B, $C, $D, $A, $words[11], 22, 0x895cd7be);
|
||||
self::step($F, $A, $B, $C, $D, $words[12], 7, 0x6b901122);
|
||||
self::step($F, $D, $A, $B, $C, $words[13], 12, 0xfd987193);
|
||||
self::step($F, $C, $D, $A, $B, $words[14], 17, 0xa679438e);
|
||||
self::step($F, $B, $C, $D, $A, $words[15], 22, 0x49b40821);
|
||||
|
||||
/* ROUND 2 */
|
||||
self::step($G, $A, $B, $C, $D, $words[1], 5, 0xf61e2562);
|
||||
self::step($G, $D, $A, $B, $C, $words[6], 9, 0xc040b340);
|
||||
self::step($G, $C, $D, $A, $B, $words[11], 14, 0x265e5a51);
|
||||
self::step($G, $B, $C, $D, $A, $words[0], 20, 0xe9b6c7aa);
|
||||
self::step($G, $A, $B, $C, $D, $words[5], 5, 0xd62f105d);
|
||||
self::step($G, $D, $A, $B, $C, $words[10], 9, 0x02441453);
|
||||
self::step($G, $C, $D, $A, $B, $words[15], 14, 0xd8a1e681);
|
||||
self::step($G, $B, $C, $D, $A, $words[4], 20, 0xe7d3fbc8);
|
||||
self::step($G, $A, $B, $C, $D, $words[9], 5, 0x21e1cde6);
|
||||
self::step($G, $D, $A, $B, $C, $words[14], 9, 0xc33707d6);
|
||||
self::step($G, $C, $D, $A, $B, $words[3], 14, 0xf4d50d87);
|
||||
self::step($G, $B, $C, $D, $A, $words[8], 20, 0x455a14ed);
|
||||
self::step($G, $A, $B, $C, $D, $words[13], 5, 0xa9e3e905);
|
||||
self::step($G, $D, $A, $B, $C, $words[2], 9, 0xfcefa3f8);
|
||||
self::step($G, $C, $D, $A, $B, $words[7], 14, 0x676f02d9);
|
||||
self::step($G, $B, $C, $D, $A, $words[12], 20, 0x8d2a4c8a);
|
||||
|
||||
/* ROUND 3 */
|
||||
self::step($H, $A, $B, $C, $D, $words[5], 4, 0xfffa3942);
|
||||
self::step($H, $D, $A, $B, $C, $words[8], 11, 0x8771f681);
|
||||
self::step($H, $C, $D, $A, $B, $words[11], 16, 0x6d9d6122);
|
||||
self::step($H, $B, $C, $D, $A, $words[14], 23, 0xfde5380c);
|
||||
self::step($H, $A, $B, $C, $D, $words[1], 4, 0xa4beea44);
|
||||
self::step($H, $D, $A, $B, $C, $words[4], 11, 0x4bdecfa9);
|
||||
self::step($H, $C, $D, $A, $B, $words[7], 16, 0xf6bb4b60);
|
||||
self::step($H, $B, $C, $D, $A, $words[10], 23, 0xbebfbc70);
|
||||
self::step($H, $A, $B, $C, $D, $words[13], 4, 0x289b7ec6);
|
||||
self::step($H, $D, $A, $B, $C, $words[0], 11, 0xeaa127fa);
|
||||
self::step($H, $C, $D, $A, $B, $words[3], 16, 0xd4ef3085);
|
||||
self::step($H, $B, $C, $D, $A, $words[6], 23, 0x04881d05);
|
||||
self::step($H, $A, $B, $C, $D, $words[9], 4, 0xd9d4d039);
|
||||
self::step($H, $D, $A, $B, $C, $words[12], 11, 0xe6db99e5);
|
||||
self::step($H, $C, $D, $A, $B, $words[15], 16, 0x1fa27cf8);
|
||||
self::step($H, $B, $C, $D, $A, $words[2], 23, 0xc4ac5665);
|
||||
|
||||
/* ROUND 4 */
|
||||
self::step($I, $A, $B, $C, $D, $words[0], 6, 0xf4292244);
|
||||
self::step($I, $D, $A, $B, $C, $words[7], 10, 0x432aff97);
|
||||
self::step($I, $C, $D, $A, $B, $words[14], 15, 0xab9423a7);
|
||||
self::step($I, $B, $C, $D, $A, $words[5], 21, 0xfc93a039);
|
||||
self::step($I, $A, $B, $C, $D, $words[12], 6, 0x655b59c3);
|
||||
self::step($I, $D, $A, $B, $C, $words[3], 10, 0x8f0ccc92);
|
||||
self::step($I, $C, $D, $A, $B, $words[10], 15, 0xffeff47d);
|
||||
self::step($I, $B, $C, $D, $A, $words[1], 21, 0x85845dd1);
|
||||
self::step($I, $A, $B, $C, $D, $words[8], 6, 0x6fa87e4f);
|
||||
self::step($I, $D, $A, $B, $C, $words[15], 10, 0xfe2ce6e0);
|
||||
self::step($I, $C, $D, $A, $B, $words[6], 15, 0xa3014314);
|
||||
self::step($I, $B, $C, $D, $A, $words[13], 21, 0x4e0811a1);
|
||||
self::step($I, $A, $B, $C, $D, $words[4], 6, 0xf7537e82);
|
||||
self::step($I, $D, $A, $B, $C, $words[11], 10, 0xbd3af235);
|
||||
self::step($I, $C, $D, $A, $B, $words[2], 15, 0x2ad7d2bb);
|
||||
self::step($I, $B, $C, $D, $A, $words[9], 21, 0xeb86d391);
|
||||
|
||||
$this->a = ($this->a + $A) & 0xffffffff;
|
||||
$this->b = ($this->b + $B) & 0xffffffff;
|
||||
$this->c = ($this->c + $C) & 0xffffffff;
|
||||
$this->d = ($this->d + $D) & 0xffffffff;
|
||||
}
|
||||
|
||||
|
||||
private static function F($X, $Y, $Z)
|
||||
{
|
||||
return (($X & $Y) | ((~ $X) & $Z)); // X AND Y OR NOT X AND Z
|
||||
}
|
||||
|
||||
|
||||
private static function G($X, $Y, $Z)
|
||||
{
|
||||
return (($X & $Z) | ($Y & (~ $Z))); // X AND Z OR Y AND NOT Z
|
||||
}
|
||||
|
||||
|
||||
private static function H($X, $Y, $Z)
|
||||
{
|
||||
return ($X ^ $Y ^ $Z); // X XOR Y XOR Z
|
||||
}
|
||||
|
||||
|
||||
private static function I($X, $Y, $Z)
|
||||
{
|
||||
return ($Y ^ ($X | (~ $Z))) ; // Y XOR (X OR NOT Z)
|
||||
}
|
||||
|
||||
|
||||
private static function step($func, &$A, $B, $C, $D, $M, $s, $t)
|
||||
{
|
||||
$A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff;
|
||||
$A = self::rotate($A, $s);
|
||||
$A = ($B + $A) & 0xffffffff;
|
||||
}
|
||||
|
||||
|
||||
private static function rotate($decimal, $bits)
|
||||
{
|
||||
$binary = str_pad(decbin($decimal), 32, "0", STR_PAD_LEFT);
|
||||
return bindec(substr($binary, $bits).substr($binary, 0, $bits));
|
||||
}
|
||||
}
|
88
PHPExcel/Reader/Excel5/RC4.php
Normal file
88
PHPExcel/Reader/Excel5/RC4.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel5_RC4
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Excel5_RC4
|
||||
{
|
||||
// Context
|
||||
var $s = array();
|
||||
var $i = 0;
|
||||
var $j = 0;
|
||||
|
||||
/**
|
||||
* RC4 stream decryption/encryption constrcutor
|
||||
*
|
||||
* @param string $key Encryption key/passphrase
|
||||
*/
|
||||
public function __construct($key)
|
||||
{
|
||||
$len = strlen($key);
|
||||
|
||||
for ($this->i = 0; $this->i < 256; $this->i++) {
|
||||
$this->s[$this->i] = $this->i;
|
||||
}
|
||||
|
||||
$this->j = 0;
|
||||
for ($this->i = 0; $this->i < 256; $this->i++) {
|
||||
$this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256;
|
||||
$t = $this->s[$this->i];
|
||||
$this->s[$this->i] = $this->s[$this->j];
|
||||
$this->s[$this->j] = $t;
|
||||
}
|
||||
$this->i = $this->j = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Symmetric decryption/encryption function
|
||||
*
|
||||
* @param string $data Data to encrypt/decrypt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function RC4($data)
|
||||
{
|
||||
$len = strlen($data);
|
||||
for ($c = 0; $c < $len; $c++) {
|
||||
$this->i = ($this->i + 1) % 256;
|
||||
$this->j = ($this->j + $this->s[$this->i]) % 256;
|
||||
$t = $this->s[$this->i];
|
||||
$this->s[$this->i] = $this->s[$this->j];
|
||||
$this->s[$this->j] = $t;
|
||||
|
||||
$t = ($this->s[$this->i] + $this->s[$this->j]) % 256;
|
||||
|
||||
$data[$c] = chr(ord($data[$c]) ^ $this->s[$t]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
52
PHPExcel/Reader/Exception.php
Normal file
52
PHPExcel/Reader/Exception.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Exception extends PHPExcel_Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
873
PHPExcel/Reader/Gnumeric.php
Normal file
873
PHPExcel/Reader/Gnumeric.php
Normal file
File diff suppressed because it is too large
Load Diff
468
PHPExcel/Reader/HTML.php
Normal file
468
PHPExcel/Reader/HTML.php
Normal file
@ -0,0 +1,468 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_HTML
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Input encoding
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_inputEncoding = 'ANSI';
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex = 0;
|
||||
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_formats = array( 'h1' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 24,
|
||||
),
|
||||
), // Bold, 24pt
|
||||
'h2' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 18,
|
||||
),
|
||||
), // Bold, 18pt
|
||||
'h3' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 13.5,
|
||||
),
|
||||
), // Bold, 13.5pt
|
||||
'h4' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 12,
|
||||
),
|
||||
), // Bold, 12pt
|
||||
'h5' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 10,
|
||||
),
|
||||
), // Bold, 10pt
|
||||
'h6' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 7.5,
|
||||
),
|
||||
), // Bold, 7.5pt
|
||||
'a' => array( 'font' => array( 'underline' => true,
|
||||
'color' => array( 'argb' => PHPExcel_Style_Color::COLOR_BLUE,
|
||||
),
|
||||
),
|
||||
), // Blue underlined
|
||||
'hr' => array( 'borders' => array( 'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN,
|
||||
'color' => array( PHPExcel_Style_Color::COLOR_BLACK,
|
||||
),
|
||||
),
|
||||
),
|
||||
), // Bottom border
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_HTML
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the current file is an HTML file
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _isValidFormat()
|
||||
{
|
||||
// Reading 2048 bytes should be enough to validate that the format is HTML
|
||||
$data = fread($this->_fileHandle, 2048);
|
||||
if ((strpos($data, '<') !== FALSE) &&
|
||||
(strlen($data) !== strlen(strip_tags($data)))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set input encoding
|
||||
*
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'ANSI')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
}
|
||||
|
||||
// Data Array used for testing only, should write to PHPExcel object on completion of tests
|
||||
private $_dataArray = array();
|
||||
|
||||
private $_tableLevel = 0;
|
||||
private $_nestedColumn = array('A');
|
||||
|
||||
private function _setTableStartColumn($column) {
|
||||
if ($this->_tableLevel == 0)
|
||||
$column = 'A';
|
||||
++$this->_tableLevel;
|
||||
$this->_nestedColumn[$this->_tableLevel] = $column;
|
||||
|
||||
return $this->_nestedColumn[$this->_tableLevel];
|
||||
}
|
||||
|
||||
private function _getTableStartColumn() {
|
||||
return $this->_nestedColumn[$this->_tableLevel];
|
||||
}
|
||||
|
||||
private function _releaseTableStartColumn() {
|
||||
--$this->_tableLevel;
|
||||
return array_pop($this->_nestedColumn);
|
||||
}
|
||||
|
||||
private function _flushCell($sheet,$column,$row,&$cellContent) {
|
||||
if (is_string($cellContent)) {
|
||||
// Simple String content
|
||||
if (trim($cellContent) > '') {
|
||||
// Only actually write it if there's content in the string
|
||||
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
|
||||
// Write to worksheet to be done here...
|
||||
// ... we return the cell so we can mess about with styles more easily
|
||||
$cell = $sheet->setCellValue($column.$row,$cellContent,true);
|
||||
$this->_dataArray[$row][$column] = $cellContent;
|
||||
}
|
||||
} else {
|
||||
// We have a Rich Text run
|
||||
// TODO
|
||||
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
|
||||
}
|
||||
$cellContent = (string) '';
|
||||
}
|
||||
|
||||
private function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent){
|
||||
foreach($element->childNodes as $child){
|
||||
if ($child instanceof DOMText) {
|
||||
$domText = preg_replace('/\s+/',' ',trim($child->nodeValue));
|
||||
if (is_string($cellContent)) {
|
||||
// simply append the text if the cell content is a plain text string
|
||||
$cellContent .= $domText;
|
||||
} else {
|
||||
// but if we have a rich text run instead, we need to append it correctly
|
||||
// TODO
|
||||
}
|
||||
} elseif($child instanceof DOMElement) {
|
||||
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
|
||||
|
||||
$attributeArray = array();
|
||||
foreach($child->attributes as $attribute) {
|
||||
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
|
||||
$attributeArray[$attribute->name] = $attribute->value;
|
||||
}
|
||||
|
||||
switch($child->nodeName) {
|
||||
case 'meta' :
|
||||
foreach($attributeArray as $attributeName => $attributeValue) {
|
||||
switch($attributeName) {
|
||||
case 'content':
|
||||
// TODO
|
||||
// Extract character set, so we can convert to UTF-8 if required
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
break;
|
||||
case 'title' :
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
$sheet->setTitle($cellContent);
|
||||
$cellContent = '';
|
||||
break;
|
||||
case 'span' :
|
||||
case 'div' :
|
||||
case 'font' :
|
||||
case 'i' :
|
||||
case 'em' :
|
||||
case 'strong':
|
||||
case 'b' :
|
||||
// echo 'STYLING, SPAN OR DIV<br />';
|
||||
if ($cellContent > '')
|
||||
$cellContent .= ' ';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
if ($cellContent > '')
|
||||
$cellContent .= ' ';
|
||||
// echo 'END OF STYLING, SPAN OR DIV<br />';
|
||||
break;
|
||||
case 'hr' :
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
++$row;
|
||||
if (isset($this->_formats[$child->nodeName])) {
|
||||
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
|
||||
} else {
|
||||
$cellContent = '----------';
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
}
|
||||
++$row;
|
||||
case 'br' :
|
||||
if ($this->_tableLevel > 0) {
|
||||
// If we're inside a table, replace with a \n
|
||||
$cellContent .= "\n";
|
||||
} else {
|
||||
// Otherwise flush our existing content and move the row cursor on
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
++$row;
|
||||
}
|
||||
// echo 'HARD LINE BREAK: ' , '<br />';
|
||||
break;
|
||||
case 'a' :
|
||||
// echo 'START OF HYPERLINK: ' , '<br />';
|
||||
foreach($attributeArray as $attributeName => $attributeValue) {
|
||||
switch($attributeName) {
|
||||
case 'href':
|
||||
// echo 'Link to ' , $attributeValue , '<br />';
|
||||
$sheet->getCell($column.$row)->getHyperlink()->setUrl($attributeValue);
|
||||
if (isset($this->_formats[$child->nodeName])) {
|
||||
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$cellContent .= ' ';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
// echo 'END OF HYPERLINK:' , '<br />';
|
||||
break;
|
||||
case 'h1' :
|
||||
case 'h2' :
|
||||
case 'h3' :
|
||||
case 'h4' :
|
||||
case 'h5' :
|
||||
case 'h6' :
|
||||
case 'ol' :
|
||||
case 'ul' :
|
||||
case 'p' :
|
||||
if ($this->_tableLevel > 0) {
|
||||
// If we're inside a table, replace with a \n
|
||||
$cellContent .= "\n";
|
||||
// echo 'LIST ENTRY: ' , '<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
// echo 'END OF LIST ENTRY:' , '<br />';
|
||||
} else {
|
||||
if ($cellContent > '') {
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
$row += 2;
|
||||
}
|
||||
// echo 'START OF PARAGRAPH: ' , '<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
// echo 'END OF PARAGRAPH:' , '<br />';
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
|
||||
if (isset($this->_formats[$child->nodeName])) {
|
||||
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
|
||||
}
|
||||
|
||||
$row += 2;
|
||||
$column = 'A';
|
||||
}
|
||||
break;
|
||||
case 'li' :
|
||||
if ($this->_tableLevel > 0) {
|
||||
// If we're inside a table, replace with a \n
|
||||
$cellContent .= "\n";
|
||||
// echo 'LIST ENTRY: ' , '<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
// echo 'END OF LIST ENTRY:' , '<br />';
|
||||
} else {
|
||||
if ($cellContent > '') {
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
}
|
||||
++$row;
|
||||
// echo 'LIST ENTRY: ' , '<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
// echo 'END OF LIST ENTRY:' , '<br />';
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
$column = 'A';
|
||||
}
|
||||
break;
|
||||
case 'table' :
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
$column = $this->_setTableStartColumn($column);
|
||||
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
||||
if ($this->_tableLevel > 1)
|
||||
--$row;
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
||||
$column = $this->_releaseTableStartColumn();
|
||||
if ($this->_tableLevel > 1) {
|
||||
++$column;
|
||||
} else {
|
||||
++$row;
|
||||
}
|
||||
break;
|
||||
case 'thead' :
|
||||
case 'tbody' :
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
break;
|
||||
case 'tr' :
|
||||
++$row;
|
||||
$column = $this->_getTableStartColumn();
|
||||
$cellContent = '';
|
||||
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
||||
break;
|
||||
case 'th' :
|
||||
case 'td' :
|
||||
// echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
// echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
++$column;
|
||||
break;
|
||||
case 'body' :
|
||||
$row = 1;
|
||||
$column = 'A';
|
||||
$content = '';
|
||||
$this->_tableLevel = 0;
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
break;
|
||||
default:
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
// Open file to validate
|
||||
$this->_openFile($pFilename);
|
||||
if (!$this->_isValidFormat()) {
|
||||
fclose ($this->_fileHandle);
|
||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
|
||||
}
|
||||
// Close after validating
|
||||
fclose ($this->_fileHandle);
|
||||
|
||||
// Create new PHPExcel
|
||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||
$objPHPExcel->createSheet();
|
||||
}
|
||||
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
||||
|
||||
// Create a new DOM object
|
||||
$dom = new domDocument;
|
||||
// Reload the HTML file into the DOM object
|
||||
$loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions());
|
||||
if ($loaded === FALSE) {
|
||||
throw new PHPExcel_Reader_Exception('Failed to load ',$pFilename,' as a DOM Document');
|
||||
}
|
||||
|
||||
// Discard white space
|
||||
$dom->preserveWhiteSpace = false;
|
||||
|
||||
|
||||
$row = 0;
|
||||
$column = 'A';
|
||||
$content = '';
|
||||
$this->_processDomElement($dom,$objPHPExcel->getActiveSheet(),$row,$column,$content);
|
||||
|
||||
// echo '<hr />';
|
||||
// var_dump($this->_dataArray);
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_HTML
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
47
PHPExcel/Reader/IReadFilter.php
Normal file
47
PHPExcel/Reader/IReadFilter.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReadFilter
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
/**
|
||||
* Should this cell be read?
|
||||
*
|
||||
* @param $column String column index
|
||||
* @param $row Row index
|
||||
* @param $worksheetName Optional worksheet name
|
||||
* @return boolean
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '');
|
||||
}
|
53
PHPExcel/Reader/IReader.php
Normal file
53
PHPExcel/Reader/IReader.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReader
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename);
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename);
|
||||
}
|
707
PHPExcel/Reader/OOCalc.php
Normal file
707
PHPExcel/Reader/OOCalc.php
Normal file
File diff suppressed because it is too large
Load Diff
450
PHPExcel/Reader/SYLK.php
Normal file
450
PHPExcel/Reader/SYLK.php
Normal file
@ -0,0 +1,450 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_SYLK
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Input encoding
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_inputEncoding = 'ANSI';
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex = 0;
|
||||
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_formats = array();
|
||||
|
||||
/**
|
||||
* Format Count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_format = 0;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the current file is a SYLK file
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _isValidFormat()
|
||||
{
|
||||
// Read sample data (first 2 KB will do)
|
||||
$data = fread($this->_fileHandle, 2048);
|
||||
|
||||
// Count delimiters in file
|
||||
$delimiterCount = substr_count($data, ';');
|
||||
if ($delimiterCount < 1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Analyze first line looking for ID; signature
|
||||
$lines = explode("\n", $data);
|
||||
if (substr($lines[0],0,4) != 'ID;P') {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set input encoding
|
||||
*
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'ANSI')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetInfo($pFilename)
|
||||
{
|
||||
// Open file
|
||||
$this->_openFile($pFilename);
|
||||
if (!$this->_isValidFormat()) {
|
||||
fclose ($this->_fileHandle);
|
||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
}
|
||||
$fileHandle = $this->_fileHandle;
|
||||
rewind($fileHandle);
|
||||
|
||||
$worksheetInfo = array();
|
||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||
$worksheetInfo[0]['totalRows'] = 0;
|
||||
$worksheetInfo[0]['totalColumns'] = 0;
|
||||
|
||||
// Loop through file
|
||||
$rowData = array();
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
$rowIndex = 0;
|
||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
||||
$columnIndex = 0;
|
||||
|
||||
// convert SYLK encoded $rowData to UTF-8
|
||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||
|
||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||
// is escaped like this (;;)
|
||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
if ($dataType == 'C') {
|
||||
// Read cell value data
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' :
|
||||
$columnIndex = substr($rowDatum,1) - 1;
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' :
|
||||
$rowIndex = substr($rowDatum,1);
|
||||
break;
|
||||
}
|
||||
|
||||
$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
|
||||
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
||||
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
// Open file
|
||||
$this->_openFile($pFilename);
|
||||
if (!$this->_isValidFormat()) {
|
||||
fclose ($this->_fileHandle);
|
||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
}
|
||||
$fileHandle = $this->_fileHandle;
|
||||
rewind($fileHandle);
|
||||
|
||||
// Create new PHPExcel
|
||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||
$objPHPExcel->createSheet();
|
||||
}
|
||||
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
||||
|
||||
$fromFormats = array('\-', '\ ');
|
||||
$toFormats = array('-', ' ');
|
||||
|
||||
// Loop through file
|
||||
$rowData = array();
|
||||
$column = $row = '';
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
||||
|
||||
// convert SYLK encoded $rowData to UTF-8
|
||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||
|
||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||
// is escaped like this (;;)
|
||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
// Read shared styles
|
||||
if ($dataType == 'P') {
|
||||
$formatArray = array();
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1));
|
||||
break;
|
||||
case 'E' :
|
||||
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
|
||||
break;
|
||||
case 'L' : $formatArray['font']['size'] = substr($rowDatum,1);
|
||||
break;
|
||||
case 'S' : $styleSettings = substr($rowDatum,1);
|
||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||
switch ($styleSettings{$i}) {
|
||||
case 'I' : $formatArray['font']['italic'] = true;
|
||||
break;
|
||||
case 'D' : $formatArray['font']['bold'] = true;
|
||||
break;
|
||||
case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_formats['P'.$this->_format++] = $formatArray;
|
||||
// Read cell value data
|
||||
} elseif ($dataType == 'C') {
|
||||
$hasCalculatedValue = false;
|
||||
$cellData = $cellDataFormula = '';
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' : $column = substr($rowDatum,1);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' : $row = substr($rowDatum,1);
|
||||
break;
|
||||
case 'K' : $cellData = substr($rowDatum,1);
|
||||
break;
|
||||
case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
$temp = explode('"',$cellDataFormula);
|
||||
$key = false;
|
||||
foreach($temp as &$value) {
|
||||
// Only count/replace in alternate array entries
|
||||
if ($key = !$key) {
|
||||
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
|
||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// the formula
|
||||
$cellReferences = array_reverse($cellReferences);
|
||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||
// then modify the formula to use that new reference
|
||||
foreach($cellReferences as $cellReference) {
|
||||
$rowReference = $cellReference[2][0];
|
||||
// Empty R reference is the current row
|
||||
if ($rowReference == '') $rowReference = $row;
|
||||
// Bracketed R references are relative to the current row
|
||||
if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]');
|
||||
$columnReference = $cellReference[4][0];
|
||||
// Empty C reference is the current column
|
||||
if ($columnReference == '') $columnReference = $column;
|
||||
// Bracketed C references are relative to the current column
|
||||
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
|
||||
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
|
||||
|
||||
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"',$temp);
|
||||
$hasCalculatedValue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
||||
|
||||
// Set cell value
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
|
||||
if ($hasCalculatedValue) {
|
||||
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
|
||||
}
|
||||
// Read cell formatting
|
||||
} elseif ($dataType == 'F') {
|
||||
$formatStyle = $columnWidth = $styleSettings = '';
|
||||
$styleData = array();
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' : $column = substr($rowDatum,1);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' : $row = substr($rowDatum,1);
|
||||
break;
|
||||
case 'P' : $formatStyle = $rowDatum;
|
||||
break;
|
||||
case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1));
|
||||
break;
|
||||
case 'S' : $styleSettings = substr($rowDatum,1);
|
||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||
switch ($styleSettings{$i}) {
|
||||
case 'I' : $styleData['font']['italic'] = true;
|
||||
break;
|
||||
case 'D' : $styleData['font']['bold'] = true;
|
||||
break;
|
||||
case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (($formatStyle > '') && ($column > '') && ($row > '')) {
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
if (isset($this->_formats[$formatStyle])) {
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]);
|
||||
}
|
||||
}
|
||||
if ((!empty($styleData)) && ($column > '') && ($row > '')) {
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
|
||||
}
|
||||
if ($columnWidth > '') {
|
||||
if ($startCol == $endCol) {
|
||||
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||
} else {
|
||||
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||
do {
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
|
||||
} while ($startCol != $endCol);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' : $column = substr($rowDatum,1);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' : $row = substr($rowDatum,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
922
PHPExcel/ReferenceHelper.php
Normal file
922
PHPExcel/ReferenceHelper.php
Normal file
File diff suppressed because it is too large
Load Diff
199
PHPExcel/RichText.php
Normal file
199
PHPExcel/RichText.php
Normal file
@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Rich text elements
|
||||
*
|
||||
* @var PHPExcel_RichText_ITextElement[]
|
||||
*/
|
||||
private $_richTextElements;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText instance
|
||||
*
|
||||
* @param PHPExcel_Cell $pCell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function __construct(PHPExcel_Cell $pCell = null)
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_richTextElements = array();
|
||||
|
||||
// Rich-Text string attached to cell?
|
||||
if ($pCell !== NULL) {
|
||||
// Add cell text and style
|
||||
if ($pCell->getValue() != "") {
|
||||
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
|
||||
$objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
|
||||
$this->addText($objRun);
|
||||
}
|
||||
|
||||
// Set parent value
|
||||
$pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
*
|
||||
* @param PHPExcel_RichText_ITextElement $pText Rich text element
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function addText(PHPExcel_RichText_ITextElement $pText = null)
|
||||
{
|
||||
$this->_richTextElements[] = $pText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPExcel_RichText_TextElement
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
$objText = new PHPExcel_RichText_TextElement($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text run
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPExcel_RichText_Run
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
{
|
||||
$objText = new PHPExcel_RichText_Run($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlainText()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop through all PHPExcel_RichText_ITextElement
|
||||
foreach ($this->_richTextElements as $text) {
|
||||
$returnValue .= $text->getText();
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getPlainText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rich Text elements
|
||||
*
|
||||
* @return PHPExcel_RichText_ITextElement[]
|
||||
*/
|
||||
public function getRichTextElements()
|
||||
{
|
||||
return $this->_richTextElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich Text elements
|
||||
*
|
||||
* @param PHPExcel_RichText_ITextElement[] $pElements Array of elements
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function setRichTextElements($pElements = null)
|
||||
{
|
||||
if (is_array($pElements)) {
|
||||
$this->_richTextElements = $pElements;
|
||||
} else {
|
||||
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->_richTextElements as $element) {
|
||||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5(
|
||||
$hashElements
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
64
PHPExcel/RichText/ITextElement.php
Normal file
64
PHPExcel/RichText/ITextElement.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* 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_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText_ITextElement
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText();
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return PHPExcel_RichText_ITextElement
|
||||
*/
|
||||
public function setText($pText = '');
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
public function getFont();
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
}
|
102
PHPExcel/RichText/Run.php
Normal file
102
PHPExcel/RichText/Run.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* 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_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText_Run
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var PHPExcel_Style_Font
|
||||
*/
|
||||
private $_font;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText_Run instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->setText($pText);
|
||||
$this->_font = new PHPExcel_Style_Font();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return $this->_font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param PHPExcel_Style_Font $pFont Font
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_RichText_ITextElement
|
||||
*/
|
||||
public function setFont(PHPExcel_Style_Font $pFont = null) {
|
||||
$this->_font = $pFont;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->getText()
|
||||
. $this->_font->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
108
PHPExcel/RichText/TextElement.php
Normal file
108
PHPExcel/RichText/TextElement.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* 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_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText_TextElement
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText_TextElement instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_text = $pText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return PHPExcel_RichText_ITextElement
|
||||
*/
|
||||
public function setText($pText = '') {
|
||||
$this->_text = $pText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_text
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
387
PHPExcel/Settings.php
Normal file
387
PHPExcel/Settings.php
Normal file
@ -0,0 +1,387 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Settings
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
class PHPExcel_Settings
|
||||
{
|
||||
/** constants */
|
||||
/** Available Zip library classes */
|
||||
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
|
||||
const ZIPARCHIVE = 'ZipArchive';
|
||||
|
||||
/** Optional Chart Rendering libraries */
|
||||
const CHART_RENDERER_JPGRAPH = 'jpgraph';
|
||||
|
||||
/** Optional PDF Rendering libraries */
|
||||
const PDF_RENDERER_TCPDF = 'tcPDF';
|
||||
const PDF_RENDERER_DOMPDF = 'DomPDF';
|
||||
const PDF_RENDERER_MPDF = 'mPDF';
|
||||
|
||||
|
||||
private static $_chartRenderers = array(
|
||||
self::CHART_RENDERER_JPGRAPH,
|
||||
);
|
||||
|
||||
private static $_pdfRenderers = array(
|
||||
self::PDF_RENDERER_TCPDF,
|
||||
self::PDF_RENDERER_DOMPDF,
|
||||
self::PDF_RENDERER_MPDF,
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Name of the class used for Zip file management
|
||||
* e.g.
|
||||
* ZipArchive
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_zipClass = self::ZIPARCHIVE;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the external Library used for rendering charts
|
||||
* e.g.
|
||||
* jpgraph
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_chartRendererName = NULL;
|
||||
|
||||
/**
|
||||
* Directory Path to the external Library used for rendering charts
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_chartRendererPath = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the external Library used for rendering PDF files
|
||||
* e.g.
|
||||
* mPDF
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_pdfRendererName = NULL;
|
||||
|
||||
/**
|
||||
* Directory Path to the external Library used for rendering PDF files
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_pdfRendererPath = NULL;
|
||||
|
||||
/**
|
||||
* Default options for libxml loader
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $_libXmlLoaderOptions = null;
|
||||
|
||||
/**
|
||||
* Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
|
||||
*
|
||||
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
|
||||
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setZipClass($zipClass)
|
||||
{
|
||||
if (($zipClass === self::PCLZIP) ||
|
||||
($zipClass === self::ZIPARCHIVE)) {
|
||||
self::$_zipClass = $zipClass;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
} // function setZipClass()
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
|
||||
* or Zip file management
|
||||
*
|
||||
* @return string Name of the Zip handler Class that PHPExcel is configured to use
|
||||
* for Zip file management
|
||||
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
||||
*/
|
||||
public static function getZipClass()
|
||||
{
|
||||
return self::$_zipClass;
|
||||
} // function getZipClass()
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the method that is currently configured for cell cacheing
|
||||
*
|
||||
* @return string Name of the cacheing method
|
||||
*/
|
||||
public static function getCacheStorageMethod()
|
||||
{
|
||||
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
|
||||
} // function getCacheStorageMethod()
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the class that is currently being used for cell cacheing
|
||||
*
|
||||
* @return string Name of the class currently being used for cacheing
|
||||
*/
|
||||
public static function getCacheStorageClass()
|
||||
{
|
||||
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
|
||||
} // function getCacheStorageClass()
|
||||
|
||||
|
||||
/**
|
||||
* Set the method that should be used for cell cacheing
|
||||
*
|
||||
* @param string $method Name of the cacheing method
|
||||
* @param array $arguments Optional configuration arguments for the cacheing method
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setCacheStorageMethod(
|
||||
$method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
|
||||
$arguments = array()
|
||||
)
|
||||
{
|
||||
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
|
||||
} // function setCacheStorageMethod()
|
||||
|
||||
|
||||
/**
|
||||
* Set the locale code to use for formula translations and any special formatting
|
||||
*
|
||||
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setLocale($locale='en_us')
|
||||
{
|
||||
return PHPExcel_Calculation::getInstance()->setLocale($locale);
|
||||
} // function setLocale()
|
||||
|
||||
|
||||
/**
|
||||
* Set details of the external library that PHPExcel should use for rendering charts
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setChartRenderer($libraryName, $libraryBaseDir)
|
||||
{
|
||||
if (!self::setChartRendererName($libraryName))
|
||||
return FALSE;
|
||||
return self::setChartRendererPath($libraryBaseDir);
|
||||
} // function setChartRenderer()
|
||||
|
||||
|
||||
/**
|
||||
* Identify to PHPExcel the external library to use for rendering charts
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setChartRendererName($libraryName)
|
||||
{
|
||||
if (!in_array($libraryName,self::$_chartRenderers)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self::$_chartRendererName = $libraryName;
|
||||
|
||||
return TRUE;
|
||||
} // function setChartRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Tell PHPExcel where to find the external library to use for rendering charts
|
||||
*
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setChartRendererPath($libraryBaseDir)
|
||||
{
|
||||
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
||||
return FALSE;
|
||||
}
|
||||
self::$_chartRendererPath = $libraryBaseDir;
|
||||
|
||||
return TRUE;
|
||||
} // function setChartRendererPath()
|
||||
|
||||
|
||||
/**
|
||||
* Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph)
|
||||
*
|
||||
* @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||
*/
|
||||
public static function getChartRendererName()
|
||||
{
|
||||
return self::$_chartRendererName;
|
||||
} // function getChartRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use
|
||||
*
|
||||
* @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
*/
|
||||
public static function getChartRendererPath()
|
||||
{
|
||||
return self::$_chartRendererPath;
|
||||
} // function getChartRendererPath()
|
||||
|
||||
|
||||
/**
|
||||
* Set details of the external library that PHPExcel should use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setPdfRenderer($libraryName, $libraryBaseDir)
|
||||
{
|
||||
if (!self::setPdfRendererName($libraryName))
|
||||
return FALSE;
|
||||
return self::setPdfRendererPath($libraryBaseDir);
|
||||
} // function setPdfRenderer()
|
||||
|
||||
|
||||
/**
|
||||
* Identify to PHPExcel the external library to use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setPdfRendererName($libraryName)
|
||||
{
|
||||
if (!in_array($libraryName,self::$_pdfRenderers)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self::$_pdfRendererName = $libraryName;
|
||||
|
||||
return TRUE;
|
||||
} // function setPdfRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Tell PHPExcel where to find the external library to use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setPdfRendererPath($libraryBaseDir)
|
||||
{
|
||||
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
||||
return FALSE;
|
||||
}
|
||||
self::$_pdfRendererPath = $libraryBaseDir;
|
||||
|
||||
return TRUE;
|
||||
} // function setPdfRendererPath()
|
||||
|
||||
|
||||
/**
|
||||
* Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf)
|
||||
*
|
||||
* @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||
*/
|
||||
public static function getPdfRendererName()
|
||||
{
|
||||
return self::$_pdfRendererName;
|
||||
} // function getPdfRendererName()
|
||||
|
||||
/**
|
||||
* Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
|
||||
*
|
||||
* @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
*/
|
||||
public static function getPdfRendererPath()
|
||||
{
|
||||
return self::$_pdfRendererPath;
|
||||
} // function getPdfRendererPath()
|
||||
|
||||
/**
|
||||
* Set default options for libxml loader
|
||||
*
|
||||
* @param int $options Default options for libxml loader
|
||||
*/
|
||||
public static function setLibXmlLoaderOptions($options = null)
|
||||
{
|
||||
if (is_null($options)) {
|
||||
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
|
||||
}
|
||||
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
|
||||
self::$_libXmlLoaderOptions = $options;
|
||||
} // function setLibXmlLoaderOptions
|
||||
|
||||
/**
|
||||
* Get default options for libxml loader.
|
||||
* Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly.
|
||||
*
|
||||
* @return int Default options for libxml loader
|
||||
*/
|
||||
public static function getLibXmlLoaderOptions()
|
||||
{
|
||||
if (is_null(self::$_libXmlLoaderOptions)) {
|
||||
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
|
||||
}
|
||||
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
|
||||
return self::$_libXmlLoaderOptions;
|
||||
} // function getLibXmlLoaderOptions
|
||||
}
|
102
PHPExcel/Shared/CodePage.php
Normal file
102
PHPExcel/Shared/CodePage.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_CodePage
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_CodePage
|
||||
{
|
||||
/**
|
||||
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
|
||||
* and mbstring understands
|
||||
*
|
||||
* @param integer $codePage Microsoft Code Page Indentifier
|
||||
* @return string Code Page Name
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public static function NumberToName($codePage = 1252)
|
||||
{
|
||||
switch ($codePage) {
|
||||
case 367: return 'ASCII'; break; // ASCII
|
||||
case 437: return 'CP437'; break; // OEM US
|
||||
case 720: throw new PHPExcel_Exception('Code page 720 not supported.');
|
||||
break; // OEM Arabic
|
||||
case 737: return 'CP737'; break; // OEM Greek
|
||||
case 775: return 'CP775'; break; // OEM Baltic
|
||||
case 850: return 'CP850'; break; // OEM Latin I
|
||||
case 852: return 'CP852'; break; // OEM Latin II (Central European)
|
||||
case 855: return 'CP855'; break; // OEM Cyrillic
|
||||
case 857: return 'CP857'; break; // OEM Turkish
|
||||
case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro
|
||||
case 860: return 'CP860'; break; // OEM Portugese
|
||||
case 861: return 'CP861'; break; // OEM Icelandic
|
||||
case 862: return 'CP862'; break; // OEM Hebrew
|
||||
case 863: return 'CP863'; break; // OEM Canadian (French)
|
||||
case 864: return 'CP864'; break; // OEM Arabic
|
||||
case 865: return 'CP865'; break; // OEM Nordic
|
||||
case 866: return 'CP866'; break; // OEM Cyrillic (Russian)
|
||||
case 869: return 'CP869'; break; // OEM Greek (Modern)
|
||||
case 874: return 'CP874'; break; // ANSI Thai
|
||||
case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS
|
||||
case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK
|
||||
case 949: return 'CP949'; break; // ANSI Korean (Wansung)
|
||||
case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5
|
||||
case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8)
|
||||
case 1250: return 'CP1250'; break; // ANSI Latin II (Central European)
|
||||
case 1251: return 'CP1251'; break; // ANSI Cyrillic
|
||||
case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
|
||||
case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7)
|
||||
case 1253: return 'CP1253'; break; // ANSI Greek
|
||||
case 1254: return 'CP1254'; break; // ANSI Turkish
|
||||
case 1255: return 'CP1255'; break; // ANSI Hebrew
|
||||
case 1256: return 'CP1256'; break; // ANSI Arabic
|
||||
case 1257: return 'CP1257'; break; // ANSI Baltic
|
||||
case 1258: return 'CP1258'; break; // ANSI Vietnamese
|
||||
case 1361: return 'CP1361'; break; // ANSI Korean (Johab)
|
||||
case 10000: return 'MAC'; break; // Apple Roman
|
||||
case 10006: return 'MACGREEK'; break; // Macintosh Greek
|
||||
case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic
|
||||
case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312)
|
||||
case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe
|
||||
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
|
||||
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
|
||||
case 32768: return 'MAC'; break; // Apple Roman
|
||||
case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.');
|
||||
break; // ANSI Latin I (BIFF2-BIFF3)
|
||||
case 65000: return 'UTF-7'; break; // Unicode (UTF-7)
|
||||
case 65001: return 'UTF-8'; break; // Unicode (UTF-8)
|
||||
}
|
||||
|
||||
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
|
||||
}
|
||||
|
||||
}
|
393
PHPExcel/Shared/Date.php
Normal file
393
PHPExcel/Shared/Date.php
Normal file
@ -0,0 +1,393 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Date
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Date
|
||||
{
|
||||
/** constants */
|
||||
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
|
||||
const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0
|
||||
|
||||
/*
|
||||
* Names of the months of the year, indexed by shortname
|
||||
* Planned usage for locale settings
|
||||
*
|
||||
* @public
|
||||
* @var string[]
|
||||
*/
|
||||
public static $_monthNames = array( 'Jan' => 'January',
|
||||
'Feb' => 'February',
|
||||
'Mar' => 'March',
|
||||
'Apr' => 'April',
|
||||
'May' => 'May',
|
||||
'Jun' => 'June',
|
||||
'Jul' => 'July',
|
||||
'Aug' => 'August',
|
||||
'Sep' => 'September',
|
||||
'Oct' => 'October',
|
||||
'Nov' => 'November',
|
||||
'Dec' => 'December',
|
||||
);
|
||||
|
||||
/*
|
||||
* Names of the months of the year, indexed by shortname
|
||||
* Planned usage for locale settings
|
||||
*
|
||||
* @public
|
||||
* @var string[]
|
||||
*/
|
||||
public static $_numberSuffixes = array( 'st',
|
||||
'nd',
|
||||
'rd',
|
||||
'th',
|
||||
);
|
||||
|
||||
/*
|
||||
* Base calendar year to use for calculations
|
||||
*
|
||||
* @private
|
||||
* @var int
|
||||
*/
|
||||
protected static $_excelBaseDate = self::CALENDAR_WINDOWS_1900;
|
||||
|
||||
/**
|
||||
* Set the Excel calendar (Windows 1900 or Mac 1904)
|
||||
*
|
||||
* @param integer $baseDate Excel base date (1900 or 1904)
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setExcelCalendar($baseDate) {
|
||||
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
|
||||
($baseDate == self::CALENDAR_MAC_1904)) {
|
||||
self::$_excelBaseDate = $baseDate;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
} // function setExcelCalendar()
|
||||
|
||||
|
||||
/**
|
||||
* Return the Excel calendar (Windows 1900 or Mac 1904)
|
||||
*
|
||||
* @return integer Excel base date (1900 or 1904)
|
||||
*/
|
||||
public static function getExcelCalendar() {
|
||||
return self::$_excelBaseDate;
|
||||
} // function getExcelCalendar()
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date from Excel to PHP
|
||||
*
|
||||
* @param long $dateValue Excel date/time value
|
||||
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
|
||||
* a UST timestamp, or adjusted to UST
|
||||
* @param string $timezone The timezone for finding the adjustment from UST
|
||||
* @return long PHP serialized date/time
|
||||
*/
|
||||
public static function ExcelToPHP($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
|
||||
if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {
|
||||
$my_excelBaseDate = 25569;
|
||||
// Adjust for the spurious 29-Feb-1900 (Day 60)
|
||||
if ($dateValue < 60) {
|
||||
--$my_excelBaseDate;
|
||||
}
|
||||
} else {
|
||||
$my_excelBaseDate = 24107;
|
||||
}
|
||||
|
||||
// Perform conversion
|
||||
if ($dateValue >= 1) {
|
||||
$utcDays = $dateValue - $my_excelBaseDate;
|
||||
$returnValue = round($utcDays * 86400);
|
||||
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
|
||||
$returnValue = (integer) $returnValue;
|
||||
}
|
||||
} else {
|
||||
$hours = round($dateValue * 24);
|
||||
$mins = round($dateValue * 1440) - round($hours * 60);
|
||||
$secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
|
||||
$returnValue = (integer) gmmktime($hours, $mins, $secs);
|
||||
}
|
||||
|
||||
$timezoneAdjustment = ($adjustToTimezone) ?
|
||||
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) :
|
||||
0;
|
||||
|
||||
// Return
|
||||
return $returnValue + $timezoneAdjustment;
|
||||
} // function ExcelToPHP()
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date from Excel to a PHP Date/Time object
|
||||
*
|
||||
* @param integer $dateValue Excel date/time value
|
||||
* @return integer PHP date/time object
|
||||
*/
|
||||
public static function ExcelToPHPObject($dateValue = 0) {
|
||||
$dateTime = self::ExcelToPHP($dateValue);
|
||||
$days = floor($dateTime / 86400);
|
||||
$time = round((($dateTime / 86400) - $days) * 86400);
|
||||
$hours = round($time / 3600);
|
||||
$minutes = round($time / 60) - ($hours * 60);
|
||||
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
|
||||
|
||||
$dateObj = date_create('1-Jan-1970+'.$days.' days');
|
||||
$dateObj->setTime($hours,$minutes,$seconds);
|
||||
|
||||
return $dateObj;
|
||||
} // function ExcelToPHPObject()
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date from PHP to Excel
|
||||
*
|
||||
* @param mixed $dateValue PHP serialized date/time or date object
|
||||
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
|
||||
* a UST timestamp, or adjusted to UST
|
||||
* @param string $timezone The timezone for finding the adjustment from UST
|
||||
* @return mixed Excel date/time value
|
||||
* or boolean FALSE on failure
|
||||
*/
|
||||
public static function PHPToExcel($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
|
||||
$saveTimeZone = date_default_timezone_get();
|
||||
date_default_timezone_set('UTC');
|
||||
$retValue = FALSE;
|
||||
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
|
||||
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
|
||||
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
|
||||
);
|
||||
} elseif (is_numeric($dateValue)) {
|
||||
$retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue),
|
||||
date('H',$dateValue), date('i',$dateValue), date('s',$dateValue)
|
||||
);
|
||||
}
|
||||
date_default_timezone_set($saveTimeZone);
|
||||
|
||||
return $retValue;
|
||||
} // function PHPToExcel()
|
||||
|
||||
|
||||
/**
|
||||
* FormattedPHPToExcel
|
||||
*
|
||||
* @param long $year
|
||||
* @param long $month
|
||||
* @param long $day
|
||||
* @param long $hours
|
||||
* @param long $minutes
|
||||
* @param long $seconds
|
||||
* @return long Excel date/time value
|
||||
*/
|
||||
public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) {
|
||||
if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {
|
||||
//
|
||||
// Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel
|
||||
// This affects every date following 28th February 1900
|
||||
//
|
||||
$excel1900isLeapYear = TRUE;
|
||||
if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = FALSE; }
|
||||
$my_excelBaseDate = 2415020;
|
||||
} else {
|
||||
$my_excelBaseDate = 2416481;
|
||||
$excel1900isLeapYear = FALSE;
|
||||
}
|
||||
|
||||
// Julian base date Adjustment
|
||||
if ($month > 2) {
|
||||
$month -= 3;
|
||||
} else {
|
||||
$month += 9;
|
||||
--$year;
|
||||
}
|
||||
|
||||
// Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0)
|
||||
$century = substr($year,0,2);
|
||||
$decade = substr($year,2,2);
|
||||
$excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $my_excelBaseDate + $excel1900isLeapYear;
|
||||
|
||||
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
|
||||
|
||||
return (float) $excelDate + $excelTime;
|
||||
} // function FormattedPHPToExcel()
|
||||
|
||||
|
||||
/**
|
||||
* Is a given cell a date/time?
|
||||
*
|
||||
* @param PHPExcel_Cell $pCell
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isDateTime(PHPExcel_Cell $pCell) {
|
||||
return self::isDateTimeFormat(
|
||||
$pCell->getWorksheet()->getStyle(
|
||||
$pCell->getCoordinate()
|
||||
)->getNumberFormat()
|
||||
);
|
||||
} // function isDateTime()
|
||||
|
||||
|
||||
/**
|
||||
* Is a given number format a date/time?
|
||||
*
|
||||
* @param PHPExcel_Style_NumberFormat $pFormat
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat) {
|
||||
return self::isDateTimeFormatCode($pFormat->getFormatCode());
|
||||
} // function isDateTimeFormat()
|
||||
|
||||
|
||||
private static $possibleDateFormatCharacters = 'eymdHs';
|
||||
|
||||
/**
|
||||
* Is a given number format code a date/time?
|
||||
*
|
||||
* @param string $pFormatCode
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isDateTimeFormatCode($pFormatCode = '') {
|
||||
if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL))
|
||||
// "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check)
|
||||
return FALSE;
|
||||
if (preg_match('/[0#]E[+-]0/i', $pFormatCode))
|
||||
// Scientific format
|
||||
return FALSE;
|
||||
// Switch on formatcode
|
||||
switch ($pFormatCode) {
|
||||
// Explicitly defined date formats
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Typically number, currency or accounting (or occasionally fraction) formats
|
||||
if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) {
|
||||
return FALSE;
|
||||
}
|
||||
// Try checking for any of the date formatting characters that don't appear within square braces
|
||||
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
|
||||
// We might also have a format mask containing quoted strings...
|
||||
// we don't want to test for any of our characters within the quoted blocks
|
||||
if (strpos($pFormatCode,'"') !== FALSE) {
|
||||
$segMatcher = FALSE;
|
||||
foreach(explode('"',$pFormatCode) as $subVal) {
|
||||
// Only test in alternate array entries (the non-quoted blocks)
|
||||
if (($segMatcher = !$segMatcher) &&
|
||||
(preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// No date...
|
||||
return FALSE;
|
||||
} // function isDateTimeFormatCode()
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date/time string to Excel time
|
||||
*
|
||||
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
|
||||
* @return float|FALSE Excel date/time serial value
|
||||
*/
|
||||
public static function stringToExcel($dateValue = '') {
|
||||
if (strlen($dateValue) < 2)
|
||||
return FALSE;
|
||||
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;
|
||||
|
||||
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
|
||||
|
||||
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
|
||||
return FALSE;
|
||||
} else {
|
||||
if (strpos($dateValue, ':') !== FALSE) {
|
||||
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
|
||||
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
|
||||
return FALSE;
|
||||
}
|
||||
$dateValueNew += $timeValue;
|
||||
}
|
||||
return $dateValueNew;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function monthStringToNumber($month) {
|
||||
$monthIndex = 1;
|
||||
foreach(self::$_monthNames as $shortMonthName => $longMonthName) {
|
||||
if (($month === $longMonthName) || ($month === $shortMonthName)) {
|
||||
return $monthIndex;
|
||||
}
|
||||
++$monthIndex;
|
||||
}
|
||||
return $month;
|
||||
}
|
||||
|
||||
public static function dayStringToNumber($day) {
|
||||
$strippedDayValue = (str_replace(self::$_numberSuffixes,'',$day));
|
||||
if (is_numeric($strippedDayValue)) {
|
||||
return $strippedDayValue;
|
||||
}
|
||||
return $day;
|
||||
}
|
||||
|
||||
}
|
272
PHPExcel/Shared/Drawing.php
Normal file
272
PHPExcel/Shared/Drawing.php
Normal file
@ -0,0 +1,272 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Drawing
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Drawing
|
||||
{
|
||||
/**
|
||||
* Convert pixels to EMU
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in EMU
|
||||
*/
|
||||
public static function pixelsToEMU($pValue = 0) {
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EMU to pixels
|
||||
*
|
||||
* @param int $pValue Value in EMU
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function EMUToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 9525);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to column width. Exact algorithm not known.
|
||||
* By inspection of a real Excel file using Calibri 11, one finds 1000px ~ 142.85546875
|
||||
* This gives a conversion factor of 7. Also, we assume that pixels and font size are proportional.
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||
* @return int Value in cell dimension
|
||||
*/
|
||||
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
||||
// Font name and size
|
||||
$name = $pDefaultFont->getName();
|
||||
$size = $pDefaultFont->getSize();
|
||||
|
||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||
// Exact width can be determined
|
||||
$colWidth = $pValue
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
|
||||
} else {
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$colWidth = $pValue * 11
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
|
||||
}
|
||||
|
||||
return $colWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert column width from (intrinsic) Excel units to pixels
|
||||
*
|
||||
* @param float $pValue Value in cell dimension
|
||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
||||
// Font name and size
|
||||
$name = $pDefaultFont->getName();
|
||||
$size = $pDefaultFont->getSize();
|
||||
|
||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||
// Exact width can be determined
|
||||
$colWidth = $pValue
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
|
||||
|
||||
} else {
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$colWidth = $pValue * $size
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
|
||||
}
|
||||
|
||||
// Round pixels to closest integer
|
||||
$colWidth = (int) round($colWidth);
|
||||
|
||||
return $colWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in points
|
||||
*/
|
||||
public static function pixelsToPoints($pValue = 0) {
|
||||
return $pValue * 0.67777777;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points to pixels
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function pointsToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return (int) ceil($pValue * 1.333333333);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert degrees to angle
|
||||
*
|
||||
* @param int $pValue Degrees
|
||||
* @return int Angle
|
||||
*/
|
||||
public static function degreesToAngle($pValue = 0) {
|
||||
return (int)round($pValue * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert angle to degrees
|
||||
*
|
||||
* @param int $pValue Angle
|
||||
* @return int Degrees
|
||||
*/
|
||||
public static function angleToDegrees($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 60000);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new image from file. By alexander at alexauto dot nl
|
||||
*
|
||||
* @link http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
|
||||
* @param string $filename Path to Windows DIB (BMP) image
|
||||
* @return resource
|
||||
*/
|
||||
public static function imagecreatefrombmp($p_sFile)
|
||||
{
|
||||
// Load the image into a string
|
||||
$file = fopen($p_sFile,"rb");
|
||||
$read = fread($file,10);
|
||||
while(!feof($file)&&($read<>""))
|
||||
$read .= fread($file,1024);
|
||||
|
||||
$temp = unpack("H*",$read);
|
||||
$hex = $temp[1];
|
||||
$header = substr($hex,0,108);
|
||||
|
||||
// Process the header
|
||||
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
|
||||
if (substr($header,0,4)=="424d")
|
||||
{
|
||||
// Cut it in parts of 2 bytes
|
||||
$header_parts = str_split($header,2);
|
||||
|
||||
// Get the width 4 bytes
|
||||
$width = hexdec($header_parts[19].$header_parts[18]);
|
||||
|
||||
// Get the height 4 bytes
|
||||
$height = hexdec($header_parts[23].$header_parts[22]);
|
||||
|
||||
// Unset the header params
|
||||
unset($header_parts);
|
||||
}
|
||||
|
||||
// Define starting X and Y
|
||||
$x = 0;
|
||||
$y = 1;
|
||||
|
||||
// Create newimage
|
||||
$image = imagecreatetruecolor($width,$height);
|
||||
|
||||
// Grab the body from the image
|
||||
$body = substr($hex,108);
|
||||
|
||||
// Calculate if padding at the end-line is needed
|
||||
// Divided by two to keep overview.
|
||||
// 1 byte = 2 HEX-chars
|
||||
$body_size = (strlen($body)/2);
|
||||
$header_size = ($width*$height);
|
||||
|
||||
// Use end-line padding? Only when needed
|
||||
$usePadding = ($body_size>($header_size*3)+4);
|
||||
|
||||
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
|
||||
// Calculate the next DWORD-position in the body
|
||||
for ($i=0;$i<$body_size;$i+=3)
|
||||
{
|
||||
// Calculate line-ending and padding
|
||||
if ($x>=$width)
|
||||
{
|
||||
// If padding needed, ignore image-padding
|
||||
// Shift i to the ending of the current 32-bit-block
|
||||
if ($usePadding)
|
||||
$i += $width%4;
|
||||
|
||||
// Reset horizontal position
|
||||
$x = 0;
|
||||
|
||||
// Raise the height-position (bottom-up)
|
||||
$y++;
|
||||
|
||||
// Reached the image-height? Break the for-loop
|
||||
if ($y>$height)
|
||||
break;
|
||||
}
|
||||
|
||||
// Calculation of the RGB-pixel (defined as BGR in image-data)
|
||||
// Define $i_pos as absolute position in the body
|
||||
$i_pos = $i*2;
|
||||
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
|
||||
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
|
||||
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
|
||||
|
||||
// Calculate and draw the pixel
|
||||
$color = imagecolorallocate($image,$r,$g,$b);
|
||||
imagesetpixel($image,$x,$height-$y,$color);
|
||||
|
||||
// Raise the horizontal position
|
||||
$x++;
|
||||
}
|
||||
|
||||
// Unset the body / free the memory
|
||||
unset($body);
|
||||
|
||||
// Return image-object
|
||||
return $image;
|
||||
}
|
||||
|
||||
}
|
91
PHPExcel/Shared/Escher.php
Normal file
91
PHPExcel/Shared/Escher.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher
|
||||
{
|
||||
/**
|
||||
* Drawing Group Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DggContainer
|
||||
*/
|
||||
private $_dggContainer;
|
||||
|
||||
/**
|
||||
* Drawing Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DgContainer
|
||||
*/
|
||||
private $_dgContainer;
|
||||
|
||||
/**
|
||||
* Get Drawing Group Container
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer
|
||||
*/
|
||||
public function getDggContainer()
|
||||
{
|
||||
return $this->_dggContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Drawing Group Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer $dggContainer
|
||||
*/
|
||||
public function setDggContainer($dggContainer)
|
||||
{
|
||||
return $this->_dggContainer = $dggContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Drawing Container
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer
|
||||
*/
|
||||
public function getDgContainer()
|
||||
{
|
||||
return $this->_dgContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Drawing Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DgContainer $dgContainer
|
||||
*/
|
||||
public function setDgContainer($dgContainer)
|
||||
{
|
||||
return $this->_dgContainer = $dgContainer;
|
||||
}
|
||||
|
||||
}
|
83
PHPExcel/Shared/Escher/DgContainer.php
Normal file
83
PHPExcel/Shared/Escher/DgContainer.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DgContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer
|
||||
{
|
||||
/**
|
||||
* Drawing index, 1-based.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_dgId;
|
||||
|
||||
/**
|
||||
* Last shape index in this drawing
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_lastSpId;
|
||||
|
||||
private $_spgrContainer = null;
|
||||
|
||||
public function getDgId()
|
||||
{
|
||||
return $this->_dgId;
|
||||
}
|
||||
|
||||
public function setDgId($value)
|
||||
{
|
||||
$this->_dgId = $value;
|
||||
}
|
||||
|
||||
public function getLastSpId()
|
||||
{
|
||||
return $this->_lastSpId;
|
||||
}
|
||||
|
||||
public function setLastSpId($value)
|
||||
{
|
||||
$this->_lastSpId = $value;
|
||||
}
|
||||
|
||||
public function getSpgrContainer()
|
||||
{
|
||||
return $this->_spgrContainer;
|
||||
}
|
||||
|
||||
public function setSpgrContainer($spgrContainer)
|
||||
{
|
||||
return $this->_spgrContainer = $spgrContainer;
|
||||
}
|
||||
|
||||
}
|
109
PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php
Normal file
109
PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
{
|
||||
/**
|
||||
* Parent Shape Group Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Shape Container collection
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_children = array();
|
||||
|
||||
/**
|
||||
* Set parent Shape Group Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DgContainer_SpgrContainer $parent
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent Shape Group Container if any
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer|null
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a child. This will be either spgrContainer or spContainer
|
||||
*
|
||||
* @param mixed $child
|
||||
*/
|
||||
public function addChild($child)
|
||||
{
|
||||
$this->_children[] = $child;
|
||||
$child->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of Shape Containers
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->_children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively get all spContainers within this spgrContainer
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer[]
|
||||
*/
|
||||
public function getAllSpContainers()
|
||||
{
|
||||
$allSpContainers = array();
|
||||
|
||||
foreach ($this->_children as $child) {
|
||||
if ($child instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) {
|
||||
$allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers());
|
||||
} else {
|
||||
$allSpContainers[] = $child;
|
||||
}
|
||||
}
|
||||
|
||||
return $allSpContainers;
|
||||
}
|
||||
}
|
395
PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php
Normal file
395
PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php
Normal file
@ -0,0 +1,395 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
|
||||
{
|
||||
/**
|
||||
* Parent Shape Group Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Is this a group shape?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_spgr = false;
|
||||
|
||||
/**
|
||||
* Shape type
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_spType;
|
||||
|
||||
/**
|
||||
* Shape flag
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_spFlag;
|
||||
|
||||
/**
|
||||
* Shape index (usually group shape has index 0, and the rest: 1,2,3...)
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_spId;
|
||||
|
||||
/**
|
||||
* Array of options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_OPT;
|
||||
|
||||
/**
|
||||
* Cell coordinates of upper-left corner of shape, e.g. 'A1'
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_startCoordinates;
|
||||
|
||||
/**
|
||||
* Horizontal offset of upper-left corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_startOffsetX;
|
||||
|
||||
/**
|
||||
* Vertical offset of upper-left corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_startOffsetY;
|
||||
|
||||
/**
|
||||
* Cell coordinates of bottom-right corner of shape, e.g. 'B2'
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_endCoordinates;
|
||||
|
||||
/**
|
||||
* Horizontal offset of bottom-right corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_endOffsetX;
|
||||
|
||||
/**
|
||||
* Vertical offset of bottom-right corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_endOffsetY;
|
||||
|
||||
/**
|
||||
* Set parent Shape Group Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DgContainer_SpgrContainer $parent
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent Shape Group Container
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this is a group shape
|
||||
*
|
||||
* @param boolean $value
|
||||
*/
|
||||
public function setSpgr($value = false)
|
||||
{
|
||||
$this->_spgr = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether this is a group shape
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getSpgr()
|
||||
{
|
||||
return $this->_spgr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the shape type
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setSpType($value)
|
||||
{
|
||||
$this->_spType = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shape type
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpType()
|
||||
{
|
||||
return $this->_spType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the shape flag
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setSpFlag($value)
|
||||
{
|
||||
$this->_spFlag = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shape flag
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpFlag()
|
||||
{
|
||||
return $this->_spFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the shape index
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setSpId($value)
|
||||
{
|
||||
$this->_spId = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shape index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpId()
|
||||
{
|
||||
return $this->_spId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the Shape Group Container
|
||||
*
|
||||
* @param int $property The number specifies the option
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setOPT($property, $value)
|
||||
{
|
||||
$this->_OPT[$property] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option for the Shape Group Container
|
||||
*
|
||||
* @param int $property The number specifies the option
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOPT($property)
|
||||
{
|
||||
if (isset($this->_OPT[$property])) {
|
||||
return $this->_OPT[$property];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collection of options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOPTCollection()
|
||||
{
|
||||
return $this->_OPT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell coordinates of upper-left corner of shape
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setStartCoordinates($value = 'A1')
|
||||
{
|
||||
$this->_startCoordinates = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell coordinates of upper-left corner of shape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStartCoordinates()
|
||||
{
|
||||
return $this->_startCoordinates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offset in x-direction of upper-left corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @param int $startOffsetX
|
||||
*/
|
||||
public function setStartOffsetX($startOffsetX = 0)
|
||||
{
|
||||
$this->_startOffsetX = $startOffsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offset in x-direction of upper-left corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStartOffsetX()
|
||||
{
|
||||
return $this->_startOffsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offset in y-direction of upper-left corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @param int $startOffsetY
|
||||
*/
|
||||
public function setStartOffsetY($startOffsetY = 0)
|
||||
{
|
||||
$this->_startOffsetY = $startOffsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offset in y-direction of upper-left corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStartOffsetY()
|
||||
{
|
||||
return $this->_startOffsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell coordinates of bottom-right corner of shape
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setEndCoordinates($value = 'A1')
|
||||
{
|
||||
$this->_endCoordinates = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell coordinates of bottom-right corner of shape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEndCoordinates()
|
||||
{
|
||||
return $this->_endCoordinates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @param int $startOffsetX
|
||||
*/
|
||||
public function setEndOffsetX($endOffsetX = 0)
|
||||
{
|
||||
$this->_endOffsetX = $endOffsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getEndOffsetX()
|
||||
{
|
||||
return $this->_endOffsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offset in y-direction of bottom-right corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @param int $endOffsetY
|
||||
*/
|
||||
public function setEndOffsetY($endOffsetY = 0)
|
||||
{
|
||||
$this->_endOffsetY = $endOffsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offset in y-direction of bottom-right corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getEndOffsetY()
|
||||
{
|
||||
return $this->_endOffsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the nesting level of this spContainer. This is the number of spgrContainers between this spContainer and
|
||||
* the dgContainer. A value of 1 = immediately within first spgrContainer
|
||||
* Higher nesting level occurs if and only if spContainer is part of a shape group
|
||||
*
|
||||
* @return int Nesting level
|
||||
*/
|
||||
public function getNestingLevel()
|
||||
{
|
||||
$nestingLevel = 0;
|
||||
|
||||
$parent = $this->getParent();
|
||||
while ($parent instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) {
|
||||
++$nestingLevel;
|
||||
$parent = $parent->getParent();
|
||||
}
|
||||
|
||||
return $nestingLevel;
|
||||
}
|
||||
}
|
203
PHPExcel/Shared/Escher/DggContainer.php
Normal file
203
PHPExcel/Shared/Escher/DggContainer.php
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DggContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer
|
||||
{
|
||||
/**
|
||||
* Maximum shape index of all shapes in all drawings increased by one
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_spIdMax;
|
||||
|
||||
/**
|
||||
* Total number of drawings saved
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cDgSaved;
|
||||
|
||||
/**
|
||||
* Total number of shapes saved (including group shapes)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cSpSaved;
|
||||
|
||||
/**
|
||||
* BLIP Store Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
*/
|
||||
private $_bstoreContainer;
|
||||
|
||||
/**
|
||||
* Array of options for the drawing group
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_OPT = array();
|
||||
|
||||
/**
|
||||
* Array of identifier clusters containg information about the maximum shape identifiers
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_IDCLs = array();
|
||||
|
||||
/**
|
||||
* Get maximum shape index of all shapes in all drawings (plus one)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpIdMax()
|
||||
{
|
||||
return $this->_spIdMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set maximum shape index of all shapes in all drawings (plus one)
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
public function setSpIdMax($value)
|
||||
{
|
||||
$this->_spIdMax = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total number of drawings saved
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCDgSaved()
|
||||
{
|
||||
return $this->_cDgSaved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set total number of drawings saved
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
public function setCDgSaved($value)
|
||||
{
|
||||
$this->_cDgSaved = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total number of shapes saved (including group shapes)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCSpSaved()
|
||||
{
|
||||
return $this->_cSpSaved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set total number of shapes saved (including group shapes)
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
public function setCSpSaved($value)
|
||||
{
|
||||
$this->_cSpSaved = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get BLIP Store Container
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
*/
|
||||
public function getBstoreContainer()
|
||||
{
|
||||
return $this->_bstoreContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set BLIP Store Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer $bstoreContainer
|
||||
*/
|
||||
public function setBstoreContainer($bstoreContainer)
|
||||
{
|
||||
$this->_bstoreContainer = $bstoreContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the drawing group
|
||||
*
|
||||
* @param int $property The number specifies the option
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setOPT($property, $value)
|
||||
{
|
||||
$this->_OPT[$property] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option for the drawing group
|
||||
*
|
||||
* @param int $property The number specifies the option
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOPT($property)
|
||||
{
|
||||
if (isset($this->_OPT[$property])) {
|
||||
return $this->_OPT[$property];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identifier clusters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getIDCLs()
|
||||
{
|
||||
return $this->_IDCLs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set identifier clusters. array(<drawingId> => <max shape id>, ...)
|
||||
*
|
||||
* @param array $pValue
|
||||
*/
|
||||
public function setIDCLs($pValue)
|
||||
{
|
||||
$this->_IDCLs = $pValue;
|
||||
}
|
||||
}
|
65
PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php
Normal file
65
PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
{
|
||||
/**
|
||||
* BLIP Store Entries. Each of them holds one BLIP (Big Large Image or Picture)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_BSECollection = array();
|
||||
|
||||
/**
|
||||
* Add a BLIP Store Entry
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $BSE
|
||||
*/
|
||||
public function addBSE($BSE)
|
||||
{
|
||||
$this->_BSECollection[] = $BSE;
|
||||
$BSE->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collection of BLIP Store Entries
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE[]
|
||||
*/
|
||||
public function getBSECollection()
|
||||
{
|
||||
return $this->_BSECollection;
|
||||
}
|
||||
|
||||
}
|
120
PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php
Normal file
120
PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
|
||||
{
|
||||
const BLIPTYPE_ERROR = 0x00;
|
||||
const BLIPTYPE_UNKNOWN = 0x01;
|
||||
const BLIPTYPE_EMF = 0x02;
|
||||
const BLIPTYPE_WMF = 0x03;
|
||||
const BLIPTYPE_PICT = 0x04;
|
||||
const BLIPTYPE_JPEG = 0x05;
|
||||
const BLIPTYPE_PNG = 0x06;
|
||||
const BLIPTYPE_DIB = 0x07;
|
||||
const BLIPTYPE_TIFF = 0x11;
|
||||
const BLIPTYPE_CMYKJPEG = 0x12;
|
||||
|
||||
/**
|
||||
* The parent BLIP Store Entry Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* The BLIP (Big Large Image or Picture)
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
|
||||
*/
|
||||
private $_blip;
|
||||
|
||||
/**
|
||||
* The BLIP type
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_blipType;
|
||||
|
||||
/**
|
||||
* Set parent BLIP Store Entry Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer $parent
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BLIP
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
|
||||
*/
|
||||
public function getBlip()
|
||||
{
|
||||
return $this->_blip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BLIP
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip $blip
|
||||
*/
|
||||
public function setBlip($blip)
|
||||
{
|
||||
$this->_blip = $blip;
|
||||
$blip->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BLIP type
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlipType()
|
||||
{
|
||||
return $this->_blipType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BLIP type
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
public function setBlipType($blipType)
|
||||
{
|
||||
$this->_blipType = $blipType;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
|
||||
{
|
||||
/**
|
||||
* The parent BSE
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Raw image data
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_data;
|
||||
|
||||
/**
|
||||
* Get the raw image data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the raw image data
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->_data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent BSE
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $parent
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent BSE
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $parent
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
}
|
317
PHPExcel/Shared/Excel5.php
Normal file
317
PHPExcel/Shared/Excel5.php
Normal file
@ -0,0 +1,317 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Excel5
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Excel5
|
||||
{
|
||||
/**
|
||||
* 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)
|
||||
* This holds for Arial 10
|
||||
*
|
||||
* @param PHPExcel_Worksheet $sheet The sheet
|
||||
* @param string $col The column
|
||||
* @return integer The width in pixels
|
||||
*/
|
||||
public static function sizeCol($sheet, $col = 'A')
|
||||
{
|
||||
// default font of the workbook
|
||||
$font = $sheet->getParent()->getDefaultStyle()->getFont();
|
||||
|
||||
$columnDimensions = $sheet->getColumnDimensions();
|
||||
|
||||
// first find the true column width in pixels (uncollapsed and unhidden)
|
||||
if ( isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1 ) {
|
||||
|
||||
// then we have column dimension with explicit width
|
||||
$columnDimension = $columnDimensions[$col];
|
||||
$width = $columnDimension->getWidth();
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
|
||||
|
||||
} else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
|
||||
|
||||
// then we have default column dimension with explicit width
|
||||
$defaultColumnDimension = $sheet->getDefaultColumnDimension();
|
||||
$width = $defaultColumnDimension->getWidth();
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
|
||||
|
||||
} else {
|
||||
|
||||
// we don't even have any default column dimension. Width depends on default font
|
||||
$pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true);
|
||||
}
|
||||
|
||||
// now find the effective column width in pixels
|
||||
if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) {
|
||||
$effectivePixelWidth = 0;
|
||||
} else {
|
||||
$effectivePixelWidth = $pixelWidth;
|
||||
}
|
||||
|
||||
return $effectivePixelWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the height of a cell from user's units to pixels. By interpolation
|
||||
* 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.
|
||||
*
|
||||
* @param PHPExcel_Worksheet $sheet The sheet
|
||||
* @param integer $row The row index (1-based)
|
||||
* @return integer The width in pixels
|
||||
*/
|
||||
public static function sizeRow($sheet, $row = 1)
|
||||
{
|
||||
// default font of the workbook
|
||||
$font = $sheet->getParent()->getDefaultStyle()->getFont();
|
||||
|
||||
$rowDimensions = $sheet->getRowDimensions();
|
||||
|
||||
// first find the true row height in pixels (uncollapsed and unhidden)
|
||||
if ( isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) {
|
||||
|
||||
// then we have a row dimension
|
||||
$rowDimension = $rowDimensions[$row];
|
||||
$rowHeight = $rowDimension->getRowHeight();
|
||||
$pixelRowHeight = (int) ceil(4 * $rowHeight / 3); // here we assume Arial 10
|
||||
|
||||
} else if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) {
|
||||
|
||||
// then we have a default row dimension with explicit height
|
||||
$defaultRowDimension = $sheet->getDefaultRowDimension();
|
||||
$rowHeight = $defaultRowDimension->getRowHeight();
|
||||
$pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight);
|
||||
|
||||
} else {
|
||||
|
||||
// we don't even have any default row dimension. Height depends on default font
|
||||
$pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font);
|
||||
$pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight);
|
||||
|
||||
}
|
||||
|
||||
// now find the effective row height in pixels
|
||||
if ( isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible() ) {
|
||||
$effectivePixelRowHeight = 0;
|
||||
} else {
|
||||
$effectivePixelRowHeight = $pixelRowHeight;
|
||||
}
|
||||
|
||||
return $effectivePixelRowHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @param PHPExcel_Worksheet $sheet
|
||||
* @param string $startColumn
|
||||
* @param integer $startOffsetX Offset within start cell measured in 1/1024 of the cell width
|
||||
* @param string $endColumn
|
||||
* @param integer $endOffsetX Offset within end cell measured in 1/1024 of the cell width
|
||||
* @return integer Horizontal measured in pixels
|
||||
*/
|
||||
public static function getDistanceX(PHPExcel_Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0)
|
||||
{
|
||||
$distanceX = 0;
|
||||
|
||||
// add the widths of the spanning columns
|
||||
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; // 1-based
|
||||
$endColumnIndex = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; // 1-based
|
||||
for ($i = $startColumnIndex; $i <= $endColumnIndex; ++$i) {
|
||||
$distanceX += self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($i));
|
||||
}
|
||||
|
||||
// correct for offsetX in startcell
|
||||
$distanceX -= (int) floor(self::sizeCol($sheet, $startColumn) * $startOffsetX / 1024);
|
||||
|
||||
// correct for offsetX in endcell
|
||||
$distanceX -= (int) floor(self::sizeCol($sheet, $endColumn) * (1 - $endOffsetX / 1024));
|
||||
|
||||
return $distanceX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vertical distance in pixels between two anchors
|
||||
* The distanceY is found as sum of all the spanning rows minus two offsets
|
||||
*
|
||||
* @param PHPExcel_Worksheet $sheet
|
||||
* @param integer $startRow (1-based)
|
||||
* @param integer $startOffsetY Offset within start cell measured in 1/256 of the cell height
|
||||
* @param integer $endRow (1-based)
|
||||
* @param integer $endOffsetY Offset within end cell measured in 1/256 of the cell height
|
||||
* @return integer Vertical distance measured in pixels
|
||||
*/
|
||||
public static function getDistanceY(PHPExcel_Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0)
|
||||
{
|
||||
$distanceY = 0;
|
||||
|
||||
// add the widths of the spanning rows
|
||||
for ($row = $startRow; $row <= $endRow; ++$row) {
|
||||
$distanceY += self::sizeRow($sheet, $row);
|
||||
}
|
||||
|
||||
// correct for offsetX in startcell
|
||||
$distanceY -= (int) floor(self::sizeRow($sheet, $startRow) * $startOffsetY / 256);
|
||||
|
||||
// correct for offsetX in endcell
|
||||
$distanceY -= (int) floor(self::sizeRow($sheet, $endRow) * (1 - $endOffsetY / 256));
|
||||
|
||||
return $distanceY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert 1-cell anchor coordinates to 2-cell anchor coordinates
|
||||
* This function is ported from PEAR Spreadsheet_Writer_Excel with small modifications
|
||||
*
|
||||
* Calculate the vertices that define the position of the image as required by
|
||||
* the OBJ record.
|
||||
*
|
||||
* +------------+------------+
|
||||
* | A | B |
|
||||
* +-----+------------+------------+
|
||||
* | |(x1,y1) | |
|
||||
* | 1 |(A1)._______|______ |
|
||||
* | | | | |
|
||||
* | | | | |
|
||||
* +-----+----| BITMAP |-----+
|
||||
* | | | | |
|
||||
* | 2 | |______________. |
|
||||
* | | | (B2)|
|
||||
* | | | (x2,y2)|
|
||||
* +---- +------------+------------+
|
||||
*
|
||||
* Example of a bitmap that covers some of the area from cell A1 to cell B2.
|
||||
*
|
||||
* Based on the width and height of the bitmap we need to calculate 8 vars:
|
||||
* $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2.
|
||||
* The width and height of the cells are also variable and have to be taken into
|
||||
* account.
|
||||
* The values of $col_start and $row_start are passed in from the calling
|
||||
* function. The values of $col_end and $row_end are calculated by subtracting
|
||||
* the width and height of the bitmap from the width and height of the
|
||||
* underlying cells.
|
||||
* The vertices are expressed as a percentage of the underlying cell width as
|
||||
* follows (rhs values are in pixels):
|
||||
*
|
||||
* x1 = X / W *1024
|
||||
* y1 = Y / H *256
|
||||
* x2 = (X-1) / W *1024
|
||||
* y2 = (Y-1) / H *256
|
||||
*
|
||||
* Where: X is distance from the left side of the underlying cell
|
||||
* Y is distance from the top of the underlying cell
|
||||
* W is the width of the cell
|
||||
* H is the height of the cell
|
||||
*
|
||||
* @param PHPExcel_Worksheet $sheet
|
||||
* @param string $coordinates E.g. 'A1'
|
||||
* @param integer $offsetX Horizontal offset in pixels
|
||||
* @param integer $offsetY Vertical offset in pixels
|
||||
* @param integer $width Width in pixels
|
||||
* @param integer $height Height in pixels
|
||||
* @return array
|
||||
*/
|
||||
public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height)
|
||||
{
|
||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinates);
|
||||
$col_start = PHPExcel_Cell::columnIndexFromString($column) - 1;
|
||||
$row_start = $row - 1;
|
||||
|
||||
$x1 = $offsetX;
|
||||
$y1 = $offsetY;
|
||||
|
||||
// Initialise end cell to the same as the start cell
|
||||
$col_end = $col_start; // Col containing lower 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
|
||||
if ($x1 >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start))) {
|
||||
$x1 = 0;
|
||||
}
|
||||
if ($y1 >= self::sizeRow($sheet, $row_start + 1)) {
|
||||
$y1 = 0;
|
||||
}
|
||||
|
||||
$width = $width + $x1 -1;
|
||||
$height = $height + $y1 -1;
|
||||
|
||||
// Subtract the underlying cell widths to find the end cell of the image
|
||||
while ($width >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end))) {
|
||||
$width -= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end));
|
||||
++$col_end;
|
||||
}
|
||||
|
||||
// Subtract the underlying cell heights to find the end cell of the image
|
||||
while ($height >= self::sizeRow($sheet, $row_end + 1)) {
|
||||
$height -= self::sizeRow($sheet, $row_end + 1);
|
||||
++$row_end;
|
||||
}
|
||||
|
||||
// Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell
|
||||
// with zero height or width.
|
||||
if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) == 0) {
|
||||
return;
|
||||
}
|
||||
if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) == 0) {
|
||||
return;
|
||||
}
|
||||
if (self::sizeRow($sheet, $row_start + 1) == 0) {
|
||||
return;
|
||||
}
|
||||
if (self::sizeRow($sheet, $row_end + 1) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert the pixel values to the percentage value expected by Excel
|
||||
$x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024;
|
||||
$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
|
||||
$y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object
|
||||
|
||||
$startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start) . ($row_start + 1);
|
||||
$endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end) . ($row_end + 1);
|
||||
|
||||
$twoAnchor = array(
|
||||
'startCoordinates' => $startCoordinates,
|
||||
'startOffsetX' => $x1,
|
||||
'startOffsetY' => $y1,
|
||||
'endCoordinates' => $endCoordinates,
|
||||
'endOffsetX' => $x2,
|
||||
'endOffsetY' => $y2,
|
||||
);
|
||||
|
||||
return $twoAnchor;
|
||||
}
|
||||
|
||||
}
|
178
PHPExcel/Shared/File.php
Normal file
178
PHPExcel/Shared/File.php
Normal file
@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_File
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_File
|
||||
{
|
||||
/*
|
||||
* Use Temp or File Upload Temp for temporary files
|
||||
*
|
||||
* @protected
|
||||
* @var boolean
|
||||
*/
|
||||
protected static $_useUploadTempDirectory = FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* Set the flag indicating whether the File Upload Temp directory should be used for temporary files
|
||||
*
|
||||
* @param boolean $useUploadTempDir Use File Upload Temporary directory (true or false)
|
||||
*/
|
||||
public static function setUseUploadTempDirectory($useUploadTempDir = FALSE) {
|
||||
self::$_useUploadTempDirectory = (boolean) $useUploadTempDir;
|
||||
} // function setUseUploadTempDirectory()
|
||||
|
||||
|
||||
/**
|
||||
* Get the flag indicating whether the File Upload Temp directory should be used for temporary files
|
||||
*
|
||||
* @return boolean Use File Upload Temporary directory (true or false)
|
||||
*/
|
||||
public static function getUseUploadTempDirectory() {
|
||||
return self::$_useUploadTempDirectory;
|
||||
} // function getUseUploadTempDirectory()
|
||||
|
||||
|
||||
/**
|
||||
* Verify if a file exists
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @return bool
|
||||
*/
|
||||
public static function file_exists($pFilename) {
|
||||
// Sick construction, but it seems that
|
||||
// file_exists returns strange values when
|
||||
// doing the original file_exists on ZIP archives...
|
||||
if ( strtolower(substr($pFilename, 0, 3)) == 'zip' ) {
|
||||
// Open ZIP file and verify if the file exists
|
||||
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
|
||||
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = ($zip->getFromName($archiveFile) !== false);
|
||||
$zip->close();
|
||||
return $returnValue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Regular file_exists
|
||||
return file_exists($pFilename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns canonicalized absolute pathname, also for ZIP archives
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return string
|
||||
*/
|
||||
public static function realpath($pFilename) {
|
||||
// Returnvalue
|
||||
$returnValue = '';
|
||||
|
||||
// Try using realpath()
|
||||
if (file_exists($pFilename)) {
|
||||
$returnValue = realpath($pFilename);
|
||||
}
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || ($returnValue === NULL)) {
|
||||
$pathArray = explode('/' , $pFilename);
|
||||
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
unset($pathArray[$i]);
|
||||
unset($pathArray[$i - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$returnValue = implode('/', $pathArray);
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the systems temporary directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function sys_get_temp_dir()
|
||||
{
|
||||
if (self::$_useUploadTempDirectory) {
|
||||
// use upload-directory when defined to allow running on environments having very restricted
|
||||
// open_basedir configs
|
||||
if (ini_get('upload_tmp_dir') !== FALSE) {
|
||||
if ($temp = ini_get('upload_tmp_dir')) {
|
||||
if (file_exists($temp))
|
||||
return realpath($temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sys_get_temp_dir is only available since PHP 5.2.1
|
||||
// http://php.net/manual/en/function.sys-get-temp-dir.php#94119
|
||||
if ( !function_exists('sys_get_temp_dir')) {
|
||||
if ($temp = getenv('TMP') ) {
|
||||
if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); }
|
||||
}
|
||||
if ($temp = getenv('TEMP') ) {
|
||||
if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); }
|
||||
}
|
||||
if ($temp = getenv('TMPDIR') ) {
|
||||
if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); }
|
||||
}
|
||||
|
||||
// trick for creating a file in system's temporary dir
|
||||
// without knowing the path of the system's temporary dir
|
||||
$temp = tempnam(__FILE__, '');
|
||||
if (file_exists($temp)) {
|
||||
unlink($temp);
|
||||
return realpath(dirname($temp));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// use ordinary built-in PHP function
|
||||
// There should be no problem with the 5.2.4 Suhosin realpath() bug, because this line should only
|
||||
// be called if we're running 5.2.1 or earlier
|
||||
return realpath(sys_get_temp_dir());
|
||||
}
|
||||
|
||||
}
|
775
PHPExcel/Shared/Font.php
Normal file
775
PHPExcel/Shared/Font.php
Normal file
File diff suppressed because it is too large
Load Diff
16
PHPExcel/Shared/JAMA/CHANGELOG.TXT
Normal file
16
PHPExcel/Shared/JAMA/CHANGELOG.TXT
Normal file
@ -0,0 +1,16 @@
|
||||
Mar 1, 2005 11:15 AST by PM
|
||||
|
||||
+ For consistency, renamed Math.php to Maths.java, utils to util,
|
||||
tests to test, docs to doc -
|
||||
|
||||
+ Removed conditional logic from top of Matrix class.
|
||||
|
||||
+ Switched to using hypo function in Maths.php for all php-hypot calls.
|
||||
NOTE TO SELF: Need to make sure that all decompositions have been
|
||||
switched over to using the bundled hypo.
|
||||
|
||||
Feb 25, 2005 at 10:00 AST by PM
|
||||
|
||||
+ Recommend using simpler Error.php instead of JAMA_Error.php but
|
||||
can be persuaded otherwise.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user