mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2025-04-04 22:03:37 +03:00
Compare commits
172 commits
Author | SHA1 | Date | |
---|---|---|---|
|
e31d0fa339 | ||
|
39534e3dd3 | ||
|
c269793ee7 | ||
|
185bf41233 | ||
|
afb11493d0 | ||
|
12f91aa295 | ||
|
d3373c97e1 | ||
|
1c8c2379cc | ||
|
900325d0c8 | ||
|
e487f5c11a | ||
|
fcc5c65855 | ||
|
650d2d099c | ||
|
b2029564e5 | ||
|
b0ce48fd92 | ||
|
772e66f74a | ||
|
8af620f97b | ||
|
c4782b6606 | ||
|
a1dee8f6c3 | ||
|
1a237573f9 | ||
|
44918984a1 | ||
|
7fa160905b | ||
|
79f95213e0 | ||
|
a806b79aba | ||
|
7d1c140974 | ||
|
5e89b26e9d | ||
|
1b6ed6b9c6 | ||
|
6fe91ac86a | ||
|
d3fd1508a1 | ||
|
bf2b74b57e | ||
|
802a94fc5d | ||
|
da91993df0 | ||
|
39d8b8f57a | ||
|
352e6ea5cc | ||
|
6a3dd85f6f | ||
|
19d7849bd1 | ||
|
36d2ba12e3 | ||
|
144f57e44a | ||
|
6ae1056fb2 | ||
|
f29b05b473 | ||
|
e6ded71172 | ||
|
de3aaa3726 | ||
|
2221c5ed12 | ||
|
a27e053354 | ||
|
dbb819003c | ||
|
e11a76759f | ||
|
2743dc4acf | ||
|
6d3a440aae | ||
|
2058c8468a | ||
|
7eb10adb3b | ||
|
6f43f0429b | ||
|
65310d164c | ||
|
ecdb406d4d | ||
|
6a8fca703c | ||
|
ba04463cc9 | ||
|
cd151ae2e4 | ||
|
681c30b2ea | ||
|
49d123e910 | ||
|
875f92dac9 | ||
|
f6a2107856 | ||
|
e7c7a6eb53 | ||
|
54738ea3db | ||
|
bf3e07e810 | ||
|
e878104849 | ||
|
78df8592e5 | ||
|
bc29a1c38a | ||
|
889b0a4b3e | ||
|
18c6b498f8 | ||
|
6eae139301 | ||
|
663d942205 | ||
|
8f7c2fd464 | ||
|
941ab7d739 | ||
|
87ba429020 | ||
|
36eef2f163 | ||
|
1e4988e12c | ||
|
78378f1c88 | ||
|
879f86c235 | ||
|
7ced78b0be | ||
|
77cc77209b | ||
|
891478f6ab | ||
|
4f6d009ba5 | ||
|
3092adbb18 | ||
|
5bb69032b8 | ||
|
5f73ef34d3 | ||
|
e4d29824a6 | ||
|
1ba2ae0cec | ||
|
0f427685bd | ||
|
99b375613d | ||
|
beec8f167a | ||
|
003c259801 | ||
|
217ef4297c | ||
|
98a087afb4 | ||
|
8f1be4f4de | ||
|
44f049a0a5 | ||
|
4c0434d608 | ||
|
e0cefe3360 | ||
|
8e977aee29 | ||
|
3dcdba0c67 | ||
|
8026fce4b6 | ||
|
85692956a7 | ||
|
547d495247 | ||
|
c4ff34dde4 | ||
|
17c644bef6 | ||
|
0c177b5ea2 | ||
|
b394056b56 | ||
|
7cd731e416 | ||
|
f94dcb9852 | ||
|
4648e386f5 | ||
|
066a85d3d2 | ||
|
004d411772 | ||
|
004936e35a | ||
|
b6bc0db105 | ||
|
576effef30 | ||
|
09352e3e80 | ||
|
1d842ed218 | ||
|
4d65197b03 | ||
|
6b1764f771 | ||
|
b531fd487e | ||
|
f0fdc9430b | ||
|
9140e3da2e | ||
|
4a6686e2dd | ||
|
334747867d | ||
|
1663ef141c | ||
|
61e81377cb | ||
|
082fb1b475 | ||
|
f827a25af2 | ||
|
1bf5ea414b | ||
|
2af5e55f2c | ||
|
4c8dd00dff | ||
|
121eccd4c8 | ||
|
5508013569 | ||
|
96f3d0e6ee | ||
|
e18ba38f16 | ||
|
1c26425915 | ||
|
66169af898 | ||
|
7d9f45c176 | ||
|
feac76dadf | ||
|
141a61a908 | ||
|
7d086fdbee | ||
|
2881bca443 | ||
|
06c1ea78de | ||
|
d85222b45a | ||
|
e018257896 | ||
|
b057a52377 | ||
|
4a977f1848 | ||
|
99b0beb721 | ||
|
f7296f58b4 | ||
|
f37630e938 | ||
|
5bb747f8cc | ||
|
2896d62e08 | ||
|
6850d8a29d | ||
|
d019ce5956 | ||
|
661ff77749 | ||
|
95b3fb024a | ||
|
61b5fa0beb | ||
|
a86cbaa230 | ||
|
0d855d0627 | ||
|
986b20bbb1 | ||
|
c70e289dac | ||
|
bb13357dcb | ||
|
46dfaa9f8a | ||
|
547d2bd3b2 | ||
|
1efa7e8533 | ||
|
c07b54172a | ||
|
b8f67c6f4d | ||
|
4f8c9bfc96 | ||
|
3c3154c4a3 | ||
|
e885ef9196 | ||
|
b88a6f4947 | ||
|
b3d2db79ea | ||
|
e83c359c7c | ||
|
fca778225c | ||
|
c9cb4d4286 |
359 changed files with 88600 additions and 86615 deletions
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -1,4 +1,3 @@
|
||||||
/Build export-ignore
|
/Build export-ignore
|
||||||
/Documentation export-ignore
|
/unitTests export-ignore
|
||||||
/Tests export-ignore
|
|
||||||
README.md export-ignore
|
README.md export-ignore
|
||||||
|
|
21
.travis.yml
21
.travis.yml
|
@ -1,20 +1,29 @@
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.2
|
|
||||||
- 5.3.3
|
|
||||||
- 5.3
|
|
||||||
- 5.4
|
- 5.4
|
||||||
- 5.5
|
- 5.5
|
||||||
- 5.6
|
- 5.6
|
||||||
|
- 7.0
|
||||||
- hhvm
|
- hhvm
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: hhvm
|
- php: hhvm
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
## Packages
|
||||||
|
- sudo apt-get -qq update > /dev/null
|
||||||
|
## Composer
|
||||||
|
- composer self-update
|
||||||
|
- composer install --prefer-source --dev
|
||||||
|
- phpenv global "$TRAVIS_PHP_VERSION"
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- phpunit -c ./unitTests/
|
## PHP_CodeSniffer
|
||||||
|
- ./vendor/bin/phpcs --report-width=200 --report-summary --report-full Classes/ unitTests/ --standard=PSR2 -n
|
||||||
|
## PHPUnit
|
||||||
|
- phpunit -c ./unitTests/
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,70 +31,51 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PHPExcel_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
|
class PHPExcel_Autoloader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Register the Autoloader with SPL
|
* Register the Autoloader with SPL
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function Register() {
|
public static function register()
|
||||||
|
{
|
||||||
if (function_exists('__autoload')) {
|
if (function_exists('__autoload')) {
|
||||||
// Register any existing autoloader function with SPL, so we don't get any clashes
|
// Register any existing autoloader function with SPL, so we don't get any clashes
|
||||||
spl_autoload_register('__autoload');
|
spl_autoload_register('__autoload');
|
||||||
}
|
}
|
||||||
// Register ourselves with SPL
|
// Register ourselves with SPL
|
||||||
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
|
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
|
||||||
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'), true, true);
|
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'), true, true);
|
||||||
} else {
|
} else {
|
||||||
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
|
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'));
|
||||||
}
|
}
|
||||||
} // function Register()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autoload a class identified by name
|
* Autoload a class identified by name
|
||||||
*
|
*
|
||||||
* @param string $pClassName Name of the object to load
|
* @param string $pClassName Name of the object to load
|
||||||
*/
|
*/
|
||||||
public static function Load($pClassName){
|
public static function load($pClassName)
|
||||||
if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
|
{
|
||||||
// Either already loaded, or not a PHPExcel class request
|
if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
|
||||||
return FALSE;
|
// Either already loaded, or not a PHPExcel class request
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pClassFilePath = PHPEXCEL_ROOT .
|
$pClassFilePath = PHPEXCEL_ROOT .
|
||||||
str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
|
str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
|
||||||
'.php';
|
'.php';
|
||||||
|
|
||||||
if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
|
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
|
||||||
// Can't load
|
// Can't load
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
require($pClassFilePath);
|
require($pClassFilePath);
|
||||||
} // function Load()
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_CachedObjectStorage_APC
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,28 +21,19 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
|
{
|
||||||
/**
|
|
||||||
* 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
|
* Prefix used to uniquely identify cache data for this worksheet
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_cachePrefix = null;
|
private $cachePrefix = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache timeout
|
* Cache timeout
|
||||||
|
@ -49,8 +41,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
* @access private
|
* @access private
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
private $_cacheTime = 600;
|
private $cacheTime = 600;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
|
@ -60,19 +51,23 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
* @return void
|
* @return void
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
protected function _storeData() {
|
protected function storeData()
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
{
|
||||||
$this->_currentObject->detach();
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
|
$this->currentObject->detach();
|
||||||
|
|
||||||
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
|
if (!apc_store(
|
||||||
|
$this->cachePrefix . $this->currentObjectID . '.cache',
|
||||||
|
serialize($this->currentObject),
|
||||||
|
$this->cacheTime
|
||||||
|
)) {
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
|
throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in APC');
|
||||||
}
|
}
|
||||||
$this->_currentCellIsDirty = false;
|
$this->currentCellIsDirty = false;
|
||||||
}
|
}
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
} // function _storeData()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
|
@ -83,19 +78,19 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
* @return PHPExcel_Cell
|
* @return PHPExcel_Cell
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
{
|
||||||
$this->_storeData();
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
|
$this->storeData();
|
||||||
}
|
}
|
||||||
$this->_cellCache[$pCoord] = true;
|
$this->cellCache[$pCoord] = true;
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->currentObjectID = $pCoord;
|
||||||
$this->_currentObject = $cell;
|
$this->currentObject = $cell;
|
||||||
$this->_currentCellIsDirty = true;
|
$this->currentCellIsDirty = true;
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
|
@ -105,15 +100,16 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isDataSet($pCoord) {
|
public function isDataSet($pCoord)
|
||||||
|
{
|
||||||
// Check if the requested entry is the current object, or exists in the cache
|
// Check if the requested entry is the current object, or exists in the cache
|
||||||
if (parent::isDataSet($pCoord)) {
|
if (parent::isDataSet($pCoord)) {
|
||||||
if ($this->_currentObjectID == $pCoord) {
|
if ($this->currentObjectID == $pCoord) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check if the requested entry still exists in apc
|
// Check if the requested entry still exists in apc
|
||||||
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
$success = apc_fetch($this->cachePrefix.$pCoord.'.cache');
|
||||||
if ($success === FALSE) {
|
if ($success === false) {
|
||||||
// Entry no longer exists in APC, so clear it from the cache array
|
// Entry no longer exists in APC, so clear it from the cache array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
||||||
|
@ -121,8 +117,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} // function isDataSet()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell at a specific coordinate
|
* Get cell at a specific coordinate
|
||||||
|
@ -132,16 +127,17 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord)
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
{
|
||||||
return $this->_currentObject;
|
if ($pCoord === $this->currentObjectID) {
|
||||||
|
return $this->currentObject;
|
||||||
}
|
}
|
||||||
$this->_storeData();
|
$this->storeData();
|
||||||
|
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
if (parent::isDataSet($pCoord)) {
|
if (parent::isDataSet($pCoord)) {
|
||||||
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
$obj = apc_fetch($this->cachePrefix . $pCoord . '.cache');
|
||||||
if ($obj === FALSE) {
|
if ($obj === false) {
|
||||||
// Entry no longer exists in APC, so clear it from the cache array
|
// Entry no longer exists in APC, so clear it from the cache array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
||||||
|
@ -152,29 +148,28 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize($obj);
|
$this->currentObject = unserialize($obj);
|
||||||
// Re-attach this as the cell's parent
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this);
|
$this->currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->currentObject;
|
||||||
} // function getCacheData()
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all cell addresses currently held in cache
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getCellList()
|
||||||
|
{
|
||||||
|
if ($this->currentObjectID !== null) {
|
||||||
|
$this->storeData();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return parent::getCellList();
|
||||||
* Get a list of all cell addresses currently held in cache
|
}
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function getCellList() {
|
|
||||||
if ($this->_currentObjectID !== null) {
|
|
||||||
$this->_storeData();
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::getCellList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a cell in cache identified by coordinate address
|
* Delete a cell in cache identified by coordinate address
|
||||||
|
@ -183,14 +178,14 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function deleteCacheData($pCoord) {
|
public function deleteCacheData($pCoord)
|
||||||
|
{
|
||||||
// Delete the entry from APC
|
// Delete the entry from APC
|
||||||
apc_delete($this->_cachePrefix.$pCoord.'.cache');
|
apc_delete($this->cachePrefix.$pCoord.'.cache');
|
||||||
|
|
||||||
// Delete the entry from our cell address array
|
// Delete the entry from our cell address array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
} // function deleteCacheData()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone the cell collection
|
* Clone the cell collection
|
||||||
|
@ -200,50 +195,50 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||||
|
{
|
||||||
parent::copyCellCollection($parent);
|
parent::copyCellCollection($parent);
|
||||||
// Get a new id for the new file name
|
// Get a new id for the new file name
|
||||||
$baseUnique = $this->_getUniqueID();
|
$baseUnique = $this->getUniqueID();
|
||||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||||
$cacheList = $this->getCellList();
|
$cacheList = $this->getCellList();
|
||||||
foreach($cacheList as $cellID) {
|
foreach ($cacheList as $cellID) {
|
||||||
if ($cellID != $this->_currentObjectID) {
|
if ($cellID != $this->currentObjectID) {
|
||||||
$obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
|
$obj = apc_fetch($this->cachePrefix . $cellID . '.cache');
|
||||||
if ($obj === FALSE) {
|
if ($obj === false) {
|
||||||
// Entry no longer exists in APC, so clear it from the cache array
|
// Entry no longer exists in APC, so clear it from the cache array
|
||||||
parent::deleteCacheData($cellID);
|
parent::deleteCacheData($cellID);
|
||||||
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC');
|
throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in APC');
|
||||||
}
|
}
|
||||||
if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
|
if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) {
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC');
|
throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in APC');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_cachePrefix = $newCachePrefix;
|
$this->cachePrefix = $newCachePrefix;
|
||||||
} // function copyCellCollection()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the cell collection and disconnect from our parent
|
* Clear the cell collection and disconnect from our parent
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unsetWorksheetCells() {
|
public function unsetWorksheetCells()
|
||||||
if ($this->_currentObject !== NULL) {
|
{
|
||||||
$this->_currentObject->detach();
|
if ($this->currentObject !== null) {
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->currentObject->detach();
|
||||||
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush the APC cache
|
// Flush the APC cache
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
|
|
||||||
$this->_cellCache = array();
|
$this->cellCache = array();
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->parent = null;
|
||||||
} // function unsetWorksheetCells()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise this new cell collection
|
* Initialise this new cell collection
|
||||||
|
@ -251,29 +246,29 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||||
* @param array of mixed $arguments Additional initialisation arguments
|
* @param array of mixed $arguments Additional initialisation arguments
|
||||||
*/
|
*/
|
||||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
public function __construct(PHPExcel_Worksheet $parent, $arguments)
|
||||||
|
{
|
||||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||||
|
|
||||||
if ($this->_cachePrefix === NULL) {
|
if ($this->cachePrefix === null) {
|
||||||
$baseUnique = $this->_getUniqueID();
|
$baseUnique = $this->getUniqueID();
|
||||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||||
$this->_cacheTime = $cacheTime;
|
$this->cacheTime = $cacheTime;
|
||||||
|
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy this cell collection
|
* Destroy this cell collection
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct()
|
||||||
|
{
|
||||||
$cacheList = $this->getCellList();
|
$cacheList = $this->getCellList();
|
||||||
foreach($cacheList as $cellID) {
|
foreach ($cacheList as $cellID) {
|
||||||
apc_delete($this->_cachePrefix.$cellID.'.cache');
|
apc_delete($this->cachePrefix . $cellID . '.cache');
|
||||||
}
|
}
|
||||||
} // function __destruct()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify whether the caching method is currently available
|
* Identify whether the caching method is currently available
|
||||||
|
@ -281,15 +276,15 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function cacheMethodIsAvailable() {
|
public static function cacheMethodIsAvailable()
|
||||||
|
{
|
||||||
if (!function_exists('apc_store')) {
|
if (!function_exists('apc_store')) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (apc_sma_info() === FALSE) {
|
if (apc_sma_info() === false) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,376 +1,368 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_CacheBase
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
abstract class PHPExcel_CachedObjectStorage_CacheBase
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_CacheBase
|
/**
|
||||||
*
|
* Parent worksheet
|
||||||
* @category PHPExcel
|
*
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @var PHPExcel_Worksheet
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
*/
|
||||||
*/
|
protected $parent;
|
||||||
abstract class PHPExcel_CachedObjectStorage_CacheBase {
|
|
||||||
|
/**
|
||||||
/**
|
* The currently active Cell
|
||||||
* Parent worksheet
|
*
|
||||||
*
|
* @var PHPExcel_Cell
|
||||||
* @var PHPExcel_Worksheet
|
*/
|
||||||
*/
|
protected $currentObject = null;
|
||||||
protected $_parent;
|
|
||||||
|
/**
|
||||||
/**
|
* Coordinate address of the currently active Cell
|
||||||
* The currently active Cell
|
*
|
||||||
*
|
* @var string
|
||||||
* @var PHPExcel_Cell
|
*/
|
||||||
*/
|
protected $currentObjectID = null;
|
||||||
protected $_currentObject = null;
|
|
||||||
|
/**
|
||||||
/**
|
* Flag indicating whether the currently active Cell requires saving
|
||||||
* Coordinate address of the currently active Cell
|
*
|
||||||
*
|
* @var boolean
|
||||||
* @var string
|
*/
|
||||||
*/
|
protected $currentCellIsDirty = true;
|
||||||
protected $_currentObjectID = null;
|
|
||||||
|
/**
|
||||||
|
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
||||||
/**
|
* and indexed by their coordinate address within the worksheet
|
||||||
* Flag indicating whether the currently active Cell requires saving
|
*
|
||||||
*
|
* @var array of mixed
|
||||||
* @var boolean
|
*/
|
||||||
*/
|
protected $cellCache = array();
|
||||||
protected $_currentCellIsDirty = true;
|
|
||||||
|
/**
|
||||||
/**
|
* Initialise this new cell collection
|
||||||
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
*
|
||||||
* and indexed by their coordinate address within the worksheet
|
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||||
*
|
*/
|
||||||
* @var array of mixed
|
public function __construct(PHPExcel_Worksheet $parent)
|
||||||
*/
|
{
|
||||||
protected $_cellCache = array();
|
// 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;
|
||||||
* Initialise this new cell collection
|
}
|
||||||
*
|
|
||||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
/**
|
||||||
*/
|
* Return the parent worksheet for this cell collection
|
||||||
public function __construct(PHPExcel_Worksheet $parent) {
|
*
|
||||||
// Set our parent worksheet.
|
* @return PHPExcel_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
|
public function getParent()
|
||||||
$this->_parent = $parent;
|
{
|
||||||
} // function __construct()
|
return $this->parent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the parent worksheet for this cell collection
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
*/
|
* @return boolean
|
||||||
public function getParent()
|
*/
|
||||||
{
|
public function isDataSet($pCoord)
|
||||||
return $this->_parent;
|
{
|
||||||
}
|
if ($pCoord === $this->currentObjectID) {
|
||||||
|
return true;
|
||||||
/**
|
}
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
// Check if the requested entry exists in the cache
|
||||||
*
|
return isset($this->cellCache[$pCoord]);
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
}
|
||||||
* @return boolean
|
|
||||||
*/
|
/**
|
||||||
public function isDataSet($pCoord) {
|
* Move a cell object from one address to another
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
*
|
||||||
return true;
|
* @param string $fromAddress Current address of the cell to move
|
||||||
}
|
* @param string $toAddress Destination address of the cell to move
|
||||||
// Check if the requested entry exists in the cache
|
* @return boolean
|
||||||
return isset($this->_cellCache[$pCoord]);
|
*/
|
||||||
} // function isDataSet()
|
public function moveCell($fromAddress, $toAddress)
|
||||||
|
{
|
||||||
|
if ($fromAddress === $this->currentObjectID) {
|
||||||
/**
|
$this->currentObjectID = $toAddress;
|
||||||
* Move a cell object from one address to another
|
}
|
||||||
*
|
$this->currentCellIsDirty = true;
|
||||||
* @param string $fromAddress Current address of the cell to move
|
if (isset($this->cellCache[$fromAddress])) {
|
||||||
* @param string $toAddress Destination address of the cell to move
|
$this->cellCache[$toAddress] = &$this->cellCache[$fromAddress];
|
||||||
* @return boolean
|
unset($this->cellCache[$fromAddress]);
|
||||||
*/
|
}
|
||||||
public function moveCell($fromAddress, $toAddress) {
|
|
||||||
if ($fromAddress === $this->_currentObjectID) {
|
return true;
|
||||||
$this->_currentObjectID = $toAddress;
|
}
|
||||||
}
|
|
||||||
$this->_currentCellIsDirty = true;
|
/**
|
||||||
if (isset($this->_cellCache[$fromAddress])) {
|
* Add or Update a cell in cache
|
||||||
$this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress];
|
*
|
||||||
unset($this->_cellCache[$fromAddress]);
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
}
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
return TRUE;
|
*/
|
||||||
} // function moveCell()
|
public function updateCacheData(PHPExcel_Cell $cell)
|
||||||
|
{
|
||||||
|
return $this->addCacheData($cell->getCoordinate(), $cell);
|
||||||
/**
|
}
|
||||||
* Add or Update a cell in cache
|
|
||||||
*
|
/**
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* Delete a cell in cache identified by coordinate address
|
||||||
* @return PHPExcel_Cell
|
*
|
||||||
* @throws PHPExcel_Exception
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
*/
|
* @throws PHPExcel_Exception
|
||||||
public function updateCacheData(PHPExcel_Cell $cell) {
|
*/
|
||||||
return $this->addCacheData($cell->getCoordinate(),$cell);
|
public function deleteCacheData($pCoord)
|
||||||
} // function updateCacheData()
|
{
|
||||||
|
if ($pCoord === $this->currentObjectID && !is_null($this->currentObject)) {
|
||||||
|
$this->currentObject->detach();
|
||||||
/**
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
* Delete a cell in cache identified by coordinate address
|
}
|
||||||
*
|
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
if (is_object($this->cellCache[$pCoord])) {
|
||||||
* @throws PHPExcel_Exception
|
$this->cellCache[$pCoord]->detach();
|
||||||
*/
|
unset($this->cellCache[$pCoord]);
|
||||||
public function deleteCacheData($pCoord) {
|
}
|
||||||
if ($pCoord === $this->_currentObjectID && !is_null($this->_currentObject)) {
|
$this->currentCellIsDirty = false;
|
||||||
$this->_currentObject->detach();
|
}
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
|
||||||
}
|
/**
|
||||||
|
* Get a list of all cell addresses currently held in cache
|
||||||
if (is_object($this->_cellCache[$pCoord])) {
|
*
|
||||||
$this->_cellCache[$pCoord]->detach();
|
* @return string[]
|
||||||
unset($this->_cellCache[$pCoord]);
|
*/
|
||||||
}
|
public function getCellList()
|
||||||
$this->_currentCellIsDirty = false;
|
{
|
||||||
} // function deleteCacheData()
|
return array_keys($this->cellCache);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all cell addresses currently held in cache
|
* Sort the list of all cell addresses currently held in cache by row and column
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getCellList() {
|
public function getSortedCellList()
|
||||||
return array_keys($this->_cellCache);
|
{
|
||||||
} // function getCellList()
|
$sortKeys = array();
|
||||||
|
foreach ($this->getCellList() as $coord) {
|
||||||
|
sscanf($coord, '%[A-Z]%d', $column, $row);
|
||||||
/**
|
$sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
|
||||||
* Sort the list of all cell addresses currently held in cache by row and column
|
}
|
||||||
*
|
ksort($sortKeys);
|
||||||
* @return string[]
|
|
||||||
*/
|
return array_values($sortKeys);
|
||||||
public function getSortedCellList() {
|
}
|
||||||
$sortKeys = array();
|
|
||||||
foreach ($this->getCellList() as $coord) {
|
/**
|
||||||
sscanf($coord,'%[A-Z]%d', $column, $row);
|
* Get highest worksheet column and highest row that have cell records
|
||||||
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
|
*
|
||||||
}
|
* @return array Highest column name and highest row number
|
||||||
ksort($sortKeys);
|
*/
|
||||||
|
public function getHighestRowAndColumn()
|
||||||
return array_values($sortKeys);
|
{
|
||||||
} // function sortCellList()
|
// 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);
|
||||||
* Get highest worksheet column and highest row that have cell records
|
$row[$r] = $r;
|
||||||
*
|
$col[$c] = strlen($c).$c;
|
||||||
* @return array Highest column name and highest row number
|
}
|
||||||
*/
|
if (!empty($row)) {
|
||||||
public function getHighestRowAndColumn()
|
// Determine highest column and row
|
||||||
{
|
$highestRow = max($row);
|
||||||
// Lookup highest column and highest row
|
$highestColumn = substr(max($col), 1);
|
||||||
$col = array('A' => '1A');
|
}
|
||||||
$row = array(1);
|
|
||||||
foreach ($this->getCellList() as $coord) {
|
return array(
|
||||||
sscanf($coord,'%[A-Z]%d', $c, $r);
|
'row' => $highestRow,
|
||||||
$row[$r] = $r;
|
'column' => $highestColumn
|
||||||
$col[$c] = strlen($c).$c;
|
);
|
||||||
}
|
}
|
||||||
if (!empty($row)) {
|
|
||||||
// Determine highest column and row
|
/**
|
||||||
$highestRow = max($row);
|
* Return the cell address of the currently active cell object
|
||||||
$highestColumn = substr(max($col),1);
|
*
|
||||||
}
|
* @return string
|
||||||
|
*/
|
||||||
return array( 'row' => $highestRow,
|
public function getCurrentAddress()
|
||||||
'column' => $highestColumn
|
{
|
||||||
);
|
return $this->currentObjectID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Return the column address of the currently active cell object
|
||||||
* Return the cell address of the currently active cell object
|
*
|
||||||
*
|
* @return string
|
||||||
* @return string
|
*/
|
||||||
*/
|
public function getCurrentColumn()
|
||||||
public function getCurrentAddress()
|
{
|
||||||
{
|
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||||
return $this->_currentObjectID;
|
return $column;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the column address of the currently active cell object
|
* Return the row address of the currently active cell object
|
||||||
*
|
*
|
||||||
* @return string
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getCurrentColumn()
|
public function getCurrentRow()
|
||||||
{
|
{
|
||||||
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
|
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||||
return $column;
|
return (integer) $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the row address of the currently active cell object
|
* Get highest worksheet column
|
||||||
*
|
*
|
||||||
* @return integer
|
* @param string $row Return the highest column for the specified row,
|
||||||
*/
|
* or the highest column of any row if no row number is passed
|
||||||
public function getCurrentRow()
|
* @return string Highest column name
|
||||||
{
|
*/
|
||||||
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
|
public function getHighestColumn($row = null)
|
||||||
return (integer) $row;
|
{
|
||||||
}
|
if ($row == null) {
|
||||||
|
$colRow = $this->getHighestRowAndColumn();
|
||||||
/**
|
return $colRow['column'];
|
||||||
* Get highest worksheet column
|
}
|
||||||
*
|
|
||||||
* @param string $row Return the highest column for the specified row,
|
$columnList = array(1);
|
||||||
* or the highest column of any row if no row number is passed
|
foreach ($this->getCellList() as $coord) {
|
||||||
* @return string Highest column name
|
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||||
*/
|
if ($r != $row) {
|
||||||
public function getHighestColumn($row = null)
|
continue;
|
||||||
{
|
}
|
||||||
if ($row == null) {
|
$columnList[] = PHPExcel_Cell::columnIndexFromString($c);
|
||||||
$colRow = $this->getHighestRowAndColumn();
|
}
|
||||||
return $colRow['column'];
|
return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$columnList = array(1);
|
/**
|
||||||
foreach ($this->getCellList() as $coord) {
|
* Get highest worksheet row
|
||||||
sscanf($coord,'%[A-Z]%d', $c, $r);
|
*
|
||||||
if ($r != $row) {
|
* @param string $column Return the highest row for the specified column,
|
||||||
continue;
|
* or the highest row of any column if no column letter is passed
|
||||||
}
|
* @return int Highest row number
|
||||||
$columnList[] = PHPExcel_Cell::columnIndexFromString($c);
|
*/
|
||||||
}
|
public function getHighestRow($column = null)
|
||||||
return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
|
{
|
||||||
}
|
if ($column == null) {
|
||||||
|
$colRow = $this->getHighestRowAndColumn();
|
||||||
/**
|
return $colRow['row'];
|
||||||
* Get highest worksheet row
|
}
|
||||||
*
|
|
||||||
* @param string $column Return the highest row for the specified column,
|
$rowList = array(0);
|
||||||
* or the highest row of any column if no column letter is passed
|
foreach ($this->getCellList() as $coord) {
|
||||||
* @return int Highest row number
|
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||||
*/
|
if ($c != $column) {
|
||||||
public function getHighestRow($column = null)
|
continue;
|
||||||
{
|
}
|
||||||
if ($column == null) {
|
$rowList[] = $r;
|
||||||
$colRow = $this->getHighestRowAndColumn();
|
}
|
||||||
return $colRow['row'];
|
|
||||||
}
|
return max($rowList);
|
||||||
|
}
|
||||||
$rowList = array(0);
|
|
||||||
foreach ($this->getCellList() as $coord) {
|
/**
|
||||||
sscanf($coord,'%[A-Z]%d', $c, $r);
|
* Generate a unique ID for cache referencing
|
||||||
if ($c != $column) {
|
*
|
||||||
continue;
|
* @return string Unique Reference
|
||||||
}
|
*/
|
||||||
$rowList[] = $r;
|
protected function getUniqueID()
|
||||||
}
|
{
|
||||||
|
if (function_exists('posix_getpid')) {
|
||||||
return max($rowList);
|
$baseUnique = posix_getpid();
|
||||||
}
|
} else {
|
||||||
|
$baseUnique = mt_rand();
|
||||||
|
}
|
||||||
/**
|
return uniqid($baseUnique, true);
|
||||||
* Generate a unique ID for cache referencing
|
}
|
||||||
*
|
|
||||||
* @return string Unique Reference
|
/**
|
||||||
*/
|
* Clone the cell collection
|
||||||
protected function _getUniqueID() {
|
*
|
||||||
if (function_exists('posix_getpid')) {
|
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||||
$baseUnique = posix_getpid();
|
* @return void
|
||||||
} else {
|
*/
|
||||||
$baseUnique = mt_rand();
|
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||||
}
|
{
|
||||||
return uniqid($baseUnique,true);
|
$this->currentCellIsDirty;
|
||||||
}
|
$this->storeData();
|
||||||
|
|
||||||
/**
|
$this->parent = $parent;
|
||||||
* Clone the cell collection
|
if (($this->currentObject !== null) && (is_object($this->currentObject))) {
|
||||||
*
|
$this->currentObject->attach($this);
|
||||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
}
|
||||||
* @return void
|
} // function copyCellCollection()
|
||||||
*/
|
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
/**
|
||||||
$this->_currentCellIsDirty;
|
* Remove a row, deleting all cells in that row
|
||||||
$this->_storeData();
|
*
|
||||||
|
* @param string $row Row number to remove
|
||||||
$this->_parent = $parent;
|
* @return void
|
||||||
if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
|
*/
|
||||||
$this->_currentObject->attach($this);
|
public function removeRow($row)
|
||||||
}
|
{
|
||||||
} // function copyCellCollection()
|
foreach ($this->getCellList() as $coord) {
|
||||||
|
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||||
/**
|
if ($r == $row) {
|
||||||
* Remove a row, deleting all cells in that row
|
$this->deleteCacheData($coord);
|
||||||
*
|
}
|
||||||
* @param string $row Row number to remove
|
}
|
||||||
* @return void
|
}
|
||||||
*/
|
|
||||||
public function removeRow($row) {
|
/**
|
||||||
foreach ($this->getCellList() as $coord) {
|
* Remove a column, deleting all cells in that column
|
||||||
sscanf($coord,'%[A-Z]%d', $c, $r);
|
*
|
||||||
if ($r == $row) {
|
* @param string $column Column ID to remove
|
||||||
$this->deleteCacheData($coord);
|
* @return void
|
||||||
}
|
*/
|
||||||
}
|
public function removeColumn($column)
|
||||||
}
|
{
|
||||||
|
foreach ($this->getCellList() as $coord) {
|
||||||
/**
|
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||||
* Remove a column, deleting all cells in that column
|
if ($c == $column) {
|
||||||
*
|
$this->deleteCacheData($coord);
|
||||||
* @param string $column Column ID to remove
|
}
|
||||||
* @return void
|
}
|
||||||
*/
|
}
|
||||||
public function removeColumn($column) {
|
|
||||||
foreach ($this->getCellList() as $coord) {
|
/**
|
||||||
sscanf($coord,'%[A-Z]%d', $c, $r);
|
* Identify whether the caching method is currently available
|
||||||
if ($c == $column) {
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
$this->deleteCacheData($coord);
|
*
|
||||||
}
|
* @return boolean
|
||||||
}
|
*/
|
||||||
}
|
public static function cacheMethodIsAvailable()
|
||||||
|
{
|
||||||
/**
|
return true;
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,219 +1,208 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_DiscISAM
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_DiscISAM
|
/**
|
||||||
*
|
* Name of the file for this cache
|
||||||
* @category PHPExcel
|
*
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @var string
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
*/
|
||||||
*/
|
private $fileName = null;
|
||||||
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
|
||||||
|
/**
|
||||||
/**
|
* File handle for this cache file
|
||||||
* Name of the file for this cache
|
*
|
||||||
*
|
* @var resource
|
||||||
* @var string
|
*/
|
||||||
*/
|
private $fileHandle = null;
|
||||||
private $_fileName = NULL;
|
|
||||||
|
/**
|
||||||
/**
|
* Directory/Folder where the cache file is located
|
||||||
* File handle for this cache file
|
*
|
||||||
*
|
* @var string
|
||||||
* @var resource
|
*/
|
||||||
*/
|
private $cacheDirectory = null;
|
||||||
private $_fileHandle = NULL;
|
|
||||||
|
/**
|
||||||
/**
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
* Directory/Folder where the cache file is located
|
* and the 'nullify' the current cell object
|
||||||
*
|
*
|
||||||
* @var string
|
* @return void
|
||||||
*/
|
* @throws PHPExcel_Exception
|
||||||
private $_cacheDirectory = NULL;
|
*/
|
||||||
|
protected function storeData()
|
||||||
|
{
|
||||||
/**
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
$this->currentObject->detach();
|
||||||
* and the 'nullify' the current cell object
|
|
||||||
*
|
fseek($this->fileHandle, 0, SEEK_END);
|
||||||
* @return void
|
|
||||||
* @throws PHPExcel_Exception
|
$this->cellCache[$this->currentObjectID] = array(
|
||||||
*/
|
'ptr' => ftell($this->fileHandle),
|
||||||
protected function _storeData() {
|
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
);
|
||||||
$this->_currentObject->detach();
|
$this->currentCellIsDirty = false;
|
||||||
|
}
|
||||||
fseek($this->_fileHandle,0,SEEK_END);
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
|
}
|
||||||
$this->_cellCache[$this->_currentObjectID] = array(
|
|
||||||
'ptr' => ftell($this->_fileHandle),
|
/**
|
||||||
'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject))
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
);
|
*
|
||||||
$this->_currentCellIsDirty = false;
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
}
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
* @return PHPExcel_Cell
|
||||||
} // function _storeData()
|
* @throws PHPExcel_Exception
|
||||||
|
*/
|
||||||
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
/**
|
{
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
*
|
$this->storeData();
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
}
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
|
||||||
* @return PHPExcel_Cell
|
$this->currentObjectID = $pCoord;
|
||||||
* @throws PHPExcel_Exception
|
$this->currentObject = $cell;
|
||||||
*/
|
$this->currentCellIsDirty = true;
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
return $cell;
|
||||||
$this->_storeData();
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
$this->_currentObjectID = $pCoord;
|
* Get cell at a specific coordinate
|
||||||
$this->_currentObject = $cell;
|
*
|
||||||
$this->_currentCellIsDirty = true;
|
* @param string $pCoord Coordinate of the cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
return $cell;
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
} // function addCacheData()
|
*/
|
||||||
|
public function getCacheData($pCoord)
|
||||||
|
{
|
||||||
/**
|
if ($pCoord === $this->currentObjectID) {
|
||||||
* Get cell at a specific coordinate
|
return $this->currentObject;
|
||||||
*
|
}
|
||||||
* @param string $pCoord Coordinate of the cell
|
$this->storeData();
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
// Check if the entry that has been requested actually exists
|
||||||
*/
|
if (!isset($this->cellCache[$pCoord])) {
|
||||||
public function getCacheData($pCoord) {
|
// Return null if requested entry doesn't exist in cache
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
return null;
|
||||||
return $this->_currentObject;
|
}
|
||||||
}
|
|
||||||
$this->_storeData();
|
// Set current entry to the requested entry
|
||||||
|
$this->currentObjectID = $pCoord;
|
||||||
// Check if the entry that has been requested actually exists
|
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Re-attach this as the cell's parent
|
||||||
return null;
|
$this->currentObject->attach($this);
|
||||||
}
|
|
||||||
|
// Return requested entry
|
||||||
// Set current entry to the requested entry
|
return $this->currentObject;
|
||||||
$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
|
* Get a list of all cell addresses currently held in cache
|
||||||
$this->_currentObject->attach($this);
|
*
|
||||||
|
* @return string[]
|
||||||
// Return requested entry
|
*/
|
||||||
return $this->_currentObject;
|
public function getCellList()
|
||||||
} // function getCacheData()
|
{
|
||||||
|
if ($this->currentObjectID !== null) {
|
||||||
|
$this->storeData();
|
||||||
/**
|
}
|
||||||
* Get a list of all cell addresses currently held in cache
|
|
||||||
*
|
return parent::getCellList();
|
||||||
* @return string[]
|
}
|
||||||
*/
|
|
||||||
public function getCellList() {
|
/**
|
||||||
if ($this->_currentObjectID !== null) {
|
* Clone the cell collection
|
||||||
$this->_storeData();
|
*
|
||||||
}
|
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||||
|
*/
|
||||||
return parent::getCellList();
|
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||||
}
|
{
|
||||||
|
parent::copyCellCollection($parent);
|
||||||
|
// Get a new id for the new file name
|
||||||
/**
|
$baseUnique = $this->getUniqueID();
|
||||||
* Clone the cell collection
|
$newFileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||||
*
|
// Copy the existing cell cache file
|
||||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
copy($this->fileName, $newFileName);
|
||||||
* @return void
|
$this->fileName = $newFileName;
|
||||||
*/
|
// Open the copied cell cache file
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
$this->fileHandle = fopen($this->fileName, 'a+');
|
||||||
parent::copyCellCollection($parent);
|
}
|
||||||
// Get a new id for the new file name
|
|
||||||
$baseUnique = $this->_getUniqueID();
|
/**
|
||||||
$newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
* Clear the cell collection and disconnect from our parent
|
||||||
// Copy the existing cell cache file
|
*
|
||||||
copy ($this->_fileName,$newFileName);
|
*/
|
||||||
$this->_fileName = $newFileName;
|
public function unsetWorksheetCells()
|
||||||
// Open the copied cell cache file
|
{
|
||||||
$this->_fileHandle = fopen($this->_fileName,'a+');
|
if (!is_null($this->currentObject)) {
|
||||||
} // function copyCellCollection()
|
$this->currentObject->detach();
|
||||||
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
|
}
|
||||||
/**
|
$this->cellCache = array();
|
||||||
* Clear the cell collection and disconnect from our parent
|
|
||||||
*
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
* @return void
|
$this->parent = null;
|
||||||
*/
|
|
||||||
public function unsetWorksheetCells() {
|
// Close down the temporary cache file
|
||||||
if(!is_null($this->_currentObject)) {
|
$this->__destruct();
|
||||||
$this->_currentObject->detach();
|
}
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
|
||||||
}
|
/**
|
||||||
$this->_cellCache = array();
|
* Initialise this new cell collection
|
||||||
|
*
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||||
$this->_parent = null;
|
* @param array of mixed $arguments Additional initialisation arguments
|
||||||
|
*/
|
||||||
// Close down the temporary cache file
|
public function __construct(PHPExcel_Worksheet $parent, $arguments)
|
||||||
$this->__destruct();
|
{
|
||||||
} // function unsetWorksheetCells()
|
$this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null))
|
||||||
|
? $arguments['dir']
|
||||||
|
: PHPExcel_Shared_File::sys_get_temp_dir();
|
||||||
/**
|
|
||||||
* Initialise this new cell collection
|
parent::__construct($parent);
|
||||||
*
|
if (is_null($this->fileHandle)) {
|
||||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
$baseUnique = $this->getUniqueID();
|
||||||
* @param array of mixed $arguments Additional initialisation arguments
|
$this->fileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||||
*/
|
$this->fileHandle = fopen($this->fileName, 'a+');
|
||||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
}
|
||||||
$this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
|
}
|
||||||
? $arguments['dir']
|
|
||||||
: PHPExcel_Shared_File::sys_get_temp_dir();
|
/**
|
||||||
|
* Destroy this cell collection
|
||||||
parent::__construct($parent);
|
*/
|
||||||
if (is_null($this->_fileHandle)) {
|
public function __destruct()
|
||||||
$baseUnique = $this->_getUniqueID();
|
{
|
||||||
$this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
if (!is_null($this->fileHandle)) {
|
||||||
$this->_fileHandle = fopen($this->_fileName,'a+');
|
fclose($this->fileHandle);
|
||||||
}
|
unlink($this->fileName);
|
||||||
} // function __construct()
|
}
|
||||||
|
$this->fileHandle = null;
|
||||||
|
}
|
||||||
/**
|
}
|
||||||
* Destroy this cell collection
|
|
||||||
*/
|
|
||||||
public function __destruct() {
|
|
||||||
if (!is_null($this->_fileHandle)) {
|
|
||||||
fclose($this->_fileHandle);
|
|
||||||
unlink($this->_fileName);
|
|
||||||
}
|
|
||||||
$this->_fileHandle = null;
|
|
||||||
} // function __destruct()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_CachedObjectStorage_ICache
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,93 +21,83 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_CachedObjectStorage_ICache
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_CachedObjectStorage
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
interface PHPExcel_CachedObjectStorage_ICache
|
interface PHPExcel_CachedObjectStorage_ICache
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return PHPExcel_Cell
|
* @return PHPExcel_Cell
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell);
|
public function addCacheData($pCoord, PHPExcel_Cell $cell);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache
|
* Add or Update a cell in cache
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return PHPExcel_Cell
|
* @return PHPExcel_Cell
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function updateCacheData(PHPExcel_Cell $cell);
|
public function updateCacheData(PHPExcel_Cell $cell);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a cell from cache identified by coordinate address
|
* Fetch a cell from cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to retrieve
|
* @param string $pCoord Coordinate address of the cell to retrieve
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord);
|
public function getCacheData($pCoord);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a cell in cache identified by coordinate address
|
* Delete a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function deleteCacheData($pCoord);
|
public function deleteCacheData($pCoord);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isDataSet($pCoord);
|
public function isDataSet($pCoord);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all cell addresses currently held in cache
|
* Get a list of all cell addresses currently held in cache
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getCellList();
|
public function getCellList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of all cell addresses currently held in cache sorted by column and row
|
* Get the list of all cell addresses currently held in cache sorted by column and row
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getSortedCellList();
|
public function getSortedCellList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone the cell collection
|
* Clone the cell collection
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent);
|
public function copyCellCollection(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();
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,152 +1,149 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_Igbinary
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_Igbinary
|
/**
|
||||||
*
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
* @category PHPExcel
|
* and the 'nullify' the current cell object
|
||||||
* @package PHPExcel_CachedObjectStorage
|
*
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @return void
|
||||||
*/
|
* @throws PHPExcel_Exception
|
||||||
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
*/
|
||||||
|
protected function storeData()
|
||||||
/**
|
{
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
* and the 'nullify' the current cell object
|
$this->currentObject->detach();
|
||||||
*
|
|
||||||
* @return void
|
$this->cellCache[$this->currentObjectID] = igbinary_serialize($this->currentObject);
|
||||||
* @throws PHPExcel_Exception
|
$this->currentCellIsDirty = false;
|
||||||
*/
|
}
|
||||||
protected function _storeData() {
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
} // function _storeData()
|
||||||
$this->_currentObject->detach();
|
|
||||||
|
|
||||||
$this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
|
/**
|
||||||
$this->_currentCellIsDirty = false;
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
}
|
*
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
} // function _storeData()
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
/**
|
*/
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
$this->storeData();
|
||||||
* @return PHPExcel_Cell
|
}
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
*/
|
$this->currentObjectID = $pCoord;
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
$this->currentObject = $cell;
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
$this->currentCellIsDirty = true;
|
||||||
$this->_storeData();
|
|
||||||
}
|
return $cell;
|
||||||
|
} // function addCacheData()
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
$this->_currentObject = $cell;
|
|
||||||
$this->_currentCellIsDirty = true;
|
/**
|
||||||
|
* Get cell at a specific coordinate
|
||||||
return $cell;
|
*
|
||||||
} // function addCacheData()
|
* @param string $pCoord Coordinate of the cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
/**
|
*/
|
||||||
* Get cell at a specific coordinate
|
public function getCacheData($pCoord)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate of the cell
|
if ($pCoord === $this->currentObjectID) {
|
||||||
* @throws PHPExcel_Exception
|
return $this->currentObject;
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
}
|
||||||
*/
|
$this->storeData();
|
||||||
public function getCacheData($pCoord) {
|
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
// Check if the entry that has been requested actually exists
|
||||||
return $this->_currentObject;
|
if (!isset($this->cellCache[$pCoord])) {
|
||||||
}
|
// Return null if requested entry doesn't exist in cache
|
||||||
$this->_storeData();
|
return null;
|
||||||
|
}
|
||||||
// Check if the entry that has been requested actually exists
|
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
// Set current entry to the requested entry
|
||||||
// Return null if requested entry doesn't exist in cache
|
$this->currentObjectID = $pCoord;
|
||||||
return null;
|
$this->currentObject = igbinary_unserialize($this->cellCache[$pCoord]);
|
||||||
}
|
// Re-attach this as the cell's parent
|
||||||
|
$this->currentObject->attach($this);
|
||||||
// Set current entry to the requested entry
|
|
||||||
$this->_currentObjectID = $pCoord;
|
// Return requested entry
|
||||||
$this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);
|
return $this->currentObject;
|
||||||
// Re-attach this as the cell's parent
|
} // function getCacheData()
|
||||||
$this->_currentObject->attach($this);
|
|
||||||
|
|
||||||
// Return requested entry
|
/**
|
||||||
return $this->_currentObject;
|
* Get a list of all cell addresses currently held in cache
|
||||||
} // function getCacheData()
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
/**
|
public function getCellList()
|
||||||
* Get a list of all cell addresses currently held in cache
|
{
|
||||||
*
|
if ($this->currentObjectID !== null) {
|
||||||
* @return string[]
|
$this->storeData();
|
||||||
*/
|
}
|
||||||
public function getCellList() {
|
|
||||||
if ($this->_currentObjectID !== null) {
|
return parent::getCellList();
|
||||||
$this->_storeData();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return parent::getCellList();
|
/**
|
||||||
}
|
* Clear the cell collection and disconnect from our parent
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
/**
|
*/
|
||||||
* Clear the cell collection and disconnect from our parent
|
public function unsetWorksheetCells()
|
||||||
*
|
{
|
||||||
* @return void
|
if (!is_null($this->currentObject)) {
|
||||||
*/
|
$this->currentObject->detach();
|
||||||
public function unsetWorksheetCells() {
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
if(!is_null($this->_currentObject)) {
|
}
|
||||||
$this->_currentObject->detach();
|
$this->cellCache = array();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
|
||||||
}
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_cellCache = array();
|
$this->parent = null;
|
||||||
|
} // function unsetWorksheetCells()
|
||||||
// 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
|
||||||
/**
|
*
|
||||||
* Identify whether the caching method is currently available
|
* @return boolean
|
||||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
*/
|
||||||
*
|
public static function cacheMethodIsAvailable()
|
||||||
* @return boolean
|
{
|
||||||
*/
|
if (!function_exists('igbinary_serialize')) {
|
||||||
public static function cacheMethodIsAvailable() {
|
return false;
|
||||||
if (!function_exists('igbinary_serialize')) {
|
}
|
||||||
return false;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,312 +1,308 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_Memcache
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_Memcache
|
/**
|
||||||
*
|
* Prefix used to uniquely identify cache data for this worksheet
|
||||||
* @category PHPExcel
|
*
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @var string
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
*/
|
||||||
*/
|
private $cachePrefix = null;
|
||||||
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
|
||||||
|
/**
|
||||||
/**
|
* Cache timeout
|
||||||
* Prefix used to uniquely identify cache data for this worksheet
|
*
|
||||||
*
|
* @var integer
|
||||||
* @var string
|
*/
|
||||||
*/
|
private $cacheTime = 600;
|
||||||
private $_cachePrefix = null;
|
|
||||||
|
/**
|
||||||
/**
|
* Memcache interface
|
||||||
* Cache timeout
|
*
|
||||||
*
|
* @var resource
|
||||||
* @var integer
|
*/
|
||||||
*/
|
private $memcache = null;
|
||||||
private $_cacheTime = 600;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Memcache interface
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
*
|
* and the 'nullify' the current cell object
|
||||||
* @var resource
|
*
|
||||||
*/
|
* @return void
|
||||||
private $_memcache = null;
|
* @throws PHPExcel_Exception
|
||||||
|
*/
|
||||||
|
protected function storeData()
|
||||||
/**
|
{
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
* and the 'nullify' the current cell object
|
$this->currentObject->detach();
|
||||||
*
|
|
||||||
* @return void
|
$obj = serialize($this->currentObject);
|
||||||
* @throws PHPExcel_Exception
|
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)) {
|
||||||
protected function _storeData() {
|
$this->__destruct();
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
throw new PHPExcel_Exception("Failed to store cell {$this->currentObjectID} in MemCache");
|
||||||
$this->_currentObject->detach();
|
}
|
||||||
|
}
|
||||||
$obj = serialize($this->_currentObject);
|
$this->currentCellIsDirty = false;
|
||||||
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->currentObjectID = $this->currentObject = null;
|
||||||
$this->__destruct();
|
} // function _storeData()
|
||||||
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
|
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
$this->_currentCellIsDirty = false;
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
}
|
*
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
} // function _storeData()
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
/**
|
*/
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
$this->storeData();
|
||||||
* @return PHPExcel_Cell
|
}
|
||||||
* @throws PHPExcel_Exception
|
$this->cellCache[$pCoord] = true;
|
||||||
*/
|
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
$this->currentObjectID = $pCoord;
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
$this->currentObject = $cell;
|
||||||
$this->_storeData();
|
$this->currentCellIsDirty = true;
|
||||||
}
|
|
||||||
$this->_cellCache[$pCoord] = true;
|
return $cell;
|
||||||
|
} // function addCacheData()
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
$this->_currentObject = $cell;
|
|
||||||
$this->_currentCellIsDirty = true;
|
/**
|
||||||
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
return $cell;
|
*
|
||||||
} // function addCacheData()
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
|
* @return boolean
|
||||||
|
* @return boolean
|
||||||
/**
|
*/
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
public function isDataSet($pCoord)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
// Check if the requested entry is the current object, or exists in the cache
|
||||||
* @return boolean
|
if (parent::isDataSet($pCoord)) {
|
||||||
* @return boolean
|
if ($this->currentObjectID == $pCoord) {
|
||||||
*/
|
return true;
|
||||||
public function isDataSet($pCoord) {
|
}
|
||||||
// Check if the requested entry is the current object, or exists in the cache
|
// Check if the requested entry still exists in Memcache
|
||||||
if (parent::isDataSet($pCoord)) {
|
$success = $this->memcache->get($this->cachePrefix.$pCoord.'.cache');
|
||||||
if ($this->_currentObjectID == $pCoord) {
|
if ($success === false) {
|
||||||
return true;
|
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||||
}
|
parent::deleteCacheData($pCoord);
|
||||||
// Check if the requested entry still exists in Memcache
|
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
|
||||||
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
}
|
||||||
if ($success === false) {
|
return true;
|
||||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
}
|
||||||
parent::deleteCacheData($pCoord);
|
return false;
|
||||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
|
}
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
/**
|
||||||
return false;
|
* Get cell at a specific coordinate
|
||||||
} // function isDataSet()
|
*
|
||||||
|
* @param string $pCoord Coordinate of the cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
/**
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
* Get cell at a specific coordinate
|
*/
|
||||||
*
|
public function getCacheData($pCoord)
|
||||||
* @param string $pCoord Coordinate of the cell
|
{
|
||||||
* @throws PHPExcel_Exception
|
if ($pCoord === $this->currentObjectID) {
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
return $this->currentObject;
|
||||||
*/
|
}
|
||||||
public function getCacheData($pCoord) {
|
$this->storeData();
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
|
||||||
return $this->_currentObject;
|
// Check if the entry that has been requested actually exists
|
||||||
}
|
if (parent::isDataSet($pCoord)) {
|
||||||
$this->_storeData();
|
$obj = $this->memcache->get($this->cachePrefix . $pCoord . '.cache');
|
||||||
|
if ($obj === false) {
|
||||||
// Check if the entry that has been requested actually exists
|
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||||
if (parent::isDataSet($pCoord)) {
|
parent::deleteCacheData($pCoord);
|
||||||
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
throw new PHPExcel_Exception("Cell entry {$pCoord} no longer exists in MemCache");
|
||||||
if ($obj === false) {
|
}
|
||||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
} else {
|
||||||
parent::deleteCacheData($pCoord);
|
// Return null if requested entry doesn't exist in cache
|
||||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Set current entry to the requested entry
|
||||||
return null;
|
$this->currentObjectID = $pCoord;
|
||||||
}
|
$this->currentObject = unserialize($obj);
|
||||||
|
// Re-attach this as the cell's parent
|
||||||
// Set current entry to the requested entry
|
$this->currentObject->attach($this);
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
$this->_currentObject = unserialize($obj);
|
// Return requested entry
|
||||||
// Re-attach this as the cell's parent
|
return $this->currentObject;
|
||||||
$this->_currentObject->attach($this);
|
}
|
||||||
|
|
||||||
// Return requested entry
|
/**
|
||||||
return $this->_currentObject;
|
* Get a list of all cell addresses currently held in cache
|
||||||
} // function getCacheData()
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
/**
|
public function getCellList()
|
||||||
* Get a list of all cell addresses currently held in cache
|
{
|
||||||
*
|
if ($this->currentObjectID !== null) {
|
||||||
* @return string[]
|
$this->storeData();
|
||||||
*/
|
}
|
||||||
public function getCellList() {
|
|
||||||
if ($this->_currentObjectID !== null) {
|
return parent::getCellList();
|
||||||
$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
|
||||||
/**
|
*/
|
||||||
* Delete a cell in cache identified by coordinate address
|
public function deleteCacheData($pCoord)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
// Delete the entry from Memcache
|
||||||
* @throws PHPExcel_Exception
|
$this->memcache->delete($this->cachePrefix . $pCoord . '.cache');
|
||||||
*/
|
|
||||||
public function deleteCacheData($pCoord) {
|
// Delete the entry from our cell address array
|
||||||
// Delete the entry from Memcache
|
parent::deleteCacheData($pCoord);
|
||||||
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
|
}
|
||||||
|
|
||||||
// Delete the entry from our cell address array
|
/**
|
||||||
parent::deleteCacheData($pCoord);
|
* Clone the cell collection
|
||||||
} // function deleteCacheData()
|
*
|
||||||
|
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||||
|
* @return void
|
||||||
/**
|
*/
|
||||||
* Clone the cell collection
|
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||||
*
|
{
|
||||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
parent::copyCellCollection($parent);
|
||||||
* @return void
|
// Get a new id for the new file name
|
||||||
*/
|
$baseUnique = $this->getUniqueID();
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||||
parent::copyCellCollection($parent);
|
$cacheList = $this->getCellList();
|
||||||
// Get a new id for the new file name
|
foreach ($cacheList as $cellID) {
|
||||||
$baseUnique = $this->_getUniqueID();
|
if ($cellID != $this->currentObjectID) {
|
||||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
$obj = $this->memcache->get($this->cachePrefix.$cellID.'.cache');
|
||||||
$cacheList = $this->getCellList();
|
if ($obj === false) {
|
||||||
foreach($cacheList as $cellID) {
|
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||||
if ($cellID != $this->_currentObjectID) {
|
parent::deleteCacheData($cellID);
|
||||||
$obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');
|
throw new PHPExcel_Exception("Cell entry {$cellID} no longer exists in MemCache");
|
||||||
if ($obj === false) {
|
}
|
||||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
if (!$this->memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->cacheTime)) {
|
||||||
parent::deleteCacheData($cellID);
|
$this->__destruct();
|
||||||
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in MemCache');
|
throw new PHPExcel_Exception("Failed to store cell {$cellID} 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;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
$this->_cachePrefix = $newCachePrefix;
|
* Clear the cell collection and disconnect from our parent
|
||||||
} // function copyCellCollection()
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
/**
|
public function unsetWorksheetCells()
|
||||||
* Clear the cell collection and disconnect from our parent
|
{
|
||||||
*
|
if (!is_null($this->currentObject)) {
|
||||||
* @return void
|
$this->currentObject->detach();
|
||||||
*/
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
public function unsetWorksheetCells() {
|
}
|
||||||
if(!is_null($this->_currentObject)) {
|
|
||||||
$this->_currentObject->detach();
|
// Flush the Memcache cache
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->__destruct();
|
||||||
}
|
|
||||||
|
$this->cellCache = array();
|
||||||
// Flush the Memcache cache
|
|
||||||
$this->__destruct();
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
|
$this->parent = null;
|
||||||
$this->_cellCache = array();
|
}
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
/**
|
||||||
$this->_parent = null;
|
* Initialise this new cell collection
|
||||||
} // function unsetWorksheetCells()
|
*
|
||||||
|
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||||
|
* @param array of mixed $arguments Additional initialisation arguments
|
||||||
/**
|
*/
|
||||||
* Initialise this new cell collection
|
public function __construct(PHPExcel_Worksheet $parent, $arguments)
|
||||||
*
|
{
|
||||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
||||||
* @param array of mixed $arguments Additional initialisation arguments
|
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
||||||
*/
|
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
|
||||||
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
if (is_null($this->cachePrefix)) {
|
||||||
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
$baseUnique = $this->getUniqueID();
|
||||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||||
|
|
||||||
if (is_null($this->_cachePrefix)) {
|
// Set a new Memcache object and connect to the Memcache server
|
||||||
$baseUnique = $this->_getUniqueID();
|
$this->memcache = new Memcache();
|
||||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
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}");
|
||||||
// Set a new Memcache object and connect to the Memcache server
|
}
|
||||||
$this->_memcache = new Memcache();
|
$this->cacheTime = $cacheTime;
|
||||||
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);
|
parent::__construct($parent);
|
||||||
}
|
}
|
||||||
$this->_cacheTime = $cacheTime;
|
}
|
||||||
|
|
||||||
parent::__construct($parent);
|
/**
|
||||||
}
|
* Memcache error handler
|
||||||
} // function __construct()
|
*
|
||||||
|
* @param string $host Memcache server
|
||||||
|
* @param integer $port Memcache port
|
||||||
/**
|
* @throws PHPExcel_Exception
|
||||||
* Memcache error handler
|
*/
|
||||||
*
|
public function failureCallback($host, $port)
|
||||||
* @param string $host Memcache server
|
{
|
||||||
* @param integer $port Memcache port
|
throw new PHPExcel_Exception("memcache {$host}:{$port} failed");
|
||||||
* @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();
|
||||||
* Destroy this cell collection
|
foreach ($cacheList as $cellID) {
|
||||||
*/
|
$this->memcache->delete($this->cachePrefix.$cellID . '.cache');
|
||||||
public function __destruct() {
|
}
|
||||||
$cacheList = $this->getCellList();
|
}
|
||||||
foreach($cacheList as $cellID) {
|
|
||||||
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
|
/**
|
||||||
}
|
* Identify whether the caching method is currently available
|
||||||
} // function __destruct()
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
/**
|
* @return boolean
|
||||||
* Identify whether the caching method is currently available
|
*/
|
||||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
public static function cacheMethodIsAvailable()
|
||||||
*
|
{
|
||||||
* @return boolean
|
if (!function_exists('memcache_add')) {
|
||||||
*/
|
return false;
|
||||||
public static function cacheMethodIsAvailable() {
|
}
|
||||||
if (!function_exists('memcache_add')) {
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,125 +1,118 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_Memory
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_Memory
|
/**
|
||||||
*
|
* Dummy method callable from CacheBase, but unused by Memory cache
|
||||||
* @category PHPExcel
|
*
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @return void
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
*/
|
||||||
*/
|
protected function storeData()
|
||||||
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
{
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Dummy method callable from CacheBase, but unused by Memory cache
|
/**
|
||||||
*
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
* @return void
|
*
|
||||||
*/
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
protected function _storeData() {
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
} // function _storeData()
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
/**
|
*/
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
$this->cellCache[$pCoord] = $cell;
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
|
||||||
* @return PHPExcel_Cell
|
// Set current entry to the new/updated entry
|
||||||
* @throws PHPExcel_Exception
|
$this->currentObjectID = $pCoord;
|
||||||
*/
|
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
return $cell;
|
||||||
$this->_cellCache[$pCoord] = $cell;
|
}
|
||||||
|
|
||||||
// Set current entry to the new/updated entry
|
|
||||||
$this->_currentObjectID = $pCoord;
|
/**
|
||||||
|
* Get cell at a specific coordinate
|
||||||
return $cell;
|
*
|
||||||
} // function addCacheData()
|
* @param string $pCoord Coordinate of the cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
/**
|
*/
|
||||||
* Get cell at a specific coordinate
|
public function getCacheData($pCoord)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate of the cell
|
// Check if the entry that has been requested actually exists
|
||||||
* @throws PHPExcel_Exception
|
if (!isset($this->cellCache[$pCoord])) {
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
$this->currentObjectID = null;
|
||||||
*/
|
// Return null if requested entry doesn't exist in cache
|
||||||
public function getCacheData($pCoord) {
|
return null;
|
||||||
// Check if the entry that has been requested actually exists
|
}
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
|
||||||
$this->_currentObjectID = NULL;
|
// Set current entry to the requested entry
|
||||||
// Return null if requested entry doesn't exist in cache
|
$this->currentObjectID = $pCoord;
|
||||||
return null;
|
|
||||||
}
|
// Return requested entry
|
||||||
|
return $this->cellCache[$pCoord];
|
||||||
// Set current entry to the requested entry
|
}
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
|
|
||||||
// Return requested entry
|
/**
|
||||||
return $this->_cellCache[$pCoord];
|
* Clone the cell collection
|
||||||
} // function getCacheData()
|
*
|
||||||
|
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||||
|
*/
|
||||||
/**
|
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||||
* Clone the cell collection
|
{
|
||||||
*
|
parent::copyCellCollection($parent);
|
||||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
|
||||||
* @return void
|
$newCollection = array();
|
||||||
*/
|
foreach ($this->cellCache as $k => &$cell) {
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
$newCollection[$k] = clone $cell;
|
||||||
parent::copyCellCollection($parent);
|
$newCollection[$k]->attach($this);
|
||||||
|
}
|
||||||
$newCollection = array();
|
|
||||||
foreach($this->_cellCache as $k => &$cell) {
|
$this->cellCache = $newCollection;
|
||||||
$newCollection[$k] = clone $cell;
|
}
|
||||||
$newCollection[$k]->attach($this);
|
|
||||||
}
|
/**
|
||||||
|
* Clear the cell collection and disconnect from our parent
|
||||||
$this->_cellCache = $newCollection;
|
*
|
||||||
}
|
*/
|
||||||
|
public function unsetWorksheetCells()
|
||||||
|
{
|
||||||
/**
|
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
|
||||||
* Clear the cell collection and disconnect from our parent
|
foreach ($this->cellCache as $k => &$cell) {
|
||||||
*
|
$cell->detach();
|
||||||
* @return void
|
$this->cellCache[$k] = null;
|
||||||
*/
|
}
|
||||||
public function unsetWorksheetCells() {
|
unset($cell);
|
||||||
// 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) {
|
$this->cellCache = array();
|
||||||
$cell->detach();
|
|
||||||
$this->_cellCache[$k] = null;
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
}
|
$this->parent = 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()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,137 +1,133 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_MemoryGZip
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_MemoryGZip
|
/**
|
||||||
*
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
* @category PHPExcel
|
* and the 'nullify' the current cell object
|
||||||
* @package PHPExcel_CachedObjectStorage
|
*
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @return void
|
||||||
*/
|
* @throws PHPExcel_Exception
|
||||||
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
*/
|
||||||
|
protected function storeData()
|
||||||
/**
|
{
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
* and the 'nullify' the current cell object
|
$this->currentObject->detach();
|
||||||
*
|
|
||||||
* @return void
|
$this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject));
|
||||||
* @throws PHPExcel_Exception
|
$this->currentCellIsDirty = false;
|
||||||
*/
|
}
|
||||||
protected function _storeData() {
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
}
|
||||||
$this->_currentObject->detach();
|
|
||||||
|
|
||||||
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
|
/**
|
||||||
$this->_currentCellIsDirty = false;
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
}
|
*
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
} // function _storeData()
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
/**
|
*/
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
$this->storeData();
|
||||||
* @return PHPExcel_Cell
|
}
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
*/
|
$this->currentObjectID = $pCoord;
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
$this->currentObject = $cell;
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
$this->currentCellIsDirty = true;
|
||||||
$this->_storeData();
|
|
||||||
}
|
return $cell;
|
||||||
|
}
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
$this->_currentObject = $cell;
|
|
||||||
$this->_currentCellIsDirty = true;
|
/**
|
||||||
|
* Get cell at a specific coordinate
|
||||||
return $cell;
|
*
|
||||||
} // function addCacheData()
|
* @param string $pCoord Coordinate of the cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
/**
|
*/
|
||||||
* Get cell at a specific coordinate
|
public function getCacheData($pCoord)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate of the cell
|
if ($pCoord === $this->currentObjectID) {
|
||||||
* @throws PHPExcel_Exception
|
return $this->currentObject;
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
}
|
||||||
*/
|
$this->storeData();
|
||||||
public function getCacheData($pCoord) {
|
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
// Check if the entry that has been requested actually exists
|
||||||
return $this->_currentObject;
|
if (!isset($this->cellCache[$pCoord])) {
|
||||||
}
|
// Return null if requested entry doesn't exist in cache
|
||||||
$this->_storeData();
|
return null;
|
||||||
|
}
|
||||||
// Check if the entry that has been requested actually exists
|
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
// Set current entry to the requested entry
|
||||||
// Return null if requested entry doesn't exist in cache
|
$this->currentObjectID = $pCoord;
|
||||||
return null;
|
$this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
|
||||||
}
|
// Re-attach this as the cell's parent
|
||||||
|
$this->currentObject->attach($this);
|
||||||
// Set current entry to the requested entry
|
|
||||||
$this->_currentObjectID = $pCoord;
|
// Return requested entry
|
||||||
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
|
return $this->currentObject;
|
||||||
// Re-attach this as the cell's parent
|
}
|
||||||
$this->_currentObject->attach($this);
|
|
||||||
|
|
||||||
// Return requested entry
|
/**
|
||||||
return $this->_currentObject;
|
* Get a list of all cell addresses currently held in cache
|
||||||
} // function getCacheData()
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
/**
|
public function getCellList()
|
||||||
* Get a list of all cell addresses currently held in cache
|
{
|
||||||
*
|
if ($this->currentObjectID !== null) {
|
||||||
* @return string[]
|
$this->storeData();
|
||||||
*/
|
}
|
||||||
public function getCellList() {
|
|
||||||
if ($this->_currentObjectID !== null) {
|
return parent::getCellList();
|
||||||
$this->_storeData();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return parent::getCellList();
|
/**
|
||||||
}
|
* Clear the cell collection and disconnect from our parent
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
/**
|
*/
|
||||||
* Clear the cell collection and disconnect from our parent
|
public function unsetWorksheetCells()
|
||||||
*
|
{
|
||||||
* @return void
|
if (!is_null($this->currentObject)) {
|
||||||
*/
|
$this->currentObject->detach();
|
||||||
public function unsetWorksheetCells() {
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
if(!is_null($this->_currentObject)) {
|
}
|
||||||
$this->_currentObject->detach();
|
$this->cellCache = array();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
|
||||||
}
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_cellCache = array();
|
$this->parent = null;
|
||||||
|
}
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
}
|
||||||
$this->_parent = null;
|
|
||||||
} // function unsetWorksheetCells()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,137 +1,129 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_MemorySerialized
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_MemorySerialized
|
/**
|
||||||
*
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
* @category PHPExcel
|
* and the 'nullify' the current cell object
|
||||||
* @package PHPExcel_CachedObjectStorage
|
*
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @return void
|
||||||
*/
|
* @throws PHPExcel_Exception
|
||||||
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
*/
|
||||||
|
protected function storeData()
|
||||||
/**
|
{
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
* and the 'nullify' the current cell object
|
$this->currentObject->detach();
|
||||||
*
|
|
||||||
* @return void
|
$this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
|
||||||
* @throws PHPExcel_Exception
|
$this->currentCellIsDirty = false;
|
||||||
*/
|
}
|
||||||
protected function _storeData() {
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
}
|
||||||
$this->_currentObject->detach();
|
|
||||||
|
/**
|
||||||
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
$this->_currentCellIsDirty = false;
|
*
|
||||||
}
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
} // function _storeData()
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
|
*/
|
||||||
/**
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
{
|
||||||
*
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
$this->storeData();
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
}
|
||||||
* @return PHPExcel_Cell
|
|
||||||
* @throws PHPExcel_Exception
|
$this->currentObjectID = $pCoord;
|
||||||
*/
|
$this->currentObject = $cell;
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
$this->currentCellIsDirty = true;
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
|
||||||
$this->_storeData();
|
return $cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
/**
|
||||||
$this->_currentObject = $cell;
|
* Get cell at a specific coordinate
|
||||||
$this->_currentCellIsDirty = true;
|
*
|
||||||
|
* @param string $pCoord Coordinate of the cell
|
||||||
return $cell;
|
* @throws PHPExcel_Exception
|
||||||
} // function addCacheData()
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
|
*/
|
||||||
|
public function getCacheData($pCoord)
|
||||||
/**
|
{
|
||||||
* Get cell at a specific coordinate
|
if ($pCoord === $this->currentObjectID) {
|
||||||
*
|
return $this->currentObject;
|
||||||
* @param string $pCoord Coordinate of the cell
|
}
|
||||||
* @throws PHPExcel_Exception
|
$this->storeData();
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
|
||||||
*/
|
// Check if the entry that has been requested actually exists
|
||||||
public function getCacheData($pCoord) {
|
if (!isset($this->cellCache[$pCoord])) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
// Return null if requested entry doesn't exist in cache
|
||||||
return $this->_currentObject;
|
return null;
|
||||||
}
|
}
|
||||||
$this->_storeData();
|
|
||||||
|
// Set current entry to the requested entry
|
||||||
// Check if the entry that has been requested actually exists
|
$this->currentObjectID = $pCoord;
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
$this->currentObject = unserialize($this->cellCache[$pCoord]);
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Re-attach this as the cell's parent
|
||||||
return null;
|
$this->currentObject->attach($this);
|
||||||
}
|
|
||||||
|
// Return requested entry
|
||||||
// Set current entry to the requested entry
|
return $this->currentObject;
|
||||||
$this->_currentObjectID = $pCoord;
|
}
|
||||||
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
|
|
||||||
// Re-attach this as the cell's parent
|
/**
|
||||||
$this->_currentObject->attach($this);
|
* Get a list of all cell addresses currently held in cache
|
||||||
|
*
|
||||||
// Return requested entry
|
* @return string[]
|
||||||
return $this->_currentObject;
|
*/
|
||||||
} // function getCacheData()
|
public function getCellList()
|
||||||
|
{
|
||||||
|
if ($this->currentObjectID !== null) {
|
||||||
/**
|
$this->storeData();
|
||||||
* Get a list of all cell addresses currently held in cache
|
}
|
||||||
*
|
|
||||||
* @return string[]
|
return parent::getCellList();
|
||||||
*/
|
}
|
||||||
public function getCellList() {
|
|
||||||
if ($this->_currentObjectID !== null) {
|
/**
|
||||||
$this->_storeData();
|
* Clear the cell collection and disconnect from our parent
|
||||||
}
|
*
|
||||||
|
* @return void
|
||||||
return parent::getCellList();
|
*/
|
||||||
}
|
public function unsetWorksheetCells()
|
||||||
|
{
|
||||||
|
if (!is_null($this->currentObject)) {
|
||||||
/**
|
$this->currentObject->detach();
|
||||||
* Clear the cell collection and disconnect from our parent
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
*
|
}
|
||||||
* @return void
|
$this->cellCache = array();
|
||||||
*/
|
|
||||||
public function unsetWorksheetCells() {
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
if(!is_null($this->_currentObject)) {
|
$this->parent = null;
|
||||||
$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()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,206 +1,200 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_PHPTemp
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_PHPTemp
|
/**
|
||||||
*
|
* Name of the file for this cache
|
||||||
* @category PHPExcel
|
*
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @var string
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
*/
|
||||||
*/
|
private $fileHandle = null;
|
||||||
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
|
||||||
|
/**
|
||||||
/**
|
* Memory limit to use before reverting to file cache
|
||||||
* Name of the file for this cache
|
*
|
||||||
*
|
* @var integer
|
||||||
* @var string
|
*/
|
||||||
*/
|
private $memoryCacheSize = null;
|
||||||
private $_fileHandle = null;
|
|
||||||
|
/**
|
||||||
/**
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
* Memory limit to use before reverting to file cache
|
* and the 'nullify' the current cell object
|
||||||
*
|
*
|
||||||
* @var integer
|
* @return void
|
||||||
*/
|
* @throws PHPExcel_Exception
|
||||||
private $_memoryCacheSize = null;
|
*/
|
||||||
|
protected function storeData()
|
||||||
/**
|
{
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
* and the 'nullify' the current cell object
|
$this->currentObject->detach();
|
||||||
*
|
|
||||||
* @return void
|
fseek($this->fileHandle, 0, SEEK_END);
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
*/
|
$this->cellCache[$this->currentObjectID] = array(
|
||||||
protected function _storeData() {
|
'ptr' => ftell($this->fileHandle),
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
|
||||||
$this->_currentObject->detach();
|
);
|
||||||
|
$this->currentCellIsDirty = false;
|
||||||
fseek($this->_fileHandle,0,SEEK_END);
|
}
|
||||||
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
$this->_cellCache[$this->_currentObjectID] = array(
|
}
|
||||||
'ptr' => ftell($this->_fileHandle),
|
|
||||||
'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject))
|
|
||||||
);
|
/**
|
||||||
$this->_currentCellIsDirty = false;
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
}
|
*
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
} // function _storeData()
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
/**
|
*/
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
$this->storeData();
|
||||||
* @return PHPExcel_Cell
|
}
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
*/
|
$this->currentObjectID = $pCoord;
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
$this->currentObject = $cell;
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
$this->currentCellIsDirty = true;
|
||||||
$this->_storeData();
|
|
||||||
}
|
return $cell;
|
||||||
|
}
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
$this->_currentObject = $cell;
|
|
||||||
$this->_currentCellIsDirty = true;
|
/**
|
||||||
|
* Get cell at a specific coordinate
|
||||||
return $cell;
|
*
|
||||||
} // function addCacheData()
|
* @param string $pCoord Coordinate of the cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
/**
|
*/
|
||||||
* Get cell at a specific coordinate
|
public function getCacheData($pCoord)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate of the cell
|
if ($pCoord === $this->currentObjectID) {
|
||||||
* @throws PHPExcel_Exception
|
return $this->currentObject;
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
}
|
||||||
*/
|
$this->storeData();
|
||||||
public function getCacheData($pCoord) {
|
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
// Check if the entry that has been requested actually exists
|
||||||
return $this->_currentObject;
|
if (!isset($this->cellCache[$pCoord])) {
|
||||||
}
|
// Return null if requested entry doesn't exist in cache
|
||||||
$this->_storeData();
|
return null;
|
||||||
|
}
|
||||||
// Check if the entry that has been requested actually exists
|
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
// Set current entry to the requested entry
|
||||||
// Return null if requested entry doesn't exist in cache
|
$this->currentObjectID = $pCoord;
|
||||||
return null;
|
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
|
||||||
// Set current entry to the requested entry
|
$this->currentObject->attach($this);
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
// Return requested entry
|
||||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
return $this->currentObject;
|
||||||
// Re-attach this as the cell's parent
|
}
|
||||||
$this->_currentObject->attach($this);
|
|
||||||
|
/**
|
||||||
// Return requested entry
|
* Get a list of all cell addresses currently held in cache
|
||||||
return $this->_currentObject;
|
*
|
||||||
} // function getCacheData()
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getCellList()
|
||||||
/**
|
{
|
||||||
* Get a list of all cell addresses currently held in cache
|
if ($this->currentObjectID !== null) {
|
||||||
*
|
$this->storeData();
|
||||||
* @return string[]
|
}
|
||||||
*/
|
|
||||||
public function getCellList() {
|
return parent::getCellList();
|
||||||
if ($this->_currentObjectID !== null) {
|
}
|
||||||
$this->_storeData();
|
|
||||||
}
|
/**
|
||||||
|
* Clone the cell collection
|
||||||
return parent::getCellList();
|
*
|
||||||
}
|
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
/**
|
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||||
* Clone the cell collection
|
{
|
||||||
*
|
parent::copyCellCollection($parent);
|
||||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
// Open a new stream for the cell cache data
|
||||||
* @return void
|
$newFileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
|
||||||
*/
|
// Copy the existing cell cache data to the new stream
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
fseek($this->fileHandle, 0);
|
||||||
parent::copyCellCollection($parent);
|
while (!feof($this->fileHandle)) {
|
||||||
// Open a new stream for the cell cache data
|
fwrite($newFileHandle, fread($this->fileHandle, 1024));
|
||||||
$newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
|
}
|
||||||
// Copy the existing cell cache data to the new stream
|
$this->fileHandle = $newFileHandle;
|
||||||
fseek($this->_fileHandle,0);
|
}
|
||||||
while (!feof($this->_fileHandle)) {
|
|
||||||
fwrite($newFileHandle,fread($this->_fileHandle, 1024));
|
/**
|
||||||
}
|
* Clear the cell collection and disconnect from our parent
|
||||||
$this->_fileHandle = $newFileHandle;
|
*
|
||||||
} // function copyCellCollection()
|
* @return void
|
||||||
|
*/
|
||||||
|
public function unsetWorksheetCells()
|
||||||
/**
|
{
|
||||||
* Clear the cell collection and disconnect from our parent
|
if (!is_null($this->currentObject)) {
|
||||||
*
|
$this->currentObject->detach();
|
||||||
* @return void
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
*/
|
}
|
||||||
public function unsetWorksheetCells() {
|
$this->cellCache = array();
|
||||||
if(!is_null($this->_currentObject)) {
|
|
||||||
$this->_currentObject->detach();
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->parent = null;
|
||||||
}
|
|
||||||
$this->_cellCache = array();
|
// Close down the php://temp file
|
||||||
|
$this->__destruct();
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
}
|
||||||
$this->_parent = null;
|
|
||||||
|
/**
|
||||||
// Close down the php://temp file
|
* Initialise this new cell collection
|
||||||
$this->__destruct();
|
*
|
||||||
} // function unsetWorksheetCells()
|
* @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)
|
||||||
* Initialise this new cell collection
|
{
|
||||||
*
|
$this->memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
|
||||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
|
||||||
* @param array of mixed $arguments Additional initialisation arguments
|
parent::__construct($parent);
|
||||||
*/
|
if (is_null($this->fileHandle)) {
|
||||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
$this->fileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
|
||||||
$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+');
|
* Destroy this cell collection
|
||||||
}
|
*/
|
||||||
} // function __construct()
|
public function __destruct()
|
||||||
|
{
|
||||||
|
if (!is_null($this->fileHandle)) {
|
||||||
/**
|
fclose($this->fileHandle);
|
||||||
* Destroy this cell collection
|
}
|
||||||
*/
|
$this->fileHandle = null;
|
||||||
public function __destruct() {
|
}
|
||||||
if (!is_null($this->_fileHandle)) {
|
}
|
||||||
fclose($this->_fileHandle);
|
|
||||||
}
|
|
||||||
$this->_fileHandle = null;
|
|
||||||
} // function __destruct()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,306 +1,307 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_SQLite
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_SQLite
|
/**
|
||||||
*
|
* Database table name
|
||||||
* @category PHPExcel
|
*
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @var string
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
*/
|
||||||
*/
|
private $TableName = null;
|
||||||
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
|
||||||
|
/**
|
||||||
/**
|
* Database handle
|
||||||
* Database table name
|
*
|
||||||
*
|
* @var resource
|
||||||
* @var string
|
*/
|
||||||
*/
|
private $DBHandle = null;
|
||||||
private $_TableName = null;
|
|
||||||
|
/**
|
||||||
/**
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
* Database handle
|
* and the 'nullify' the current cell object
|
||||||
*
|
*
|
||||||
* @var resource
|
* @return void
|
||||||
*/
|
* @throws PHPExcel_Exception
|
||||||
private $_DBHandle = null;
|
*/
|
||||||
|
protected function storeData()
|
||||||
/**
|
{
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
* and the 'nullify' the current cell object
|
$this->currentObject->detach();
|
||||||
*
|
|
||||||
* @return void
|
if (!$this->DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES('".$this->currentObjectID."','".sqlite_escape_string(serialize($this->currentObject))."')")) {
|
||||||
* @throws PHPExcel_Exception
|
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
*/
|
}
|
||||||
protected function _storeData() {
|
$this->currentCellIsDirty = false;
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
}
|
||||||
$this->_currentObject->detach();
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
|
}
|
||||||
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;
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
}
|
*
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
} // function _storeData()
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
/**
|
*/
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
$this->storeData();
|
||||||
* @return PHPExcel_Cell
|
}
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
*/
|
$this->currentObjectID = $pCoord;
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
$this->currentObject = $cell;
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
$this->currentCellIsDirty = true;
|
||||||
$this->_storeData();
|
|
||||||
}
|
return $cell;
|
||||||
|
}
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
$this->_currentObject = $cell;
|
/**
|
||||||
$this->_currentCellIsDirty = true;
|
* Get cell at a specific coordinate
|
||||||
|
*
|
||||||
return $cell;
|
* @param string $pCoord Coordinate of the cell
|
||||||
} // function addCacheData()
|
* @throws PHPExcel_Exception
|
||||||
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
|
*/
|
||||||
/**
|
public function getCacheData($pCoord)
|
||||||
* Get cell at a specific coordinate
|
{
|
||||||
*
|
if ($pCoord === $this->currentObjectID) {
|
||||||
* @param string $pCoord Coordinate of the cell
|
return $this->currentObject;
|
||||||
* @throws PHPExcel_Exception
|
}
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
$this->storeData();
|
||||||
*/
|
|
||||||
public function getCacheData($pCoord) {
|
$query = "SELECT value FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
|
||||||
return $this->_currentObject;
|
if ($cellResultSet === false) {
|
||||||
}
|
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
$this->_storeData();
|
} elseif ($cellResultSet->numRows() == 0) {
|
||||||
|
// Return null if requested entry doesn't exist in cache
|
||||||
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
return null;
|
||||||
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
|
}
|
||||||
if ($cellResultSet === false) {
|
|
||||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
// Set current entry to the requested entry
|
||||||
} elseif ($cellResultSet->numRows() == 0) {
|
$this->currentObjectID = $pCoord;
|
||||||
// Return null if requested entry doesn't exist in cache
|
|
||||||
return null;
|
$cellResult = $cellResultSet->fetchSingle();
|
||||||
}
|
$this->currentObject = unserialize($cellResult);
|
||||||
|
// Re-attach this as the cell's parent
|
||||||
// Set current entry to the requested entry
|
$this->currentObject->attach($this);
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
|
// Return requested entry
|
||||||
$cellResult = $cellResultSet->fetchSingle();
|
return $this->currentObject;
|
||||||
$this->_currentObject = unserialize($cellResult);
|
}
|
||||||
// Re-attach this as the cell's parent
|
|
||||||
$this->_currentObject->attach($this);
|
/**
|
||||||
|
* Is a value set for an indexed cell?
|
||||||
// Return requested entry
|
*
|
||||||
return $this->_currentObject;
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
} // function getCacheData()
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isDataSet($pCoord)
|
||||||
/**
|
{
|
||||||
* Is a value set for an indexed cell?
|
if ($pCoord === $this->currentObjectID) {
|
||||||
*
|
return true;
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
}
|
||||||
* @return boolean
|
|
||||||
*/
|
// Check if the requested entry exists in the cache
|
||||||
public function isDataSet($pCoord) {
|
$query = "SELECT id FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
|
||||||
return true;
|
if ($cellResultSet === false) {
|
||||||
}
|
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
|
} elseif ($cellResultSet->numRows() == 0) {
|
||||||
// Check if the requested entry exists in the cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
$query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
return false;
|
||||||
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
|
}
|
||||||
if ($cellResultSet === false) {
|
return true;
|
||||||
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;
|
* Delete a cell in cache identified by coordinate address
|
||||||
}
|
*
|
||||||
return true;
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
} // function isDataSet()
|
* @throws PHPExcel_Exception
|
||||||
|
*/
|
||||||
|
public function deleteCacheData($pCoord)
|
||||||
/**
|
{
|
||||||
* Delete a cell in cache identified by coordinate address
|
if ($pCoord === $this->currentObjectID) {
|
||||||
*
|
$this->currentObject->detach();
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
* @throws PHPExcel_Exception
|
}
|
||||||
*/
|
|
||||||
public function deleteCacheData($pCoord) {
|
// Check if the requested entry exists in the cache
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||||
$this->_currentObject->detach();
|
if (!$this->DBHandle->queryExec($query)) {
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the requested entry exists in the cache
|
$this->currentCellIsDirty = false;
|
||||||
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
}
|
||||||
if (!$this->_DBHandle->queryExec($query))
|
|
||||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
/**
|
||||||
|
* Move a cell object from one address to another
|
||||||
$this->_currentCellIsDirty = false;
|
*
|
||||||
} // function deleteCacheData()
|
* @param string $fromAddress Current address of the cell to move
|
||||||
|
* @param string $toAddress Destination address of the cell to move
|
||||||
|
* @return boolean
|
||||||
/**
|
*/
|
||||||
* Move a cell object from one address to another
|
public function moveCell($fromAddress, $toAddress)
|
||||||
*
|
{
|
||||||
* @param string $fromAddress Current address of the cell to move
|
if ($fromAddress === $this->currentObjectID) {
|
||||||
* @param string $toAddress Destination address of the cell to move
|
$this->currentObjectID = $toAddress;
|
||||||
* @return boolean
|
}
|
||||||
*/
|
|
||||||
public function moveCell($fromAddress, $toAddress) {
|
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
|
||||||
if ($fromAddress === $this->_currentObjectID) {
|
$result = $this->DBHandle->exec($query);
|
||||||
$this->_currentObjectID = $toAddress;
|
if ($result === false) {
|
||||||
}
|
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
|
|
||||||
$result = $this->_DBHandle->exec($query);
|
$query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
||||||
if ($result === false)
|
$result = $this->DBHandle->exec($query);
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
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)
|
return true;
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
}
|
||||||
|
|
||||||
return TRUE;
|
/**
|
||||||
} // function moveCell()
|
* Get a list of all cell addresses currently held in cache
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
/**
|
*/
|
||||||
* Get a list of all cell addresses currently held in cache
|
public function getCellList()
|
||||||
*
|
{
|
||||||
* @return string[]
|
if ($this->currentObjectID !== null) {
|
||||||
*/
|
$this->storeData();
|
||||||
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) {
|
||||||
$query = "SELECT id FROM kvp_".$this->_TableName;
|
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
$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 = array();
|
$cellKeys[] = $row['id'];
|
||||||
foreach($cellIdsResult as $row) {
|
}
|
||||||
$cellKeys[] = $row['id'];
|
|
||||||
}
|
return $cellKeys;
|
||||||
|
}
|
||||||
return $cellKeys;
|
|
||||||
} // function getCellList()
|
/**
|
||||||
|
* Clone the cell collection
|
||||||
|
*
|
||||||
/**
|
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||||
* Clone the cell collection
|
* @return void
|
||||||
*
|
*/
|
||||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||||
* @return void
|
{
|
||||||
*/
|
$this->currentCellIsDirty;
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
$this->storeData();
|
||||||
$this->_currentCellIsDirty;
|
|
||||||
$this->_storeData();
|
// Get a new id for the new table name
|
||||||
|
$tableName = str_replace('.', '_', $this->getUniqueID());
|
||||||
// Get a new id for the new table name
|
if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||||
$tableName = str_replace('.','_',$this->_getUniqueID());
|
AS SELECT * FROM kvp_'.$this->TableName)
|
||||||
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()));
|
||||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
}
|
||||||
|
|
||||||
// Copy the existing cell cache file
|
// Copy the existing cell cache file
|
||||||
$this->_TableName = $tableName;
|
$this->TableName = $tableName;
|
||||||
} // function copyCellCollection()
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Clear the cell collection and disconnect from our parent
|
||||||
* Clear the cell collection and disconnect from our parent
|
*
|
||||||
*
|
* @return void
|
||||||
* @return void
|
*/
|
||||||
*/
|
public function unsetWorksheetCells()
|
||||||
public function unsetWorksheetCells() {
|
{
|
||||||
if(!is_null($this->_currentObject)) {
|
if (!is_null($this->currentObject)) {
|
||||||
$this->_currentObject->detach();
|
$this->currentObject->detach();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
}
|
}
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->parent = null;
|
||||||
|
|
||||||
// Close down the temporary cache file
|
// Close down the temporary cache file
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
} // function unsetWorksheetCells()
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Initialise this new cell collection
|
||||||
* Initialise this new cell collection
|
*
|
||||||
*
|
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
*/
|
||||||
*/
|
public function __construct(PHPExcel_Worksheet $parent)
|
||||||
public function __construct(PHPExcel_Worksheet $parent) {
|
{
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
if (is_null($this->_DBHandle)) {
|
if (is_null($this->DBHandle)) {
|
||||||
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
|
$this->TableName = str_replace('.', '_', $this->getUniqueID());
|
||||||
$_DBName = ':memory:';
|
$_DBName = ':memory:';
|
||||||
|
|
||||||
$this->_DBHandle = new SQLiteDatabase($_DBName);
|
$this->DBHandle = new SQLiteDatabase($_DBName);
|
||||||
if ($this->_DBHandle === false)
|
if ($this->DBHandle === false) {
|
||||||
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
throw new 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()));
|
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
|
/**
|
||||||
*/
|
* Destroy this cell collection
|
||||||
public function __destruct() {
|
*/
|
||||||
if (!is_null($this->_DBHandle)) {
|
public function __destruct()
|
||||||
$this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);
|
{
|
||||||
}
|
if (!is_null($this->DBHandle)) {
|
||||||
$this->_DBHandle = null;
|
$this->DBHandle->queryExec('DROP TABLE kvp_'.$this->TableName);
|
||||||
} // function __destruct()
|
}
|
||||||
|
$this->DBHandle = null;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Identify whether the caching method is currently available
|
/**
|
||||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
* 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
|
*
|
||||||
*/
|
* @return boolean
|
||||||
public static function cacheMethodIsAvailable() {
|
*/
|
||||||
if (!function_exists('sqlite_open')) {
|
public static function cacheMethodIsAvailable()
|
||||||
return false;
|
{
|
||||||
}
|
if (!function_exists('sqlite_open')) {
|
||||||
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,345 +1,346 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_SQLite3
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_SQLite3
|
/**
|
||||||
*
|
* Database table name
|
||||||
* @category PHPExcel
|
*
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @var string
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
*/
|
||||||
*/
|
private $TableName = null;
|
||||||
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
|
||||||
|
/**
|
||||||
/**
|
* Database handle
|
||||||
* Database table name
|
*
|
||||||
*
|
* @var resource
|
||||||
* @var string
|
*/
|
||||||
*/
|
private $DBHandle = null;
|
||||||
private $_TableName = null;
|
|
||||||
|
/**
|
||||||
/**
|
* Prepared statement for a SQLite3 select query
|
||||||
* Database handle
|
*
|
||||||
*
|
* @var SQLite3Stmt
|
||||||
* @var resource
|
*/
|
||||||
*/
|
private $selectQuery;
|
||||||
private $_DBHandle = null;
|
|
||||||
|
/**
|
||||||
/**
|
* Prepared statement for a SQLite3 insert query
|
||||||
* Prepared statement for a SQLite3 select query
|
*
|
||||||
*
|
* @var SQLite3Stmt
|
||||||
* @var SQLite3Stmt
|
*/
|
||||||
*/
|
private $insertQuery;
|
||||||
private $_selectQuery;
|
|
||||||
|
/**
|
||||||
/**
|
* Prepared statement for a SQLite3 update query
|
||||||
* Prepared statement for a SQLite3 insert query
|
*
|
||||||
*
|
* @var SQLite3Stmt
|
||||||
* @var SQLite3Stmt
|
*/
|
||||||
*/
|
private $updateQuery;
|
||||||
private $_insertQuery;
|
|
||||||
|
/**
|
||||||
/**
|
* Prepared statement for a SQLite3 delete query
|
||||||
* Prepared statement for a SQLite3 update query
|
*
|
||||||
*
|
* @var SQLite3Stmt
|
||||||
* @var SQLite3Stmt
|
*/
|
||||||
*/
|
private $deleteQuery;
|
||||||
private $_updateQuery;
|
|
||||||
|
/**
|
||||||
/**
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
* Prepared statement for a SQLite3 delete query
|
* and the 'nullify' the current cell object
|
||||||
*
|
*
|
||||||
* @var SQLite3Stmt
|
* @return void
|
||||||
*/
|
* @throws PHPExcel_Exception
|
||||||
private $_deleteQuery;
|
*/
|
||||||
|
protected function storeData()
|
||||||
/**
|
{
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
* and the 'nullify' the current cell object
|
$this->currentObject->detach();
|
||||||
*
|
|
||||||
* @return void
|
$this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
|
||||||
* @throws PHPExcel_Exception
|
$this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
|
||||||
*/
|
$result = $this->insertQuery->execute();
|
||||||
protected function _storeData() {
|
if ($result === false) {
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||||
$this->_currentObject->detach();
|
}
|
||||||
|
$this->currentCellIsDirty = false;
|
||||||
$this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
|
}
|
||||||
$this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
$result = $this->_insertQuery->execute();
|
}
|
||||||
if ($result === false)
|
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
/**
|
||||||
$this->_currentCellIsDirty = false;
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
}
|
*
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
} // function _storeData()
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
/**
|
*/
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
*
|
{
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
$this->storeData();
|
||||||
* @return PHPExcel_Cell
|
}
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
*/
|
$this->currentObjectID = $pCoord;
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
$this->currentObject = $cell;
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
$this->currentCellIsDirty = true;
|
||||||
$this->_storeData();
|
|
||||||
}
|
return $cell;
|
||||||
|
}
|
||||||
$this->_currentObjectID = $pCoord;
|
|
||||||
$this->_currentObject = $cell;
|
/**
|
||||||
$this->_currentCellIsDirty = true;
|
* Get cell at a specific coordinate
|
||||||
|
*
|
||||||
return $cell;
|
* @param string $pCoord Coordinate of the cell
|
||||||
} // function addCacheData()
|
* @throws PHPExcel_Exception
|
||||||
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
|
*/
|
||||||
/**
|
public function getCacheData($pCoord)
|
||||||
* Get cell at a specific coordinate
|
{
|
||||||
*
|
if ($pCoord === $this->currentObjectID) {
|
||||||
* @param string $pCoord Coordinate of the cell
|
return $this->currentObject;
|
||||||
* @throws PHPExcel_Exception
|
}
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
$this->storeData();
|
||||||
*/
|
|
||||||
public function getCacheData($pCoord) {
|
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
$cellResult = $this->selectQuery->execute();
|
||||||
return $this->_currentObject;
|
if ($cellResult === false) {
|
||||||
}
|
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||||
$this->_storeData();
|
}
|
||||||
|
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||||
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
if ($cellData === false) {
|
||||||
$cellResult = $this->_selectQuery->execute();
|
// Return null if requested entry doesn't exist in cache
|
||||||
if ($cellResult === FALSE) {
|
return null;
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
}
|
||||||
}
|
|
||||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
// Set current entry to the requested entry
|
||||||
if ($cellData === FALSE) {
|
$this->currentObjectID = $pCoord;
|
||||||
// Return null if requested entry doesn't exist in cache
|
|
||||||
return NULL;
|
$this->currentObject = unserialize($cellData['value']);
|
||||||
}
|
// Re-attach this as the cell's parent
|
||||||
|
$this->currentObject->attach($this);
|
||||||
// Set current entry to the requested entry
|
|
||||||
$this->_currentObjectID = $pCoord;
|
// Return requested entry
|
||||||
|
return $this->currentObject;
|
||||||
$this->_currentObject = unserialize($cellData['value']);
|
}
|
||||||
// Re-attach this as the cell's parent
|
|
||||||
$this->_currentObject->attach($this);
|
/**
|
||||||
|
* Is a value set for an indexed cell?
|
||||||
// Return requested entry
|
*
|
||||||
return $this->_currentObject;
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
} // function getCacheData()
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isDataSet($pCoord)
|
||||||
/**
|
{
|
||||||
* Is a value set for an indexed cell?
|
if ($pCoord === $this->currentObjectID) {
|
||||||
*
|
return true;
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
}
|
||||||
* @return boolean
|
|
||||||
*/
|
// Check if the requested entry exists in the cache
|
||||||
public function isDataSet($pCoord) {
|
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
$cellResult = $this->selectQuery->execute();
|
||||||
return TRUE;
|
if ($cellResult === false) {
|
||||||
}
|
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
// Check if the requested entry exists in the cache
|
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||||
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
|
||||||
$cellResult = $this->_selectQuery->execute();
|
return ($cellData === false) ? false : true;
|
||||||
if ($cellResult === FALSE) {
|
}
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
|
||||||
}
|
/**
|
||||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
* Delete a cell in cache identified by coordinate address
|
||||||
|
*
|
||||||
return ($cellData === FALSE) ? FALSE : TRUE;
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
} // function isDataSet()
|
* @throws PHPExcel_Exception
|
||||||
|
*/
|
||||||
|
public function deleteCacheData($pCoord)
|
||||||
/**
|
{
|
||||||
* Delete a cell in cache identified by coordinate address
|
if ($pCoord === $this->currentObjectID) {
|
||||||
*
|
$this->currentObject->detach();
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
* @throws PHPExcel_Exception
|
}
|
||||||
*/
|
|
||||||
public function deleteCacheData($pCoord) {
|
// Check if the requested entry exists in the cache
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
$this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||||
$this->_currentObject->detach();
|
$result = $this->deleteQuery->execute();
|
||||||
$this->_currentObjectID = $this->_currentObject = NULL;
|
if ($result === false) {
|
||||||
}
|
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
// Check if the requested entry exists in the cache
|
|
||||||
$this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
$this->currentCellIsDirty = false;
|
||||||
$result = $this->_deleteQuery->execute();
|
}
|
||||||
if ($result === FALSE)
|
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
/**
|
||||||
|
* Move a cell object from one address to another
|
||||||
$this->_currentCellIsDirty = FALSE;
|
*
|
||||||
} // function deleteCacheData()
|
* @param string $fromAddress Current address of the cell to move
|
||||||
|
* @param string $toAddress Destination address of the cell to move
|
||||||
|
* @return boolean
|
||||||
/**
|
*/
|
||||||
* Move a cell object from one address to another
|
public function moveCell($fromAddress, $toAddress)
|
||||||
*
|
{
|
||||||
* @param string $fromAddress Current address of the cell to move
|
if ($fromAddress === $this->currentObjectID) {
|
||||||
* @param string $toAddress Destination address of the cell to move
|
$this->currentObjectID = $toAddress;
|
||||||
* @return boolean
|
}
|
||||||
*/
|
|
||||||
public function moveCell($fromAddress, $toAddress) {
|
$this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
|
||||||
if ($fromAddress === $this->_currentObjectID) {
|
$result = $this->deleteQuery->execute();
|
||||||
$this->_currentObjectID = $toAddress;
|
if ($result === false) {
|
||||||
}
|
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
$this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);
|
|
||||||
$result = $this->_deleteQuery->execute();
|
$this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
|
||||||
if ($result === false)
|
$this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
$result = $this->updateQuery->execute();
|
||||||
|
if ($result === false) {
|
||||||
$this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);
|
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||||
$this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);
|
}
|
||||||
$result = $this->_updateQuery->execute();
|
|
||||||
if ($result === false)
|
return true;
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
}
|
||||||
|
|
||||||
return TRUE;
|
/**
|
||||||
} // function moveCell()
|
* Get a list of all cell addresses currently held in cache
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
/**
|
*/
|
||||||
* Get a list of all cell addresses currently held in cache
|
public function getCellList()
|
||||||
*
|
{
|
||||||
* @return string[]
|
if ($this->currentObjectID !== null) {
|
||||||
*/
|
$this->storeData();
|
||||||
public function getCellList() {
|
}
|
||||||
if ($this->_currentObjectID !== null) {
|
|
||||||
$this->_storeData();
|
$query = "SELECT id FROM kvp_".$this->TableName;
|
||||||
}
|
$cellIdsResult = $this->DBHandle->query($query);
|
||||||
|
if ($cellIdsResult === false) {
|
||||||
$query = "SELECT id FROM kvp_".$this->_TableName;
|
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||||
$cellIdsResult = $this->_DBHandle->query($query);
|
}
|
||||||
if ($cellIdsResult === false)
|
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
$cellKeys = array();
|
||||||
|
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
|
||||||
$cellKeys = array();
|
$cellKeys[] = $row['id'];
|
||||||
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
|
}
|
||||||
$cellKeys[] = $row['id'];
|
|
||||||
}
|
return $cellKeys;
|
||||||
|
}
|
||||||
return $cellKeys;
|
|
||||||
} // function getCellList()
|
/**
|
||||||
|
* Clone the cell collection
|
||||||
|
*
|
||||||
/**
|
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||||
* Clone the cell collection
|
* @return void
|
||||||
*
|
*/
|
||||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||||
* @return void
|
{
|
||||||
*/
|
$this->currentCellIsDirty;
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
$this->storeData();
|
||||||
$this->_currentCellIsDirty;
|
|
||||||
$this->_storeData();
|
// Get a new id for the new table name
|
||||||
|
$tableName = str_replace('.', '_', $this->getUniqueID());
|
||||||
// Get a new id for the new table name
|
if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||||
$tableName = str_replace('.','_',$this->_getUniqueID());
|
AS SELECT * FROM kvp_'.$this->TableName)
|
||||||
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());
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
}
|
||||||
|
|
||||||
// Copy the existing cell cache file
|
// Copy the existing cell cache file
|
||||||
$this->_TableName = $tableName;
|
$this->TableName = $tableName;
|
||||||
} // function copyCellCollection()
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Clear the cell collection and disconnect from our parent
|
||||||
* Clear the cell collection and disconnect from our parent
|
*
|
||||||
*
|
* @return void
|
||||||
* @return void
|
*/
|
||||||
*/
|
public function unsetWorksheetCells()
|
||||||
public function unsetWorksheetCells() {
|
{
|
||||||
if(!is_null($this->_currentObject)) {
|
if (!is_null($this->currentObject)) {
|
||||||
$this->_currentObject->detach();
|
$this->currentObject->detach();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
}
|
}
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->parent = null;
|
||||||
|
|
||||||
// Close down the temporary cache file
|
// Close down the temporary cache file
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
} // function unsetWorksheetCells()
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Initialise this new cell collection
|
||||||
* Initialise this new cell collection
|
*
|
||||||
*
|
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
*/
|
||||||
*/
|
public function __construct(PHPExcel_Worksheet $parent)
|
||||||
public function __construct(PHPExcel_Worksheet $parent) {
|
{
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
if (is_null($this->_DBHandle)) {
|
if (is_null($this->DBHandle)) {
|
||||||
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
|
$this->TableName = str_replace('.', '_', $this->getUniqueID());
|
||||||
$_DBName = ':memory:';
|
$_DBName = ':memory:';
|
||||||
|
|
||||||
$this->_DBHandle = new SQLite3($_DBName);
|
$this->DBHandle = new SQLite3($_DBName);
|
||||||
if ($this->_DBHandle === false)
|
if ($this->DBHandle === false) {
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
throw new 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());
|
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->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_".$this->TableName." WHERE id = :id");
|
||||||
$this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id");
|
$this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES(:id,:data)");
|
||||||
} // function __construct()
|
$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");
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Destroy this cell collection
|
/**
|
||||||
*/
|
* Destroy this cell collection
|
||||||
public function __destruct() {
|
*/
|
||||||
if (!is_null($this->_DBHandle)) {
|
public function __destruct()
|
||||||
$this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName);
|
{
|
||||||
$this->_DBHandle->close();
|
if (!is_null($this->DBHandle)) {
|
||||||
}
|
$this->DBHandle->exec('DROP TABLE kvp_'.$this->TableName);
|
||||||
$this->_DBHandle = null;
|
$this->DBHandle->close();
|
||||||
} // function __destruct()
|
}
|
||||||
|
$this->DBHandle = null;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Identify whether the caching method is currently available
|
/**
|
||||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
* 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
|
*
|
||||||
*/
|
* @return boolean
|
||||||
public static function cacheMethodIsAvailable() {
|
*/
|
||||||
if (!class_exists('SQLite3',FALSE)) {
|
public static function cacheMethodIsAvailable()
|
||||||
return false;
|
{
|
||||||
}
|
if (!class_exists('SQLite3', false)) {
|
||||||
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,294 +1,289 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHPExcel
|
/**
|
||||||
*
|
* PHPExcel_CachedObjectStorage_Wincache
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
*
|
||||||
*
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
* This library is free software; you can redistribute it and/or
|
*
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* This library is free software; you can redistribute it and/or
|
||||||
* License as published by the Free Software Foundation; either
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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
|
* This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Lesser General Public License for more details.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @category PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @version ##VERSION##, ##DATE##
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
*/
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||||
/**
|
{
|
||||||
* PHPExcel_CachedObjectStorage_Wincache
|
/**
|
||||||
*
|
* Prefix used to uniquely identify cache data for this worksheet
|
||||||
* @category PHPExcel
|
*
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @var string
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
*/
|
||||||
*/
|
private $cachePrefix = null;
|
||||||
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
|
||||||
|
/**
|
||||||
/**
|
* Cache timeout
|
||||||
* Prefix used to uniquely identify cache data for this worksheet
|
*
|
||||||
*
|
* @var integer
|
||||||
* @var string
|
*/
|
||||||
*/
|
private $cacheTime = 600;
|
||||||
private $_cachePrefix = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache timeout
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
*
|
* and the 'nullify' the current cell object
|
||||||
* @var integer
|
*
|
||||||
*/
|
* @return void
|
||||||
private $_cacheTime = 600;
|
* @throws PHPExcel_Exception
|
||||||
|
*/
|
||||||
|
protected function storeData()
|
||||||
/**
|
{
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||||
* and the 'nullify' the current cell object
|
$this->currentObject->detach();
|
||||||
*
|
|
||||||
* @return void
|
$obj = serialize($this->currentObject);
|
||||||
* @throws PHPExcel_Exception
|
if (wincache_ucache_exists($this->cachePrefix.$this->currentObjectID.'.cache')) {
|
||||||
*/
|
if (!wincache_ucache_set($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
|
||||||
protected function _storeData() {
|
$this->__destruct();
|
||||||
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
|
throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
|
||||||
$this->_currentObject->detach();
|
}
|
||||||
|
} else {
|
||||||
$obj = serialize($this->_currentObject);
|
if (!wincache_ucache_add($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
|
||||||
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
|
$this->__destruct();
|
||||||
if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
|
throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
|
||||||
$this->__destruct();
|
}
|
||||||
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
|
}
|
||||||
}
|
$this->currentCellIsDirty = false;
|
||||||
} else {
|
}
|
||||||
if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
|
|
||||||
$this->__destruct();
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
$this->_currentCellIsDirty = false;
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
}
|
*
|
||||||
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
} // function _storeData()
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
|
*/
|
||||||
/**
|
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
{
|
||||||
*
|
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
$this->storeData();
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
}
|
||||||
* @return PHPExcel_Cell
|
$this->cellCache[$pCoord] = true;
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
*/
|
$this->currentObjectID = $pCoord;
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
$this->currentObject = $cell;
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
$this->currentCellIsDirty = true;
|
||||||
$this->_storeData();
|
|
||||||
}
|
return $cell;
|
||||||
$this->_cellCache[$pCoord] = true;
|
}
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
/**
|
||||||
$this->_currentObject = $cell;
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
$this->_currentCellIsDirty = true;
|
*
|
||||||
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
return $cell;
|
* @return boolean
|
||||||
} // function addCacheData()
|
*/
|
||||||
|
public function isDataSet($pCoord)
|
||||||
|
{
|
||||||
/**
|
// Check if the requested entry is the current object, or exists in the cache
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
if (parent::isDataSet($pCoord)) {
|
||||||
*
|
if ($this->currentObjectID == $pCoord) {
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
return true;
|
||||||
* @return boolean
|
}
|
||||||
*/
|
// Check if the requested entry still exists in cache
|
||||||
public function isDataSet($pCoord) {
|
$success = wincache_ucache_exists($this->cachePrefix.$pCoord.'.cache');
|
||||||
// Check if the requested entry is the current object, or exists in the cache
|
if ($success === false) {
|
||||||
if (parent::isDataSet($pCoord)) {
|
// Entry no longer exists in Wincache, so clear it from the cache array
|
||||||
if ($this->_currentObjectID == $pCoord) {
|
parent::deleteCacheData($pCoord);
|
||||||
return true;
|
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
|
||||||
}
|
}
|
||||||
// Check if the requested entry still exists in cache
|
return true;
|
||||||
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache');
|
}
|
||||||
if ($success === false) {
|
return 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;
|
* Get cell at a specific coordinate
|
||||||
}
|
*
|
||||||
return false;
|
* @param string $pCoord Coordinate of the cell
|
||||||
} // function isDataSet()
|
* @throws PHPExcel_Exception
|
||||||
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
|
*/
|
||||||
/**
|
public function getCacheData($pCoord)
|
||||||
* Get cell at a specific coordinate
|
{
|
||||||
*
|
if ($pCoord === $this->currentObjectID) {
|
||||||
* @param string $pCoord Coordinate of the cell
|
return $this->currentObject;
|
||||||
* @throws PHPExcel_Exception
|
}
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
$this->storeData();
|
||||||
*/
|
|
||||||
public function getCacheData($pCoord) {
|
// Check if the entry that has been requested actually exists
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
$obj = null;
|
||||||
return $this->_currentObject;
|
if (parent::isDataSet($pCoord)) {
|
||||||
}
|
$success = false;
|
||||||
$this->_storeData();
|
$obj = wincache_ucache_get($this->cachePrefix.$pCoord.'.cache', $success);
|
||||||
|
if ($success === false) {
|
||||||
// Check if the entry that has been requested actually exists
|
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||||
$obj = null;
|
parent::deleteCacheData($pCoord);
|
||||||
if (parent::isDataSet($pCoord)) {
|
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
|
||||||
$success = false;
|
}
|
||||||
$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
|
} else {
|
||||||
if ($success === false) {
|
// Return null if requested entry doesn't exist in cache
|
||||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
return null;
|
||||||
parent::deleteCacheData($pCoord);
|
}
|
||||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
|
|
||||||
}
|
// Set current entry to the requested entry
|
||||||
} else {
|
$this->currentObjectID = $pCoord;
|
||||||
// Return null if requested entry doesn't exist in cache
|
$this->currentObject = unserialize($obj);
|
||||||
return null;
|
// Re-attach this as the cell's parent
|
||||||
}
|
$this->currentObject->attach($this);
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Return requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
return $this->currentObject;
|
||||||
$this->_currentObject = unserialize($obj);
|
}
|
||||||
// Re-attach this as the cell's parent
|
|
||||||
$this->_currentObject->attach($this);
|
|
||||||
|
/**
|
||||||
// Return requested entry
|
* Get a list of all cell addresses currently held in cache
|
||||||
return $this->_currentObject;
|
*
|
||||||
} // function getCacheData()
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getCellList()
|
||||||
/**
|
{
|
||||||
* Get a list of all cell addresses currently held in cache
|
if ($this->currentObjectID !== null) {
|
||||||
*
|
$this->storeData();
|
||||||
* @return string[]
|
}
|
||||||
*/
|
|
||||||
public function getCellList() {
|
return parent::getCellList();
|
||||||
if ($this->_currentObjectID !== null) {
|
}
|
||||||
$this->_storeData();
|
|
||||||
}
|
/**
|
||||||
|
* Delete a cell in cache identified by coordinate address
|
||||||
return parent::getCellList();
|
*
|
||||||
}
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
|
*/
|
||||||
/**
|
public function deleteCacheData($pCoord)
|
||||||
* Delete a cell in cache identified by coordinate address
|
{
|
||||||
*
|
// Delete the entry from Wincache
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
wincache_ucache_delete($this->cachePrefix.$pCoord.'.cache');
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
*/
|
// Delete the entry from our cell address array
|
||||||
public function deleteCacheData($pCoord) {
|
parent::deleteCacheData($pCoord);
|
||||||
// Delete the entry from Wincache
|
}
|
||||||
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
|
|
||||||
|
/**
|
||||||
// Delete the entry from our cell address array
|
* Clone the cell collection
|
||||||
parent::deleteCacheData($pCoord);
|
*
|
||||||
} // function deleteCacheData()
|
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
/**
|
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||||
* Clone the cell collection
|
{
|
||||||
*
|
parent::copyCellCollection($parent);
|
||||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
// Get a new id for the new file name
|
||||||
* @return void
|
$baseUnique = $this->getUniqueID();
|
||||||
*/
|
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
$cacheList = $this->getCellList();
|
||||||
parent::copyCellCollection($parent);
|
foreach ($cacheList as $cellID) {
|
||||||
// Get a new id for the new file name
|
if ($cellID != $this->currentObjectID) {
|
||||||
$baseUnique = $this->_getUniqueID();
|
$success = false;
|
||||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
$obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success);
|
||||||
$cacheList = $this->getCellList();
|
if ($success === false) {
|
||||||
foreach($cacheList as $cellID) {
|
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||||
if ($cellID != $this->_currentObjectID) {
|
parent::deleteCacheData($cellID);
|
||||||
$success = false;
|
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache');
|
||||||
$obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success);
|
}
|
||||||
if ($success === false) {
|
if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->cacheTime)) {
|
||||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
$this->__destruct();
|
||||||
parent::deleteCacheData($cellID);
|
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache');
|
||||||
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache');
|
}
|
||||||
}
|
}
|
||||||
if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) {
|
}
|
||||||
$this->__destruct();
|
$this->cachePrefix = $newCachePrefix;
|
||||||
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache');
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
$this->_cachePrefix = $newCachePrefix;
|
* Clear the cell collection and disconnect from our parent
|
||||||
} // function copyCellCollection()
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
/**
|
public function unsetWorksheetCells()
|
||||||
* Clear the cell collection and disconnect from our parent
|
{
|
||||||
*
|
if (!is_null($this->currentObject)) {
|
||||||
* @return void
|
$this->currentObject->detach();
|
||||||
*/
|
$this->currentObject = $this->currentObjectID = null;
|
||||||
public function unsetWorksheetCells() {
|
}
|
||||||
if(!is_null($this->_currentObject)) {
|
|
||||||
$this->_currentObject->detach();
|
// Flush the WinCache cache
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->__destruct();
|
||||||
}
|
|
||||||
|
$this->cellCache = array();
|
||||||
// Flush the WinCache cache
|
|
||||||
$this->__destruct();
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
|
$this->parent = null;
|
||||||
$this->_cellCache = array();
|
}
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
/**
|
||||||
$this->_parent = null;
|
* Initialise this new cell collection
|
||||||
} // function unsetWorksheetCells()
|
*
|
||||||
|
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||||
|
* @param array of mixed $arguments Additional initialisation arguments
|
||||||
/**
|
*/
|
||||||
* Initialise this new cell collection
|
public function __construct(PHPExcel_Worksheet $parent, $arguments)
|
||||||
*
|
{
|
||||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||||
* @param array of mixed $arguments Additional initialisation arguments
|
|
||||||
*/
|
if (is_null($this->cachePrefix)) {
|
||||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
$baseUnique = $this->getUniqueID();
|
||||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
$this->cachePrefix = substr(md5($baseUnique), 0, 8).'.';
|
||||||
|
$this->cacheTime = $cacheTime;
|
||||||
if (is_null($this->_cachePrefix)) {
|
|
||||||
$baseUnique = $this->_getUniqueID();
|
parent::__construct($parent);
|
||||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
}
|
||||||
$this->_cacheTime = $cacheTime;
|
}
|
||||||
|
|
||||||
parent::__construct($parent);
|
/**
|
||||||
}
|
* Destroy this cell collection
|
||||||
} // function __construct()
|
*/
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
/**
|
$cacheList = $this->getCellList();
|
||||||
* Destroy this cell collection
|
foreach ($cacheList as $cellID) {
|
||||||
*/
|
wincache_ucache_delete($this->cachePrefix.$cellID.'.cache');
|
||||||
public function __destruct() {
|
}
|
||||||
$cacheList = $this->getCellList();
|
}
|
||||||
foreach($cacheList as $cellID) {
|
|
||||||
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
|
/**
|
||||||
}
|
* Identify whether the caching method is currently available
|
||||||
} // function __destruct()
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
/**
|
*/
|
||||||
* Identify whether the caching method is currently available
|
public static function cacheMethodIsAvailable()
|
||||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
{
|
||||||
*
|
if (!function_exists('wincache_ucache_add')) {
|
||||||
* @return boolean
|
return false;
|
||||||
*/
|
}
|
||||||
public static function cacheMethodIsAvailable() {
|
|
||||||
if (!function_exists('wincache_ucache_add')) {
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_CachedObjectStorageFactory
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -21,19 +21,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_CachedObjectStorageFactory
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_CachedObjectStorage
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_CachedObjectStorageFactory
|
class PHPExcel_CachedObjectStorageFactory
|
||||||
{
|
{
|
||||||
const cache_in_memory = 'Memory';
|
const cache_in_memory = 'Memory';
|
||||||
|
@ -48,28 +39,26 @@ class PHPExcel_CachedObjectStorageFactory
|
||||||
const cache_to_sqlite = 'SQLite';
|
const cache_to_sqlite = 'SQLite';
|
||||||
const cache_to_sqlite3 = 'SQLite3';
|
const cache_to_sqlite3 = 'SQLite3';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the method used for cell cacheing
|
* Name of the method used for cell cacheing
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $_cacheStorageMethod = NULL;
|
private static $cacheStorageMethod = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the class used for cell cacheing
|
* Name of the class used for cell cacheing
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $_cacheStorageClass = NULL;
|
private static $cacheStorageClass = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all possible cache storage methods
|
* List of all possible cache storage methods
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
private static $_storageMethods = array(
|
private static $storageMethods = array(
|
||||||
self::cache_in_memory,
|
self::cache_in_memory,
|
||||||
self::cache_in_memory_gzip,
|
self::cache_in_memory_gzip,
|
||||||
self::cache_in_memory_serialized,
|
self::cache_in_memory_serialized,
|
||||||
|
@ -83,13 +72,12 @@ class PHPExcel_CachedObjectStorageFactory
|
||||||
self::cache_to_sqlite3,
|
self::cache_to_sqlite3,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default arguments for each cache storage method
|
* Default arguments for each cache storage method
|
||||||
*
|
*
|
||||||
* @var array of mixed array
|
* @var array of mixed array
|
||||||
*/
|
*/
|
||||||
private static $_storageMethodDefaultParameters = array(
|
private static $storageMethodDefaultParameters = array(
|
||||||
self::cache_in_memory => array(
|
self::cache_in_memory => array(
|
||||||
),
|
),
|
||||||
self::cache_in_memory_gzip => array(
|
self::cache_in_memory_gzip => array(
|
||||||
|
@ -100,7 +88,7 @@ class PHPExcel_CachedObjectStorageFactory
|
||||||
),
|
),
|
||||||
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
|
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
|
||||||
),
|
),
|
||||||
self::cache_to_discISAM => array( 'dir' => NULL
|
self::cache_to_discISAM => array( 'dir' => null
|
||||||
),
|
),
|
||||||
self::cache_to_apc => array( 'cacheTime' => 600
|
self::cache_to_apc => array( 'cacheTime' => 600
|
||||||
),
|
),
|
||||||
|
@ -116,36 +104,32 @@ class PHPExcel_CachedObjectStorageFactory
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arguments for the active cache storage method
|
* Arguments for the active cache storage method
|
||||||
*
|
*
|
||||||
* @var array of mixed array
|
* @var array of mixed array
|
||||||
*/
|
*/
|
||||||
private static $_storageMethodParameters = array();
|
private static $storageMethodParameters = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current cache storage method
|
* Return the current cache storage method
|
||||||
*
|
*
|
||||||
* @return string|NULL
|
* @return string|null
|
||||||
**/
|
**/
|
||||||
public static function getCacheStorageMethod()
|
public static function getCacheStorageMethod()
|
||||||
{
|
{
|
||||||
return self::$_cacheStorageMethod;
|
return self::$cacheStorageMethod;
|
||||||
} // function getCacheStorageMethod()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current cache storage class
|
* Return the current cache storage class
|
||||||
*
|
*
|
||||||
* @return PHPExcel_CachedObjectStorage_ICache|NULL
|
* @return PHPExcel_CachedObjectStorage_ICache|null
|
||||||
**/
|
**/
|
||||||
public static function getCacheStorageClass()
|
public static function getCacheStorageClass()
|
||||||
{
|
{
|
||||||
return self::$_cacheStorageClass;
|
return self::$cacheStorageClass;
|
||||||
} // function getCacheStorageClass()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of all possible cache storage methods
|
* Return the list of all possible cache storage methods
|
||||||
|
@ -154,9 +138,8 @@ class PHPExcel_CachedObjectStorageFactory
|
||||||
**/
|
**/
|
||||||
public static function getAllCacheStorageMethods()
|
public static function getAllCacheStorageMethods()
|
||||||
{
|
{
|
||||||
return self::$_storageMethods;
|
return self::$storageMethods;
|
||||||
} // function getCacheStorageMethods()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of all available cache storage methods
|
* Return the list of all available cache storage methods
|
||||||
|
@ -166,15 +149,14 @@ class PHPExcel_CachedObjectStorageFactory
|
||||||
public static function getCacheStorageMethods()
|
public static function getCacheStorageMethods()
|
||||||
{
|
{
|
||||||
$activeMethods = array();
|
$activeMethods = array();
|
||||||
foreach(self::$_storageMethods as $storageMethod) {
|
foreach (self::$storageMethods as $storageMethod) {
|
||||||
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
|
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
|
||||||
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
|
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
|
||||||
$activeMethods[] = $storageMethod;
|
$activeMethods[] = $storageMethod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $activeMethods;
|
return $activeMethods;
|
||||||
} // function getCacheStorageMethods()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify the cache storage method to use
|
* Identify the cache storage method to use
|
||||||
|
@ -186,30 +168,29 @@ class PHPExcel_CachedObjectStorageFactory
|
||||||
**/
|
**/
|
||||||
public static function initialize($method = self::cache_in_memory, $arguments = array())
|
public static function initialize($method = self::cache_in_memory, $arguments = array())
|
||||||
{
|
{
|
||||||
if (!in_array($method,self::$_storageMethods)) {
|
if (!in_array($method, self::$storageMethods)) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
||||||
if (!call_user_func(array( $cacheStorageClass,
|
if (!call_user_func(array( $cacheStorageClass,
|
||||||
'cacheMethodIsAvailable'))) {
|
'cacheMethodIsAvailable'))) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
|
self::$storageMethodParameters[$method] = self::$storageMethodDefaultParameters[$method];
|
||||||
foreach($arguments as $k => $v) {
|
foreach ($arguments as $k => $v) {
|
||||||
if (array_key_exists($k, self::$_storageMethodParameters[$method])) {
|
if (array_key_exists($k, self::$storageMethodParameters[$method])) {
|
||||||
self::$_storageMethodParameters[$method][$k] = $v;
|
self::$storageMethodParameters[$method][$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$_cacheStorageMethod === NULL) {
|
if (self::$cacheStorageMethod === null) {
|
||||||
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
|
self::$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
|
||||||
self::$_cacheStorageMethod = $method;
|
self::$cacheStorageMethod = $method;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
} // function initialize()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise the cache storage
|
* Initialise the cache storage
|
||||||
|
@ -219,33 +200,32 @@ class PHPExcel_CachedObjectStorageFactory
|
||||||
**/
|
**/
|
||||||
public static function getInstance(PHPExcel_Worksheet $parent)
|
public static function getInstance(PHPExcel_Worksheet $parent)
|
||||||
{
|
{
|
||||||
$cacheMethodIsAvailable = TRUE;
|
$cacheMethodIsAvailable = true;
|
||||||
if (self::$_cacheStorageMethod === NULL) {
|
if (self::$cacheStorageMethod === null) {
|
||||||
$cacheMethodIsAvailable = self::initialize();
|
$cacheMethodIsAvailable = self::initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cacheMethodIsAvailable) {
|
if ($cacheMethodIsAvailable) {
|
||||||
$instance = new self::$_cacheStorageClass( $parent,
|
$instance = new self::$cacheStorageClass(
|
||||||
self::$_storageMethodParameters[self::$_cacheStorageMethod]
|
$parent,
|
||||||
);
|
self::$storageMethodParameters[self::$cacheStorageMethod]
|
||||||
if ($instance !== NULL) {
|
);
|
||||||
|
if ($instance !== null) {
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
} // function getInstance()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the cache storage
|
* Clear the cache storage
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
public static function finalize()
|
public static function finalize()
|
||||||
{
|
{
|
||||||
self::$_cacheStorageMethod = NULL;
|
self::$cacheStorageMethod = null;
|
||||||
self::$_cacheStorageClass = NULL;
|
self::$cacheStorageClass = null;
|
||||||
self::$_storageMethodParameters = array();
|
self::$storageMethodParameters = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_CalcEngine_CyclicReferenceStack
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,79 +21,74 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CalcEngine_CyclicReferenceStack
|
* Push a new entry onto the stack
|
||||||
*
|
*
|
||||||
* @category PHPExcel_CalcEngine_CyclicReferenceStack
|
* @param mixed $value
|
||||||
* @package PHPExcel_Calculation
|
*/
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
public function push($value)
|
||||||
*/
|
{
|
||||||
class PHPExcel_CalcEngine_CyclicReferenceStack {
|
$this->stack[$value] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The call stack for calculated cells
|
* Pop the last entry from the stack
|
||||||
*
|
*
|
||||||
* @var mixed[]
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private $_stack = array();
|
public function pop()
|
||||||
|
{
|
||||||
|
return array_pop($this->stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test to see if a specified entry exists on the stack
|
||||||
|
*
|
||||||
|
* @param mixed $value The value to test
|
||||||
|
*/
|
||||||
|
public function onStack($value)
|
||||||
|
{
|
||||||
|
return isset($this->stack[$value]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of entries on the stack
|
* Clear the stack
|
||||||
*
|
*/
|
||||||
* @return integer
|
public function clear()
|
||||||
*/
|
{
|
||||||
public function count() {
|
$this->stack = array();
|
||||||
return count($this->_stack);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Push a new entry onto the stack
|
|
||||||
*
|
|
||||||
* @param mixed $value
|
|
||||||
*/
|
|
||||||
public function push($value) {
|
|
||||||
$this->_stack[$value] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pop the last entry from the stack
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function pop() {
|
|
||||||
return array_pop($this->_stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test to see if a specified entry exists on the stack
|
|
||||||
*
|
|
||||||
* @param mixed $value The value to test
|
|
||||||
*/
|
|
||||||
public function onStack($value) {
|
|
||||||
return isset($this->_stack[$value]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear the stack
|
|
||||||
*/
|
|
||||||
public function clear() {
|
|
||||||
$this->_stack = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an array of all entries on the stack
|
|
||||||
*
|
|
||||||
* @return mixed[]
|
|
||||||
*/
|
|
||||||
public function showStack() {
|
|
||||||
return $this->_stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of all entries on the stack
|
||||||
|
*
|
||||||
|
* @return mixed[]
|
||||||
|
*/
|
||||||
|
public function showStack()
|
||||||
|
{
|
||||||
|
return $this->stack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_CalcEngine_Logger
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,134 +21,131 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CalcEngine_Logger
|
* Flag to determine whether a debug log should be echoed by the calculation engine
|
||||||
*
|
* If true, then a debug log will be echoed
|
||||||
* @category PHPExcel
|
* If false, then a debug log will not be echoed
|
||||||
* @package PHPExcel_Calculation
|
* A debug log can only be echoed if it is generated
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
*
|
||||||
*/
|
* @var boolean
|
||||||
class PHPExcel_CalcEngine_Logger {
|
*/
|
||||||
|
private $echoDebugLog = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to determine whether a debug log should be generated by the calculation engine
|
* The debug log 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 string[]
|
||||||
*
|
*/
|
||||||
* @var boolean
|
private $debugLog = array();
|
||||||
*/
|
|
||||||
private $_writeDebugLog = FALSE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to determine whether a debug log should be echoed by the calculation engine
|
* The calculation engine cell reference stack
|
||||||
* If true, then a debug log will be echoed
|
*
|
||||||
* If false, then a debug log will not be echoed
|
* @var PHPExcel_CalcEngine_CyclicReferenceStack
|
||||||
* A debug log can only be echoed if it is generated
|
*/
|
||||||
*
|
private $cellStack;
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private $_echoDebugLog = FALSE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The debug log generated by the calculation engine
|
* Instantiate a Calculation engine logger
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @param PHPExcel_CalcEngine_CyclicReferenceStack $stack
|
||||||
*/
|
*/
|
||||||
private $_debugLog = array();
|
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack)
|
||||||
|
{
|
||||||
|
$this->cellStack = $stack;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The calculation engine cell reference stack
|
* Enable/Disable Calculation engine logging
|
||||||
*
|
*
|
||||||
* @var PHPExcel_CalcEngine_CyclicReferenceStack
|
* @param boolean $pValue
|
||||||
*/
|
*/
|
||||||
private $_cellStack;
|
public function setWriteDebugLog($pValue = false)
|
||||||
|
{
|
||||||
|
$this->writeDebugLog = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Return whether calculation engine logging is enabled or disabled
|
||||||
* Instantiate a Calculation engine logger
|
*
|
||||||
*
|
* @return boolean
|
||||||
* @param PHPExcel_CalcEngine_CyclicReferenceStack $stack
|
*/
|
||||||
*/
|
public function getWriteDebugLog()
|
||||||
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack) {
|
{
|
||||||
$this->_cellStack = $stack;
|
return $this->writeDebugLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/Disable Calculation engine logging
|
* Enable/Disable echoing of debug log information
|
||||||
*
|
*
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
*/
|
*/
|
||||||
public function setWriteDebugLog($pValue = FALSE) {
|
public function setEchoDebugLog($pValue = false)
|
||||||
$this->_writeDebugLog = $pValue;
|
{
|
||||||
}
|
$this->echoDebugLog = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether calculation engine logging is enabled or disabled
|
* Return whether echoing of debug log information is enabled or disabled
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getWriteDebugLog() {
|
public function getEchoDebugLog()
|
||||||
return $this->_writeDebugLog;
|
{
|
||||||
}
|
return $this->echoDebugLog;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/Disable echoing of debug log information
|
* Write an entry to the calculation engine debug log
|
||||||
*
|
*/
|
||||||
* @param boolean $pValue
|
public function writeDebugLog()
|
||||||
*/
|
{
|
||||||
public function setEchoDebugLog($pValue = FALSE) {
|
// Only write the debug log if logging is enabled
|
||||||
$this->_echoDebugLog = $pValue;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether echoing of debug log information is enabled or disabled
|
* Clear the calculation engine debug log
|
||||||
*
|
*/
|
||||||
* @return boolean
|
public function clearLog()
|
||||||
*/
|
{
|
||||||
public function getEchoDebugLog() {
|
$this->debugLog = array();
|
||||||
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
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the calculation engine debug log
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getLog()
|
||||||
|
{
|
||||||
|
return $this->debugLog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_Exception
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,33 +21,26 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Calculation_Exception extends PHPExcel_Exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Calculation_Exception
|
* Error handler callback
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @param mixed $code
|
||||||
* @package PHPExcel_Calculation
|
* @param mixed $string
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @param mixed $file
|
||||||
*/
|
* @param mixed $line
|
||||||
class PHPExcel_Calculation_Exception extends PHPExcel_Exception {
|
* @param mixed $context
|
||||||
/**
|
*/
|
||||||
* Error handler callback
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
*
|
{
|
||||||
* @param mixed $code
|
$e = new self($string, $code);
|
||||||
* @param mixed $string
|
$e->line = $line;
|
||||||
* @param mixed $file
|
$e->file = $file;
|
||||||
* @param mixed $line
|
throw $e;
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_ExceptionHandler
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,30 +21,25 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Calculation_ExceptionHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register errorhandler
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Calculation_ExceptionHandler
|
* Unregister errorhandler
|
||||||
*
|
*/
|
||||||
* @category PHPExcel
|
public function __destruct()
|
||||||
* @package PHPExcel_Calculation
|
{
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
restore_error_handler();
|
||||||
*/
|
}
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
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
|
* PHPExcel_Calculation_FormulaToken
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,104 +44,74 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
class PHPExcel_Calculation_FormulaToken
|
||||||
PARTLY BASED ON:
|
{
|
||||||
Copyright (c) 2007 E. W. Bachtal, Inc.
|
/* 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';
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
/* Token subtypes */
|
||||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
|
||||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
const TOKEN_SUBTYPE_START = 'Start';
|
||||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
const TOKEN_SUBTYPE_STOP = 'Stop';
|
||||||
subject to the following conditions:
|
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';
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
/**
|
||||||
portions of the Software.
|
* Value
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $value;
|
||||||
|
|
||||||
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
|
* Token Type (represented by TOKEN_TYPE_*)
|
||||||
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
|
* @var string
|
||||||
software or the use or other dealings in the software.
|
*/
|
||||||
|
private $tokenType;
|
||||||
|
|
||||||
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
|
/**
|
||||||
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
|
* Token SubType (represented by TOKEN_SUBTYPE_*)
|
||||||
*/
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
/**
|
private $tokenSubType;
|
||||||
* 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
|
* Create a new PHPExcel_Calculation_FormulaToken
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
|
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
|
||||||
* @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
|
* @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
|
||||||
*/
|
*/
|
||||||
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
||||||
{
|
{
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_value = $pValue;
|
$this->value = $pValue;
|
||||||
$this->_tokenType = $pTokenType;
|
$this->tokenType = $pTokenType;
|
||||||
$this->_tokenSubType = $pTokenSubType;
|
$this->tokenSubType = $pTokenSubType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,17 +119,19 @@ class PHPExcel_Calculation_FormulaToken {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getValue() {
|
public function getValue()
|
||||||
return $this->_value;
|
{
|
||||||
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Value
|
* Set Value
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setValue($value) {
|
public function setValue($value)
|
||||||
$this->_value = $value;
|
{
|
||||||
|
$this->value = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,17 +139,19 @@ class PHPExcel_Calculation_FormulaToken {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTokenType() {
|
public function getTokenType()
|
||||||
return $this->_tokenType;
|
{
|
||||||
|
return $this->tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Token Type
|
* Set Token Type
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) {
|
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN)
|
||||||
$this->_tokenType = $value;
|
{
|
||||||
|
$this->tokenType = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,16 +159,18 @@ class PHPExcel_Calculation_FormulaToken {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTokenSubType() {
|
public function getTokenSubType()
|
||||||
return $this->_tokenSubType;
|
{
|
||||||
|
return $this->tokenSubType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Token SubType
|
* Set Token SubType
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
||||||
$this->_tokenSubType = $value;
|
{
|
||||||
|
$this->tokenSubType = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_Function
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,72 +21,64 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Calculation_Function
|
* Excel name
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @var string
|
||||||
* @package PHPExcel_Calculation
|
*/
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
private $excelName;
|
||||||
*/
|
|
||||||
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_*)
|
* PHPExcel name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_category;
|
private $phpExcelName;
|
||||||
|
|
||||||
/**
|
|
||||||
* Excel name
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_excelName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel name
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_phpExcelName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Calculation_Function
|
* Create a new PHPExcel_Calculation_Function
|
||||||
*
|
*
|
||||||
* @param string $pCategory Category (represented by CATEGORY_*)
|
* @param string $pCategory Category (represented by CATEGORY_*)
|
||||||
* @param string $pExcelName Excel function name
|
* @param string $pExcelName Excel function name
|
||||||
* @param string $pPHPExcelName PHPExcel function mapping
|
* @param string $pPHPExcelName PHPExcel function mapping
|
||||||
* @throws PHPExcel_Calculation_Exception
|
* @throws PHPExcel_Calculation_Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL)
|
public function __construct($pCategory = null, $pExcelName = null, $pPHPExcelName = null)
|
||||||
{
|
{
|
||||||
if (($pCategory !== NULL) && ($pExcelName !== NULL) && ($pPHPExcelName !== NULL)) {
|
if (($pCategory !== null) && ($pExcelName !== null) && ($pPHPExcelName !== null)) {
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_category = $pCategory;
|
$this->category = $pCategory;
|
||||||
$this->_excelName = $pExcelName;
|
$this->excelName = $pExcelName;
|
||||||
$this->_phpExcelName = $pPHPExcelName;
|
$this->phpExcelName = $pPHPExcelName;
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
|
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,22 +86,24 @@ class PHPExcel_Calculation_Function {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCategory() {
|
public function getCategory()
|
||||||
return $this->_category;
|
{
|
||||||
|
return $this->category;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Category (represented by CATEGORY_*)
|
* Set Category (represented by CATEGORY_*)
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @throws PHPExcel_Calculation_Exception
|
* @throws PHPExcel_Calculation_Exception
|
||||||
*/
|
*/
|
||||||
public function setCategory($value = null) {
|
public function setCategory($value = null)
|
||||||
if (!is_null($value)) {
|
{
|
||||||
$this->_category = $value;
|
if (!is_null($value)) {
|
||||||
} else {
|
$this->category = $value;
|
||||||
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
|
} else {
|
||||||
}
|
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,17 +111,19 @@ class PHPExcel_Calculation_Function {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getExcelName() {
|
public function getExcelName()
|
||||||
return $this->_excelName;
|
{
|
||||||
|
return $this->excelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Excel name
|
* Set Excel name
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setExcelName($value) {
|
public function setExcelName($value)
|
||||||
$this->_excelName = $value;
|
{
|
||||||
|
$this->excelName = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,16 +131,18 @@ class PHPExcel_Calculation_Function {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPHPExcelName() {
|
public function getPHPExcelName()
|
||||||
return $this->_phpExcelName;
|
{
|
||||||
|
return $this->phpExcelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set PHPExcel name
|
* Set PHPExcel name
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setPHPExcelName($value) {
|
public function setPHPExcelName($value)
|
||||||
$this->_phpExcelName = $value;
|
{
|
||||||
|
$this->phpExcelName = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_Logical
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,271 +28,258 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel root directory */
|
/**
|
||||||
if (!defined('PHPEXCEL_ROOT')) {
|
* FALSE
|
||||||
/**
|
*
|
||||||
* @ignore
|
* Returns the boolean FALSE.
|
||||||
*/
|
*
|
||||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
* Excel Function:
|
||||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
* =FALSE()
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @category Logical Functions
|
||||||
|
* @return boolean False
|
||||||
|
*/
|
||||||
|
public static function FALSE()
|
||||||
|
{
|
||||||
|
return 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_Token_Stack
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,96 +21,91 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Calculation_Token_Stack
|
* Return the number of entries on the stack
|
||||||
*
|
*
|
||||||
* @category PHPExcel_Calculation_Token_Stack
|
* @return integer
|
||||||
* @package PHPExcel_Calculation
|
*/
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
public function count()
|
||||||
*/
|
{
|
||||||
class PHPExcel_Calculation_Token_Stack {
|
return $this->count;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parser stack for formulae
|
* Push a new entry onto the stack
|
||||||
*
|
*
|
||||||
* @var mixed[]
|
* @param mixed $type
|
||||||
*/
|
* @param mixed $value
|
||||||
private $_stack = array();
|
* @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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count of entries in the parser stack
|
* Pop the last entry from the stack
|
||||||
*
|
*
|
||||||
* @var integer
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private $_count = 0;
|
public function pop()
|
||||||
|
{
|
||||||
|
if ($this->count > 0) {
|
||||||
|
return $this->stack[--$this->count];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of entries on the stack
|
* Clear the stack
|
||||||
*
|
*/
|
||||||
* @return integer
|
public function clear()
|
||||||
*/
|
{
|
||||||
public function count() {
|
$this->stack = array();
|
||||||
return $this->_count;
|
$this->count = 0;
|
||||||
} // 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
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Cell_AdvancedValueBinder
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,29 +30,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Cell
|
* @package PHPExcel_Cell
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel 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
|
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -66,16 +57,16 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
||||||
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
|
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
|
||||||
// Test for booleans using locale-setting
|
// Test for booleans using locale-setting
|
||||||
if ($value == PHPExcel_Calculation::getTRUE()) {
|
if ($value == PHPExcel_Calculation::getTRUE()) {
|
||||||
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
$cell->setValueExplicit(true, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||||
return true;
|
return true;
|
||||||
} elseif($value == PHPExcel_Calculation::getFALSE()) {
|
} elseif ($value == PHPExcel_Calculation::getFALSE()) {
|
||||||
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
$cell->setValueExplicit(false, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for number in scientific format
|
// Check for number in scientific format
|
||||||
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
|
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
|
||||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,20 +74,24 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
||||||
if (preg_match('/^([+-]?)\s*([0-9]+)\s?\/\s*([0-9]+)$/', $value, $matches)) {
|
if (preg_match('/^([+-]?)\s*([0-9]+)\s?\/\s*([0-9]+)$/', $value, $matches)) {
|
||||||
// Convert value to number
|
// Convert value to number
|
||||||
$value = $matches[2] / $matches[3];
|
$value = $matches[2] / $matches[3];
|
||||||
if ($matches[1] == '-') $value = 0 - $value;
|
if ($matches[1] == '-') {
|
||||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$value = 0 - $value;
|
||||||
|
}
|
||||||
|
$cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||||
->getNumberFormat()->setFormatCode( '??/??' );
|
->getNumberFormat()->setFormatCode('??/??');
|
||||||
return true;
|
return true;
|
||||||
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||||
// Convert value to number
|
// Convert value to number
|
||||||
$value = $matches[2] + ($matches[3] / $matches[4]);
|
$value = $matches[2] + ($matches[3] / $matches[4]);
|
||||||
if ($matches[1] == '-') $value = 0 - $value;
|
if ($matches[1] == '-') {
|
||||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$value = 0 - $value;
|
||||||
|
}
|
||||||
|
$cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||||
->getNumberFormat()->setFormatCode( '# ??/??' );
|
->getNumberFormat()->setFormatCode('# ??/??');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,10 +99,10 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
||||||
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
|
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
|
||||||
// Convert value to number
|
// Convert value to number
|
||||||
$value = (float) str_replace('%', '', $value) / 100;
|
$value = (float) str_replace('%', '', $value) / 100;
|
||||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
|
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,20 +113,20 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
||||||
if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) {
|
if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) {
|
||||||
// Convert value to number
|
// Convert value to number
|
||||||
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
|
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
|
||||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||||
->getNumberFormat()->setFormatCode(
|
->getNumberFormat()->setFormatCode(
|
||||||
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
|
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE)
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
|
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
|
||||||
// Convert value to number
|
// Convert value to number
|
||||||
$value = (float) trim(str_replace(array('$',','), '', $value));
|
$value = (float) trim(str_replace(array('$',','), '', $value));
|
||||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
|
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,8 +137,8 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
||||||
$days = $h / 24 + $m / 1440;
|
$days = $h / 24 + $m / 1440;
|
||||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
|
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +150,8 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
||||||
// Convert value to number
|
// Convert value to number
|
||||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
|
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,18 +165,18 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
||||||
} else {
|
} else {
|
||||||
$formatCode = 'yyyy-mm-dd';
|
$formatCode = 'yyyy-mm-dd';
|
||||||
}
|
}
|
||||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||||
->getNumberFormat()->setFormatCode($formatCode);
|
->getNumberFormat()->setFormatCode($formatCode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for newline character "\n"
|
// Check for newline character "\n"
|
||||||
if (strpos($value, "\n") !== FALSE) {
|
if (strpos($value, "\n") !== false) {
|
||||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||||
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
|
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||||
->getAlignment()->setWrapText(TRUE);
|
->getAlignment()->setWrapText(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Cell_DataType
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,19 +21,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Cell
|
* @package PHPExcel_Cell
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Cell_DataType
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Cell
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Cell_DataType
|
class PHPExcel_Cell_DataType
|
||||||
{
|
{
|
||||||
/* Data types */
|
/* Data types */
|
||||||
|
@ -50,7 +42,7 @@ class PHPExcel_Cell_DataType
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $_errorCodes = array(
|
private static $errorCodes = array(
|
||||||
'#NULL!' => 0,
|
'#NULL!' => 0,
|
||||||
'#DIV/0!' => 1,
|
'#DIV/0!' => 1,
|
||||||
'#VALUE!' => 2,
|
'#VALUE!' => 2,
|
||||||
|
@ -65,8 +57,9 @@ class PHPExcel_Cell_DataType
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getErrorCodes() {
|
public static function getErrorCodes()
|
||||||
return self::$_errorCodes;
|
{
|
||||||
|
return self::$errorCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +69,8 @@ class PHPExcel_Cell_DataType
|
||||||
* @param mixed $pValue
|
* @param mixed $pValue
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function dataTypeForValue($pValue = null) {
|
public static function dataTypeForValue($pValue = null)
|
||||||
|
{
|
||||||
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
|
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,11 +106,10 @@ class PHPExcel_Cell_DataType
|
||||||
{
|
{
|
||||||
$pValue = (string) $pValue;
|
$pValue = (string) $pValue;
|
||||||
|
|
||||||
if ( !array_key_exists($pValue, self::$_errorCodes) ) {
|
if (!array_key_exists($pValue, self::$errorCodes)) {
|
||||||
$pValue = '#NULL!';
|
$pValue = '#NULL!';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pValue;
|
return $pValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,19 +21,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Cell
|
* @package PHPExcel_Cell
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Cell_DataValidation
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Cell
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Cell_DataValidation
|
class PHPExcel_Cell_DataValidation
|
||||||
{
|
{
|
||||||
/* Data validation types */
|
/* Data validation types */
|
||||||
|
@ -65,91 +57,91 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_formula1;
|
private $formula1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formula 2
|
* Formula 2
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_formula2;
|
private $formula2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type
|
* Type
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
private $type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error style
|
* Error style
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
private $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operator
|
* Operator
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_operator;
|
private $operator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow Blank
|
* Allow Blank
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_allowBlank;
|
private $allowBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show DropDown
|
* Show DropDown
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showDropDown;
|
private $showDropDown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show InputMessage
|
* Show InputMessage
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showInputMessage;
|
private $showInputMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show ErrorMessage
|
* Show ErrorMessage
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showErrorMessage;
|
private $showErrorMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error title
|
* Error title
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_errorTitle;
|
private $errorTitle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error
|
* Error
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_error;
|
private $error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompt title
|
* Prompt title
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_promptTitle;
|
private $promptTitle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompt
|
* Prompt
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_prompt;
|
private $prompt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Cell_DataValidation
|
* Create a new PHPExcel_Cell_DataValidation
|
||||||
|
@ -157,19 +149,19 @@ class PHPExcel_Cell_DataValidation
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Initialise member variables
|
// Initialise member variables
|
||||||
$this->_formula1 = '';
|
$this->formula1 = '';
|
||||||
$this->_formula2 = '';
|
$this->formula2 = '';
|
||||||
$this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
$this->type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
||||||
$this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
$this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
||||||
$this->_operator = '';
|
$this->operator = '';
|
||||||
$this->_allowBlank = FALSE;
|
$this->allowBlank = false;
|
||||||
$this->_showDropDown = FALSE;
|
$this->showDropDown = false;
|
||||||
$this->_showInputMessage = FALSE;
|
$this->showInputMessage = false;
|
||||||
$this->_showErrorMessage = FALSE;
|
$this->showErrorMessage = false;
|
||||||
$this->_errorTitle = '';
|
$this->errorTitle = '';
|
||||||
$this->_error = '';
|
$this->error = '';
|
||||||
$this->_promptTitle = '';
|
$this->promptTitle = '';
|
||||||
$this->_prompt = '';
|
$this->prompt = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,8 +169,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFormula1() {
|
public function getFormula1()
|
||||||
return $this->_formula1;
|
{
|
||||||
|
return $this->formula1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,8 +180,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setFormula1($value = '') {
|
public function setFormula1($value = '')
|
||||||
$this->_formula1 = $value;
|
{
|
||||||
|
$this->formula1 = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,8 +191,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFormula2() {
|
public function getFormula2()
|
||||||
return $this->_formula2;
|
{
|
||||||
|
return $this->formula2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,8 +202,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setFormula2($value = '') {
|
public function setFormula2($value = '')
|
||||||
$this->_formula2 = $value;
|
{
|
||||||
|
$this->formula2 = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,8 +213,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType()
|
||||||
return $this->_type;
|
{
|
||||||
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,8 +224,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) {
|
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE)
|
||||||
$this->_type = $value;
|
{
|
||||||
|
$this->type = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,8 +235,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getErrorStyle() {
|
public function getErrorStyle()
|
||||||
return $this->_errorStyle;
|
{
|
||||||
|
return $this->errorStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,8 +246,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) {
|
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP)
|
||||||
$this->_errorStyle = $value;
|
{
|
||||||
|
$this->errorStyle = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,8 +257,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getOperator() {
|
public function getOperator()
|
||||||
return $this->_operator;
|
{
|
||||||
|
return $this->operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,8 +268,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setOperator($value = '') {
|
public function setOperator($value = '')
|
||||||
$this->_operator = $value;
|
{
|
||||||
|
$this->operator = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,8 +279,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getAllowBlank() {
|
public function getAllowBlank()
|
||||||
return $this->_allowBlank;
|
{
|
||||||
|
return $this->allowBlank;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -287,8 +290,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param boolean $value
|
* @param boolean $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setAllowBlank($value = false) {
|
public function setAllowBlank($value = false)
|
||||||
$this->_allowBlank = $value;
|
{
|
||||||
|
$this->allowBlank = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,8 +301,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowDropDown() {
|
public function getShowDropDown()
|
||||||
return $this->_showDropDown;
|
{
|
||||||
|
return $this->showDropDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -307,8 +312,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param boolean $value
|
* @param boolean $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setShowDropDown($value = false) {
|
public function setShowDropDown($value = false)
|
||||||
$this->_showDropDown = $value;
|
{
|
||||||
|
$this->showDropDown = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,8 +323,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowInputMessage() {
|
public function getShowInputMessage()
|
||||||
return $this->_showInputMessage;
|
{
|
||||||
|
return $this->showInputMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -327,8 +334,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param boolean $value
|
* @param boolean $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setShowInputMessage($value = false) {
|
public function setShowInputMessage($value = false)
|
||||||
$this->_showInputMessage = $value;
|
{
|
||||||
|
$this->showInputMessage = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,8 +345,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowErrorMessage() {
|
public function getShowErrorMessage()
|
||||||
return $this->_showErrorMessage;
|
{
|
||||||
|
return $this->showErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,8 +356,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param boolean $value
|
* @param boolean $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setShowErrorMessage($value = false) {
|
public function setShowErrorMessage($value = false)
|
||||||
$this->_showErrorMessage = $value;
|
{
|
||||||
|
$this->showErrorMessage = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,8 +367,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getErrorTitle() {
|
public function getErrorTitle()
|
||||||
return $this->_errorTitle;
|
{
|
||||||
|
return $this->errorTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -367,8 +378,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setErrorTitle($value = '') {
|
public function setErrorTitle($value = '')
|
||||||
$this->_errorTitle = $value;
|
{
|
||||||
|
$this->errorTitle = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,8 +389,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getError() {
|
public function getError()
|
||||||
return $this->_error;
|
{
|
||||||
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -387,8 +400,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setError($value = '') {
|
public function setError($value = '')
|
||||||
$this->_error = $value;
|
{
|
||||||
|
$this->error = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,8 +411,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPromptTitle() {
|
public function getPromptTitle()
|
||||||
return $this->_promptTitle;
|
{
|
||||||
|
return $this->promptTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -407,8 +422,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setPromptTitle($value = '') {
|
public function setPromptTitle($value = '')
|
||||||
$this->_promptTitle = $value;
|
{
|
||||||
|
$this->promptTitle = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,8 +433,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPrompt() {
|
public function getPrompt()
|
||||||
return $this->_prompt;
|
{
|
||||||
|
return $this->prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -427,8 +444,9 @@ class PHPExcel_Cell_DataValidation
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_DataValidation
|
* @return PHPExcel_Cell_DataValidation
|
||||||
*/
|
*/
|
||||||
public function setPrompt($value = '') {
|
public function setPrompt($value = '')
|
||||||
$this->_prompt = $value;
|
{
|
||||||
|
$this->prompt = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,29 +455,31 @@ class PHPExcel_Cell_DataValidation
|
||||||
*
|
*
|
||||||
* @return string Hash code
|
* @return string Hash code
|
||||||
*/
|
*/
|
||||||
public function getHashCode() {
|
public function getHashCode()
|
||||||
|
{
|
||||||
return md5(
|
return md5(
|
||||||
$this->_formula1
|
$this->formula1 .
|
||||||
. $this->_formula2
|
$this->formula2 .
|
||||||
. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
|
$this->type = PHPExcel_Cell_DataValidation::TYPE_NONE .
|
||||||
. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
|
$this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP .
|
||||||
. $this->_operator
|
$this->operator .
|
||||||
. ($this->_allowBlank ? 't' : 'f')
|
($this->allowBlank ? 't' : 'f') .
|
||||||
. ($this->_showDropDown ? 't' : 'f')
|
($this->showDropDown ? 't' : 'f') .
|
||||||
. ($this->_showInputMessage ? 't' : 'f')
|
($this->showInputMessage ? 't' : 'f') .
|
||||||
. ($this->_showErrorMessage ? 't' : 'f')
|
($this->showErrorMessage ? 't' : 'f') .
|
||||||
. $this->_errorTitle
|
$this->errorTitle .
|
||||||
. $this->_error
|
$this->error .
|
||||||
. $this->_promptTitle
|
$this->promptTitle .
|
||||||
. $this->_prompt
|
$this->prompt .
|
||||||
. __CLASS__
|
__CLASS__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
|
{
|
||||||
$vars = get_object_vars($this);
|
$vars = get_object_vars($this);
|
||||||
foreach ($vars as $key => $value) {
|
foreach ($vars as $key => $value) {
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Cell_DefaultValueBinder
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,29 +30,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Cell
|
* @package PHPExcel_Cell
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel 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
|
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +58,7 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set value explicit
|
// Set value explicit
|
||||||
$cell->setValueExplicit( $value, self::dataTypeForValue($value) );
|
$cell->setValueExplicit($value, self::dataTypeForValue($value));
|
||||||
|
|
||||||
// Done!
|
// Done!
|
||||||
return true;
|
return true;
|
||||||
|
@ -79,7 +70,8 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||||
* @param mixed $pValue
|
* @param mixed $pValue
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function dataTypeForValue($pValue = null) {
|
public static function dataTypeForValue($pValue = null)
|
||||||
|
{
|
||||||
// Match the value against a few data types
|
// Match the value against a few data types
|
||||||
if ($pValue === null) {
|
if ($pValue === null) {
|
||||||
return PHPExcel_Cell_DataType::TYPE_NULL;
|
return PHPExcel_Cell_DataType::TYPE_NULL;
|
||||||
|
@ -95,9 +87,9 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||||
} elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) {
|
} elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) {
|
||||||
$tValue = ltrim($pValue, '+-');
|
$tValue = ltrim($pValue, '+-');
|
||||||
if (is_string($pValue) && $tValue{0} === '0' && strlen($tValue) > 1 && $tValue{1} !== '.' ) {
|
if (is_string($pValue) && $tValue{0} === '0' && strlen($tValue) > 1 && $tValue{1} !== '.') {
|
||||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||||
} elseif((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
|
} elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
|
||||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||||
}
|
}
|
||||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Cell_Hyperlink
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,19 +21,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Cell
|
* @package PHPExcel_Cell
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Cell_Hyperlink
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Cell
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Cell_Hyperlink
|
class PHPExcel_Cell_Hyperlink
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -40,14 +32,14 @@ class PHPExcel_Cell_Hyperlink
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_url;
|
private $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tooltip to display on the hyperlink
|
* Tooltip to display on the hyperlink
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_tooltip;
|
private $tooltip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Cell_Hyperlink
|
* Create a new PHPExcel_Cell_Hyperlink
|
||||||
|
@ -58,8 +50,8 @@ class PHPExcel_Cell_Hyperlink
|
||||||
public function __construct($pUrl = '', $pTooltip = '')
|
public function __construct($pUrl = '', $pTooltip = '')
|
||||||
{
|
{
|
||||||
// Initialise member variables
|
// Initialise member variables
|
||||||
$this->_url = $pUrl;
|
$this->url = $pUrl;
|
||||||
$this->_tooltip = $pTooltip;
|
$this->tooltip = $pTooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +59,9 @@ class PHPExcel_Cell_Hyperlink
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUrl() {
|
public function getUrl()
|
||||||
return $this->_url;
|
{
|
||||||
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,8 +70,9 @@ class PHPExcel_Cell_Hyperlink
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_Hyperlink
|
* @return PHPExcel_Cell_Hyperlink
|
||||||
*/
|
*/
|
||||||
public function setUrl($value = '') {
|
public function setUrl($value = '')
|
||||||
$this->_url = $value;
|
{
|
||||||
|
$this->url = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +81,9 @@ class PHPExcel_Cell_Hyperlink
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTooltip() {
|
public function getTooltip()
|
||||||
return $this->_tooltip;
|
{
|
||||||
|
return $this->tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,8 +92,9 @@ class PHPExcel_Cell_Hyperlink
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Cell_Hyperlink
|
* @return PHPExcel_Cell_Hyperlink
|
||||||
*/
|
*/
|
||||||
public function setTooltip($value = '') {
|
public function setTooltip($value = '')
|
||||||
$this->_tooltip = $value;
|
{
|
||||||
|
$this->tooltip = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,8 +103,9 @@ class PHPExcel_Cell_Hyperlink
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isInternal() {
|
public function isInternal()
|
||||||
return strpos($this->_url, 'sheet://') !== false;
|
{
|
||||||
|
return strpos($this->url, 'sheet://') !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,11 +113,12 @@ class PHPExcel_Cell_Hyperlink
|
||||||
*
|
*
|
||||||
* @return string Hash code
|
* @return string Hash code
|
||||||
*/
|
*/
|
||||||
public function getHashCode() {
|
public function getHashCode()
|
||||||
|
{
|
||||||
return md5(
|
return md5(
|
||||||
$this->_url
|
$this->url .
|
||||||
. $this->_tooltip
|
$this->tooltip .
|
||||||
. __CLASS__
|
__CLASS__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,7 +21,7 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Cell
|
* @package PHPExcel_Cell
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
@ -31,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Cell
|
* @package PHPExcel_Cell
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
interface PHPExcel_Cell_IValueBinder
|
interface PHPExcel_Cell_IValueBinder
|
||||||
{
|
{
|
||||||
|
@ -42,5 +43,5 @@ interface PHPExcel_Cell_IValueBinder
|
||||||
* @param mixed $value Value to bind in cell
|
* @param mixed $value Value to bind in cell
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function bindValue(PHPExcel_Cell $cell, $value = NULL);
|
public function bindValue(PHPExcel_Cell $cell, $value = null);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,353 +18,373 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Chart
|
* @package PHPExcel_Chart
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Chart_DataSeries
|
* PHPExcel_Chart_DataSeries
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Chart
|
* @package PHPExcel_Chart
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Chart_DataSeries
|
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 TYPE_BARCHART = 'barChart';
|
const GROUPING_CLUSTERED = 'clustered';
|
||||||
const TYPE_BARCHART_3D = 'bar3DChart';
|
const GROUPING_STACKED = 'stacked';
|
||||||
const TYPE_LINECHART = 'lineChart';
|
const GROUPING_PERCENT_STACKED = 'percentStacked';
|
||||||
const TYPE_LINECHART_3D = 'line3DChart';
|
const GROUPING_STANDARD = 'standard';
|
||||||
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 DIRECTION_BAR = 'bar';
|
||||||
const GROUPING_STACKED = 'stacked';
|
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
|
||||||
const GROUPING_PERCENT_STACKED = 'percentStacked';
|
const DIRECTION_COL = 'col';
|
||||||
const GROUPING_STANDARD = 'standard';
|
const DIRECTION_COLUMN = self::DIRECTION_COL;
|
||||||
|
const DIRECTION_VERTICAL = self::DIRECTION_COL;
|
||||||
|
|
||||||
const DIRECTION_BAR = 'bar';
|
const STYLE_LINEMARKER = 'lineMarker';
|
||||||
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
|
const STYLE_SMOOTHMARKER = 'smoothMarker';
|
||||||
const DIRECTION_COL = 'col';
|
const STYLE_MARKER = 'marker';
|
||||||
const DIRECTION_COLUMN = self::DIRECTION_COL;
|
const STYLE_FILLED = 'filled';
|
||||||
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
|
* Series Plot Type
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_plotType = null;
|
private $plotType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot Grouping Type
|
* Plot Grouping Type
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_plotGrouping = null;
|
private $plotGrouping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot Direction
|
* Plot Direction
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_plotDirection = null;
|
private $plotDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot Style
|
* Plot Style
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_plotStyle = null;
|
private $plotStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order of plots in Series
|
* Order of plots in Series
|
||||||
*
|
*
|
||||||
* @var array of integer
|
* @var array of integer
|
||||||
*/
|
*/
|
||||||
private $_plotOrder = array();
|
private $plotOrder = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot Label
|
* Plot Label
|
||||||
*
|
*
|
||||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
private $_plotLabel = array();
|
private $plotLabel = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot Category
|
* Plot Category
|
||||||
*
|
*
|
||||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
private $_plotCategory = array();
|
private $plotCategory = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smooth Line
|
* Smooth Line
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_smoothLine = null;
|
private $smoothLine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot Values
|
* Plot Values
|
||||||
*
|
*
|
||||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
private $_plotValues = array();
|
private $plotValues = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Chart_DataSeries
|
* Create a new PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null)
|
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null)
|
||||||
{
|
{
|
||||||
$this->_plotType = $plotType;
|
$this->plotType = $plotType;
|
||||||
$this->_plotGrouping = $plotGrouping;
|
$this->plotGrouping = $plotGrouping;
|
||||||
$this->_plotOrder = $plotOrder;
|
$this->plotOrder = $plotOrder;
|
||||||
$keys = array_keys($plotValues);
|
$keys = array_keys($plotValues);
|
||||||
$this->_plotValues = $plotValues;
|
$this->plotValues = $plotValues;
|
||||||
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
|
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
|
||||||
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_plotLabel = $plotLabel;
|
$this->plotLabel = $plotLabel;
|
||||||
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
|
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
|
||||||
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||||
}
|
}
|
||||||
$this->_plotCategory = $plotCategory;
|
$this->plotCategory = $plotCategory;
|
||||||
$this->_smoothLine = $smoothLine;
|
$this->smoothLine = $smoothLine;
|
||||||
$this->_plotStyle = $plotStyle;
|
$this->plotStyle = $plotStyle;
|
||||||
|
|
||||||
if (is_null($plotDirection)) {
|
if (is_null($plotDirection)) {
|
||||||
$plotDirection = self::DIRECTION_COL;
|
$plotDirection = self::DIRECTION_COL;
|
||||||
}
|
}
|
||||||
$this->_plotDirection = $plotDirection;
|
$this->plotDirection = $plotDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Type
|
* Get Plot Type
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPlotType() {
|
public function getPlotType()
|
||||||
return $this->_plotType;
|
{
|
||||||
}
|
return $this->plotType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Plot Type
|
* Set Plot Type
|
||||||
*
|
*
|
||||||
* @param string $plotType
|
* @param string $plotType
|
||||||
* @return PHPExcel_Chart_DataSeries
|
* @return PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
public function setPlotType($plotType = '') {
|
public function setPlotType($plotType = '')
|
||||||
$this->_plotType = $plotType;
|
{
|
||||||
|
$this->plotType = $plotType;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Grouping Type
|
* Get Plot Grouping Type
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPlotGrouping() {
|
public function getPlotGrouping()
|
||||||
return $this->_plotGrouping;
|
{
|
||||||
}
|
return $this->plotGrouping;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Plot Grouping Type
|
* Set Plot Grouping Type
|
||||||
*
|
*
|
||||||
* @param string $groupingType
|
* @param string $groupingType
|
||||||
* @return PHPExcel_Chart_DataSeries
|
* @return PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
public function setPlotGrouping($groupingType = null) {
|
public function setPlotGrouping($groupingType = null)
|
||||||
$this->_plotGrouping = $groupingType;
|
{
|
||||||
|
$this->plotGrouping = $groupingType;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Direction
|
* Get Plot Direction
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPlotDirection() {
|
public function getPlotDirection()
|
||||||
return $this->_plotDirection;
|
{
|
||||||
}
|
return $this->plotDirection;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Plot Direction
|
* Set Plot Direction
|
||||||
*
|
*
|
||||||
* @param string $plotDirection
|
* @param string $plotDirection
|
||||||
* @return PHPExcel_Chart_DataSeries
|
* @return PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
public function setPlotDirection($plotDirection = null) {
|
public function setPlotDirection($plotDirection = null)
|
||||||
$this->_plotDirection = $plotDirection;
|
{
|
||||||
|
$this->plotDirection = $plotDirection;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Order
|
* Get Plot Order
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPlotOrder() {
|
public function getPlotOrder()
|
||||||
return $this->_plotOrder;
|
{
|
||||||
}
|
return $this->plotOrder;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Labels
|
* Get Plot Labels
|
||||||
*
|
*
|
||||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function getPlotLabels() {
|
public function getPlotLabels()
|
||||||
return $this->_plotLabel;
|
{
|
||||||
}
|
return $this->plotLabel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Label by Index
|
* Get Plot Label by Index
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Chart_DataSeriesValues
|
* @return PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function getPlotLabelByIndex($index) {
|
public function getPlotLabelByIndex($index)
|
||||||
$keys = array_keys($this->_plotLabel);
|
{
|
||||||
if (in_array($index,$keys)) {
|
$keys = array_keys($this->plotLabel);
|
||||||
return $this->_plotLabel[$index];
|
if (in_array($index, $keys)) {
|
||||||
} elseif(isset($keys[$index])) {
|
return $this->plotLabel[$index];
|
||||||
return $this->_plotLabel[$keys[$index]];
|
} elseif (isset($keys[$index])) {
|
||||||
}
|
return $this->plotLabel[$keys[$index]];
|
||||||
return false;
|
}
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Categories
|
* Get Plot Categories
|
||||||
*
|
*
|
||||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function getPlotCategories() {
|
public function getPlotCategories()
|
||||||
return $this->_plotCategory;
|
{
|
||||||
}
|
return $this->plotCategory;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Category by Index
|
* Get Plot Category by Index
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Chart_DataSeriesValues
|
* @return PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function getPlotCategoryByIndex($index) {
|
public function getPlotCategoryByIndex($index)
|
||||||
$keys = array_keys($this->_plotCategory);
|
{
|
||||||
if (in_array($index,$keys)) {
|
$keys = array_keys($this->plotCategory);
|
||||||
return $this->_plotCategory[$index];
|
if (in_array($index, $keys)) {
|
||||||
} elseif(isset($keys[$index])) {
|
return $this->plotCategory[$index];
|
||||||
return $this->_plotCategory[$keys[$index]];
|
} elseif (isset($keys[$index])) {
|
||||||
}
|
return $this->plotCategory[$keys[$index]];
|
||||||
return false;
|
}
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Style
|
* Get Plot Style
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPlotStyle() {
|
public function getPlotStyle()
|
||||||
return $this->_plotStyle;
|
{
|
||||||
}
|
return $this->plotStyle;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Plot Style
|
* Set Plot Style
|
||||||
*
|
*
|
||||||
* @param string $plotStyle
|
* @param string $plotStyle
|
||||||
* @return PHPExcel_Chart_DataSeries
|
* @return PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
public function setPlotStyle($plotStyle = null) {
|
public function setPlotStyle($plotStyle = null)
|
||||||
$this->_plotStyle = $plotStyle;
|
{
|
||||||
|
$this->plotStyle = $plotStyle;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Values
|
* Get Plot Values
|
||||||
*
|
*
|
||||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function getPlotValues() {
|
public function getPlotValues()
|
||||||
return $this->_plotValues;
|
{
|
||||||
}
|
return $this->plotValues;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Values by Index
|
* Get Plot Values by Index
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Chart_DataSeriesValues
|
* @return PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function getPlotValuesByIndex($index) {
|
public function getPlotValuesByIndex($index)
|
||||||
$keys = array_keys($this->_plotValues);
|
{
|
||||||
if (in_array($index,$keys)) {
|
$keys = array_keys($this->plotValues);
|
||||||
return $this->_plotValues[$index];
|
if (in_array($index, $keys)) {
|
||||||
} elseif(isset($keys[$index])) {
|
return $this->plotValues[$index];
|
||||||
return $this->_plotValues[$keys[$index]];
|
} elseif (isset($keys[$index])) {
|
||||||
}
|
return $this->plotValues[$keys[$index]];
|
||||||
return false;
|
}
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Number of Plot Series
|
* Get Number of Plot Series
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getPlotSeriesCount() {
|
public function getPlotSeriesCount()
|
||||||
return count($this->_plotValues);
|
{
|
||||||
}
|
return count($this->plotValues);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Smooth Line
|
* Get Smooth Line
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getSmoothLine() {
|
public function getSmoothLine()
|
||||||
return $this->_smoothLine;
|
{
|
||||||
}
|
return $this->smoothLine;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Smooth Line
|
* Set Smooth Line
|
||||||
*
|
*
|
||||||
* @param boolean $smoothLine
|
* @param boolean $smoothLine
|
||||||
* @return PHPExcel_Chart_DataSeries
|
* @return PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
public function setSmoothLine($smoothLine = TRUE) {
|
public function setSmoothLine($smoothLine = true)
|
||||||
$this->_smoothLine = $smoothLine;
|
{
|
||||||
|
$this->smoothLine = $smoothLine;
|
||||||
return $this;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Chart_DataSeriesValues
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,310 +19,315 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Chart
|
* @package PHPExcel_Chart
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Chart_DataSeriesValues
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Chart
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Chart_DataSeriesValues
|
class PHPExcel_Chart_DataSeriesValues
|
||||||
{
|
{
|
||||||
|
|
||||||
const DATASERIES_TYPE_STRING = 'String';
|
const DATASERIES_TYPE_STRING = 'String';
|
||||||
const DATASERIES_TYPE_NUMBER = 'Number';
|
const DATASERIES_TYPE_NUMBER = 'Number';
|
||||||
|
|
||||||
private static $_dataTypeValues = array(
|
private static $dataTypeValues = array(
|
||||||
self::DATASERIES_TYPE_STRING,
|
self::DATASERIES_TYPE_STRING,
|
||||||
self::DATASERIES_TYPE_NUMBER,
|
self::DATASERIES_TYPE_NUMBER,
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Series Data Type
|
* Series Data Type
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_dataType = null;
|
private $dataType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Series Data Source
|
* Series Data Source
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_dataSource = null;
|
private $dataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format Code
|
* Format Code
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_formatCode = null;
|
private $formatCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Series Point Marker
|
* Series Point Marker
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_marker = null;
|
private $pointMarker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Point Count (The number of datapoints in the dataseries)
|
* Point Count (The number of datapoints in the dataseries)
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
private $_pointCount = 0;
|
private $pointCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data Values
|
* Data Values
|
||||||
*
|
*
|
||||||
* @var array of mixed
|
* @var array of mixed
|
||||||
*/
|
*/
|
||||||
private $_dataValues = array();
|
private $dataValues = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Chart_DataSeriesValues object
|
* Create a new PHPExcel_Chart_DataSeriesValues object
|
||||||
*/
|
*/
|
||||||
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
|
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
|
||||||
{
|
{
|
||||||
$this->setDataType($dataType);
|
$this->setDataType($dataType);
|
||||||
$this->_dataSource = $dataSource;
|
$this->dataSource = $dataSource;
|
||||||
$this->_formatCode = $formatCode;
|
$this->formatCode = $formatCode;
|
||||||
$this->_pointCount = $pointCount;
|
$this->pointCount = $pointCount;
|
||||||
$this->_dataValues = $dataValues;
|
$this->dataValues = $dataValues;
|
||||||
$this->_marker = $marker;
|
$this->pointMarker = $marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Series Data Type
|
* Get Series Data Type
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDataType() {
|
public function getDataType()
|
||||||
return $this->_dataType;
|
{
|
||||||
}
|
return $this->dataType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Series Data Type
|
* Set Series Data Type
|
||||||
*
|
*
|
||||||
* @param string $dataType Datatype of this data series
|
* @param string $dataType Datatype of this data series
|
||||||
* Typical values are:
|
* Typical values are:
|
||||||
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
|
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
|
||||||
* Normally used for axis point values
|
* Normally used for axis point values
|
||||||
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
|
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
|
||||||
* Normally used for chart data values
|
* Normally used for chart data values
|
||||||
* @return PHPExcel_Chart_DataSeriesValues
|
* @return PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) {
|
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER)
|
||||||
if (!in_array($dataType, self::$_dataTypeValues)) {
|
{
|
||||||
throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
|
if (!in_array($dataType, self::$dataTypeValues)) {
|
||||||
}
|
throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
|
||||||
$this->_dataType = $dataType;
|
}
|
||||||
|
$this->dataType = $dataType;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Series Data Source (formula)
|
* Get Series Data Source (formula)
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDataSource() {
|
public function getDataSource()
|
||||||
return $this->_dataSource;
|
{
|
||||||
}
|
return $this->dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Series Data Source (formula)
|
* Set Series Data Source (formula)
|
||||||
*
|
*
|
||||||
* @param string $dataSource
|
* @param string $dataSource
|
||||||
* @return PHPExcel_Chart_DataSeriesValues
|
* @return PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function setDataSource($dataSource = null, $refreshDataValues = true) {
|
public function setDataSource($dataSource = null, $refreshDataValues = true)
|
||||||
$this->_dataSource = $dataSource;
|
{
|
||||||
|
$this->dataSource = $dataSource;
|
||||||
|
|
||||||
if ($refreshDataValues) {
|
if ($refreshDataValues) {
|
||||||
// TO DO
|
// TO DO
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Point Marker
|
* Get Point Marker
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPointMarker() {
|
public function getPointMarker()
|
||||||
return $this->_marker;
|
{
|
||||||
}
|
return $this->pointMarker;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Point Marker
|
* Set Point Marker
|
||||||
*
|
*
|
||||||
* @param string $marker
|
* @param string $marker
|
||||||
* @return PHPExcel_Chart_DataSeriesValues
|
* @return PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function setPointMarker($marker = null) {
|
public function setPointMarker($marker = null)
|
||||||
$this->_marker = $marker;
|
{
|
||||||
|
$this->pointMarker = $marker;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Series Format Code
|
* Get Series Format Code
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFormatCode() {
|
public function getFormatCode()
|
||||||
return $this->_formatCode;
|
{
|
||||||
}
|
return $this->formatCode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Series Format Code
|
* Set Series Format Code
|
||||||
*
|
*
|
||||||
* @param string $formatCode
|
* @param string $formatCode
|
||||||
* @return PHPExcel_Chart_DataSeriesValues
|
* @return PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function setFormatCode($formatCode = null) {
|
public function setFormatCode($formatCode = null)
|
||||||
$this->_formatCode = $formatCode;
|
{
|
||||||
|
$this->formatCode = $formatCode;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Series Point Count
|
* Get Series Point Count
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getPointCount() {
|
public function getPointCount()
|
||||||
return $this->_pointCount;
|
{
|
||||||
}
|
return $this->pointCount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify if the Data Series is a multi-level or a simple series
|
* Identify if the Data Series is a multi-level or a simple series
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isMultiLevelSeries() {
|
public function isMultiLevelSeries()
|
||||||
if (count($this->_dataValues) > 0) {
|
{
|
||||||
return is_array($this->_dataValues[0]);
|
if (count($this->dataValues) > 0) {
|
||||||
}
|
return is_array($this->dataValues[0]);
|
||||||
return null;
|
}
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the level count of a multi-level Data Series
|
* Return the level count of a multi-level Data Series
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function multiLevelCount() {
|
public function multiLevelCount()
|
||||||
$levelCount = 0;
|
{
|
||||||
foreach($this->_dataValues as $dataValueSet) {
|
$levelCount = 0;
|
||||||
$levelCount = max($levelCount,count($dataValueSet));
|
foreach ($this->dataValues as $dataValueSet) {
|
||||||
}
|
$levelCount = max($levelCount, count($dataValueSet));
|
||||||
return $levelCount;
|
}
|
||||||
}
|
return $levelCount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Series Data Values
|
* Get Series Data Values
|
||||||
*
|
*
|
||||||
* @return array of mixed
|
* @return array of mixed
|
||||||
*/
|
*/
|
||||||
public function getDataValues() {
|
public function getDataValues()
|
||||||
return $this->_dataValues;
|
{
|
||||||
}
|
return $this->dataValues;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the first Series Data value
|
* Get the first Series Data value
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getDataValue() {
|
public function getDataValue()
|
||||||
$count = count($this->_dataValues);
|
{
|
||||||
if ($count == 0) {
|
$count = count($this->dataValues);
|
||||||
return null;
|
if ($count == 0) {
|
||||||
} elseif ($count == 1) {
|
return null;
|
||||||
return $this->_dataValues[0];
|
} elseif ($count == 1) {
|
||||||
}
|
return $this->dataValues[0];
|
||||||
return $this->_dataValues;
|
}
|
||||||
}
|
return $this->dataValues;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Series Data Values
|
* Set Series Data Values
|
||||||
*
|
*
|
||||||
* @param array $dataValues
|
* @param array $dataValues
|
||||||
* @param boolean $refreshDataSource
|
* @param boolean $refreshDataSource
|
||||||
* TRUE - refresh the value of _dataSource based on the values of $dataValues
|
* TRUE - refresh the value of dataSource based on the values of $dataValues
|
||||||
* FALSE - don't change the value of _dataSource
|
* FALSE - don't change the value of dataSource
|
||||||
* @return PHPExcel_Chart_DataSeriesValues
|
* @return PHPExcel_Chart_DataSeriesValues
|
||||||
*/
|
*/
|
||||||
public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) {
|
public function setDataValues($dataValues = array(), $refreshDataSource = true)
|
||||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
|
{
|
||||||
$this->_pointCount = count($dataValues);
|
$this->dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
|
||||||
|
$this->pointCount = count($dataValues);
|
||||||
|
|
||||||
if ($refreshDataSource) {
|
if ($refreshDataSource) {
|
||||||
// TO DO
|
// TO DO
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _stripNulls($var) {
|
private function stripNulls($var)
|
||||||
return $var !== NULL;
|
{
|
||||||
}
|
return $var !== null;
|
||||||
|
}
|
||||||
|
|
||||||
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) {
|
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = true)
|
||||||
if ($this->_dataSource !== NULL) {
|
{
|
||||||
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
|
if ($this->dataSource !== null) {
|
||||||
$newDataValues = PHPExcel_Calculation::_unwrapResult(
|
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
|
||||||
$calcEngine->_calculateFormulaValue(
|
$newDataValues = PHPExcel_Calculation::unwrapResult(
|
||||||
'='.$this->_dataSource,
|
$calcEngine->_calculateFormulaValue(
|
||||||
NULL,
|
'='.$this->dataSource,
|
||||||
$worksheet->getCell('A1')
|
null,
|
||||||
)
|
$worksheet->getCell('A1')
|
||||||
);
|
)
|
||||||
if ($flatten) {
|
);
|
||||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
|
if ($flatten) {
|
||||||
foreach($this->_dataValues as &$dataValue) {
|
$this->dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
|
||||||
if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
|
foreach ($this->dataValues as &$dataValue) {
|
||||||
$dataValue = 0.0;
|
if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
|
||||||
}
|
$dataValue = 0.0;
|
||||||
}
|
}
|
||||||
unset($dataValue);
|
}
|
||||||
} else {
|
unset($dataValue);
|
||||||
$cellRange = explode('!',$this->_dataSource);
|
} else {
|
||||||
if (count($cellRange) > 1) {
|
$cellRange = explode('!', $this->dataSource);
|
||||||
list(,$cellRange) = $cellRange;
|
if (count($cellRange) > 1) {
|
||||||
}
|
list(, $cellRange) = $cellRange;
|
||||||
|
}
|
||||||
|
|
||||||
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange));
|
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$', '', $cellRange));
|
||||||
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
|
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
|
||||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
|
$this->dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
|
||||||
} else {
|
} else {
|
||||||
$newArray = array_values(array_shift($newDataValues));
|
$newArray = array_values(array_shift($newDataValues));
|
||||||
foreach($newArray as $i => $newDataSet) {
|
foreach ($newArray as $i => $newDataSet) {
|
||||||
$newArray[$i] = array($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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
foreach ($newDataValues as $newDataSet) {
|
||||||
|
$i = 0;
|
||||||
|
foreach ($newDataSet as $newDataVal) {
|
||||||
|
array_unshift($newArray[$i++], $newDataVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->dataValues = $newArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->pointCount = count($this->dataValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Chart_Exception
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,33 +21,26 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Chart
|
* @package PHPExcel_Chart
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Chart_Exception extends PHPExcel_Exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Chart_Exception
|
* Error handler callback
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @param mixed $code
|
||||||
* @package PHPExcel_Chart
|
* @param mixed $string
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @param mixed $file
|
||||||
*/
|
* @param mixed $line
|
||||||
class PHPExcel_Chart_Exception extends PHPExcel_Exception {
|
* @param mixed $context
|
||||||
/**
|
*/
|
||||||
* Error handler callback
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
*
|
{
|
||||||
* @param mixed $code
|
$e = new self($string, $code);
|
||||||
* @param mixed $string
|
$e->line = $line;
|
||||||
* @param mixed $file
|
$e->file = $file;
|
||||||
* @param mixed $line
|
throw $e;
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
require_once 'Properties.php';
|
|
||||||
/**
|
/**
|
||||||
* Created by PhpStorm.
|
* Created by PhpStorm.
|
||||||
* User: Wiktor Trzonkowski
|
* User: Wiktor Trzonkowski
|
||||||
|
@ -7,8 +7,8 @@ require_once 'Properties.php';
|
||||||
* Time: 2:36 PM
|
* Time: 2:36 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PHPExcel_Chart_GridLines extends
|
class PHPExcel_Chart_GridLines extends PHPExcel_Chart_Properties
|
||||||
PHPExcel_Properties {
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properties of Class:
|
* Properties of Class:
|
||||||
|
@ -20,439 +20,453 @@ class PHPExcel_Chart_GridLines extends
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private
|
private $objectState = false;
|
||||||
$_object_state = FALSE,
|
|
||||||
$_line_properties = array(
|
|
||||||
'color' => array(
|
|
||||||
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
|
||||||
'value' => NULL,
|
|
||||||
'alpha' => 0
|
|
||||||
),
|
|
||||||
'style' => array(
|
|
||||||
'width' => '9525',
|
|
||||||
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
|
|
||||||
'dash' => self::LINE_STYLE_DASH_SOLID,
|
|
||||||
'cap' => self::LINE_STYLE_CAP_FLAT,
|
|
||||||
'join' => self::LINE_STYLE_JOIN_BEVEL,
|
|
||||||
'arrow' => array(
|
|
||||||
'head' => array(
|
|
||||||
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
|
||||||
'size' => self::LINE_STYLE_ARROW_SIZE_5
|
|
||||||
),
|
|
||||||
'end' => array(
|
|
||||||
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
|
||||||
'size' => self::LINE_STYLE_ARROW_SIZE_8
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
$_shadow_properties = array(
|
|
||||||
'presets' => self::SHADOW_PRESETS_NOSHADOW,
|
|
||||||
'effect' => NULL,
|
|
||||||
'color' => array(
|
|
||||||
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
|
||||||
'value' => 'black',
|
|
||||||
'alpha' => 85,
|
|
||||||
),
|
|
||||||
'size' => array(
|
|
||||||
'sx' => NULL,
|
|
||||||
'sy' => NULL,
|
|
||||||
'kx' => NULL
|
|
||||||
),
|
|
||||||
'blur' => NULL,
|
|
||||||
'direction' => NULL,
|
|
||||||
'distance' => NULL,
|
|
||||||
'algn' => NULL,
|
|
||||||
'rotWithShape' => NULL
|
|
||||||
),
|
|
||||||
$_glow_properties = array(
|
|
||||||
'size' => NULL,
|
|
||||||
'color' => array(
|
|
||||||
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
|
||||||
'value' => 'black',
|
|
||||||
'alpha' => 40
|
|
||||||
)
|
|
||||||
),
|
|
||||||
$_soft_edges = array(
|
|
||||||
'size' => NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
private $lineProperties = array(
|
||||||
* Get Object State
|
'color' => array(
|
||||||
*
|
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
||||||
* @return bool
|
'value' => null,
|
||||||
*/
|
'alpha' => 0
|
||||||
|
),
|
||||||
|
'style' => array(
|
||||||
|
'width' => '9525',
|
||||||
|
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
|
||||||
|
'dash' => self::LINE_STYLE_DASH_SOLID,
|
||||||
|
'cap' => self::LINE_STYLE_CAP_FLAT,
|
||||||
|
'join' => self::LINE_STYLE_JOIN_BEVEL,
|
||||||
|
'arrow' => array(
|
||||||
|
'head' => array(
|
||||||
|
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
||||||
|
'size' => self::LINE_STYLE_ARROW_SIZE_5
|
||||||
|
),
|
||||||
|
'end' => array(
|
||||||
|
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
||||||
|
'size' => self::LINE_STYLE_ARROW_SIZE_8
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
public function getObjectState() {
|
private $shadowProperties = array(
|
||||||
return $this->_object_state;
|
'presets' => self::SHADOW_PRESETS_NOSHADOW,
|
||||||
}
|
'effect' => null,
|
||||||
|
'color' => array(
|
||||||
|
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
||||||
|
'value' => 'black',
|
||||||
|
'alpha' => 85,
|
||||||
|
),
|
||||||
|
'size' => array(
|
||||||
|
'sx' => null,
|
||||||
|
'sy' => null,
|
||||||
|
'kx' => null
|
||||||
|
),
|
||||||
|
'blur' => null,
|
||||||
|
'direction' => null,
|
||||||
|
'distance' => null,
|
||||||
|
'algn' => null,
|
||||||
|
'rotWithShape' => null
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
private $glowProperties = array(
|
||||||
* Change Object State to True
|
'size' => null,
|
||||||
*
|
'color' => array(
|
||||||
* @return PHPExcel_Chart_GridLines
|
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
||||||
*/
|
'value' => 'black',
|
||||||
|
'alpha' => 40
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
private function _activateObject() {
|
private $softEdges = array(
|
||||||
$this->_object_state = TRUE;
|
'size' => null
|
||||||
|
);
|
||||||
|
|
||||||
return $this;
|
/**
|
||||||
}
|
* Get Object State
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
public function getObjectState()
|
||||||
* Set Line Color Properties
|
{
|
||||||
*
|
return $this->objectState;
|
||||||
* @param string $value
|
|
||||||
* @param int $alpha
|
|
||||||
* @param string $type
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD) {
|
|
||||||
$this
|
|
||||||
->_activateObject()
|
|
||||||
->_line_properties['color'] = $this->setColorProperties(
|
|
||||||
$value,
|
|
||||||
$alpha,
|
|
||||||
$type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Line Color Properties
|
|
||||||
*
|
|
||||||
* @param float $line_width
|
|
||||||
* @param string $compound_type
|
|
||||||
* @param string $dash_type
|
|
||||||
* @param string $cap_type
|
|
||||||
* @param string $join_type
|
|
||||||
* @param string $head_arrow_type
|
|
||||||
* @param string $head_arrow_size
|
|
||||||
* @param string $end_arrow_type
|
|
||||||
* @param string $end_arrow_size
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function setLineStyleProperties($line_width = NULL, $compound_type = NULL, $dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL, $head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) {
|
|
||||||
$this->_activateObject();
|
|
||||||
(!is_null($line_width))
|
|
||||||
? $this->_line_properties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
|
|
||||||
: NULL;
|
|
||||||
(!is_null($compound_type))
|
|
||||||
? $this->_line_properties['style']['compound'] = (string) $compound_type
|
|
||||||
: NULL;
|
|
||||||
(!is_null($dash_type))
|
|
||||||
? $this->_line_properties['style']['dash'] = (string) $dash_type
|
|
||||||
: NULL;
|
|
||||||
(!is_null($cap_type))
|
|
||||||
? $this->_line_properties['style']['cap'] = (string) $cap_type
|
|
||||||
: NULL;
|
|
||||||
(!is_null($join_type))
|
|
||||||
? $this->_line_properties['style']['join'] = (string) $join_type
|
|
||||||
: NULL;
|
|
||||||
(!is_null($head_arrow_type))
|
|
||||||
? $this->_line_properties['style']['arrow']['head']['type'] = (string) $head_arrow_type
|
|
||||||
: NULL;
|
|
||||||
(!is_null($head_arrow_size))
|
|
||||||
? $this->_line_properties['style']['arrow']['head']['size'] = (string) $head_arrow_size
|
|
||||||
: NULL;
|
|
||||||
(!is_null($end_arrow_type))
|
|
||||||
? $this->_line_properties['style']['arrow']['end']['type'] = (string) $end_arrow_type
|
|
||||||
: NULL;
|
|
||||||
(!is_null($end_arrow_size))
|
|
||||||
? $this->_line_properties['style']['arrow']['end']['size'] = (string) $end_arrow_size
|
|
||||||
: NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Line Color Property
|
|
||||||
*
|
|
||||||
* @param string $parameter
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getLineColorProperty($parameter) {
|
|
||||||
return $this->_line_properties['color'][$parameter];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Line Style Property
|
|
||||||
*
|
|
||||||
* @param array|string $elements
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getLineStyleProperty($elements) {
|
|
||||||
return $this->getArrayElementsValue($this->_line_properties['style'], $elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Glow Properties
|
|
||||||
*
|
|
||||||
* @param float $size
|
|
||||||
* @param string $color_value
|
|
||||||
* @param int $color_alpha
|
|
||||||
* @param string $color_type
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) {
|
|
||||||
$this
|
|
||||||
->_activateObject()
|
|
||||||
->_setGlowSize($size)
|
|
||||||
->_setGlowColor($color_value, $color_alpha, $color_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Glow Color Property
|
|
||||||
*
|
|
||||||
* @param string $property
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getGlowColor($property) {
|
|
||||||
return $this->_glow_properties['color'][$property];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Glow Size
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getGlowSize() {
|
|
||||||
return $this->_glow_properties['size'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Glow Size
|
|
||||||
*
|
|
||||||
* @param float $size
|
|
||||||
*
|
|
||||||
* @return PHPExcel_Chart_GridLines
|
|
||||||
*/
|
|
||||||
|
|
||||||
private function _setGlowSize($size) {
|
|
||||||
$this->_glow_properties['size'] = $this->getExcelPointsWidth((float) $size);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Glow Color
|
|
||||||
*
|
|
||||||
* @param string $color
|
|
||||||
* @param int $alpha
|
|
||||||
* @param string $type
|
|
||||||
*
|
|
||||||
* @return PHPExcel_Chart_GridLines
|
|
||||||
*/
|
|
||||||
|
|
||||||
private function _setGlowColor($color, $alpha, $type) {
|
|
||||||
if (!is_null($color)) {
|
|
||||||
$this->_glow_properties['color']['value'] = (string) $color;
|
|
||||||
}
|
|
||||||
if (!is_null($alpha)) {
|
|
||||||
$this->_glow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
|
|
||||||
}
|
|
||||||
if (!is_null($type)) {
|
|
||||||
$this->_glow_properties['color']['type'] = (string) $type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
/**
|
||||||
}
|
* Change Object State to True
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Chart_GridLines
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
private function activateObject()
|
||||||
* Get Line Style Arrow Parameters
|
{
|
||||||
*
|
$this->objectState = true;
|
||||||
* @param string $arrow_selector
|
|
||||||
* @param string $property_selector
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getLineStyleArrowParameters($arrow_selector, $property_selector) {
|
return $this;
|
||||||
return $this->getLineStyleArrowSize($this->_line_properties['style']['arrow'][$arrow_selector]['size'], $property_selector);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Shadow Properties
|
* Set Line Color Properties
|
||||||
*
|
*
|
||||||
* @param int $sh_presets
|
* @param string $value
|
||||||
* @param string $sh_color_value
|
* @param int $alpha
|
||||||
* @param string $sh_color_type
|
* @param string $type
|
||||||
* @param int $sh_color_alpha
|
*/
|
||||||
* @param string $sh_blur
|
|
||||||
* @param int $sh_angle
|
|
||||||
* @param float $sh_distance
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) {
|
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD)
|
||||||
$this
|
{
|
||||||
->_activateObject()
|
$this->activateObject()
|
||||||
->_setShadowPresetsProperties((int) $sh_presets)
|
->lineProperties['color'] = $this->setColorProperties(
|
||||||
->_setShadowColor(
|
$value,
|
||||||
is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value
|
$alpha,
|
||||||
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha']
|
$type
|
||||||
: $this->getTrueAlpha($sh_color_alpha)
|
);
|
||||||
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
|
}
|
||||||
->_setShadowBlur($sh_blur)
|
|
||||||
->_setShadowAngle($sh_angle)
|
|
||||||
->_setShadowDistance($sh_distance);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Shadow Presets Properties
|
* Set Line Color Properties
|
||||||
*
|
*
|
||||||
* @param int $shadow_presets
|
* @param float $line_width
|
||||||
*
|
* @param string $compound_type
|
||||||
* @return PHPExcel_Chart_GridLines
|
* @param string $dash_type
|
||||||
*/
|
* @param string $cap_type
|
||||||
|
* @param string $join_type
|
||||||
|
* @param string $head_arrow_type
|
||||||
|
* @param string $head_arrow_size
|
||||||
|
* @param string $end_arrow_type
|
||||||
|
* @param string $end_arrow_size
|
||||||
|
*/
|
||||||
|
|
||||||
private function _setShadowPresetsProperties($shadow_presets) {
|
public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null)
|
||||||
$this->_shadow_properties['presets'] = $shadow_presets;
|
{
|
||||||
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
|
$this->activateObject();
|
||||||
|
(!is_null($line_width))
|
||||||
|
? $this->lineProperties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
|
||||||
|
: null;
|
||||||
|
(!is_null($compound_type))
|
||||||
|
? $this->lineProperties['style']['compound'] = (string) $compound_type
|
||||||
|
: null;
|
||||||
|
(!is_null($dash_type))
|
||||||
|
? $this->lineProperties['style']['dash'] = (string) $dash_type
|
||||||
|
: null;
|
||||||
|
(!is_null($cap_type))
|
||||||
|
? $this->lineProperties['style']['cap'] = (string) $cap_type
|
||||||
|
: null;
|
||||||
|
(!is_null($join_type))
|
||||||
|
? $this->lineProperties['style']['join'] = (string) $join_type
|
||||||
|
: null;
|
||||||
|
(!is_null($head_arrow_type))
|
||||||
|
? $this->lineProperties['style']['arrow']['head']['type'] = (string) $head_arrow_type
|
||||||
|
: null;
|
||||||
|
(!is_null($head_arrow_size))
|
||||||
|
? $this->lineProperties['style']['arrow']['head']['size'] = (string) $head_arrow_size
|
||||||
|
: null;
|
||||||
|
(!is_null($end_arrow_type))
|
||||||
|
? $this->lineProperties['style']['arrow']['end']['type'] = (string) $end_arrow_type
|
||||||
|
: null;
|
||||||
|
(!is_null($end_arrow_size))
|
||||||
|
? $this->lineProperties['style']['arrow']['end']['size'] = (string) $end_arrow_size
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
/**
|
||||||
}
|
* Get Line Color Property
|
||||||
|
*
|
||||||
|
* @param string $parameter
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
public function getLineColorProperty($parameter)
|
||||||
* Set Shadow Properties Values
|
{
|
||||||
*
|
return $this->lineProperties['color'][$parameter];
|
||||||
* @param array $properties_map
|
}
|
||||||
* @param * $reference
|
|
||||||
*
|
|
||||||
* @return PHPExcel_Chart_GridLines
|
|
||||||
*/
|
|
||||||
|
|
||||||
private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) {
|
/**
|
||||||
$base_reference = $reference;
|
* Get Line Style Property
|
||||||
foreach ($properties_map as $property_key => $property_val) {
|
*
|
||||||
if (is_array($property_val)) {
|
* @param array|string $elements
|
||||||
if ($reference === NULL) {
|
*
|
||||||
$reference = & $this->_shadow_properties[$property_key];
|
* @return string
|
||||||
} else {
|
*/
|
||||||
$reference = & $reference[$property_key];
|
|
||||||
|
public function getLineStyleProperty($elements)
|
||||||
|
{
|
||||||
|
return $this->getArrayElementsValue($this->lineProperties['style'], $elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Glow Properties
|
||||||
|
*
|
||||||
|
* @param float $size
|
||||||
|
* @param string $color_value
|
||||||
|
* @param int $color_alpha
|
||||||
|
* @param string $color_type
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null)
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->activateObject()
|
||||||
|
->setGlowSize($size)
|
||||||
|
->setGlowColor($color_value, $color_alpha, $color_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Glow Color Property
|
||||||
|
*
|
||||||
|
* @param string $property
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function getGlowColor($property)
|
||||||
|
{
|
||||||
|
return $this->glowProperties['color'][$property];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Glow Size
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function getGlowSize()
|
||||||
|
{
|
||||||
|
return $this->glowProperties['size'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Glow Size
|
||||||
|
*
|
||||||
|
* @param float $size
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Chart_GridLines
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function setGlowSize($size)
|
||||||
|
{
|
||||||
|
$this->glowProperties['size'] = $this->getExcelPointsWidth((float) $size);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Glow Color
|
||||||
|
*
|
||||||
|
* @param string $color
|
||||||
|
* @param int $alpha
|
||||||
|
* @param string $type
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Chart_GridLines
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function setGlowColor($color, $alpha, $type)
|
||||||
|
{
|
||||||
|
if (!is_null($color)) {
|
||||||
|
$this->glowProperties['color']['value'] = (string) $color;
|
||||||
}
|
}
|
||||||
$this->_setShadowProperiesMapValues($property_val, $reference);
|
if (!is_null($alpha)) {
|
||||||
} else {
|
$this->glowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
|
||||||
if ($base_reference === NULL) {
|
|
||||||
$this->_shadow_properties[$property_key] = $property_val;
|
|
||||||
} else {
|
|
||||||
$reference[$property_key] = $property_val;
|
|
||||||
}
|
}
|
||||||
}
|
if (!is_null($type)) {
|
||||||
|
$this->glowProperties['color']['type'] = (string) $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
/**
|
||||||
}
|
* Get Line Style Arrow Parameters
|
||||||
|
*
|
||||||
|
* @param string $arrow_selector
|
||||||
|
* @param string $property_selector
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
public function getLineStyleArrowParameters($arrow_selector, $property_selector)
|
||||||
* Set Shadow Color
|
{
|
||||||
*
|
return $this->getLineStyleArrowSize($this->lineProperties['style']['arrow'][$arrow_selector]['size'], $property_selector);
|
||||||
* @param string $color
|
|
||||||
* @param int $alpha
|
|
||||||
* @param string $type
|
|
||||||
*
|
|
||||||
* @return PHPExcel_Chart_GridLines
|
|
||||||
*/
|
|
||||||
|
|
||||||
private function _setShadowColor($color, $alpha, $type) {
|
|
||||||
if (!is_null($color)) {
|
|
||||||
$this->_shadow_properties['color']['value'] = (string) $color;
|
|
||||||
}
|
|
||||||
if (!is_null($alpha)) {
|
|
||||||
$this->_shadow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
|
|
||||||
}
|
|
||||||
if (!is_null($type)) {
|
|
||||||
$this->_shadow_properties['color']['type'] = (string) $type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
/**
|
||||||
}
|
* Set Shadow Properties
|
||||||
|
*
|
||||||
|
* @param int $sh_presets
|
||||||
|
* @param string $sh_color_value
|
||||||
|
* @param string $sh_color_type
|
||||||
|
* @param int $sh_color_alpha
|
||||||
|
* @param string $sh_blur
|
||||||
|
* @param int $sh_angle
|
||||||
|
* @param float $sh_distance
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null)
|
||||||
* Set Shadow Blur
|
{
|
||||||
*
|
$this->activateObject()
|
||||||
* @param float $blur
|
->setShadowPresetsProperties((int) $sh_presets)
|
||||||
*
|
->setShadowColor(
|
||||||
* @return PHPExcel_Chart_GridLines
|
is_null($sh_color_value) ? $this->shadowProperties['color']['value'] : $sh_color_value,
|
||||||
*/
|
is_null($sh_color_alpha) ? (int) $this->shadowProperties['color']['alpha'] : $this->getTrueAlpha($sh_color_alpha),
|
||||||
|
is_null($sh_color_type) ? $this->shadowProperties['color']['type'] : $sh_color_type
|
||||||
private function _setShadowBlur($blur) {
|
)
|
||||||
if ($blur !== NULL) {
|
->setShadowBlur($sh_blur)
|
||||||
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
|
->setShadowAngle($sh_angle)
|
||||||
|
->setShadowDistance($sh_distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
/**
|
||||||
}
|
* Set Shadow Presets Properties
|
||||||
|
*
|
||||||
|
* @param int $shadow_presets
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Chart_GridLines
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
private function setShadowPresetsProperties($shadow_presets)
|
||||||
* Set Shadow Angle
|
{
|
||||||
*
|
$this->shadowProperties['presets'] = $shadow_presets;
|
||||||
* @param int $angle
|
$this->setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
|
||||||
*
|
|
||||||
* @return PHPExcel_Chart_GridLines
|
|
||||||
*/
|
|
||||||
|
|
||||||
private function _setShadowAngle($angle) {
|
return $this;
|
||||||
if ($angle !== NULL) {
|
|
||||||
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
/**
|
||||||
}
|
* Set Shadow Properties Values
|
||||||
|
*
|
||||||
|
* @param array $properties_map
|
||||||
|
* @param * $reference
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Chart_GridLines
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
private function setShadowProperiesMapValues(array $properties_map, &$reference = null)
|
||||||
* Set Shadow Distance
|
{
|
||||||
*
|
$base_reference = $reference;
|
||||||
* @param float $distance
|
foreach ($properties_map as $property_key => $property_val) {
|
||||||
*
|
if (is_array($property_val)) {
|
||||||
* @return PHPExcel_Chart_GridLines
|
if ($reference === null) {
|
||||||
*/
|
$reference = & $this->shadowProperties[$property_key];
|
||||||
|
} else {
|
||||||
|
$reference = & $reference[$property_key];
|
||||||
|
}
|
||||||
|
$this->setShadowProperiesMapValues($property_val, $reference);
|
||||||
|
} else {
|
||||||
|
if ($base_reference === null) {
|
||||||
|
$this->shadowProperties[$property_key] = $property_val;
|
||||||
|
} else {
|
||||||
|
$reference[$property_key] = $property_val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function _setShadowDistance($distance) {
|
return $this;
|
||||||
if ($distance !== NULL) {
|
|
||||||
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
/**
|
||||||
}
|
* Set Shadow Color
|
||||||
|
*
|
||||||
|
* @param string $color
|
||||||
|
* @param int $alpha
|
||||||
|
* @param string $type
|
||||||
|
* @return PHPExcel_Chart_GridLines
|
||||||
|
*/
|
||||||
|
private function setShadowColor($color, $alpha, $type)
|
||||||
|
{
|
||||||
|
if (!is_null($color)) {
|
||||||
|
$this->shadowProperties['color']['value'] = (string) $color;
|
||||||
|
}
|
||||||
|
if (!is_null($alpha)) {
|
||||||
|
$this->shadowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
|
||||||
|
}
|
||||||
|
if (!is_null($type)) {
|
||||||
|
$this->shadowProperties['color']['type'] = (string) $type;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return $this;
|
||||||
* Get Shadow Property
|
|
||||||
*
|
|
||||||
* @param string $elements
|
|
||||||
* @param array $elements
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getShadowProperty($elements) {
|
|
||||||
return $this->getArrayElementsValue($this->_shadow_properties, $elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Soft Edges Size
|
|
||||||
*
|
|
||||||
* @param float $size
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function setSoftEdgesSize($size) {
|
|
||||||
if (!is_null($size)) {
|
|
||||||
$this->_activateObject();
|
|
||||||
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Soft Edges Size
|
* Set Shadow Blur
|
||||||
*
|
*
|
||||||
* @return string
|
* @param float $blur
|
||||||
*/
|
*
|
||||||
|
* @return PHPExcel_Chart_GridLines
|
||||||
|
*/
|
||||||
|
private function setShadowBlur($blur)
|
||||||
|
{
|
||||||
|
if ($blur !== null) {
|
||||||
|
$this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur);
|
||||||
|
}
|
||||||
|
|
||||||
public function getSoftEdgesSize() {
|
return $this;
|
||||||
return $this->_soft_edges['size'];
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
|
* Set Shadow Angle
|
||||||
|
*
|
||||||
|
* @param int $angle
|
||||||
|
* @return PHPExcel_Chart_GridLines
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function setShadowAngle($angle)
|
||||||
|
{
|
||||||
|
if ($angle !== null) {
|
||||||
|
$this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Shadow Distance
|
||||||
|
*
|
||||||
|
* @param float $distance
|
||||||
|
* @return PHPExcel_Chart_GridLines
|
||||||
|
*/
|
||||||
|
private function setShadowDistance($distance)
|
||||||
|
{
|
||||||
|
if ($distance !== null) {
|
||||||
|
$this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Shadow Property
|
||||||
|
*
|
||||||
|
* @param string $elements
|
||||||
|
* @param array $elements
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getShadowProperty($elements)
|
||||||
|
{
|
||||||
|
return $this->getArrayElementsValue($this->shadowProperties, $elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Soft Edges Size
|
||||||
|
*
|
||||||
|
* @param float $size
|
||||||
|
*/
|
||||||
|
public function setSoftEdgesSize($size)
|
||||||
|
{
|
||||||
|
if (!is_null($size)) {
|
||||||
|
$this->activateObject();
|
||||||
|
$softEdges['size'] = (string) $this->getExcelPointsWidth($size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Soft Edges Size
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSoftEdgesSize()
|
||||||
|
{
|
||||||
|
return $this->softEdges['size'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,428 +18,469 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Chart
|
* @package PHPExcel_Chart
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Chart_Layout
|
* PHPExcel_Chart_Layout
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Chart
|
* @package PHPExcel_Chart
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Chart_Layout
|
class PHPExcel_Chart_Layout
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* layoutTarget
|
* layoutTarget
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_layoutTarget = NULL;
|
private $layoutTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X Mode
|
* X Mode
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_xMode = NULL;
|
private $xMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Y Mode
|
* Y Mode
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_yMode = NULL;
|
private $yMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X-Position
|
* X-Position
|
||||||
*
|
*
|
||||||
* @var float
|
* @var float
|
||||||
*/
|
*/
|
||||||
private $_xPos = NULL;
|
private $xPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Y-Position
|
* Y-Position
|
||||||
*
|
*
|
||||||
* @var float
|
* @var float
|
||||||
*/
|
*/
|
||||||
private $_yPos = NULL;
|
private $yPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* width
|
* width
|
||||||
*
|
*
|
||||||
* @var float
|
* @var float
|
||||||
*/
|
*/
|
||||||
private $_width = NULL;
|
private $width;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* height
|
* height
|
||||||
*
|
*
|
||||||
* @var float
|
* @var float
|
||||||
*/
|
*/
|
||||||
private $_height = NULL;
|
private $height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show legend key
|
* show legend key
|
||||||
* Specifies that legend keys should be shown in data labels
|
* Specifies that legend keys should be shown in data labels
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showLegendKey = NULL;
|
private $showLegendKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show value
|
* show value
|
||||||
* Specifies that the value should be shown in a data label.
|
* Specifies that the value should be shown in a data label.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showVal = NULL;
|
private $showVal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show category name
|
* show category name
|
||||||
* Specifies that the category name should be shown in the data label.
|
* Specifies that the category name should be shown in the data label.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showCatName = NULL;
|
private $showCatName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show data series name
|
* show data series name
|
||||||
* Specifies that the series name should be shown in the data label.
|
* Specifies that the series name should be shown in the data label.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showSerName = NULL;
|
private $showSerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show percentage
|
* show percentage
|
||||||
* Specifies that the percentage should be shown in the data label.
|
* Specifies that the percentage should be shown in the data label.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showPercent = NULL;
|
private $showPercent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show bubble size
|
* show bubble size
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showBubbleSize = NULL;
|
private $showBubbleSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show leader lines
|
* show leader lines
|
||||||
* Specifies that leader lines should be shown for the data label.
|
* Specifies that leader lines should be shown for the data label.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_showLeaderLines = NULL;
|
private $showLeaderLines;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Chart_Layout
|
* Create a new PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function __construct($layout=array())
|
public function __construct($layout = array())
|
||||||
{
|
{
|
||||||
if (isset($layout['layoutTarget'])) { $this->_layoutTarget = $layout['layoutTarget']; }
|
if (isset($layout['layoutTarget'])) {
|
||||||
if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; }
|
$this->layoutTarget = $layout['layoutTarget'];
|
||||||
if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; }
|
}
|
||||||
if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; }
|
if (isset($layout['xMode'])) {
|
||||||
if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; }
|
$this->xMode = $layout['xMode'];
|
||||||
if (isset($layout['w'])) { $this->_width = (float) $layout['w']; }
|
}
|
||||||
if (isset($layout['h'])) { $this->_height = (float) $layout['h']; }
|
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
|
* Get Layout Target
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLayoutTarget() {
|
public function getLayoutTarget()
|
||||||
return $this->_layoutTarget;
|
{
|
||||||
}
|
return $this->layoutTarget;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Layout Target
|
* Set Layout Target
|
||||||
*
|
*
|
||||||
* @param Layout Target $value
|
* @param Layout Target $value
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setLayoutTarget($value) {
|
public function setLayoutTarget($value)
|
||||||
$this->_layoutTarget = $value;
|
{
|
||||||
|
$this->layoutTarget = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get X-Mode
|
* Get X-Mode
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getXMode() {
|
public function getXMode()
|
||||||
return $this->_xMode;
|
{
|
||||||
}
|
return $this->xMode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set X-Mode
|
* Set X-Mode
|
||||||
*
|
*
|
||||||
* @param X-Mode $value
|
* @param X-Mode $value
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setXMode($value) {
|
public function setXMode($value)
|
||||||
$this->_xMode = $value;
|
{
|
||||||
|
$this->xMode = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Y-Mode
|
* Get Y-Mode
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getYMode() {
|
public function getYMode()
|
||||||
return $this->_yMode;
|
{
|
||||||
}
|
return $this->yMode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Y-Mode
|
* Set Y-Mode
|
||||||
*
|
*
|
||||||
* @param Y-Mode $value
|
* @param Y-Mode $value
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setYMode($value) {
|
public function setYMode($value)
|
||||||
$this->_yMode = $value;
|
{
|
||||||
|
$this->yMode = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get X-Position
|
* Get X-Position
|
||||||
*
|
*
|
||||||
* @return number
|
* @return number
|
||||||
*/
|
*/
|
||||||
public function getXPosition() {
|
public function getXPosition()
|
||||||
return $this->_xPos;
|
{
|
||||||
}
|
return $this->xPos;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set X-Position
|
* Set X-Position
|
||||||
*
|
*
|
||||||
* @param X-Position $value
|
* @param X-Position $value
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setXPosition($value) {
|
public function setXPosition($value)
|
||||||
$this->_xPos = $value;
|
{
|
||||||
|
$this->xPos = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Y-Position
|
* Get Y-Position
|
||||||
*
|
*
|
||||||
* @return number
|
* @return number
|
||||||
*/
|
*/
|
||||||
public function getYPosition() {
|
public function getYPosition()
|
||||||
return $this->_yPos;
|
{
|
||||||
}
|
return $this->yPos;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Y-Position
|
* Set Y-Position
|
||||||
*
|
*
|
||||||
* @param Y-Position $value
|
* @param Y-Position $value
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setYPosition($value) {
|
public function setYPosition($value)
|
||||||
$this->_yPos = $value;
|
{
|
||||||
|
$this->yPos = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Width
|
* Get Width
|
||||||
*
|
*
|
||||||
* @return number
|
* @return number
|
||||||
*/
|
*/
|
||||||
public function getWidth() {
|
public function getWidth()
|
||||||
return $this->_width;
|
{
|
||||||
}
|
return $this->width;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Width
|
* Set Width
|
||||||
*
|
*
|
||||||
* @param Width $value
|
* @param Width $value
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setWidth($value) {
|
public function setWidth($value)
|
||||||
$this->_width = $value;
|
{
|
||||||
|
$this->width = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Height
|
* Get Height
|
||||||
*
|
*
|
||||||
* @return number
|
* @return number
|
||||||
*/
|
*/
|
||||||
public function getHeight() {
|
public function getHeight()
|
||||||
return $this->_height;
|
{
|
||||||
}
|
return $this->height;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Height
|
* Set Height
|
||||||
*
|
*
|
||||||
* @param Height $value
|
* @param Height $value
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setHeight($value) {
|
public function setHeight($value)
|
||||||
$this->_height = $value;
|
{
|
||||||
|
$this->height = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get show legend key
|
* Get show legend key
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowLegendKey() {
|
public function getShowLegendKey()
|
||||||
return $this->_showLegendKey;
|
{
|
||||||
}
|
return $this->showLegendKey;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set show legend key
|
* Set show legend key
|
||||||
* Specifies that legend keys should be shown in data labels.
|
* Specifies that legend keys should be shown in data labels.
|
||||||
*
|
*
|
||||||
* @param boolean $value Show legend key
|
* @param boolean $value Show legend key
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setShowLegendKey($value) {
|
public function setShowLegendKey($value)
|
||||||
$this->_showLegendKey = $value;
|
{
|
||||||
|
$this->showLegendKey = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get show value
|
* Get show value
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowVal() {
|
public function getShowVal()
|
||||||
return $this->_showVal;
|
{
|
||||||
}
|
return $this->showVal;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set show val
|
* Set show val
|
||||||
* Specifies that the value should be shown in data labels.
|
* Specifies that the value should be shown in data labels.
|
||||||
*
|
*
|
||||||
* @param boolean $value Show val
|
* @param boolean $value Show val
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setShowVal($value) {
|
public function setShowVal($value)
|
||||||
$this->_showVal = $value;
|
{
|
||||||
|
$this->showVal = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get show category name
|
* Get show category name
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowCatName() {
|
public function getShowCatName()
|
||||||
return $this->_showCatName;
|
{
|
||||||
}
|
return $this->showCatName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set show cat name
|
* Set show cat name
|
||||||
* Specifies that the category name should be shown in data labels.
|
* Specifies that the category name should be shown in data labels.
|
||||||
*
|
*
|
||||||
* @param boolean $value Show cat name
|
* @param boolean $value Show cat name
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setShowCatName($value) {
|
public function setShowCatName($value)
|
||||||
$this->_showCatName = $value;
|
{
|
||||||
|
$this->showCatName = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get show data series name
|
* Get show data series name
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowSerName() {
|
public function getShowSerName()
|
||||||
return $this->_showSerName;
|
{
|
||||||
}
|
return $this->showSerName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set show ser name
|
* Set show ser name
|
||||||
* Specifies that the series name should be shown in data labels.
|
* Specifies that the series name should be shown in data labels.
|
||||||
*
|
*
|
||||||
* @param boolean $value Show series name
|
* @param boolean $value Show series name
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setShowSerName($value) {
|
public function setShowSerName($value)
|
||||||
$this->_showSerName = $value;
|
{
|
||||||
|
$this->showSerName = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get show percentage
|
* Get show percentage
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowPercent() {
|
public function getShowPercent()
|
||||||
return $this->_showPercent;
|
{
|
||||||
}
|
return $this->showPercent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set show percentage
|
* Set show percentage
|
||||||
* Specifies that the percentage should be shown in data labels.
|
* Specifies that the percentage should be shown in data labels.
|
||||||
*
|
*
|
||||||
* @param boolean $value Show percentage
|
* @param boolean $value Show percentage
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setShowPercent($value) {
|
public function setShowPercent($value)
|
||||||
$this->_showPercent = $value;
|
{
|
||||||
|
$this->showPercent = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get show bubble size
|
* Get show bubble size
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowBubbleSize() {
|
public function getShowBubbleSize()
|
||||||
return $this->_showBubbleSize;
|
{
|
||||||
}
|
return $this->showBubbleSize;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set show bubble size
|
* Set show bubble size
|
||||||
* Specifies that the bubble size should be shown in data labels.
|
* Specifies that the bubble size should be shown in data labels.
|
||||||
*
|
*
|
||||||
* @param boolean $value Show bubble size
|
* @param boolean $value Show bubble size
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setShowBubbleSize($value) {
|
public function setShowBubbleSize($value)
|
||||||
$this->_showBubbleSize = $value;
|
{
|
||||||
|
$this->showBubbleSize = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get show leader lines
|
* Get show leader lines
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getShowLeaderLines() {
|
public function getShowLeaderLines()
|
||||||
return $this->_showLeaderLines;
|
{
|
||||||
}
|
return $this->showLeaderLines;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set show leader lines
|
* Set show leader lines
|
||||||
* Specifies that leader lines should be shown in data labels.
|
* Specifies that leader lines should be shown in data labels.
|
||||||
*
|
*
|
||||||
* @param boolean $value Show leader lines
|
* @param boolean $value Show leader lines
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function setShowLeaderLines($value) {
|
public function setShowLeaderLines($value)
|
||||||
$this->_showLeaderLines = $value;
|
{
|
||||||
|
$this->showLeaderLines = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Chart_Legend
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,154 +19,152 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Chart
|
* @package PHPExcel_Chart
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Chart_Legend
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Chart
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Chart_Legend
|
class PHPExcel_Chart_Legend
|
||||||
{
|
{
|
||||||
/** Legend positions */
|
/** Legend positions */
|
||||||
const xlLegendPositionBottom = -4107; // Below the chart.
|
const xlLegendPositionBottom = -4107; // Below the chart.
|
||||||
const xlLegendPositionCorner = 2; // In the upper right-hand corner of the chart border.
|
const xlLegendPositionCorner = 2; // In the upper right-hand corner of the chart border.
|
||||||
const xlLegendPositionCustom = -4161; // A custom position.
|
const xlLegendPositionCustom = -4161; // A custom position.
|
||||||
const xlLegendPositionLeft = -4131; // Left of the chart.
|
const xlLegendPositionLeft = -4131; // Left of the chart.
|
||||||
const xlLegendPositionRight = -4152; // Right of the chart.
|
const xlLegendPositionRight = -4152; // Right of the chart.
|
||||||
const xlLegendPositionTop = -4160; // Above the chart.
|
const xlLegendPositionTop = -4160; // Above the chart.
|
||||||
|
|
||||||
const POSITION_RIGHT = 'r';
|
const POSITION_RIGHT = 'r';
|
||||||
const POSITION_LEFT = 'l';
|
const POSITION_LEFT = 'l';
|
||||||
const POSITION_BOTTOM = 'b';
|
const POSITION_BOTTOM = 'b';
|
||||||
const POSITION_TOP = 't';
|
const POSITION_TOP = 't';
|
||||||
const POSITION_TOPRIGHT = 'tr';
|
const POSITION_TOPRIGHT = 'tr';
|
||||||
|
|
||||||
private static $_positionXLref = array( self::xlLegendPositionBottom => self::POSITION_BOTTOM,
|
private static $positionXLref = array(
|
||||||
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
|
self::xlLegendPositionBottom => self::POSITION_BOTTOM,
|
||||||
self::xlLegendPositionCustom => '??',
|
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
|
||||||
self::xlLegendPositionLeft => self::POSITION_LEFT,
|
self::xlLegendPositionCustom => '??',
|
||||||
self::xlLegendPositionRight => self::POSITION_RIGHT,
|
self::xlLegendPositionLeft => self::POSITION_LEFT,
|
||||||
self::xlLegendPositionTop => self::POSITION_TOP
|
self::xlLegendPositionRight => self::POSITION_RIGHT,
|
||||||
);
|
self::xlLegendPositionTop => self::POSITION_TOP
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legend position
|
* Legend position
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_position = self::POSITION_RIGHT;
|
private $position = self::POSITION_RIGHT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow overlay of other elements?
|
* Allow overlay of other elements?
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_overlay = TRUE;
|
private $overlay = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legend Layout
|
* Legend Layout
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Chart_Layout
|
* @var PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
private $_layout = NULL;
|
private $layout = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Chart_Legend
|
* Create a new PHPExcel_Chart_Legend
|
||||||
*/
|
*/
|
||||||
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE)
|
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = null, $overlay = false)
|
||||||
{
|
{
|
||||||
$this->setPosition($position);
|
$this->setPosition($position);
|
||||||
$this->_layout = $layout;
|
$this->layout = $layout;
|
||||||
$this->setOverlay($overlay);
|
$this->setOverlay($overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get legend position as an excel string value
|
* Get legend position as an excel string value
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPosition() {
|
public function getPosition()
|
||||||
return $this->_position;
|
{
|
||||||
}
|
return $this->position;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get legend position using an excel string value
|
* Get legend position using an excel string value
|
||||||
*
|
*
|
||||||
* @param string $position
|
* @param string $position
|
||||||
*/
|
*/
|
||||||
public function setPosition($position = self::POSITION_RIGHT) {
|
public function setPosition($position = self::POSITION_RIGHT)
|
||||||
if (!in_array($position,self::$_positionXLref)) {
|
{
|
||||||
return false;
|
if (!in_array($position, self::$positionXLref)) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_position = $position;
|
$this->position = $position;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get legend position as an Excel internal numeric value
|
* Get legend position as an Excel internal numeric value
|
||||||
*
|
*
|
||||||
* @return number
|
* @return number
|
||||||
*/
|
*/
|
||||||
public function getPositionXL() {
|
public function getPositionXL()
|
||||||
return array_search($this->_position,self::$_positionXLref);
|
{
|
||||||
}
|
return array_search($this->position, self::$positionXLref);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set legend position using an Excel internal numeric value
|
* Set legend position using an Excel internal numeric value
|
||||||
*
|
*
|
||||||
* @param number $positionXL
|
* @param number $positionXL
|
||||||
*/
|
*/
|
||||||
public function setPositionXL($positionXL = self::xlLegendPositionRight) {
|
public function setPositionXL($positionXL = self::xlLegendPositionRight)
|
||||||
if (!array_key_exists($positionXL,self::$_positionXLref)) {
|
{
|
||||||
return false;
|
if (!array_key_exists($positionXL, self::$positionXLref)) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_position = self::$_positionXLref[$positionXL];
|
$this->position = self::$positionXLref[$positionXL];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get allow overlay of other elements?
|
* Get allow overlay of other elements?
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getOverlay() {
|
public function getOverlay()
|
||||||
return $this->_overlay;
|
{
|
||||||
}
|
return $this->overlay;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set allow overlay of other elements?
|
* Set allow overlay of other elements?
|
||||||
*
|
*
|
||||||
* @param boolean $overlay
|
* @param boolean $overlay
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function setOverlay($overlay = FALSE) {
|
public function setOverlay($overlay = false)
|
||||||
if (!is_bool($overlay)) {
|
{
|
||||||
return false;
|
if (!is_bool($overlay)) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_overlay = $overlay;
|
$this->overlay = $overlay;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Layout
|
|
||||||
*
|
|
||||||
* @return PHPExcel_Chart_Layout
|
|
||||||
*/
|
|
||||||
public function getLayout() {
|
|
||||||
return $this->_layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Layout
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Chart_Layout
|
||||||
|
*/
|
||||||
|
public function getLayout()
|
||||||
|
{
|
||||||
|
return $this->layout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Chart_PlotArea
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,111 +19,108 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Chart
|
* @package PHPExcel_Chart
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Chart_PlotArea
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Chart
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Chart_PlotArea
|
class PHPExcel_Chart_PlotArea
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* PlotArea Layout
|
* PlotArea Layout
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Chart_Layout
|
* @var PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
private $_layout = null;
|
private $layout = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot Series
|
* Plot Series
|
||||||
*
|
*
|
||||||
* @var array of PHPExcel_Chart_DataSeries
|
* @var array of PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
private $_plotSeries = array();
|
private $plotSeries = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Chart_PlotArea
|
* Create a new PHPExcel_Chart_PlotArea
|
||||||
*/
|
*/
|
||||||
public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array())
|
public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array())
|
||||||
{
|
{
|
||||||
$this->_layout = $layout;
|
$this->layout = $layout;
|
||||||
$this->_plotSeries = $plotSeries;
|
$this->plotSeries = $plotSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Layout
|
* Get Layout
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Chart_Layout
|
* @return PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
public function getLayout() {
|
public function getLayout()
|
||||||
return $this->_layout;
|
{
|
||||||
}
|
return $this->layout;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Number of Plot Groups
|
* Get Number of Plot Groups
|
||||||
*
|
*
|
||||||
* @return array of PHPExcel_Chart_DataSeries
|
* @return array of PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
public function getPlotGroupCount() {
|
public function getPlotGroupCount()
|
||||||
return count($this->_plotSeries);
|
{
|
||||||
}
|
return count($this->plotSeries);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Number of Plot Series
|
* Get Number of Plot Series
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getPlotSeriesCount() {
|
public function getPlotSeriesCount()
|
||||||
$seriesCount = 0;
|
{
|
||||||
foreach($this->_plotSeries as $plot) {
|
$seriesCount = 0;
|
||||||
$seriesCount += $plot->getPlotSeriesCount();
|
foreach ($this->plotSeries as $plot) {
|
||||||
}
|
$seriesCount += $plot->getPlotSeriesCount();
|
||||||
return $seriesCount;
|
}
|
||||||
}
|
return $seriesCount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Series
|
* Get Plot Series
|
||||||
*
|
*
|
||||||
* @return array of PHPExcel_Chart_DataSeries
|
* @return array of PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
public function getPlotGroup() {
|
public function getPlotGroup()
|
||||||
return $this->_plotSeries;
|
{
|
||||||
}
|
return $this->plotSeries;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Series by Index
|
* Get Plot Series by Index
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Chart_DataSeries
|
* @return PHPExcel_Chart_DataSeries
|
||||||
*/
|
*/
|
||||||
public function getPlotGroupByIndex($index) {
|
public function getPlotGroupByIndex($index)
|
||||||
return $this->_plotSeries[$index];
|
{
|
||||||
}
|
return $this->plotSeries[$index];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Plot Series
|
* Set Plot Series
|
||||||
*
|
*
|
||||||
* @param [PHPExcel_Chart_DataSeries]
|
* @param [PHPExcel_Chart_DataSeries]
|
||||||
* @return PHPExcel_Chart_PlotArea
|
* @return PHPExcel_Chart_PlotArea
|
||||||
*/
|
*/
|
||||||
public function setPlotSeries($plotSeries = array()) {
|
public function setPlotSeries($plotSeries = array())
|
||||||
$this->_plotSeries = $plotSeries;
|
{
|
||||||
|
$this->plotSeries = $plotSeries;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refresh(PHPExcel_Worksheet $worksheet) {
|
|
||||||
foreach($this->_plotSeries as $plotSeries) {
|
|
||||||
$plotSeries->refresh($worksheet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function refresh(PHPExcel_Worksheet $worksheet)
|
||||||
|
{
|
||||||
|
foreach ($this->plotSeries as $plotSeries) {
|
||||||
|
$plotSeries->refresh($worksheet);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,354 +6,358 @@
|
||||||
* Time: 5:45 PM
|
* Time: 5:45 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract class PHPExcel_Properties {
|
abstract class PHPExcel_Chart_Properties
|
||||||
|
{
|
||||||
|
const
|
||||||
|
EXCEL_COLOR_TYPE_STANDARD = 'prstClr',
|
||||||
|
EXCEL_COLOR_TYPE_SCHEME = 'schemeClr',
|
||||||
|
EXCEL_COLOR_TYPE_ARGB = 'srgbClr';
|
||||||
|
|
||||||
const
|
const
|
||||||
EXCEL_COLOR_TYPE_STANDARD = 'prstClr',
|
AXIS_LABELS_LOW = 'low',
|
||||||
EXCEL_COLOR_TYPE_SCHEME = 'schemeClr',
|
AXIS_LABELS_HIGH = 'high',
|
||||||
EXCEL_COLOR_TYPE_ARGB = 'srgbClr';
|
AXIS_LABELS_NEXT_TO = 'nextTo',
|
||||||
|
AXIS_LABELS_NONE = 'none';
|
||||||
|
|
||||||
const
|
const
|
||||||
AXIS_LABELS_LOW = 'low',
|
TICK_MARK_NONE = 'none',
|
||||||
AXIS_LABELS_HIGH = 'high',
|
TICK_MARK_INSIDE = 'in',
|
||||||
AXIS_LABELS_NEXT_TO = 'nextTo',
|
TICK_MARK_OUTSIDE = 'out',
|
||||||
AXIS_LABELS_NONE = 'none';
|
TICK_MARK_CROSS = 'cross';
|
||||||
|
|
||||||
const
|
const
|
||||||
TICK_MARK_NONE = 'none',
|
HORIZONTAL_CROSSES_AUTOZERO = 'autoZero',
|
||||||
TICK_MARK_INSIDE = 'in',
|
HORIZONTAL_CROSSES_MAXIMUM = 'max';
|
||||||
TICK_MARK_OUTSIDE = 'out',
|
|
||||||
TICK_MARK_CROSS = 'cross';
|
|
||||||
|
|
||||||
const
|
const
|
||||||
HORIZONTAL_CROSSES_AUTOZERO = 'autoZero',
|
FORMAT_CODE_GENERAL = 'General',
|
||||||
HORIZONTAL_CROSSES_MAXIMUM = 'max';
|
FORMAT_CODE_NUMBER = '#,##0.00',
|
||||||
|
FORMAT_CODE_CURRENCY = '$#,##0.00',
|
||||||
|
FORMAT_CODE_ACCOUNTING = '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',
|
||||||
|
FORMAT_CODE_DATE = 'm/d/yyyy',
|
||||||
|
FORMAT_CODE_TIME = '[$-F400]h:mm:ss AM/PM',
|
||||||
|
FORMAT_CODE_PERCENTAGE = '0.00%',
|
||||||
|
FORMAT_CODE_FRACTION = '# ?/?',
|
||||||
|
FORMAT_CODE_SCIENTIFIC = '0.00E+00',
|
||||||
|
FORMAT_CODE_TEXT = '@',
|
||||||
|
FORMAT_CODE_SPECIAL = '00000';
|
||||||
|
|
||||||
const
|
const
|
||||||
FORMAT_CODE_GENERAL = 'General',
|
ORIENTATION_NORMAL = 'minMax',
|
||||||
FORMAT_CODE_NUMBER = '#,##0.00',
|
ORIENTATION_REVERSED = 'maxMin';
|
||||||
FORMAT_CODE_CURRENCY = '$#,##0.00',
|
|
||||||
FORMAT_CODE_ACCOUNTING = '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',
|
|
||||||
FORMAT_CODE_DATE = 'm/d/yyyy',
|
|
||||||
FORMAT_CODE_TIME = '[$-F400]h:mm:ss AM/PM',
|
|
||||||
FORMAT_CODE_PERCENTAGE = '0.00%',
|
|
||||||
FORMAT_CODE_FRACTION = '# ?/?',
|
|
||||||
FORMAT_CODE_SCIENTIFIC = '0.00E+00',
|
|
||||||
FORMAT_CODE_TEXT = '@',
|
|
||||||
FORMAT_CODE_SPECIAL = '00000';
|
|
||||||
|
|
||||||
const
|
const
|
||||||
ORIENTATION_NORMAL = 'minMax',
|
LINE_STYLE_COMPOUND_SIMPLE = 'sng',
|
||||||
ORIENTATION_REVERSED = 'maxMin';
|
LINE_STYLE_COMPOUND_DOUBLE = 'dbl',
|
||||||
|
LINE_STYLE_COMPOUND_THICKTHIN = 'thickThin',
|
||||||
|
LINE_STYLE_COMPOUND_THINTHICK = 'thinThick',
|
||||||
|
LINE_STYLE_COMPOUND_TRIPLE = 'tri',
|
||||||
|
|
||||||
const
|
LINE_STYLE_DASH_SOLID = 'solid',
|
||||||
LINE_STYLE_COMPOUND_SIMPLE = 'sng',
|
LINE_STYLE_DASH_ROUND_DOT = 'sysDot',
|
||||||
LINE_STYLE_COMPOUND_DOUBLE = 'dbl',
|
LINE_STYLE_DASH_SQUERE_DOT = 'sysDash',
|
||||||
LINE_STYLE_COMPOUND_THICKTHIN = 'thickThin',
|
LINE_STYPE_DASH_DASH = 'dash',
|
||||||
LINE_STYLE_COMPOUND_THINTHICK = 'thinThick',
|
LINE_STYLE_DASH_DASH_DOT = 'dashDot',
|
||||||
LINE_STYLE_COMPOUND_TRIPLE = 'tri',
|
LINE_STYLE_DASH_LONG_DASH = 'lgDash',
|
||||||
|
LINE_STYLE_DASH_LONG_DASH_DOT = 'lgDashDot',
|
||||||
|
LINE_STYLE_DASH_LONG_DASH_DOT_DOT = 'lgDashDotDot',
|
||||||
|
|
||||||
LINE_STYLE_DASH_SOLID = 'solid',
|
LINE_STYLE_CAP_SQUARE = 'sq',
|
||||||
LINE_STYLE_DASH_ROUND_DOT = 'sysDot',
|
LINE_STYLE_CAP_ROUND = 'rnd',
|
||||||
LINE_STYLE_DASH_SQUERE_DOT = 'sysDash',
|
LINE_STYLE_CAP_FLAT = 'flat',
|
||||||
LINE_STYPE_DASH_DASH = 'dash',
|
|
||||||
LINE_STYLE_DASH_DASH_DOT = 'dashDot',
|
|
||||||
LINE_STYLE_DASH_LONG_DASH = 'lgDash',
|
|
||||||
LINE_STYLE_DASH_LONG_DASH_DOT = 'lgDashDot',
|
|
||||||
LINE_STYLE_DASH_LONG_DASH_DOT_DOT = 'lgDashDotDot',
|
|
||||||
|
|
||||||
LINE_STYLE_CAP_SQUARE = 'sq',
|
LINE_STYLE_JOIN_ROUND = 'bevel',
|
||||||
LINE_STYLE_CAP_ROUND = 'rnd',
|
LINE_STYLE_JOIN_MITER = 'miter',
|
||||||
LINE_STYLE_CAP_FLAT = 'flat',
|
LINE_STYLE_JOIN_BEVEL = 'bevel',
|
||||||
|
|
||||||
LINE_STYLE_JOIN_ROUND = 'bevel',
|
LINE_STYLE_ARROW_TYPE_NOARROW = null,
|
||||||
LINE_STYLE_JOIN_MITER = 'miter',
|
LINE_STYLE_ARROW_TYPE_ARROW = 'triangle',
|
||||||
LINE_STYLE_JOIN_BEVEL = 'bevel',
|
LINE_STYLE_ARROW_TYPE_OPEN = 'arrow',
|
||||||
|
LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth',
|
||||||
|
LINE_STYLE_ARROW_TYPE_DIAMOND = 'diamond',
|
||||||
|
LINE_STYLE_ARROW_TYPE_OVAL = 'oval',
|
||||||
|
|
||||||
LINE_STYLE_ARROW_TYPE_NOARROW = NULL,
|
LINE_STYLE_ARROW_SIZE_1 = 1,
|
||||||
LINE_STYLE_ARROW_TYPE_ARROW = 'triangle',
|
LINE_STYLE_ARROW_SIZE_2 = 2,
|
||||||
LINE_STYLE_ARROW_TYPE_OPEN = 'arrow',
|
LINE_STYLE_ARROW_SIZE_3 = 3,
|
||||||
LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth',
|
LINE_STYLE_ARROW_SIZE_4 = 4,
|
||||||
LINE_STYLE_ARROW_TYPE_DIAMOND = 'diamond',
|
LINE_STYLE_ARROW_SIZE_5 = 5,
|
||||||
LINE_STYLE_ARROW_TYPE_OVAL = 'oval',
|
LINE_STYLE_ARROW_SIZE_6 = 6,
|
||||||
|
LINE_STYLE_ARROW_SIZE_7 = 7,
|
||||||
|
LINE_STYLE_ARROW_SIZE_8 = 8,
|
||||||
|
LINE_STYLE_ARROW_SIZE_9 = 9;
|
||||||
|
|
||||||
LINE_STYLE_ARROW_SIZE_1 = 1,
|
const
|
||||||
LINE_STYLE_ARROW_SIZE_2 = 2,
|
SHADOW_PRESETS_NOSHADOW = null,
|
||||||
LINE_STYLE_ARROW_SIZE_3 = 3,
|
SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1,
|
||||||
LINE_STYLE_ARROW_SIZE_4 = 4,
|
SHADOW_PRESETS_OUTER_BOTTOM = 2,
|
||||||
LINE_STYLE_ARROW_SIZE_5 = 5,
|
SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3,
|
||||||
LINE_STYLE_ARROW_SIZE_6 = 6,
|
SHADOW_PRESETS_OUTER_RIGHT = 4,
|
||||||
LINE_STYLE_ARROW_SIZE_7 = 7,
|
SHADOW_PRESETS_OUTER_CENTER = 5,
|
||||||
LINE_STYLE_ARROW_SIZE_8 = 8,
|
SHADOW_PRESETS_OUTER_LEFT = 6,
|
||||||
LINE_STYLE_ARROW_SIZE_9 = 9;
|
SHADOW_PRESETS_OUTER_TOP_RIGHT = 7,
|
||||||
|
SHADOW_PRESETS_OUTER_TOP = 8,
|
||||||
|
SHADOW_PRESETS_OUTER_TOP_LEFT = 9,
|
||||||
|
SHADOW_PRESETS_INNER_BOTTTOM_RIGHT = 10,
|
||||||
|
SHADOW_PRESETS_INNER_BOTTOM = 11,
|
||||||
|
SHADOW_PRESETS_INNER_BOTTOM_LEFT = 12,
|
||||||
|
SHADOW_PRESETS_INNER_RIGHT = 13,
|
||||||
|
SHADOW_PRESETS_INNER_CENTER = 14,
|
||||||
|
SHADOW_PRESETS_INNER_LEFT = 15,
|
||||||
|
SHADOW_PRESETS_INNER_TOP_RIGHT = 16,
|
||||||
|
SHADOW_PRESETS_INNER_TOP = 17,
|
||||||
|
SHADOW_PRESETS_INNER_TOP_LEFT = 18,
|
||||||
|
SHADOW_PRESETS_PERSPECTIVE_BELOW = 19,
|
||||||
|
SHADOW_PRESETS_PERSPECTIVE_UPPER_RIGHT = 20,
|
||||||
|
SHADOW_PRESETS_PERSPECTIVE_UPPER_LEFT = 21,
|
||||||
|
SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22,
|
||||||
|
SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23;
|
||||||
|
|
||||||
const
|
protected function getExcelPointsWidth($width)
|
||||||
SHADOW_PRESETS_NOSHADOW = NULL,
|
{
|
||||||
SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1,
|
return $width * 12700;
|
||||||
SHADOW_PRESETS_OUTER_BOTTOM = 2,
|
|
||||||
SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3,
|
|
||||||
SHADOW_PRESETS_OUTER_RIGHT = 4,
|
|
||||||
SHADOW_PRESETS_OUTER_CENTER = 5,
|
|
||||||
SHADOW_PRESETS_OUTER_LEFT = 6,
|
|
||||||
SHADOW_PRESETS_OUTER_TOP_RIGHT = 7,
|
|
||||||
SHADOW_PRESETS_OUTER_TOP = 8,
|
|
||||||
SHADOW_PRESETS_OUTER_TOP_LEFT = 9,
|
|
||||||
SHADOW_PRESETS_INNER_BOTTTOM_RIGHT = 10,
|
|
||||||
SHADOW_PRESETS_INNER_BOTTOM = 11,
|
|
||||||
SHADOW_PRESETS_INNER_BOTTOM_LEFT = 12,
|
|
||||||
SHADOW_PRESETS_INNER_RIGHT = 13,
|
|
||||||
SHADOW_PRESETS_INNER_CENTER = 14,
|
|
||||||
SHADOW_PRESETS_INNER_LEFT = 15,
|
|
||||||
SHADOW_PRESETS_INNER_TOP_RIGHT = 16,
|
|
||||||
SHADOW_PRESETS_INNER_TOP = 17,
|
|
||||||
SHADOW_PRESETS_INNER_TOP_LEFT = 18,
|
|
||||||
SHADOW_PRESETS_PERSPECTIVE_BELOW = 19,
|
|
||||||
SHADOW_PRESETS_PERSPECTIVE_UPPER_RIGHT = 20,
|
|
||||||
SHADOW_PRESETS_PERSPECTIVE_UPPER_LEFT = 21,
|
|
||||||
SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22,
|
|
||||||
SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23;
|
|
||||||
|
|
||||||
protected function getExcelPointsWidth($width) {
|
|
||||||
return $width * 12700;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getExcelPointsAngle($angle) {
|
|
||||||
return $angle * 60000;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getTrueAlpha($alpha) {
|
|
||||||
return (string) 100 - $alpha . '000';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setColorProperties($color, $alpha, $type) {
|
|
||||||
return array(
|
|
||||||
'type' => (string) $type,
|
|
||||||
'value' => (string) $color,
|
|
||||||
'alpha' => (string) $this->getTrueAlpha($alpha)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getLineStyleArrowSize($array_selector, $array_kay_selector) {
|
|
||||||
$sizes = array(
|
|
||||||
1 => array('w' => 'sm', 'len' => 'sm'),
|
|
||||||
2 => array('w' => 'sm', 'len' => 'med'),
|
|
||||||
3 => array('w' => 'sm', 'len' => 'lg'),
|
|
||||||
4 => array('w' => 'med', 'len' => 'sm'),
|
|
||||||
5 => array('w' => 'med', 'len' => 'med'),
|
|
||||||
6 => array('w' => 'med', 'len' => 'lg'),
|
|
||||||
7 => array('w' => 'lg', 'len' => 'sm'),
|
|
||||||
8 => array('w' => 'lg', 'len' => 'med'),
|
|
||||||
9 => array('w' => 'lg', 'len' => 'lg')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $sizes[$array_selector][$array_kay_selector];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getShadowPresetsMap($shadow_presets_option) {
|
|
||||||
$presets_options = array(
|
|
||||||
//OUTER
|
|
||||||
1 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '50800',
|
|
||||||
'distance' => '38100',
|
|
||||||
'direction' => '2700000',
|
|
||||||
'algn' => 'tl',
|
|
||||||
'rotWithShape' => '0'
|
|
||||||
),
|
|
||||||
2 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '50800',
|
|
||||||
'distance' => '38100',
|
|
||||||
'direction' => '5400000',
|
|
||||||
'algn' => 't',
|
|
||||||
'rotWithShape' => '0'
|
|
||||||
),
|
|
||||||
3 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '50800',
|
|
||||||
'distance' => '38100',
|
|
||||||
'direction' => '8100000',
|
|
||||||
'algn' => 'tr',
|
|
||||||
'rotWithShape' => '0'
|
|
||||||
),
|
|
||||||
4 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '50800',
|
|
||||||
'distance' => '38100',
|
|
||||||
'algn' => 'l',
|
|
||||||
'rotWithShape' => '0'
|
|
||||||
),
|
|
||||||
5 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'size' => array(
|
|
||||||
'sx' => '102000',
|
|
||||||
'sy' => '102000'
|
|
||||||
)
|
|
||||||
,
|
|
||||||
'blur' => '63500',
|
|
||||||
'distance' => '38100',
|
|
||||||
'algn' => 'ctr',
|
|
||||||
'rotWithShape' => '0'
|
|
||||||
),
|
|
||||||
6 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '50800',
|
|
||||||
'distance' => '38100',
|
|
||||||
'direction' => '10800000',
|
|
||||||
'algn' => 'r',
|
|
||||||
'rotWithShape' => '0'
|
|
||||||
),
|
|
||||||
7 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '50800',
|
|
||||||
'distance' => '38100',
|
|
||||||
'direction' => '18900000',
|
|
||||||
'algn' => 'bl',
|
|
||||||
'rotWithShape' => '0'
|
|
||||||
),
|
|
||||||
8 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '50800',
|
|
||||||
'distance' => '38100',
|
|
||||||
'direction' => '16200000',
|
|
||||||
'rotWithShape' => '0'
|
|
||||||
),
|
|
||||||
9 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '50800',
|
|
||||||
'distance' => '38100',
|
|
||||||
'direction' => '13500000',
|
|
||||||
'algn' => 'br',
|
|
||||||
'rotWithShape' => '0'
|
|
||||||
),
|
|
||||||
//INNER
|
|
||||||
10 => array(
|
|
||||||
'effect' => 'innerShdw',
|
|
||||||
'blur' => '63500',
|
|
||||||
'distance' => '50800',
|
|
||||||
'direction' => '2700000',
|
|
||||||
),
|
|
||||||
11 => array(
|
|
||||||
'effect' => 'innerShdw',
|
|
||||||
'blur' => '63500',
|
|
||||||
'distance' => '50800',
|
|
||||||
'direction' => '5400000',
|
|
||||||
),
|
|
||||||
12 => array(
|
|
||||||
'effect' => 'innerShdw',
|
|
||||||
'blur' => '63500',
|
|
||||||
'distance' => '50800',
|
|
||||||
'direction' => '8100000',
|
|
||||||
),
|
|
||||||
13 => array(
|
|
||||||
'effect' => 'innerShdw',
|
|
||||||
'blur' => '63500',
|
|
||||||
'distance' => '50800',
|
|
||||||
),
|
|
||||||
14 => array(
|
|
||||||
'effect' => 'innerShdw',
|
|
||||||
'blur' => '114300',
|
|
||||||
),
|
|
||||||
15 => array(
|
|
||||||
'effect' => 'innerShdw',
|
|
||||||
'blur' => '63500',
|
|
||||||
'distance' => '50800',
|
|
||||||
'direction' => '10800000',
|
|
||||||
),
|
|
||||||
16 => array(
|
|
||||||
'effect' => 'innerShdw',
|
|
||||||
'blur' => '63500',
|
|
||||||
'distance' => '50800',
|
|
||||||
'direction' => '18900000',
|
|
||||||
),
|
|
||||||
17 => array(
|
|
||||||
'effect' => 'innerShdw',
|
|
||||||
'blur' => '63500',
|
|
||||||
'distance' => '50800',
|
|
||||||
'direction' => '16200000',
|
|
||||||
),
|
|
||||||
18 => array(
|
|
||||||
'effect' => 'innerShdw',
|
|
||||||
'blur' => '63500',
|
|
||||||
'distance' => '50800',
|
|
||||||
'direction' => '13500000',
|
|
||||||
),
|
|
||||||
//perspective
|
|
||||||
19 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '152400',
|
|
||||||
'distance' => '317500',
|
|
||||||
'size' => array(
|
|
||||||
'sx' => '90000',
|
|
||||||
'sy' => '-19000',
|
|
||||||
),
|
|
||||||
'direction' => '5400000',
|
|
||||||
'rotWithShape' => '0',
|
|
||||||
),
|
|
||||||
20 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '76200',
|
|
||||||
'direction' => '18900000',
|
|
||||||
'size' => array(
|
|
||||||
'sy' => '23000',
|
|
||||||
'kx' => '-1200000',
|
|
||||||
),
|
|
||||||
'algn' => 'bl',
|
|
||||||
'rotWithShape' => '0',
|
|
||||||
),
|
|
||||||
21 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '76200',
|
|
||||||
'direction' => '13500000',
|
|
||||||
'size' => array(
|
|
||||||
'sy' => '23000',
|
|
||||||
'kx' => '1200000',
|
|
||||||
),
|
|
||||||
'algn' => 'br',
|
|
||||||
'rotWithShape' => '0',
|
|
||||||
),
|
|
||||||
22 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '76200',
|
|
||||||
'distance' => '12700',
|
|
||||||
'direction' => '2700000',
|
|
||||||
'size' => array(
|
|
||||||
'sy' => '-23000',
|
|
||||||
'kx' => '-800400',
|
|
||||||
),
|
|
||||||
'algn' => 'bl',
|
|
||||||
'rotWithShape' => '0',
|
|
||||||
),
|
|
||||||
23 => array(
|
|
||||||
'effect' => 'outerShdw',
|
|
||||||
'blur' => '76200',
|
|
||||||
'distance' => '12700',
|
|
||||||
'direction' => '8100000',
|
|
||||||
'size' => array(
|
|
||||||
'sy' => '-23000',
|
|
||||||
'kx' => '800400',
|
|
||||||
),
|
|
||||||
'algn' => 'br',
|
|
||||||
'rotWithShape' => '0',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return $presets_options[$shadow_presets_option];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getArrayElementsValue($properties, $elements) {
|
|
||||||
$reference = & $properties;
|
|
||||||
if (!is_array($elements)) {
|
|
||||||
return $reference[$elements];
|
|
||||||
} else {
|
|
||||||
foreach ($elements as $keys) {
|
|
||||||
$reference = & $reference[$keys];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $reference;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
protected function getExcelPointsAngle($angle)
|
||||||
}
|
{
|
||||||
|
return $angle * 60000;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
protected function getTrueAlpha($alpha)
|
||||||
|
{
|
||||||
|
return (string) 100 - $alpha . '000';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setColorProperties($color, $alpha, $type)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'type' => (string) $type,
|
||||||
|
'value' => (string) $color,
|
||||||
|
'alpha' => (string) $this->getTrueAlpha($alpha)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getLineStyleArrowSize($array_selector, $array_kay_selector)
|
||||||
|
{
|
||||||
|
$sizes = array(
|
||||||
|
1 => array('w' => 'sm', 'len' => 'sm'),
|
||||||
|
2 => array('w' => 'sm', 'len' => 'med'),
|
||||||
|
3 => array('w' => 'sm', 'len' => 'lg'),
|
||||||
|
4 => array('w' => 'med', 'len' => 'sm'),
|
||||||
|
5 => array('w' => 'med', 'len' => 'med'),
|
||||||
|
6 => array('w' => 'med', 'len' => 'lg'),
|
||||||
|
7 => array('w' => 'lg', 'len' => 'sm'),
|
||||||
|
8 => array('w' => 'lg', 'len' => 'med'),
|
||||||
|
9 => array('w' => 'lg', 'len' => 'lg')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $sizes[$array_selector][$array_kay_selector];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getShadowPresetsMap($shadow_presets_option)
|
||||||
|
{
|
||||||
|
$presets_options = array(
|
||||||
|
//OUTER
|
||||||
|
1 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '50800',
|
||||||
|
'distance' => '38100',
|
||||||
|
'direction' => '2700000',
|
||||||
|
'algn' => 'tl',
|
||||||
|
'rotWithShape' => '0'
|
||||||
|
),
|
||||||
|
2 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '50800',
|
||||||
|
'distance' => '38100',
|
||||||
|
'direction' => '5400000',
|
||||||
|
'algn' => 't',
|
||||||
|
'rotWithShape' => '0'
|
||||||
|
),
|
||||||
|
3 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '50800',
|
||||||
|
'distance' => '38100',
|
||||||
|
'direction' => '8100000',
|
||||||
|
'algn' => 'tr',
|
||||||
|
'rotWithShape' => '0'
|
||||||
|
),
|
||||||
|
4 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '50800',
|
||||||
|
'distance' => '38100',
|
||||||
|
'algn' => 'l',
|
||||||
|
'rotWithShape' => '0'
|
||||||
|
),
|
||||||
|
5 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'size' => array(
|
||||||
|
'sx' => '102000',
|
||||||
|
'sy' => '102000'
|
||||||
|
)
|
||||||
|
,
|
||||||
|
'blur' => '63500',
|
||||||
|
'distance' => '38100',
|
||||||
|
'algn' => 'ctr',
|
||||||
|
'rotWithShape' => '0'
|
||||||
|
),
|
||||||
|
6 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '50800',
|
||||||
|
'distance' => '38100',
|
||||||
|
'direction' => '10800000',
|
||||||
|
'algn' => 'r',
|
||||||
|
'rotWithShape' => '0'
|
||||||
|
),
|
||||||
|
7 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '50800',
|
||||||
|
'distance' => '38100',
|
||||||
|
'direction' => '18900000',
|
||||||
|
'algn' => 'bl',
|
||||||
|
'rotWithShape' => '0'
|
||||||
|
),
|
||||||
|
8 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '50800',
|
||||||
|
'distance' => '38100',
|
||||||
|
'direction' => '16200000',
|
||||||
|
'rotWithShape' => '0'
|
||||||
|
),
|
||||||
|
9 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '50800',
|
||||||
|
'distance' => '38100',
|
||||||
|
'direction' => '13500000',
|
||||||
|
'algn' => 'br',
|
||||||
|
'rotWithShape' => '0'
|
||||||
|
),
|
||||||
|
//INNER
|
||||||
|
10 => array(
|
||||||
|
'effect' => 'innerShdw',
|
||||||
|
'blur' => '63500',
|
||||||
|
'distance' => '50800',
|
||||||
|
'direction' => '2700000',
|
||||||
|
),
|
||||||
|
11 => array(
|
||||||
|
'effect' => 'innerShdw',
|
||||||
|
'blur' => '63500',
|
||||||
|
'distance' => '50800',
|
||||||
|
'direction' => '5400000',
|
||||||
|
),
|
||||||
|
12 => array(
|
||||||
|
'effect' => 'innerShdw',
|
||||||
|
'blur' => '63500',
|
||||||
|
'distance' => '50800',
|
||||||
|
'direction' => '8100000',
|
||||||
|
),
|
||||||
|
13 => array(
|
||||||
|
'effect' => 'innerShdw',
|
||||||
|
'blur' => '63500',
|
||||||
|
'distance' => '50800',
|
||||||
|
),
|
||||||
|
14 => array(
|
||||||
|
'effect' => 'innerShdw',
|
||||||
|
'blur' => '114300',
|
||||||
|
),
|
||||||
|
15 => array(
|
||||||
|
'effect' => 'innerShdw',
|
||||||
|
'blur' => '63500',
|
||||||
|
'distance' => '50800',
|
||||||
|
'direction' => '10800000',
|
||||||
|
),
|
||||||
|
16 => array(
|
||||||
|
'effect' => 'innerShdw',
|
||||||
|
'blur' => '63500',
|
||||||
|
'distance' => '50800',
|
||||||
|
'direction' => '18900000',
|
||||||
|
),
|
||||||
|
17 => array(
|
||||||
|
'effect' => 'innerShdw',
|
||||||
|
'blur' => '63500',
|
||||||
|
'distance' => '50800',
|
||||||
|
'direction' => '16200000',
|
||||||
|
),
|
||||||
|
18 => array(
|
||||||
|
'effect' => 'innerShdw',
|
||||||
|
'blur' => '63500',
|
||||||
|
'distance' => '50800',
|
||||||
|
'direction' => '13500000',
|
||||||
|
),
|
||||||
|
//perspective
|
||||||
|
19 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '152400',
|
||||||
|
'distance' => '317500',
|
||||||
|
'size' => array(
|
||||||
|
'sx' => '90000',
|
||||||
|
'sy' => '-19000',
|
||||||
|
),
|
||||||
|
'direction' => '5400000',
|
||||||
|
'rotWithShape' => '0',
|
||||||
|
),
|
||||||
|
20 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '76200',
|
||||||
|
'direction' => '18900000',
|
||||||
|
'size' => array(
|
||||||
|
'sy' => '23000',
|
||||||
|
'kx' => '-1200000',
|
||||||
|
),
|
||||||
|
'algn' => 'bl',
|
||||||
|
'rotWithShape' => '0',
|
||||||
|
),
|
||||||
|
21 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '76200',
|
||||||
|
'direction' => '13500000',
|
||||||
|
'size' => array(
|
||||||
|
'sy' => '23000',
|
||||||
|
'kx' => '1200000',
|
||||||
|
),
|
||||||
|
'algn' => 'br',
|
||||||
|
'rotWithShape' => '0',
|
||||||
|
),
|
||||||
|
22 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '76200',
|
||||||
|
'distance' => '12700',
|
||||||
|
'direction' => '2700000',
|
||||||
|
'size' => array(
|
||||||
|
'sy' => '-23000',
|
||||||
|
'kx' => '-800400',
|
||||||
|
),
|
||||||
|
'algn' => 'bl',
|
||||||
|
'rotWithShape' => '0',
|
||||||
|
),
|
||||||
|
23 => array(
|
||||||
|
'effect' => 'outerShdw',
|
||||||
|
'blur' => '76200',
|
||||||
|
'distance' => '12700',
|
||||||
|
'direction' => '8100000',
|
||||||
|
'size' => array(
|
||||||
|
'sy' => '-23000',
|
||||||
|
'kx' => '800400',
|
||||||
|
),
|
||||||
|
'algn' => 'br',
|
||||||
|
'rotWithShape' => '0',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $presets_options[$shadow_presets_option];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getArrayElementsValue($properties, $elements)
|
||||||
|
{
|
||||||
|
$reference = & $properties;
|
||||||
|
if (!is_array($elements)) {
|
||||||
|
return $reference[$elements];
|
||||||
|
} else {
|
||||||
|
foreach ($elements as $keys) {
|
||||||
|
$reference = & $reference[$keys];
|
||||||
|
}
|
||||||
|
return $reference;
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,3 +15,6 @@ pChart
|
||||||
|
|
||||||
TeeChart
|
TeeChart
|
||||||
http://www.steema.com/products/teechart/overview.html
|
http://www.steema.com/products/teechart/overview.html
|
||||||
|
|
||||||
|
PHPGraphLib
|
||||||
|
http://www.ebrueggeman.com/phpgraphlib
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Chart_Title
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,75 +19,68 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Chart
|
* @package PHPExcel_Chart
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Chart_Title
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Chart
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Chart_Title
|
class PHPExcel_Chart_Title
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title Caption
|
* Title Caption
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_caption = null;
|
private $caption = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title Layout
|
* Title Layout
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Chart_Layout
|
* @var PHPExcel_Chart_Layout
|
||||||
*/
|
*/
|
||||||
private $_layout = null;
|
private $layout = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Chart_Title
|
* Create a new PHPExcel_Chart_Title
|
||||||
*/
|
*/
|
||||||
public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null)
|
public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null)
|
||||||
{
|
{
|
||||||
$this->_caption = $caption;
|
$this->caption = $caption;
|
||||||
$this->_layout = $layout;
|
$this->layout = $layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get caption
|
* Get caption
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCaption() {
|
public function getCaption()
|
||||||
return $this->_caption;
|
{
|
||||||
}
|
return $this->caption;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set caption
|
* Set caption
|
||||||
*
|
*
|
||||||
* @param string $caption
|
* @param string $caption
|
||||||
* @return PHPExcel_Chart_Title
|
* @return PHPExcel_Chart_Title
|
||||||
*/
|
*/
|
||||||
public function setCaption($caption = null) {
|
public function setCaption($caption = null)
|
||||||
$this->_caption = $caption;
|
{
|
||||||
|
$this->caption = $caption;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Layout
|
|
||||||
*
|
|
||||||
* @return PHPExcel_Chart_Layout
|
|
||||||
*/
|
|
||||||
public function getLayout() {
|
|
||||||
return $this->_layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Layout
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Chart_Layout
|
||||||
|
*/
|
||||||
|
public function getLayout()
|
||||||
|
{
|
||||||
|
return $this->layout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Comment
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,19 +21,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Comment
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Comment implements PHPExcel_IComparable
|
class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -40,63 +32,63 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_author;
|
private $author;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rich text comment
|
* Rich text comment
|
||||||
*
|
*
|
||||||
* @var PHPExcel_RichText
|
* @var PHPExcel_RichText
|
||||||
*/
|
*/
|
||||||
private $_text;
|
private $text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment width (CSS style, i.e. XXpx or YYpt)
|
* Comment width (CSS style, i.e. XXpx or YYpt)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_width = '96pt';
|
private $width = '96pt';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Left margin (CSS style, i.e. XXpx or YYpt)
|
* Left margin (CSS style, i.e. XXpx or YYpt)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_marginLeft = '59.25pt';
|
private $marginLeft = '59.25pt';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top margin (CSS style, i.e. XXpx or YYpt)
|
* Top margin (CSS style, i.e. XXpx or YYpt)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_marginTop = '1.5pt';
|
private $marginTop = '1.5pt';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visible
|
* Visible
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_visible = false;
|
private $visible = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment height (CSS style, i.e. XXpx or YYpt)
|
* Comment height (CSS style, i.e. XXpx or YYpt)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_height = '55.5pt';
|
private $height = '55.5pt';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment fill color
|
* Comment fill color
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Color
|
* @var PHPExcel_Style_Color
|
||||||
*/
|
*/
|
||||||
private $_fillColor;
|
private $fillColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alignment
|
* Alignment
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_alignment;
|
private $alignment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Comment
|
* Create a new PHPExcel_Comment
|
||||||
|
@ -106,10 +98,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Initialise variables
|
// Initialise variables
|
||||||
$this->_author = 'Author';
|
$this->author = 'Author';
|
||||||
$this->_text = new PHPExcel_RichText();
|
$this->text = new PHPExcel_RichText();
|
||||||
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
$this->fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
||||||
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
$this->alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,8 +109,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAuthor() {
|
public function getAuthor()
|
||||||
return $this->_author;
|
{
|
||||||
|
return $this->author;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,8 +120,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_Comment
|
* @return PHPExcel_Comment
|
||||||
*/
|
*/
|
||||||
public function setAuthor($pValue = '') {
|
public function setAuthor($pValue = '')
|
||||||
$this->_author = $pValue;
|
{
|
||||||
|
$this->author = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,8 +131,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return PHPExcel_RichText
|
* @return PHPExcel_RichText
|
||||||
*/
|
*/
|
||||||
public function getText() {
|
public function getText()
|
||||||
return $this->_text;
|
{
|
||||||
|
return $this->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,8 +142,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
* @param PHPExcel_RichText $pValue
|
* @param PHPExcel_RichText $pValue
|
||||||
* @return PHPExcel_Comment
|
* @return PHPExcel_Comment
|
||||||
*/
|
*/
|
||||||
public function setText(PHPExcel_RichText $pValue) {
|
public function setText(PHPExcel_RichText $pValue)
|
||||||
$this->_text = $pValue;
|
{
|
||||||
|
$this->text = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,8 +153,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getWidth() {
|
public function getWidth()
|
||||||
return $this->_width;
|
{
|
||||||
|
return $this->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,8 +164,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Comment
|
* @return PHPExcel_Comment
|
||||||
*/
|
*/
|
||||||
public function setWidth($value = '96pt') {
|
public function setWidth($value = '96pt')
|
||||||
$this->_width = $value;
|
{
|
||||||
|
$this->width = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,8 +175,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getHeight() {
|
public function getHeight()
|
||||||
return $this->_height;
|
{
|
||||||
|
return $this->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,8 +186,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Comment
|
* @return PHPExcel_Comment
|
||||||
*/
|
*/
|
||||||
public function setHeight($value = '55.5pt') {
|
public function setHeight($value = '55.5pt')
|
||||||
$this->_height = $value;
|
{
|
||||||
|
$this->height = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,8 +197,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getMarginLeft() {
|
public function getMarginLeft()
|
||||||
return $this->_marginLeft;
|
{
|
||||||
|
return $this->marginLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,8 +208,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Comment
|
* @return PHPExcel_Comment
|
||||||
*/
|
*/
|
||||||
public function setMarginLeft($value = '59.25pt') {
|
public function setMarginLeft($value = '59.25pt')
|
||||||
$this->_marginLeft = $value;
|
{
|
||||||
|
$this->marginLeft = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,8 +219,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getMarginTop() {
|
public function getMarginTop()
|
||||||
return $this->_marginTop;
|
{
|
||||||
|
return $this->marginTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,8 +230,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_Comment
|
* @return PHPExcel_Comment
|
||||||
*/
|
*/
|
||||||
public function setMarginTop($value = '1.5pt') {
|
public function setMarginTop($value = '1.5pt')
|
||||||
$this->_marginTop = $value;
|
{
|
||||||
|
$this->marginTop = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,8 +241,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getVisible() {
|
public function getVisible()
|
||||||
return $this->_visible;
|
{
|
||||||
|
return $this->visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,8 +252,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
* @param boolean $value
|
* @param boolean $value
|
||||||
* @return PHPExcel_Comment
|
* @return PHPExcel_Comment
|
||||||
*/
|
*/
|
||||||
public function setVisible($value = false) {
|
public function setVisible($value = false)
|
||||||
$this->_visible = $value;
|
{
|
||||||
|
$this->visible = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,8 +263,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Style_Color
|
* @return PHPExcel_Style_Color
|
||||||
*/
|
*/
|
||||||
public function getFillColor() {
|
public function getFillColor()
|
||||||
return $this->_fillColor;
|
{
|
||||||
|
return $this->fillColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,8 +274,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_Comment
|
* @return PHPExcel_Comment
|
||||||
*/
|
*/
|
||||||
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
|
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL)
|
||||||
$this->_alignment = $pValue;
|
{
|
||||||
|
$this->alignment = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,8 +285,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAlignment() {
|
public function getAlignment()
|
||||||
return $this->_alignment;
|
{
|
||||||
|
return $this->alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -286,25 +295,27 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return string Hash code
|
* @return string Hash code
|
||||||
*/
|
*/
|
||||||
public function getHashCode() {
|
public function getHashCode()
|
||||||
|
{
|
||||||
return md5(
|
return md5(
|
||||||
$this->_author
|
$this->author .
|
||||||
. $this->_text->getHashCode()
|
$this->text->getHashCode() .
|
||||||
. $this->_width
|
$this->width .
|
||||||
. $this->_height
|
$this->height .
|
||||||
. $this->_marginLeft
|
$this->marginLeft .
|
||||||
. $this->_marginTop
|
$this->marginTop .
|
||||||
. ($this->_visible ? 1 : 0)
|
($this->visible ? 1 : 0) .
|
||||||
. $this->_fillColor->getHashCode()
|
$this->fillColor->getHashCode() .
|
||||||
. $this->_alignment
|
$this->alignment .
|
||||||
. __CLASS__
|
__CLASS__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
|
{
|
||||||
$vars = get_object_vars($this);
|
$vars = get_object_vars($this);
|
||||||
foreach ($vars as $key => $value) {
|
foreach ($vars as $key => $value) {
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
|
@ -320,8 +331,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function __toString() {
|
public function __toString()
|
||||||
return $this->_text->getPlainText();
|
{
|
||||||
|
return $this->text->getPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,23 +21,14 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_DocumentProperties
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_DocumentProperties
|
class PHPExcel_DocumentProperties
|
||||||
{
|
{
|
||||||
/** constants */
|
/** constants */
|
||||||
const PROPERTY_TYPE_BOOLEAN = 'b';
|
const PROPERTY_TYPE_BOOLEAN = 'b';
|
||||||
const PROPERTY_TYPE_INTEGER = 'i';
|
const PROPERTY_TYPE_INTEGER = 'i';
|
||||||
const PROPERTY_TYPE_FLOAT = 'f';
|
const PROPERTY_TYPE_FLOAT = 'f';
|
||||||
const PROPERTY_TYPE_DATE = 'd';
|
const PROPERTY_TYPE_DATE = 'd';
|
||||||
|
@ -48,84 +40,84 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_creator = 'Unknown Creator';
|
private $creator = 'Unknown Creator';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LastModifiedBy
|
* LastModifiedBy
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_lastModifiedBy;
|
private $lastModifiedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created
|
* Created
|
||||||
*
|
*
|
||||||
* @var datetime
|
* @var datetime
|
||||||
*/
|
*/
|
||||||
private $_created;
|
private $created;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modified
|
* Modified
|
||||||
*
|
*
|
||||||
* @var datetime
|
* @var datetime
|
||||||
*/
|
*/
|
||||||
private $_modified;
|
private $modified;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title
|
* Title
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_title = 'Untitled Spreadsheet';
|
private $title = 'Untitled Spreadsheet';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Description
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_description = '';
|
private $description = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subject
|
* Subject
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_subject = '';
|
private $subject = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keywords
|
* Keywords
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_keywords = '';
|
private $keywords = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category
|
* Category
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_category = '';
|
private $category = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager
|
* Manager
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_manager = '';
|
private $manager = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Company
|
* Company
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_company = 'Microsoft Corporation';
|
private $company = 'Microsoft Corporation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom Properties
|
* Custom Properties
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_customProperties = array();
|
private $customProperties = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,9 +126,9 @@ class PHPExcel_DocumentProperties
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_lastModifiedBy = $this->_creator;
|
$this->lastModifiedBy = $this->creator;
|
||||||
$this->_created = time();
|
$this->created = time();
|
||||||
$this->_modified = time();
|
$this->modified = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,8 +136,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCreator() {
|
public function getCreator()
|
||||||
return $this->_creator;
|
{
|
||||||
|
return $this->creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,8 +147,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCreator($pValue = '') {
|
public function setCreator($pValue = '')
|
||||||
$this->_creator = $pValue;
|
{
|
||||||
|
$this->creator = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +158,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLastModifiedBy() {
|
public function getLastModifiedBy()
|
||||||
return $this->_lastModifiedBy;
|
{
|
||||||
|
return $this->lastModifiedBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,8 +169,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setLastModifiedBy($pValue = '') {
|
public function setLastModifiedBy($pValue = '')
|
||||||
$this->_lastModifiedBy = $pValue;
|
{
|
||||||
|
$this->lastModifiedBy = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,8 +180,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return datetime
|
* @return datetime
|
||||||
*/
|
*/
|
||||||
public function getCreated() {
|
public function getCreated()
|
||||||
return $this->_created;
|
{
|
||||||
|
return $this->created;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,8 +191,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param datetime $pValue
|
* @param datetime $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCreated($pValue = null) {
|
public function setCreated($pValue = null)
|
||||||
if ($pValue === NULL) {
|
{
|
||||||
|
if ($pValue === null) {
|
||||||
$pValue = time();
|
$pValue = time();
|
||||||
} elseif (is_string($pValue)) {
|
} elseif (is_string($pValue)) {
|
||||||
if (is_numeric($pValue)) {
|
if (is_numeric($pValue)) {
|
||||||
|
@ -205,7 +203,7 @@ class PHPExcel_DocumentProperties
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_created = $pValue;
|
$this->created = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,8 +212,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return datetime
|
* @return datetime
|
||||||
*/
|
*/
|
||||||
public function getModified() {
|
public function getModified()
|
||||||
return $this->_modified;
|
{
|
||||||
|
return $this->modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,8 +223,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param datetime $pValue
|
* @param datetime $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setModified($pValue = null) {
|
public function setModified($pValue = null)
|
||||||
if ($pValue === NULL) {
|
{
|
||||||
|
if ($pValue === null) {
|
||||||
$pValue = time();
|
$pValue = time();
|
||||||
} elseif (is_string($pValue)) {
|
} elseif (is_string($pValue)) {
|
||||||
if (is_numeric($pValue)) {
|
if (is_numeric($pValue)) {
|
||||||
|
@ -235,7 +235,7 @@ class PHPExcel_DocumentProperties
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_modified = $pValue;
|
$this->modified = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,8 +244,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTitle() {
|
public function getTitle()
|
||||||
return $this->_title;
|
{
|
||||||
|
return $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,8 +255,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setTitle($pValue = '') {
|
public function setTitle($pValue = '')
|
||||||
$this->_title = $pValue;
|
{
|
||||||
|
$this->title = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,8 +266,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
return $this->_description;
|
{
|
||||||
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,8 +277,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setDescription($pValue = '') {
|
public function setDescription($pValue = '')
|
||||||
$this->_description = $pValue;
|
{
|
||||||
|
$this->description = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,8 +288,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSubject() {
|
public function getSubject()
|
||||||
return $this->_subject;
|
{
|
||||||
|
return $this->subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -294,8 +299,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setSubject($pValue = '') {
|
public function setSubject($pValue = '')
|
||||||
$this->_subject = $pValue;
|
{
|
||||||
|
$this->subject = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,8 +310,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getKeywords() {
|
public function getKeywords()
|
||||||
return $this->_keywords;
|
{
|
||||||
|
return $this->keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,8 +321,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setKeywords($pValue = '') {
|
public function setKeywords($pValue = '')
|
||||||
$this->_keywords = $pValue;
|
{
|
||||||
|
$this->keywords = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,8 +332,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCategory() {
|
public function getCategory()
|
||||||
return $this->_category;
|
{
|
||||||
|
return $this->category;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,8 +343,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCategory($pValue = '') {
|
public function setCategory($pValue = '')
|
||||||
$this->_category = $pValue;
|
{
|
||||||
|
$this->category = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,8 +354,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCompany() {
|
public function getCompany()
|
||||||
return $this->_company;
|
{
|
||||||
|
return $this->company;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -354,8 +365,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCompany($pValue = '') {
|
public function setCompany($pValue = '')
|
||||||
$this->_company = $pValue;
|
{
|
||||||
|
$this->company = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,8 +376,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getManager() {
|
public function getManager()
|
||||||
return $this->_manager;
|
{
|
||||||
|
return $this->manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -374,8 +387,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setManager($pValue = '') {
|
public function setManager($pValue = '')
|
||||||
$this->_manager = $pValue;
|
{
|
||||||
|
$this->manager = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,8 +398,9 @@ class PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* @return array of string
|
* @return array of string
|
||||||
*/
|
*/
|
||||||
public function getCustomProperties() {
|
public function getCustomProperties()
|
||||||
return array_keys($this->_customProperties);
|
{
|
||||||
|
return array_keys($this->customProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -394,8 +409,9 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isCustomPropertySet($propertyName) {
|
public function isCustomPropertySet($propertyName)
|
||||||
return isset($this->_customProperties[$propertyName]);
|
{
|
||||||
|
return isset($this->customProperties[$propertyName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,9 +420,10 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCustomPropertyValue($propertyName) {
|
public function getCustomPropertyValue($propertyName)
|
||||||
if (isset($this->_customProperties[$propertyName])) {
|
{
|
||||||
return $this->_customProperties[$propertyName]['value'];
|
if (isset($this->customProperties[$propertyName])) {
|
||||||
|
return $this->customProperties[$propertyName]['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -417,9 +434,10 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCustomPropertyType($propertyName) {
|
public function getCustomPropertyType($propertyName)
|
||||||
if (isset($this->_customProperties[$propertyName])) {
|
{
|
||||||
return $this->_customProperties[$propertyName]['type'];
|
if (isset($this->customProperties[$propertyName])) {
|
||||||
|
return $this->customProperties[$propertyName]['type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -430,24 +448,25 @@ class PHPExcel_DocumentProperties
|
||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @param mixed $propertyValue
|
* @param mixed $propertyValue
|
||||||
* @param string $propertyType
|
* @param string $propertyType
|
||||||
* 'i' : Integer
|
* 'i' : Integer
|
||||||
* 'f' : Floating Point
|
* 'f' : Floating Point
|
||||||
* 's' : String
|
* 's' : String
|
||||||
* 'd' : Date/Time
|
* 'd' : Date/Time
|
||||||
* 'b' : Boolean
|
* 'b' : Boolean
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
|
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)
|
||||||
if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
|
{
|
||||||
self::PROPERTY_TYPE_FLOAT,
|
if (($propertyType === null) || (!in_array($propertyType, array(self::PROPERTY_TYPE_INTEGER,
|
||||||
self::PROPERTY_TYPE_STRING,
|
self::PROPERTY_TYPE_FLOAT,
|
||||||
self::PROPERTY_TYPE_DATE,
|
self::PROPERTY_TYPE_STRING,
|
||||||
self::PROPERTY_TYPE_BOOLEAN)))) {
|
self::PROPERTY_TYPE_DATE,
|
||||||
if ($propertyValue === NULL) {
|
self::PROPERTY_TYPE_BOOLEAN)))) {
|
||||||
|
if ($propertyValue === null) {
|
||||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||||
} elseif (is_float($propertyValue)) {
|
} elseif (is_float($propertyValue)) {
|
||||||
$propertyType = self::PROPERTY_TYPE_FLOAT;
|
$propertyType = self::PROPERTY_TYPE_FLOAT;
|
||||||
} elseif(is_int($propertyValue)) {
|
} elseif (is_int($propertyValue)) {
|
||||||
$propertyType = self::PROPERTY_TYPE_INTEGER;
|
$propertyType = self::PROPERTY_TYPE_INTEGER;
|
||||||
} elseif (is_bool($propertyValue)) {
|
} elseif (is_bool($propertyValue)) {
|
||||||
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
|
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
|
||||||
|
@ -456,14 +475,18 @@ class PHPExcel_DocumentProperties
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType);
|
$this->customProperties[$propertyName] = array(
|
||||||
|
'value' => $propertyValue,
|
||||||
|
'type' => $propertyType
|
||||||
|
);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
|
{
|
||||||
$vars = get_object_vars($this);
|
$vars = get_object_vars($this);
|
||||||
foreach ($vars as $key => $value) {
|
foreach ($vars as $key => $value) {
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
|
@ -474,114 +497,115 @@ class PHPExcel_DocumentProperties
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function convertProperty($propertyValue,$propertyType) {
|
public static function convertProperty($propertyValue, $propertyType)
|
||||||
|
{
|
||||||
switch ($propertyType) {
|
switch ($propertyType) {
|
||||||
case 'empty' : // Empty
|
case 'empty': // Empty
|
||||||
return '';
|
return '';
|
||||||
break;
|
break;
|
||||||
case 'null' : // Null
|
case 'null': // Null
|
||||||
return NULL;
|
return null;
|
||||||
break;
|
break;
|
||||||
case 'i1' : // 1-Byte Signed Integer
|
case 'i1': // 1-Byte Signed Integer
|
||||||
case 'i2' : // 2-Byte Signed Integer
|
case 'i2': // 2-Byte Signed Integer
|
||||||
case 'i4' : // 4-Byte Signed Integer
|
case 'i4': // 4-Byte Signed Integer
|
||||||
case 'i8' : // 8-Byte Signed Integer
|
case 'i8': // 8-Byte Signed Integer
|
||||||
case 'int' : // Integer
|
case 'int': // Integer
|
||||||
return (int) $propertyValue;
|
return (int) $propertyValue;
|
||||||
break;
|
break;
|
||||||
case 'ui1' : // 1-Byte Unsigned Integer
|
case 'ui1': // 1-Byte Unsigned Integer
|
||||||
case 'ui2' : // 2-Byte Unsigned Integer
|
case 'ui2': // 2-Byte Unsigned Integer
|
||||||
case 'ui4' : // 4-Byte Unsigned Integer
|
case 'ui4': // 4-Byte Unsigned Integer
|
||||||
case 'ui8' : // 8-Byte Unsigned Integer
|
case 'ui8': // 8-Byte Unsigned Integer
|
||||||
case 'uint' : // Unsigned Integer
|
case 'uint': // Unsigned Integer
|
||||||
return abs((int) $propertyValue);
|
return abs((int) $propertyValue);
|
||||||
break;
|
break;
|
||||||
case 'r4' : // 4-Byte Real Number
|
case 'r4': // 4-Byte Real Number
|
||||||
case 'r8' : // 8-Byte Real Number
|
case 'r8': // 8-Byte Real Number
|
||||||
case 'decimal' : // Decimal
|
case 'decimal': // Decimal
|
||||||
return (float) $propertyValue;
|
return (float) $propertyValue;
|
||||||
break;
|
break;
|
||||||
case 'lpstr' : // LPSTR
|
case 'lpstr': // LPSTR
|
||||||
case 'lpwstr' : // LPWSTR
|
case 'lpwstr': // LPWSTR
|
||||||
case 'bstr' : // Basic String
|
case 'bstr': // Basic String
|
||||||
return $propertyValue;
|
return $propertyValue;
|
||||||
break;
|
break;
|
||||||
case 'date' : // Date and Time
|
case 'date': // Date and Time
|
||||||
case 'filetime' : // File Time
|
case 'filetime': // File Time
|
||||||
return strtotime($propertyValue);
|
return strtotime($propertyValue);
|
||||||
break;
|
break;
|
||||||
case 'bool' : // Boolean
|
case 'bool': // Boolean
|
||||||
return ($propertyValue == 'true') ? True : False;
|
return ($propertyValue == 'true') ? true : false;
|
||||||
break;
|
break;
|
||||||
case 'cy' : // Currency
|
case 'cy': // Currency
|
||||||
case 'error' : // Error Status Code
|
case 'error': // Error Status Code
|
||||||
case 'vector' : // Vector
|
case 'vector': // Vector
|
||||||
case 'array' : // Array
|
case 'array': // Array
|
||||||
case 'blob' : // Binary Blob
|
case 'blob': // Binary Blob
|
||||||
case 'oblob' : // Binary Blob Object
|
case 'oblob': // Binary Blob Object
|
||||||
case 'stream' : // Binary Stream
|
case 'stream': // Binary Stream
|
||||||
case 'ostream' : // Binary Stream Object
|
case 'ostream': // Binary Stream Object
|
||||||
case 'storage' : // Binary Storage
|
case 'storage': // Binary Storage
|
||||||
case 'ostorage' : // Binary Storage Object
|
case 'ostorage': // Binary Storage Object
|
||||||
case 'vstream' : // Binary Versioned Stream
|
case 'vstream': // Binary Versioned Stream
|
||||||
case 'clsid' : // Class ID
|
case 'clsid': // Class ID
|
||||||
case 'cf' : // Clipboard Data
|
case 'cf': // Clipboard Data
|
||||||
return $propertyValue;
|
return $propertyValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $propertyValue;
|
return $propertyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function convertPropertyType($propertyType) {
|
public static function convertPropertyType($propertyType)
|
||||||
|
{
|
||||||
switch ($propertyType) {
|
switch ($propertyType) {
|
||||||
case 'i1' : // 1-Byte Signed Integer
|
case 'i1': // 1-Byte Signed Integer
|
||||||
case 'i2' : // 2-Byte Signed Integer
|
case 'i2': // 2-Byte Signed Integer
|
||||||
case 'i4' : // 4-Byte Signed Integer
|
case 'i4': // 4-Byte Signed Integer
|
||||||
case 'i8' : // 8-Byte Signed Integer
|
case 'i8': // 8-Byte Signed Integer
|
||||||
case 'int' : // Integer
|
case 'int': // Integer
|
||||||
case 'ui1' : // 1-Byte Unsigned Integer
|
case 'ui1': // 1-Byte Unsigned Integer
|
||||||
case 'ui2' : // 2-Byte Unsigned Integer
|
case 'ui2': // 2-Byte Unsigned Integer
|
||||||
case 'ui4' : // 4-Byte Unsigned Integer
|
case 'ui4': // 4-Byte Unsigned Integer
|
||||||
case 'ui8' : // 8-Byte Unsigned Integer
|
case 'ui8': // 8-Byte Unsigned Integer
|
||||||
case 'uint' : // Unsigned Integer
|
case 'uint': // Unsigned Integer
|
||||||
return self::PROPERTY_TYPE_INTEGER;
|
return self::PROPERTY_TYPE_INTEGER;
|
||||||
break;
|
break;
|
||||||
case 'r4' : // 4-Byte Real Number
|
case 'r4': // 4-Byte Real Number
|
||||||
case 'r8' : // 8-Byte Real Number
|
case 'r8': // 8-Byte Real Number
|
||||||
case 'decimal' : // Decimal
|
case 'decimal': // Decimal
|
||||||
return self::PROPERTY_TYPE_FLOAT;
|
return self::PROPERTY_TYPE_FLOAT;
|
||||||
break;
|
break;
|
||||||
case 'empty' : // Empty
|
case 'empty': // Empty
|
||||||
case 'null' : // Null
|
case 'null': // Null
|
||||||
case 'lpstr' : // LPSTR
|
case 'lpstr': // LPSTR
|
||||||
case 'lpwstr' : // LPWSTR
|
case 'lpwstr': // LPWSTR
|
||||||
case 'bstr' : // Basic String
|
case 'bstr': // Basic String
|
||||||
return self::PROPERTY_TYPE_STRING;
|
return self::PROPERTY_TYPE_STRING;
|
||||||
break;
|
break;
|
||||||
case 'date' : // Date and Time
|
case 'date': // Date and Time
|
||||||
case 'filetime' : // File Time
|
case 'filetime': // File Time
|
||||||
return self::PROPERTY_TYPE_DATE;
|
return self::PROPERTY_TYPE_DATE;
|
||||||
break;
|
break;
|
||||||
case 'bool' : // Boolean
|
case 'bool': // Boolean
|
||||||
return self::PROPERTY_TYPE_BOOLEAN;
|
return self::PROPERTY_TYPE_BOOLEAN;
|
||||||
break;
|
break;
|
||||||
case 'cy' : // Currency
|
case 'cy': // Currency
|
||||||
case 'error' : // Error Status Code
|
case 'error': // Error Status Code
|
||||||
case 'vector' : // Vector
|
case 'vector': // Vector
|
||||||
case 'array' : // Array
|
case 'array': // Array
|
||||||
case 'blob' : // Binary Blob
|
case 'blob': // Binary Blob
|
||||||
case 'oblob' : // Binary Blob Object
|
case 'oblob': // Binary Blob Object
|
||||||
case 'stream' : // Binary Stream
|
case 'stream': // Binary Stream
|
||||||
case 'ostream' : // Binary Stream Object
|
case 'ostream': // Binary Stream Object
|
||||||
case 'storage' : // Binary Storage
|
case 'storage': // Binary Storage
|
||||||
case 'ostorage' : // Binary Storage Object
|
case 'ostorage': // Binary Storage Object
|
||||||
case 'vstream' : // Binary Versioned Stream
|
case 'vstream': // Binary Versioned Stream
|
||||||
case 'clsid' : // Class ID
|
case 'clsid': // Class ID
|
||||||
case 'cf' : // Clipboard Data
|
case 'cf': // Clipboard Data
|
||||||
return self::PROPERTY_TYPE_UNKNOWN;
|
return self::PROPERTY_TYPE_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return self::PROPERTY_TYPE_UNKNOWN;
|
return self::PROPERTY_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_DocumentSecurity
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,78 +21,70 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_DocumentSecurity
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_DocumentSecurity
|
class PHPExcel_DocumentSecurity
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* LockRevision
|
* LockRevision
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_lockRevision;
|
private $lockRevision;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LockStructure
|
* LockStructure
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_lockStructure;
|
private $lockStructure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LockWindows
|
* LockWindows
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_lockWindows;
|
private $lockWindows;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RevisionsPassword
|
* RevisionsPassword
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_revisionsPassword;
|
private $revisionsPassword;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WorkbookPassword
|
* WorkbookPassword
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_workbookPassword;
|
private $workbookPassword;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_DocumentSecurity
|
* Create a new PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_lockRevision = false;
|
$this->lockRevision = false;
|
||||||
$this->_lockStructure = false;
|
$this->lockStructure = false;
|
||||||
$this->_lockWindows = false;
|
$this->lockWindows = false;
|
||||||
$this->_revisionsPassword = '';
|
$this->revisionsPassword = '';
|
||||||
$this->_workbookPassword = '';
|
$this->workbookPassword = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is some sort of dcument security enabled?
|
* Is some sort of document security enabled?
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isSecurityEnabled() {
|
public function isSecurityEnabled()
|
||||||
return $this->_lockRevision ||
|
{
|
||||||
$this->_lockStructure ||
|
return $this->lockRevision ||
|
||||||
$this->_lockWindows;
|
$this->lockStructure ||
|
||||||
|
$this->lockWindows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,8 +92,9 @@ class PHPExcel_DocumentSecurity
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function getLockRevision() {
|
public function getLockRevision()
|
||||||
return $this->_lockRevision;
|
{
|
||||||
|
return $this->lockRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,9 +103,10 @@ class PHPExcel_DocumentSecurity
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setLockRevision($pValue = false) {
|
public function setLockRevision($pValue = false)
|
||||||
$this->_lockRevision = $pValue;
|
{
|
||||||
return $this;
|
$this->lockRevision = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,8 +114,9 @@ class PHPExcel_DocumentSecurity
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function getLockStructure() {
|
public function getLockStructure()
|
||||||
return $this->_lockStructure;
|
{
|
||||||
|
return $this->lockStructure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,9 +125,10 @@ class PHPExcel_DocumentSecurity
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setLockStructure($pValue = false) {
|
public function setLockStructure($pValue = false)
|
||||||
$this->_lockStructure = $pValue;
|
{
|
||||||
return $this;
|
$this->lockStructure = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,8 +136,9 @@ class PHPExcel_DocumentSecurity
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function getLockWindows() {
|
public function getLockWindows()
|
||||||
return $this->_lockWindows;
|
{
|
||||||
|
return $this->lockWindows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,9 +147,10 @@ class PHPExcel_DocumentSecurity
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setLockWindows($pValue = false) {
|
public function setLockWindows($pValue = false)
|
||||||
$this->_lockWindows = $pValue;
|
{
|
||||||
return $this;
|
$this->lockWindows = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,23 +158,25 @@ class PHPExcel_DocumentSecurity
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getRevisionsPassword() {
|
public function getRevisionsPassword()
|
||||||
return $this->_revisionsPassword;
|
{
|
||||||
|
return $this->revisionsPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set RevisionsPassword
|
* Set RevisionsPassword
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
|
public function setRevisionsPassword($pValue = '', $pAlreadyHashed = false)
|
||||||
if (!$pAlreadyHashed) {
|
{
|
||||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
if (!$pAlreadyHashed) {
|
||||||
}
|
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||||
$this->_revisionsPassword = $pValue;
|
}
|
||||||
return $this;
|
$this->revisionsPassword = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,36 +184,39 @@ class PHPExcel_DocumentSecurity
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getWorkbookPassword() {
|
public function getWorkbookPassword()
|
||||||
return $this->_workbookPassword;
|
{
|
||||||
|
return $this->workbookPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set WorkbookPassword
|
* Set WorkbookPassword
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
|
public function setWorkbookPassword($pValue = '', $pAlreadyHashed = false)
|
||||||
if (!$pAlreadyHashed) {
|
{
|
||||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
if (!$pAlreadyHashed) {
|
||||||
}
|
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||||
$this->_workbookPassword = $pValue;
|
}
|
||||||
return $this;
|
$this->workbookPassword = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
$vars = get_object_vars($this);
|
{
|
||||||
foreach ($vars as $key => $value) {
|
$vars = get_object_vars($this);
|
||||||
if (is_object($value)) {
|
foreach ($vars as $key => $value) {
|
||||||
$this->$key = clone $value;
|
if (is_object($value)) {
|
||||||
} else {
|
$this->$key = clone $value;
|
||||||
$this->$key = $value;
|
} else {
|
||||||
}
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
@ -31,9 +31,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Exception extends Exception {
|
class PHPExcel_Exception extends Exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Error handler callback
|
* Error handler callback
|
||||||
*
|
*
|
||||||
|
@ -43,7 +44,8 @@ class PHPExcel_Exception extends Exception {
|
||||||
* @param mixed $line
|
* @param mixed $line
|
||||||
* @param mixed $context
|
* @param mixed $context
|
||||||
*/
|
*/
|
||||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
|
{
|
||||||
$e = new self($string, $code);
|
$e = new self($string, $code);
|
||||||
$e->line = $line;
|
$e->line = $line;
|
||||||
$e->file = $file;
|
$e->file = $file;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_HashTable
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,184 +20,185 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_HashTable
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
*/
|
||||||
class PHPExcel_HashTable
|
class PHPExcel_HashTable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* HashTable elements
|
* HashTable elements
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $_items = array();
|
protected $items = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashTable key map
|
* HashTable key map
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $_keyMap = array();
|
protected $keyMap = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_HashTable
|
* Create a new PHPExcel_HashTable
|
||||||
*
|
*
|
||||||
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from
|
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($pSource = null)
|
public function __construct($pSource = null)
|
||||||
{
|
{
|
||||||
if ($pSource !== NULL) {
|
if ($pSource !== null) {
|
||||||
// Create HashTable
|
// Create HashTable
|
||||||
$this->addFromSource($pSource);
|
$this->addFromSource($pSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add HashTable items from source
|
* Add HashTable items from source
|
||||||
*
|
*
|
||||||
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
|
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function addFromSource($pSource = null) {
|
public function addFromSource($pSource = null)
|
||||||
// Check if an array was passed
|
{
|
||||||
if ($pSource == null) {
|
// Check if an array was passed
|
||||||
return;
|
if ($pSource == null) {
|
||||||
} else if (!is_array($pSource)) {
|
return;
|
||||||
throw new PHPExcel_Exception('Invalid array parameter passed.');
|
} elseif (!is_array($pSource)) {
|
||||||
}
|
throw new PHPExcel_Exception('Invalid array parameter passed.');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($pSource as $item) {
|
foreach ($pSource as $item) {
|
||||||
$this->add($item);
|
$this->add($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add HashTable item
|
* Add HashTable item
|
||||||
*
|
*
|
||||||
* @param PHPExcel_IComparable $pSource Item to add
|
* @param PHPExcel_IComparable $pSource Item to add
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function add(PHPExcel_IComparable $pSource = null) {
|
public function add(PHPExcel_IComparable $pSource = null)
|
||||||
$hash = $pSource->getHashCode();
|
{
|
||||||
if (!isset($this->_items[$hash])) {
|
$hash = $pSource->getHashCode();
|
||||||
$this->_items[$hash] = $pSource;
|
if (!isset($this->items[$hash])) {
|
||||||
$this->_keyMap[count($this->_items) - 1] = $hash;
|
$this->items[$hash] = $pSource;
|
||||||
}
|
$this->keyMap[count($this->items) - 1] = $hash;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove HashTable item
|
* Remove HashTable item
|
||||||
*
|
*
|
||||||
* @param PHPExcel_IComparable $pSource Item to remove
|
* @param PHPExcel_IComparable $pSource Item to remove
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function remove(PHPExcel_IComparable $pSource = null) {
|
public function remove(PHPExcel_IComparable $pSource = null)
|
||||||
$hash = $pSource->getHashCode();
|
{
|
||||||
if (isset($this->_items[$hash])) {
|
$hash = $pSource->getHashCode();
|
||||||
unset($this->_items[$hash]);
|
if (isset($this->items[$hash])) {
|
||||||
|
unset($this->items[$hash]);
|
||||||
|
|
||||||
$deleteKey = -1;
|
$deleteKey = -1;
|
||||||
foreach ($this->_keyMap as $key => $value) {
|
foreach ($this->keyMap as $key => $value) {
|
||||||
if ($deleteKey >= 0) {
|
if ($deleteKey >= 0) {
|
||||||
$this->_keyMap[$key - 1] = $value;
|
$this->keyMap[$key - 1] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value == $hash) {
|
if ($value == $hash) {
|
||||||
$deleteKey = $key;
|
$deleteKey = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
unset($this->keyMap[count($this->keyMap) - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear HashTable
|
* Clear HashTable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function clear() {
|
public function clear()
|
||||||
$this->_items = array();
|
{
|
||||||
$this->_keyMap = array();
|
$this->items = array();
|
||||||
}
|
$this->keyMap = array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count
|
* Count
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function count() {
|
public function count()
|
||||||
return count($this->_items);
|
{
|
||||||
}
|
return count($this->items);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get index for hash code
|
* Get index for hash code
|
||||||
*
|
*
|
||||||
* @param string $pHashCode
|
* @param string $pHashCode
|
||||||
* @return int Index
|
* @return int Index
|
||||||
*/
|
*/
|
||||||
public function getIndexForHashCode($pHashCode = '') {
|
public function getIndexForHashCode($pHashCode = '')
|
||||||
return array_search($pHashCode, $this->_keyMap);
|
{
|
||||||
}
|
return array_search($pHashCode, $this->keyMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get by index
|
* Get by index
|
||||||
*
|
*
|
||||||
* @param int $pIndex
|
* @param int $pIndex
|
||||||
* @return PHPExcel_IComparable
|
* @return PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getByIndex($pIndex = 0) {
|
public function getByIndex($pIndex = 0)
|
||||||
if (isset($this->_keyMap[$pIndex])) {
|
{
|
||||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
if (isset($this->keyMap[$pIndex])) {
|
||||||
}
|
return $this->getByHashCode($this->keyMap[$pIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get by hashcode
|
* Get by hashcode
|
||||||
*
|
*
|
||||||
* @param string $pHashCode
|
* @param string $pHashCode
|
||||||
* @return PHPExcel_IComparable
|
* @return PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getByHashCode($pHashCode = '') {
|
public function getByHashCode($pHashCode = '')
|
||||||
if (isset($this->_items[$pHashCode])) {
|
{
|
||||||
return $this->_items[$pHashCode];
|
if (isset($this->items[$pHashCode])) {
|
||||||
}
|
return $this->items[$pHashCode];
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashTable to array
|
* HashTable to array
|
||||||
*
|
*
|
||||||
* @return PHPExcel_IComparable[]
|
* @return PHPExcel_IComparable[]
|
||||||
*/
|
*/
|
||||||
public function toArray() {
|
public function toArray()
|
||||||
return $this->_items;
|
{
|
||||||
}
|
return $this->items;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
$vars = get_object_vars($this);
|
{
|
||||||
foreach ($vars as $key => $value) {
|
$vars = get_object_vars($this);
|
||||||
if (is_object($value)) {
|
foreach ($vars as $key => $value) {
|
||||||
$this->$key = clone $value;
|
if (is_object($value)) {
|
||||||
}
|
$this->$key = clone $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class PHPExcel_Helper_HTML
|
class PHPExcel_Helper_HTML
|
||||||
{
|
{
|
||||||
protected static $colourMap = array(
|
protected static $colourMap = array(
|
||||||
'aliceblue' => 'f0f8ff',
|
'aliceblue' => 'f0f8ff',
|
||||||
'antiquewhite' => 'faebd7',
|
'antiquewhite' => 'faebd7',
|
||||||
'antiquewhite1' => 'ffefdb',
|
'antiquewhite1' => 'ffefdb',
|
||||||
'antiquewhite2' => 'eedfcc',
|
'antiquewhite2' => 'eedfcc',
|
||||||
|
@ -526,12 +526,12 @@ class PHPExcel_Helper_HTML
|
||||||
protected $size;
|
protected $size;
|
||||||
protected $color;
|
protected $color;
|
||||||
|
|
||||||
protected $bold = false;
|
protected $bold = false;
|
||||||
protected $italic = false;
|
protected $italic = false;
|
||||||
protected $underline = false;
|
protected $underline = false;
|
||||||
protected $superscript = false;
|
protected $superscript = false;
|
||||||
protected $subscript = false;
|
protected $subscript = false;
|
||||||
protected $strikethrough = false;
|
protected $strikethrough = false;
|
||||||
|
|
||||||
protected $startTagCallbacks = array(
|
protected $startTagCallbacks = array(
|
||||||
'font' => 'startFontTag',
|
'font' => 'startFontTag',
|
||||||
|
@ -573,7 +573,8 @@ class PHPExcel_Helper_HTML
|
||||||
|
|
||||||
protected $richTextObject;
|
protected $richTextObject;
|
||||||
|
|
||||||
protected function initialise() {
|
protected function initialise()
|
||||||
|
{
|
||||||
$this->face = $this->size = $this->color = null;
|
$this->face = $this->size = $this->color = null;
|
||||||
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
|
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
|
||||||
|
|
||||||
|
@ -582,27 +583,48 @@ class PHPExcel_Helper_HTML
|
||||||
$this->stringData = '';
|
$this->stringData = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toRichTextObject($html) {
|
public function toRichTextObject($html)
|
||||||
|
{
|
||||||
$this->initialise();
|
$this->initialise();
|
||||||
|
|
||||||
// Create a new DOM object
|
// Create a new DOM object
|
||||||
$dom = new domDocument;
|
$dom = new \DOMDocument;
|
||||||
// Load the HTML file into the DOM object
|
// Load the HTML file into the DOM object
|
||||||
// Note the use of error suppression, because typically this will be an html fragment, so not fully valid markup
|
// Note the use of error suppression, because typically this will be an html fragment, so not fully valid markup
|
||||||
$loaded = @$dom->loadHTML($html);
|
$loaded = @$dom->loadHTML($html);
|
||||||
|
|
||||||
// Discard excess white space
|
// Discard excess white space
|
||||||
$dom->preserveWhiteSpace = false;
|
$dom->preserveWhiteSpace = false;
|
||||||
|
|
||||||
$this->richTextObject = new PHPExcel_RichText();;
|
$this->richTextObject = new PHPExcel_RichText();;
|
||||||
$this->parseElements($dom);
|
$this->parseElements($dom);
|
||||||
|
|
||||||
|
// Clean any further spurious whitespace
|
||||||
|
$this->cleanWhitespace();
|
||||||
|
|
||||||
return $this->richTextObject;
|
return $this->richTextObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildTextRun() {
|
protected function cleanWhitespace()
|
||||||
|
{
|
||||||
|
foreach ($this->richTextObject->getRichTextElements() as $key => $element) {
|
||||||
|
$text = $element->getText();
|
||||||
|
// Trim any leading spaces on the first run
|
||||||
|
if ($key == 0) {
|
||||||
|
$text = ltrim($text);
|
||||||
|
}
|
||||||
|
// Trim any spaces immediately after a line break
|
||||||
|
$text = preg_replace('/\n */mu', "\n", $text);
|
||||||
|
$element->setText($text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildTextRun()
|
||||||
|
{
|
||||||
$text = $this->stringData;
|
$text = $this->stringData;
|
||||||
if (trim($text) === '')
|
if (trim($text) === '') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$richtextRun = $this->richTextObject->createTextRun($this->stringData);
|
$richtextRun = $this->richTextObject->createTextRun($this->stringData);
|
||||||
if ($this->face) {
|
if ($this->face) {
|
||||||
|
@ -612,7 +634,7 @@ class PHPExcel_Helper_HTML
|
||||||
$richtextRun->getFont()->setSize($this->size);
|
$richtextRun->getFont()->setSize($this->size);
|
||||||
}
|
}
|
||||||
if ($this->color) {
|
if ($this->color) {
|
||||||
$richtextRun->getFont()->setColor( new PHPExcel_Style_Color( 'ff' . $this->color ) );
|
$richtextRun->getFont()->setColor(new PHPExcel_Style_Color('ff' . $this->color));
|
||||||
}
|
}
|
||||||
if ($this->bold) {
|
if ($this->bold) {
|
||||||
$richtextRun->getFont()->setBold(true);
|
$richtextRun->getFont()->setBold(true);
|
||||||
|
@ -635,19 +657,22 @@ class PHPExcel_Helper_HTML
|
||||||
$this->stringData = '';
|
$this->stringData = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function rgbToColour($rgb) {
|
protected function rgbToColour($rgb)
|
||||||
|
{
|
||||||
preg_match_all('/\d+/', $rgb, $values);
|
preg_match_all('/\d+/', $rgb, $values);
|
||||||
foreach($values[0] as &$value) {
|
foreach ($values[0] as &$value) {
|
||||||
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
|
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
return implode($values[0]);
|
return implode($values[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function colourNameLookup($rgb) {
|
protected function colourNameLookup($rgb)
|
||||||
|
{
|
||||||
return self::$colourMap[$rgb];
|
return self::$colourMap[$rgb];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function startFontTag($tag) {
|
protected function startFontTag($tag)
|
||||||
|
{
|
||||||
foreach ($tag->attributes as $attribute) {
|
foreach ($tag->attributes as $attribute) {
|
||||||
$attributeName = strtolower($attribute->name);
|
$attributeName = strtolower($attribute->name);
|
||||||
$attributeValue = $attribute->value;
|
$attributeValue = $attribute->value;
|
||||||
|
@ -655,7 +680,7 @@ class PHPExcel_Helper_HTML
|
||||||
if ($attributeName == 'color') {
|
if ($attributeName == 'color') {
|
||||||
if (preg_match('/rgb\s*\(/', $attributeValue)) {
|
if (preg_match('/rgb\s*\(/', $attributeValue)) {
|
||||||
$this->$attributeName = $this->rgbToColour($attributeValue);
|
$this->$attributeName = $this->rgbToColour($attributeValue);
|
||||||
} elseif(strpos(trim($attributeValue), '#') === 0) {
|
} elseif (strpos(trim($attributeValue), '#') === 0) {
|
||||||
$this->$attributeName = ltrim($attributeValue, '#');
|
$this->$attributeName = ltrim($attributeValue, '#');
|
||||||
} else {
|
} else {
|
||||||
$this->$attributeName = $this->colourNameLookup($attributeValue);
|
$this->$attributeName = $this->colourNameLookup($attributeValue);
|
||||||
|
@ -666,69 +691,89 @@ class PHPExcel_Helper_HTML
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function endFontTag() {
|
protected function endFontTag()
|
||||||
|
{
|
||||||
$this->face = $this->size = $this->color = null;
|
$this->face = $this->size = $this->color = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function startBoldTag() {
|
protected function startBoldTag()
|
||||||
|
{
|
||||||
$this->bold = true;
|
$this->bold = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function endBoldTag() {
|
protected function endBoldTag()
|
||||||
|
{
|
||||||
$this->bold = false;
|
$this->bold = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function startItalicTag() {
|
protected function startItalicTag()
|
||||||
|
{
|
||||||
$this->italic = true;
|
$this->italic = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function endItalicTag() {
|
protected function endItalicTag()
|
||||||
|
{
|
||||||
$this->italic = false;
|
$this->italic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function startUnderlineTag() {
|
protected function startUnderlineTag()
|
||||||
|
{
|
||||||
$this->underline = true;
|
$this->underline = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function endUnderlineTag() {
|
protected function endUnderlineTag()
|
||||||
|
{
|
||||||
$this->underline = false;
|
$this->underline = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function startSubscriptTag() {
|
protected function startSubscriptTag()
|
||||||
|
{
|
||||||
$this->subscript = true;
|
$this->subscript = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function endSubscriptTag() {
|
protected function endSubscriptTag()
|
||||||
|
{
|
||||||
$this->subscript = false;
|
$this->subscript = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function startSuperscriptTag() {
|
protected function startSuperscriptTag()
|
||||||
|
{
|
||||||
$this->superscript = true;
|
$this->superscript = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function endSuperscriptTag() {
|
protected function endSuperscriptTag()
|
||||||
|
{
|
||||||
$this->superscript = false;
|
$this->superscript = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function startStrikethruTag() {
|
protected function startStrikethruTag()
|
||||||
|
{
|
||||||
$this->strikethrough = true;
|
$this->strikethrough = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function endStrikethruTag() {
|
protected function endStrikethruTag()
|
||||||
|
{
|
||||||
$this->strikethrough = false;
|
$this->strikethrough = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function breakTag() {
|
protected function breakTag()
|
||||||
$this->stringData .= PHP_EOL;
|
{
|
||||||
|
$this->stringData .= "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function parseTextNode(DOMText $textNode) {
|
protected function parseTextNode(DOMText $textNode)
|
||||||
$domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue));
|
{
|
||||||
|
$domText = preg_replace(
|
||||||
|
'/\s+/u',
|
||||||
|
' ',
|
||||||
|
str_replace(array("\r", "\n"), ' ', $textNode->nodeValue)
|
||||||
|
);
|
||||||
$this->stringData .= $domText;
|
$this->stringData .= $domText;
|
||||||
$this->buildTextRun();
|
$this->buildTextRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function handleCallback($element, $callbackTag, $callbacks) {
|
protected function handleCallback($element, $callbackTag, $callbacks)
|
||||||
|
{
|
||||||
if (isset($callbacks[$callbackTag])) {
|
if (isset($callbacks[$callbackTag])) {
|
||||||
$elementHandler = $callbacks[$callbackTag];
|
$elementHandler = $callbacks[$callbackTag];
|
||||||
if (method_exists($this, $elementHandler)) {
|
if (method_exists($this, $elementHandler)) {
|
||||||
|
@ -737,20 +782,21 @@ class PHPExcel_Helper_HTML
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function parseElementNode(DOMElement $element) {
|
protected function parseElementNode(DOMElement $element)
|
||||||
|
{
|
||||||
$callbackTag = strtolower($element->nodeName);
|
$callbackTag = strtolower($element->nodeName);
|
||||||
$this->stack[] = $callbackTag;
|
$this->stack[] = $callbackTag;
|
||||||
|
|
||||||
$this->handleCallback($element, $callbackTag, $this->startTagCallbacks);
|
$this->handleCallback($element, $callbackTag, $this->startTagCallbacks);
|
||||||
|
|
||||||
$this->parseElements($element);
|
$this->parseElements($element);
|
||||||
$this->stringData .= ' ';
|
|
||||||
array_pop($this->stack);
|
array_pop($this->stack);
|
||||||
|
|
||||||
$this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
|
$this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function parseElements(DOMNode $element) {
|
protected function parseElements(DOMNode $element)
|
||||||
|
{
|
||||||
foreach ($element->childNodes as $child) {
|
foreach ($element->childNodes as $child) {
|
||||||
if ($child instanceof DOMText) {
|
if ($child instanceof DOMText) {
|
||||||
$this->parseTextNode($child);
|
$this->parseTextNode($child);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,26 +19,16 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_IComparable
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
interface PHPExcel_IComparable
|
interface PHPExcel_IComparable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get hash code
|
* Get hash code
|
||||||
*
|
*
|
||||||
* @return string Hash code
|
* @return string Hash code
|
||||||
*/
|
*/
|
||||||
public function getHashCode();
|
public function getHashCode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_IOFactory
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,269 +30,260 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel 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
|
class PHPExcel_IOFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Search locations
|
* Search locations
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
private static $_searchLocations = array(
|
private static $searchLocations = array(
|
||||||
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
|
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
|
||||||
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{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
|
* Autoresolve classes
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
private function __construct() { }
|
private static $autoResolveClasses = array(
|
||||||
|
'Excel2007',
|
||||||
|
'Excel5',
|
||||||
|
'Excel2003XML',
|
||||||
|
'OOCalc',
|
||||||
|
'SYLK',
|
||||||
|
'Gnumeric',
|
||||||
|
'HTML',
|
||||||
|
'CSV',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constructor for PHPExcel_IOFactory
|
||||||
|
*/
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get search locations
|
* Get search locations
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getSearchLocations() {
|
public static function getSearchLocations()
|
||||||
return self::$_searchLocations;
|
{
|
||||||
} // function getSearchLocations()
|
return self::$searchLocations;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set search locations
|
* Set search locations
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $value
|
* @param array $value
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function setSearchLocations($value) {
|
public static function setSearchLocations($value)
|
||||||
if (is_array($value)) {
|
{
|
||||||
self::$_searchLocations = $value;
|
if (is_array($value)) {
|
||||||
} else {
|
self::$searchLocations = $value;
|
||||||
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
|
} else {
|
||||||
}
|
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
|
||||||
} // function setSearchLocations()
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add search location
|
* Add search location
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $type Example: IWriter
|
* @param string $type Example: IWriter
|
||||||
* @param string $location Example: PHPExcel/Writer/{0}.php
|
* @param string $location Example: PHPExcel/Writer/{0}.php
|
||||||
* @param string $classname Example: PHPExcel_Writer_{0}
|
* @param string $classname Example: PHPExcel_Writer_{0}
|
||||||
*/
|
*/
|
||||||
public static function addSearchLocation($type = '', $location = '', $classname = '') {
|
public static function addSearchLocation($type = '', $location = '', $classname = '')
|
||||||
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
{
|
||||||
} // function addSearchLocation()
|
self::$searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create PHPExcel_Writer_IWriter
|
* Create PHPExcel_Writer_IWriter
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param PHPExcel $phpExcel
|
* @param PHPExcel $phpExcel
|
||||||
* @param string $writerType Example: Excel2007
|
* @param string $writerType Example: Excel2007
|
||||||
* @return PHPExcel_Writer_IWriter
|
* @return PHPExcel_Writer_IWriter
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
|
public static function createWriter(PHPExcel $phpExcel, $writerType = '')
|
||||||
// Search type
|
{
|
||||||
$searchType = 'IWriter';
|
// Search type
|
||||||
|
$searchType = 'IWriter';
|
||||||
|
|
||||||
// Include class
|
// Include class
|
||||||
foreach (self::$_searchLocations as $searchLocation) {
|
foreach (self::$searchLocations as $searchLocation) {
|
||||||
if ($searchLocation['type'] == $searchType) {
|
if ($searchLocation['type'] == $searchType) {
|
||||||
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
||||||
|
|
||||||
$instance = new $className($phpExcel);
|
$instance = new $className($phpExcel);
|
||||||
if ($instance !== NULL) {
|
if ($instance !== null) {
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing found...
|
// Nothing found...
|
||||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
|
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
|
||||||
} // function createWriter()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create PHPExcel_Reader_IReader
|
* Create PHPExcel_Reader_IReader
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $readerType Example: Excel2007
|
* @param string $readerType Example: Excel2007
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function createReader($readerType = '') {
|
public static function createReader($readerType = '')
|
||||||
// Search type
|
{
|
||||||
$searchType = 'IReader';
|
// Search type
|
||||||
|
$searchType = 'IReader';
|
||||||
|
|
||||||
// Include class
|
// Include class
|
||||||
foreach (self::$_searchLocations as $searchLocation) {
|
foreach (self::$searchLocations as $searchLocation) {
|
||||||
if ($searchLocation['type'] == $searchType) {
|
if ($searchLocation['type'] == $searchType) {
|
||||||
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
||||||
|
|
||||||
$instance = new $className();
|
$instance = new $className();
|
||||||
if ($instance !== NULL) {
|
if ($instance !== null) {
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing found...
|
// Nothing found...
|
||||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
|
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
|
||||||
} // function createReader()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $pFilename The name of the spreadsheet file
|
* @param string $pFilename The name of the spreadsheet file
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function load($pFilename) {
|
public static function load($pFilename)
|
||||||
$reader = self::createReaderForFile($pFilename);
|
{
|
||||||
return $reader->load($pFilename);
|
$reader = self::createReaderForFile($pFilename);
|
||||||
} // function load()
|
return $reader->load($pFilename);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify file type using automatic PHPExcel_Reader_IReader resolution
|
* Identify file type using automatic PHPExcel_Reader_IReader resolution
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $pFilename The name of the spreadsheet file to identify
|
* @param string $pFilename The name of the spreadsheet file to identify
|
||||||
* @return string
|
* @return string
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function identify($pFilename) {
|
public static function identify($pFilename)
|
||||||
$reader = self::createReaderForFile($pFilename);
|
{
|
||||||
$className = get_class($reader);
|
$reader = self::createReaderForFile($pFilename);
|
||||||
$classType = explode('_',$className);
|
$className = get_class($reader);
|
||||||
unset($reader);
|
$classType = explode('_', $className);
|
||||||
return array_pop($classType);
|
unset($reader);
|
||||||
} // function identify()
|
return array_pop($classType);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
|
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $pFilename The name of the spreadsheet file
|
* @param string $pFilename The name of the spreadsheet file
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function createReaderForFile($pFilename) {
|
public static function createReaderForFile($pFilename)
|
||||||
|
{
|
||||||
|
// First, lucky guess by inspecting file extension
|
||||||
|
$pathinfo = pathinfo($pFilename);
|
||||||
|
|
||||||
// First, lucky guess by inspecting file extension
|
$extensionType = null;
|
||||||
$pathinfo = pathinfo($pFilename);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
$extensionType = NULL;
|
if ($extensionType !== null) {
|
||||||
if (isset($pathinfo['extension'])) {
|
$reader = self::createReader($extensionType);
|
||||||
switch (strtolower($pathinfo['extension'])) {
|
// Let's see if we are lucky
|
||||||
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
|
if (isset($reader) && $reader->canRead($pFilename)) {
|
||||||
case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
|
return $reader;
|
||||||
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) {
|
// If we reach here then "lucky guess" didn't give any result
|
||||||
$reader = self::createReader($extensionType);
|
// Try walking through all the options in self::$autoResolveClasses
|
||||||
// Let's see if we are lucky
|
foreach (self::$autoResolveClasses as $autoResolveClass) {
|
||||||
if (isset($reader) && $reader->canRead($pFilename)) {
|
// Ignore our original guess, we know that won't work
|
||||||
return $reader;
|
if ($autoResolveClass !== $extensionType) {
|
||||||
}
|
$reader = self::createReader($autoResolveClass);
|
||||||
}
|
if ($reader->canRead($pFilename)) {
|
||||||
}
|
return $reader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we reach here then "lucky guess" didn't give any result
|
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file');
|
||||||
// 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()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_NamedRange
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,55 +21,46 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_NamedRange
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_NamedRange
|
class PHPExcel_NamedRange
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Range name
|
* Range name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_name;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Worksheet on which the named range can be resolved
|
* Worksheet on which the named range can be resolved
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Worksheet
|
* @var PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
private $_worksheet;
|
private $worksheet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Range of the referenced cells
|
* Range of the referenced cells
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_range;
|
private $range;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the named range local? (i.e. can only be used on $this->_worksheet)
|
* Is the named range local? (i.e. can only be used on $this->worksheet)
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $_localOnly;
|
private $localOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope
|
* Scope
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Worksheet
|
* @var PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
private $_scope;
|
private $scope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new NamedRange
|
* Create a new NamedRange
|
||||||
|
@ -77,23 +69,22 @@ class PHPExcel_NamedRange
|
||||||
* @param PHPExcel_Worksheet $pWorksheet
|
* @param PHPExcel_Worksheet $pWorksheet
|
||||||
* @param string $pRange
|
* @param string $pRange
|
||||||
* @param bool $pLocalOnly
|
* @param bool $pLocalOnly
|
||||||
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
|
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
||||||
{
|
{
|
||||||
// Validate data
|
// Validate data
|
||||||
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
|
if (($pName === null) || ($pWorksheet === null) || ($pRange === null)) {
|
||||||
throw new PHPExcel_Exception('Parameters can not be null.');
|
throw new PHPExcel_Exception('Parameters can not be null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set local members
|
// Set local members
|
||||||
$this->_name = $pName;
|
$this->name = $pName;
|
||||||
$this->_worksheet = $pWorksheet;
|
$this->worksheet = $pWorksheet;
|
||||||
$this->_range = $pRange;
|
$this->range = $pRange;
|
||||||
$this->_localOnly = $pLocalOnly;
|
$this->localOnly = $pLocalOnly;
|
||||||
$this->_scope = ($pLocalOnly == true) ?
|
$this->scope = ($pLocalOnly == true) ? (($pScope == null) ? $pWorksheet : $pScope) : null;
|
||||||
(($pScope == null) ? $pWorksheet : $pScope) : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,8 +92,9 @@ class PHPExcel_NamedRange
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName() {
|
public function getName()
|
||||||
return $this->_name;
|
{
|
||||||
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,26 +103,27 @@ class PHPExcel_NamedRange
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setName($value = null) {
|
public function setName($value = null)
|
||||||
if ($value !== NULL) {
|
{
|
||||||
// Old title
|
if ($value !== null) {
|
||||||
$oldTitle = $this->_name;
|
// Old title
|
||||||
|
$oldTitle = $this->name;
|
||||||
|
|
||||||
// Re-attach
|
// Re-attach
|
||||||
if ($this->_worksheet !== NULL) {
|
if ($this->worksheet !== null) {
|
||||||
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
|
$this->worksheet->getParent()->removeNamedRange($this->name, $this->worksheet);
|
||||||
}
|
}
|
||||||
$this->_name = $value;
|
$this->name = $value;
|
||||||
|
|
||||||
if ($this->_worksheet !== NULL) {
|
if ($this->worksheet !== null) {
|
||||||
$this->_worksheet->getParent()->addNamedRange($this);
|
$this->worksheet->getParent()->addNamedRange($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// New title
|
// New title
|
||||||
$newTitle = $this->_name;
|
$newTitle = $this->name;
|
||||||
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle);
|
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->worksheet->getParent(), $oldTitle, $newTitle);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,8 +131,9 @@ class PHPExcel_NamedRange
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function getWorksheet() {
|
public function getWorksheet()
|
||||||
return $this->_worksheet;
|
{
|
||||||
|
return $this->worksheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,11 +142,12 @@ class PHPExcel_NamedRange
|
||||||
* @param PHPExcel_Worksheet $value
|
* @param PHPExcel_Worksheet $value
|
||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setWorksheet(PHPExcel_Worksheet $value = null) {
|
public function setWorksheet(PHPExcel_Worksheet $value = null)
|
||||||
if ($value !== NULL) {
|
{
|
||||||
$this->_worksheet = $value;
|
if ($value !== null) {
|
||||||
}
|
$this->worksheet = $value;
|
||||||
return $this;
|
}
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,8 +155,9 @@ class PHPExcel_NamedRange
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRange() {
|
public function getRange()
|
||||||
return $this->_range;
|
{
|
||||||
|
return $this->range;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,11 +166,12 @@ class PHPExcel_NamedRange
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setRange($value = null) {
|
public function setRange($value = null)
|
||||||
if ($value !== NULL) {
|
{
|
||||||
$this->_range = $value;
|
if ($value !== null) {
|
||||||
}
|
$this->range = $value;
|
||||||
return $this;
|
}
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,8 +179,9 @@ class PHPExcel_NamedRange
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getLocalOnly() {
|
public function getLocalOnly()
|
||||||
return $this->_localOnly;
|
{
|
||||||
|
return $this->localOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,10 +190,11 @@ class PHPExcel_NamedRange
|
||||||
* @param bool $value
|
* @param bool $value
|
||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setLocalOnly($value = false) {
|
public function setLocalOnly($value = false)
|
||||||
$this->_localOnly = $value;
|
{
|
||||||
$this->_scope = $value ? $this->_worksheet : null;
|
$this->localOnly = $value;
|
||||||
return $this;
|
$this->scope = $value ? $this->worksheet : null;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,8 +202,9 @@ class PHPExcel_NamedRange
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet|null
|
* @return PHPExcel_Worksheet|null
|
||||||
*/
|
*/
|
||||||
public function getScope() {
|
public function getScope()
|
||||||
return $this->_scope;
|
{
|
||||||
|
return $this->scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -213,10 +213,11 @@ class PHPExcel_NamedRange
|
||||||
* @param PHPExcel_Worksheet|null $value
|
* @param PHPExcel_Worksheet|null $value
|
||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setScope(PHPExcel_Worksheet $value = null) {
|
public function setScope(PHPExcel_Worksheet $value = null)
|
||||||
$this->_scope = $value;
|
{
|
||||||
$this->_localOnly = ($value == null) ? false : true;
|
$this->scope = $value;
|
||||||
return $this;
|
$this->localOnly = ($value == null) ? false : true;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,21 +227,23 @@ class PHPExcel_NamedRange
|
||||||
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
|
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
|
||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
|
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet)
|
||||||
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
|
{
|
||||||
|
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
$vars = get_object_vars($this);
|
{
|
||||||
foreach ($vars as $key => $value) {
|
$vars = get_object_vars($this);
|
||||||
if (is_object($value)) {
|
foreach ($vars as $key => $value) {
|
||||||
$this->$key = clone $value;
|
if (is_object($value)) {
|
||||||
} else {
|
$this->$key = clone $value;
|
||||||
$this->$key = $value;
|
} else {
|
||||||
}
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_Abstract
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,236 +21,269 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_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
|
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Read data only?
|
* Read data only?
|
||||||
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
|
* 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
|
* or whether it should read both data and formatting
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $_readDataOnly = FALSE;
|
protected $readDataOnly = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read charts that are defined in the workbook?
|
* Read empty cells?
|
||||||
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
|
* Identifies whether the Reader should read data values for cells all cells, or should ignore cells containing
|
||||||
*
|
* null value or empty string
|
||||||
* @var boolean
|
*
|
||||||
*/
|
* @var boolean
|
||||||
protected $_includeCharts = FALSE;
|
*/
|
||||||
|
protected $readEmptyCells = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restrict which sheets should be loaded?
|
* Read charts that are defined in the workbook?
|
||||||
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
|
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
|
||||||
*
|
*
|
||||||
* @var array of string
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $_loadSheetsOnly = NULL;
|
protected $includeCharts = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Reader_IReadFilter instance
|
* 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 PHPExcel_Reader_IReadFilter
|
*
|
||||||
*/
|
* @var array of string
|
||||||
protected $_readFilter = NULL;
|
*/
|
||||||
|
protected $loadSheetsOnly;
|
||||||
|
|
||||||
protected $_fileHandle = NULL;
|
/**
|
||||||
|
* PHPExcel_Reader_IReadFilter instance
|
||||||
|
*
|
||||||
|
* @var PHPExcel_Reader_IReadFilter
|
||||||
|
*/
|
||||||
|
protected $readFilter;
|
||||||
|
|
||||||
|
protected $fileHandle = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read data only?
|
* 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 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.
|
* If false (the default) it will read data and formatting.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getReadDataOnly() {
|
public function getReadDataOnly()
|
||||||
return $this->_readDataOnly;
|
{
|
||||||
}
|
return $this->readDataOnly;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set read data only
|
* 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 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.
|
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
|
||||||
*
|
*
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
*/
|
*/
|
||||||
public function setReadDataOnly($pValue = FALSE) {
|
public function setReadDataOnly($pValue = false)
|
||||||
$this->_readDataOnly = $pValue;
|
{
|
||||||
return $this;
|
$this->readDataOnly = $pValue;
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read charts in workbook?
|
* Read empty cells?
|
||||||
* If this is true, then the Reader will include any charts that exist in the workbook.
|
* If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
|
||||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
* If false it will not read data for cells containing a null value or an empty string.
|
||||||
* If false (the default) it will ignore any charts defined in the workbook file.
|
*
|
||||||
*
|
* @return boolean
|
||||||
* @return boolean
|
*/
|
||||||
*/
|
public function getReadEmptyCells()
|
||||||
public function getIncludeCharts() {
|
{
|
||||||
return $this->_includeCharts;
|
return $this->readEmptyCells;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set read charts in workbook
|
* Set read empty cells
|
||||||
* Set to true, to advise the Reader to include any charts that exist in the workbook.
|
* Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
|
||||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
* Set to false to advise the Reader to ignore cells containing a null value or an empty string.
|
||||||
* Set to false (the default) to discard charts.
|
*
|
||||||
*
|
* @param boolean $pValue
|
||||||
* @param boolean $pValue
|
*
|
||||||
*
|
* @return PHPExcel_Reader_IReader
|
||||||
* @return PHPExcel_Reader_IReader
|
*/
|
||||||
*/
|
public function setReadEmptyCells($pValue = true)
|
||||||
public function setIncludeCharts($pValue = FALSE) {
|
{
|
||||||
$this->_includeCharts = (boolean) $pValue;
|
$this->readEmptyCells = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get which sheets to load
|
* Read charts in workbook?
|
||||||
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
|
* If this is true, then the Reader will include any charts that exist in the workbook.
|
||||||
* indicating that all worksheets in the workbook should be loaded.
|
* 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 mixed
|
*
|
||||||
*/
|
* @return boolean
|
||||||
public function getLoadSheetsOnly()
|
*/
|
||||||
{
|
public function getIncludeCharts()
|
||||||
return $this->_loadSheetsOnly;
|
{
|
||||||
}
|
return $this->includeCharts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set which sheets to load
|
* Set read charts in workbook
|
||||||
*
|
* Set to true, to advise the Reader to include any charts that exist in the workbook.
|
||||||
* @param mixed $value
|
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||||
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
|
* Set to false (the default) to discard charts.
|
||||||
* If NULL, then it tells the Reader to read all worksheets in the workbook
|
*
|
||||||
*
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_Reader_IReader
|
*
|
||||||
*/
|
* @return PHPExcel_Reader_IReader
|
||||||
public function setLoadSheetsOnly($value = NULL)
|
*/
|
||||||
{
|
public function setIncludeCharts($pValue = false)
|
||||||
if ($value === NULL)
|
{
|
||||||
|
$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)
|
||||||
|
{
|
||||||
|
if ($value === null) {
|
||||||
return $this->setLoadAllSheets();
|
return $this->setLoadAllSheets();
|
||||||
|
}
|
||||||
|
|
||||||
$this->_loadSheetsOnly = is_array($value) ?
|
$this->loadSheetsOnly = is_array($value) ? $value : array($value);
|
||||||
$value : array($value);
|
return $this;
|
||||||
return $this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set all sheets to load
|
* Set all sheets to load
|
||||||
* Tells the Reader to load all worksheets from the workbook.
|
* Tells the Reader to load all worksheets from the workbook.
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
*/
|
*/
|
||||||
public function setLoadAllSheets()
|
public function setLoadAllSheets()
|
||||||
{
|
{
|
||||||
$this->_loadSheetsOnly = NULL;
|
$this->loadSheetsOnly = null;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read filter
|
* Read filter
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_IReadFilter
|
* @return PHPExcel_Reader_IReadFilter
|
||||||
*/
|
*/
|
||||||
public function getReadFilter() {
|
public function getReadFilter()
|
||||||
return $this->_readFilter;
|
{
|
||||||
}
|
return $this->readFilter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set read filter
|
* Set read filter
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Reader_IReadFilter $pValue
|
* @param PHPExcel_Reader_IReadFilter $pValue
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
*/
|
*/
|
||||||
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
|
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue)
|
||||||
$this->_readFilter = $pValue;
|
{
|
||||||
return $this;
|
$this->readFilter = $pValue;
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open file for reading
|
* Open file for reading
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
protected function _openFile($pFilename)
|
protected function openFile($pFilename)
|
||||||
{
|
{
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
if (!file_exists($pFilename) || !is_readable($pFilename)) {
|
if (!file_exists($pFilename) || !is_readable($pFilename)) {
|
||||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
$this->_fileHandle = fopen($pFilename, 'r');
|
$this->fileHandle = fopen($pFilename, 'r');
|
||||||
if ($this->_fileHandle === FALSE) {
|
if ($this->fileHandle === false) {
|
||||||
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
|
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can the current PHPExcel_Reader_IReader read the file?
|
* Can the current PHPExcel_Reader_IReader read the file?
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function canRead($pFilename)
|
public function canRead($pFilename)
|
||||||
{
|
{
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
try {
|
try {
|
||||||
$this->_openFile($pFilename);
|
$this->openFile($pFilename);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$readable = $this->_isValidFormat();
|
$readable = $this->isValidFormat();
|
||||||
fclose ($this->_fileHandle);
|
fclose($this->fileHandle);
|
||||||
return $readable;
|
return $readable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param string $xml
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function securityScan($xml)
|
public function securityScan($xml)
|
||||||
{
|
{
|
||||||
$pattern = '/\\0?' . implode('\\0?', str_split('<!DOCTYPE')) . '\\0?/';
|
$pattern = '/\\0?' . implode('\\0?', str_split('<!DOCTYPE')) . '\\0?/';
|
||||||
if (preg_match($pattern, $xml)) {
|
if (preg_match($pattern, $xml)) {
|
||||||
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
||||||
}
|
}
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
||||||
*
|
*
|
||||||
* @param string $filestream
|
* @param string $filestream
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function securityScanFile($filestream)
|
public function securityScanFile($filestream)
|
||||||
{
|
{
|
||||||
return $this->securityScan(file_get_contents($filestream));
|
return $this->securityScan(file_get_contents($filestream));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_CSV
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,368 +30,377 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel 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
|
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Input encoding
|
* Input encoding
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_inputEncoding = 'UTF-8';
|
private $inputEncoding = 'UTF-8';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delimiter
|
* Delimiter
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_delimiter = ',';
|
private $delimiter = ',';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enclosure
|
* Enclosure
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_enclosure = '"';
|
private $enclosure = '"';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sheet index to read
|
* Sheet index to read
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_sheetIndex = 0;
|
private $sheetIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load rows contiguously
|
* Load rows contiguously
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_contiguous = false;
|
private $contiguous = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Row counter for loading rows contiguously
|
* Row counter for loading rows contiguously
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_contiguousRow = -1;
|
private $contiguousRow = -1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Reader_CSV
|
* Create a new PHPExcel_Reader_CSV
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
{
|
||||||
}
|
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that the current file is a CSV file
|
* Validate that the current file is a CSV file
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function _isValidFormat()
|
protected function isValidFormat()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set input encoding
|
* Set input encoding
|
||||||
*
|
*
|
||||||
* @param string $pValue Input encoding
|
* @param string $pValue Input encoding
|
||||||
*/
|
*/
|
||||||
public function setInputEncoding($pValue = 'UTF-8')
|
public function setInputEncoding($pValue = 'UTF-8')
|
||||||
{
|
{
|
||||||
$this->_inputEncoding = $pValue;
|
$this->inputEncoding = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get input encoding
|
* Get input encoding
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getInputEncoding()
|
public function getInputEncoding()
|
||||||
{
|
{
|
||||||
return $this->_inputEncoding;
|
return $this->inputEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move filepointer past any BOM marker
|
* Move filepointer past any BOM marker
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function _skipBOM()
|
protected function skipBOM()
|
||||||
{
|
{
|
||||||
rewind($this->_fileHandle);
|
rewind($this->fileHandle);
|
||||||
|
|
||||||
switch ($this->_inputEncoding) {
|
switch ($this->inputEncoding) {
|
||||||
case 'UTF-8':
|
case 'UTF-8':
|
||||||
fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ?
|
fgets($this->fileHandle, 4) == "\xEF\xBB\xBF" ?
|
||||||
fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0);
|
fseek($this->fileHandle, 3) : fseek($this->fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-16LE':
|
case 'UTF-16LE':
|
||||||
fgets($this->_fileHandle, 3) == "\xFF\xFE" ?
|
fgets($this->fileHandle, 3) == "\xFF\xFE" ?
|
||||||
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-16BE':
|
case 'UTF-16BE':
|
||||||
fgets($this->_fileHandle, 3) == "\xFE\xFF" ?
|
fgets($this->fileHandle, 3) == "\xFE\xFF" ?
|
||||||
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-32LE':
|
case 'UTF-32LE':
|
||||||
fgets($this->_fileHandle, 5) == "\xFF\xFE\x00\x00" ?
|
fgets($this->fileHandle, 5) == "\xFF\xFE\x00\x00" ?
|
||||||
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-32BE':
|
case 'UTF-32BE':
|
||||||
fgets($this->_fileHandle, 5) == "\x00\x00\xFE\xFF" ?
|
fgets($this->fileHandle, 5) == "\x00\x00\xFE\xFF" ?
|
||||||
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
* Identify any separator that is explicitly set in the file
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
*/
|
||||||
* @throws PHPExcel_Reader_Exception
|
protected function checkSeparator()
|
||||||
*/
|
{
|
||||||
public function listWorksheetInfo($pFilename)
|
$line = fgets($this->fileHandle);
|
||||||
{
|
if ($line === false) {
|
||||||
// Open file
|
return;
|
||||||
$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
|
if ((strlen(trim($line, "\r\n")) == 5) && (stripos($line, 'sep=') === 0)) {
|
||||||
$this->_skipBOM();
|
$this->delimiter = substr($line, 4, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return $this->skipBOM();
|
||||||
|
}
|
||||||
|
|
||||||
$escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure );
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
$worksheetInfo = array();
|
// Skip BOM, if any
|
||||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
$this->skipBOM();
|
||||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
$this->checkSeparator();
|
||||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
|
||||||
$worksheetInfo[0]['totalRows'] = 0;
|
|
||||||
$worksheetInfo[0]['totalColumns'] = 0;
|
|
||||||
|
|
||||||
// Loop through each line of the file in turn
|
$escapeEnclosures = array( "\\" . $this->enclosure, $this->enclosure . $this->enclosure );
|
||||||
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 = array();
|
||||||
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||||
|
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||||
|
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||||
|
$worksheetInfo[0]['totalRows'] = 0;
|
||||||
|
$worksheetInfo[0]['totalColumns'] = 0;
|
||||||
|
|
||||||
// Close file
|
// Loop through each line of the file in turn
|
||||||
fclose($fileHandle);
|
while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure)) !== false) {
|
||||||
|
$worksheetInfo[0]['totalRows']++;
|
||||||
|
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
return $worksheetInfo;
|
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
||||||
}
|
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
||||||
|
|
||||||
/**
|
// Close file
|
||||||
* Loads PHPExcel from file
|
fclose($fileHandle);
|
||||||
*
|
|
||||||
* @param string $pFilename
|
|
||||||
* @return PHPExcel
|
|
||||||
* @throws PHPExcel_Reader_Exception
|
|
||||||
*/
|
|
||||||
public function load($pFilename)
|
|
||||||
{
|
|
||||||
// Create new PHPExcel
|
|
||||||
$objPHPExcel = new PHPExcel();
|
|
||||||
|
|
||||||
// Load into this instance
|
return $worksheetInfo;
|
||||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file into PHPExcel instance
|
* Loads PHPExcel from file
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @param PHPExcel $objPHPExcel
|
* @return PHPExcel
|
||||||
* @return PHPExcel
|
* @throws PHPExcel_Reader_Exception
|
||||||
* @throws PHPExcel_Reader_Exception
|
*/
|
||||||
*/
|
public function load($pFilename)
|
||||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
{
|
||||||
{
|
// Create new PHPExcel
|
||||||
$lineEnding = ini_get('auto_detect_line_endings');
|
$objPHPExcel = new PHPExcel();
|
||||||
ini_set('auto_detect_line_endings', true);
|
|
||||||
|
|
||||||
// Open file
|
// Load into this instance
|
||||||
$this->_openFile($pFilename);
|
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||||
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();
|
* 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);
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// Open file
|
||||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
$this->openFile($pFilename);
|
||||||
$objPHPExcel->createSheet();
|
if (!$this->isValidFormat()) {
|
||||||
}
|
fclose($this->fileHandle);
|
||||||
$sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||||
|
}
|
||||||
|
$fileHandle = $this->fileHandle;
|
||||||
|
|
||||||
$escapeEnclosures = array( "\\" . $this->_enclosure,
|
// Skip BOM, if any
|
||||||
$this->_enclosure . $this->_enclosure
|
$this->skipBOM();
|
||||||
);
|
$this->checkSeparator();
|
||||||
|
|
||||||
// Set our starting row based on whether we're in contiguous mode or not
|
// Create new PHPExcel object
|
||||||
$currentRow = 1;
|
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
|
||||||
if ($this->_contiguous) {
|
$objPHPExcel->createSheet();
|
||||||
$currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow;
|
}
|
||||||
}
|
$sheet = $objPHPExcel->setActiveSheetIndex($this->sheetIndex);
|
||||||
|
|
||||||
// Loop through each line of the file in turn
|
$escapeEnclosures = array( "\\" . $this->enclosure,
|
||||||
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
$this->enclosure . $this->enclosure
|
||||||
$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
|
// Set our starting row based on whether we're in contiguous mode or not
|
||||||
if ($this->_inputEncoding !== 'UTF-8') {
|
$currentRow = 1;
|
||||||
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
|
if ($this->contiguous) {
|
||||||
}
|
$currentRow = ($this->contiguousRow == -1) ? $sheet->getHighestRow(): $this->contiguousRow;
|
||||||
|
}
|
||||||
|
|
||||||
// Set cell value
|
// Loop through each line of the file in turn
|
||||||
$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
|
while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure)) !== false) {
|
||||||
}
|
$columnLetter = 'A';
|
||||||
++$columnLetter;
|
foreach ($rowData as $rowDatum) {
|
||||||
}
|
if ($rowDatum != '' && $this->readFilter->readCell($columnLetter, $currentRow)) {
|
||||||
++$currentRow;
|
// Unescape enclosures
|
||||||
}
|
$rowDatum = str_replace($escapeEnclosures, $this->enclosure, $rowDatum);
|
||||||
|
|
||||||
// Close file
|
// Convert encoding if necessary
|
||||||
fclose($fileHandle);
|
if ($this->inputEncoding !== 'UTF-8') {
|
||||||
|
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->inputEncoding);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->_contiguous) {
|
// Set cell value
|
||||||
$this->_contiguousRow = $currentRow;
|
$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
|
||||||
}
|
}
|
||||||
|
++$columnLetter;
|
||||||
|
}
|
||||||
|
++$currentRow;
|
||||||
|
}
|
||||||
|
|
||||||
ini_set('auto_detect_line_endings', $lineEnding);
|
// Close file
|
||||||
|
fclose($fileHandle);
|
||||||
|
|
||||||
// Return
|
if ($this->contiguous) {
|
||||||
return $objPHPExcel;
|
$this->contiguousRow = $currentRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
ini_set('auto_detect_line_endings', $lineEnding);
|
||||||
* Get delimiter
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getDelimiter() {
|
|
||||||
return $this->_delimiter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Return
|
||||||
* Set delimiter
|
return $objPHPExcel;
|
||||||
*
|
}
|
||||||
* @param string $pValue Delimiter, defaults to ,
|
|
||||||
* @return PHPExcel_Reader_CSV
|
|
||||||
*/
|
|
||||||
public function setDelimiter($pValue = ',') {
|
|
||||||
$this->_delimiter = $pValue;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get enclosure
|
* Get delimiter
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEnclosure() {
|
public function getDelimiter()
|
||||||
return $this->_enclosure;
|
{
|
||||||
}
|
return $this->delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set enclosure
|
* Set delimiter
|
||||||
*
|
*
|
||||||
* @param string $pValue Enclosure, defaults to "
|
* @param string $pValue Delimiter, defaults to ,
|
||||||
* @return PHPExcel_Reader_CSV
|
* @return PHPExcel_Reader_CSV
|
||||||
*/
|
*/
|
||||||
public function setEnclosure($pValue = '"') {
|
public function setDelimiter($pValue = ',')
|
||||||
if ($pValue == '') {
|
{
|
||||||
$pValue = '"';
|
$this->delimiter = $pValue;
|
||||||
}
|
return $this;
|
||||||
$this->_enclosure = $pValue;
|
}
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get sheet index
|
* Get enclosure
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSheetIndex() {
|
public function getEnclosure()
|
||||||
return $this->_sheetIndex;
|
{
|
||||||
}
|
return $this->enclosure;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set sheet index
|
* Set enclosure
|
||||||
*
|
*
|
||||||
* @param integer $pValue Sheet index
|
* @param string $pValue Enclosure, defaults to "
|
||||||
* @return PHPExcel_Reader_CSV
|
* @return PHPExcel_Reader_CSV
|
||||||
*/
|
*/
|
||||||
public function setSheetIndex($pValue = 0) {
|
public function setEnclosure($pValue = '"')
|
||||||
$this->_sheetIndex = $pValue;
|
{
|
||||||
return $this;
|
if ($pValue == '') {
|
||||||
}
|
$pValue = '"';
|
||||||
|
}
|
||||||
|
$this->enclosure = $pValue;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Contiguous
|
* Get sheet index
|
||||||
*
|
*
|
||||||
* @param boolean $contiguous
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function setContiguous($contiguous = FALSE)
|
public function getSheetIndex()
|
||||||
{
|
{
|
||||||
$this->_contiguous = (bool) $contiguous;
|
return $this->sheetIndex;
|
||||||
if (!$contiguous) {
|
}
|
||||||
$this->_contiguousRow = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
/**
|
||||||
}
|
* Set sheet index
|
||||||
|
*
|
||||||
|
* @param integer $pValue Sheet index
|
||||||
|
* @return PHPExcel_Reader_CSV
|
||||||
|
*/
|
||||||
|
public function setSheetIndex($pValue = 0)
|
||||||
|
{
|
||||||
|
$this->sheetIndex = $pValue;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Contiguous
|
* Set Contiguous
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @param boolean $contiguous
|
||||||
*/
|
*/
|
||||||
public function getContiguous() {
|
public function setContiguous($contiguous = false)
|
||||||
return $this->_contiguous;
|
{
|
||||||
}
|
$this->contiguous = (bool) $contiguous;
|
||||||
|
if (!$contiguous) {
|
||||||
|
$this->contiguousRow = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Contiguous
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function getContiguous()
|
||||||
|
{
|
||||||
|
return $this->contiguous;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_DefaultReadFilter
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,39 +30,22 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel 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
|
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Should this cell be read?
|
* Should this cell be read?
|
||||||
*
|
*
|
||||||
* @param $column String column index
|
* @param $column Column address (as a string value like "A", or "IV")
|
||||||
* @param $row Row index
|
* @param $row Row number
|
||||||
* @param $worksheetName Optional worksheet name
|
* @param $worksheetName Optional worksheet name
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function readCell($column, $row, $worksheetName = '') {
|
public function readCell($column, $row, $worksheetName = '')
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,500 +18,503 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader_Excel2007
|
* @package PHPExcel_Reader_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Reader_Excel2007_Chart
|
* PHPExcel_Reader_Excel2007_Chart
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader_Excel2007
|
* @package PHPExcel_Reader_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Reader_Excel2007_Chart
|
class PHPExcel_Reader_Excel2007_Chart
|
||||||
{
|
{
|
||||||
private static function _getAttribute($component, $name, $format) {
|
private static function getAttribute($component, $name, $format)
|
||||||
$attributes = $component->attributes();
|
{
|
||||||
if (isset($attributes[$name])) {
|
$attributes = $component->attributes();
|
||||||
if ($format == 'string') {
|
if (isset($attributes[$name])) {
|
||||||
return (string) $attributes[$name];
|
if ($format == 'string') {
|
||||||
} elseif ($format == 'integer') {
|
return (string) $attributes[$name];
|
||||||
return (integer) $attributes[$name];
|
} elseif ($format == 'integer') {
|
||||||
} elseif ($format == 'boolean') {
|
return (integer) $attributes[$name];
|
||||||
return (boolean) ($attributes[$name] === '0' || $attributes[$name] !== 'true') ? false : true;
|
} elseif ($format == 'boolean') {
|
||||||
} else {
|
return (boolean) ($attributes[$name] === '0' || $attributes[$name] !== 'true') ? false : true;
|
||||||
return (float) $attributes[$name];
|
} else {
|
||||||
}
|
return (float) $attributes[$name];
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
} // function _getAttribute()
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static function _readColor($color,$background=false) {
|
private static function readColor($color, $background = false)
|
||||||
if (isset($color["rgb"])) {
|
{
|
||||||
return (string)$color["rgb"];
|
if (isset($color["rgb"])) {
|
||||||
} else if (isset($color["indexed"])) {
|
return (string)$color["rgb"];
|
||||||
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB();
|
} elseif (isset($color["indexed"])) {
|
||||||
}
|
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function readChart($chartElements, $chartName)
|
||||||
|
{
|
||||||
|
$namespacesChartMeta = $chartElements->getNamespaces(true);
|
||||||
|
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
|
||||||
|
|
||||||
|
$XaxisLabel = $YaxisLabel = $legend = $title = null;
|
||||||
|
$dispBlanksAs = $plotVisOnly = null;
|
||||||
|
|
||||||
|
foreach ($chartElementsC as $chartElementKey => $chartElement) {
|
||||||
|
switch ($chartElementKey) {
|
||||||
|
case "chart":
|
||||||
|
foreach ($chartElement as $chartDetailsKey => $chartDetails) {
|
||||||
|
$chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
|
||||||
|
switch ($chartDetailsKey) {
|
||||||
|
case "plotArea":
|
||||||
|
$plotAreaLayout = $XaxisLable = $YaxisLable = null;
|
||||||
|
$plotSeries = $plotAttributes = array();
|
||||||
|
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
|
||||||
|
switch ($chartDetailKey) {
|
||||||
|
case "layout":
|
||||||
|
$plotAreaLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta, 'plotArea');
|
||||||
|
break;
|
||||||
|
case "catAx":
|
||||||
|
if (isset($chartDetail->title)) {
|
||||||
|
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "dateAx":
|
||||||
|
if (isset($chartDetail->title)) {
|
||||||
|
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "valAx":
|
||||||
|
if (isset($chartDetail->title)) {
|
||||||
|
$YaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "barChart":
|
||||||
|
case "bar3DChart":
|
||||||
|
$barDirection = self::getAttribute($chartDetail->barDir, 'val', 'string');
|
||||||
|
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||||
|
$plotSer->setPlotDirection($barDirection);
|
||||||
|
$plotSeries[] = $plotSer;
|
||||||
|
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||||
|
break;
|
||||||
|
case "lineChart":
|
||||||
|
case "line3DChart":
|
||||||
|
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||||
|
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||||
|
break;
|
||||||
|
case "areaChart":
|
||||||
|
case "area3DChart":
|
||||||
|
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||||
|
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||||
|
break;
|
||||||
|
case "doughnutChart":
|
||||||
|
case "pieChart":
|
||||||
|
case "pie3DChart":
|
||||||
|
$explosion = isset($chartDetail->ser->explosion);
|
||||||
|
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||||
|
$plotSer->setPlotStyle($explosion);
|
||||||
|
$plotSeries[] = $plotSer;
|
||||||
|
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||||
|
break;
|
||||||
|
case "scatterChart":
|
||||||
|
$scatterStyle = self::getAttribute($chartDetail->scatterStyle, 'val', 'string');
|
||||||
|
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||||
|
$plotSer->setPlotStyle($scatterStyle);
|
||||||
|
$plotSeries[] = $plotSer;
|
||||||
|
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||||
|
break;
|
||||||
|
case "bubbleChart":
|
||||||
|
$bubbleScale = self::getAttribute($chartDetail->bubbleScale, 'val', 'integer');
|
||||||
|
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||||
|
$plotSer->setPlotStyle($bubbleScale);
|
||||||
|
$plotSeries[] = $plotSer;
|
||||||
|
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||||
|
break;
|
||||||
|
case "radarChart":
|
||||||
|
$radarStyle = self::getAttribute($chartDetail->radarStyle, 'val', 'string');
|
||||||
|
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||||
|
$plotSer->setPlotStyle($radarStyle);
|
||||||
|
$plotSeries[] = $plotSer;
|
||||||
|
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||||
|
break;
|
||||||
|
case "surfaceChart":
|
||||||
|
case "surface3DChart":
|
||||||
|
$wireFrame = self::getAttribute($chartDetail->wireframe, 'val', 'boolean');
|
||||||
|
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||||
|
$plotSer->setPlotStyle($wireFrame);
|
||||||
|
$plotSeries[] = $plotSer;
|
||||||
|
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||||
|
break;
|
||||||
|
case "stockChart":
|
||||||
|
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||||
|
$plotAttributes = self::readChartAttributes($plotAreaLayout);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($plotAreaLayout == null) {
|
||||||
|
$plotAreaLayout = new PHPExcel_Chart_Layout();
|
||||||
|
}
|
||||||
|
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries);
|
||||||
|
self::setChartAttributes($plotAreaLayout, $plotAttributes);
|
||||||
|
break;
|
||||||
|
case "plotVisOnly":
|
||||||
|
$plotVisOnly = self::getAttribute($chartDetails, 'val', 'string');
|
||||||
|
break;
|
||||||
|
case "dispBlanksAs":
|
||||||
|
$dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string');
|
||||||
|
break;
|
||||||
|
case "title":
|
||||||
|
$title = self::chartTitle($chartDetails, $namespacesChartMeta, 'title');
|
||||||
|
break;
|
||||||
|
case "legend":
|
||||||
|
$legendPos = 'r';
|
||||||
|
$legendLayout = null;
|
||||||
|
$legendOverlay = false;
|
||||||
|
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
|
||||||
|
switch ($chartDetailKey) {
|
||||||
|
case "legendPos":
|
||||||
|
$legendPos = self::getAttribute($chartDetail, 'val', 'string');
|
||||||
|
break;
|
||||||
|
case "overlay":
|
||||||
|
$legendOverlay = self::getAttribute($chartDetail, 'val', 'boolean');
|
||||||
|
break;
|
||||||
|
case "layout":
|
||||||
|
$legendLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta, 'legend');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$chart = new PHPExcel_Chart($chartName, $title, $legend, $plotArea, $plotVisOnly, $dispBlanksAs, $XaxisLabel, $YaxisLabel);
|
||||||
|
|
||||||
|
return $chart;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function chartTitle($titleDetails, $namespacesChartMeta, $type)
|
||||||
|
{
|
||||||
|
$caption = array();
|
||||||
|
$titleLayout = null;
|
||||||
|
foreach ($titleDetails as $titleDetailKey => $chartDetail) {
|
||||||
|
switch ($titleDetailKey) {
|
||||||
|
case "tx":
|
||||||
|
$titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
|
||||||
|
foreach ($titleDetails as $titleKey => $titleDetail) {
|
||||||
|
switch ($titleKey) {
|
||||||
|
case "p":
|
||||||
|
$titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
|
||||||
|
$caption[] = self::parseRichText($titleDetailPart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "layout":
|
||||||
|
$titleLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PHPExcel_Chart_Title($caption, $titleLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function chartLayoutDetails($chartDetail, $namespacesChartMeta)
|
||||||
|
{
|
||||||
|
if (!isset($chartDetail->manualLayout)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$details = $chartDetail->manualLayout->children($namespacesChartMeta['c']);
|
||||||
|
if (is_null($details)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$layout = array();
|
||||||
|
foreach ($details as $detailKey => $detail) {
|
||||||
|
// echo $detailKey, ' => ',self::getAttribute($detail, 'val', 'string'),PHP_EOL;
|
||||||
|
$layout[$detailKey] = self::getAttribute($detail, 'val', 'string');
|
||||||
|
}
|
||||||
|
return new PHPExcel_Chart_Layout($layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function chartDataSeries($chartDetail, $namespacesChartMeta, $plotType)
|
||||||
|
{
|
||||||
|
$multiSeriesType = null;
|
||||||
|
$smoothLine = false;
|
||||||
|
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
|
||||||
|
|
||||||
|
$seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']);
|
||||||
|
foreach ($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
|
||||||
|
switch ($seriesDetailKey) {
|
||||||
|
case "grouping":
|
||||||
|
$multiSeriesType = self::getAttribute($chartDetail->grouping, 'val', 'string');
|
||||||
|
break;
|
||||||
|
case "ser":
|
||||||
|
$marker = null;
|
||||||
|
foreach ($seriesDetails as $seriesKey => $seriesDetail) {
|
||||||
|
switch ($seriesKey) {
|
||||||
|
case "idx":
|
||||||
|
$seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer');
|
||||||
|
break;
|
||||||
|
case "order":
|
||||||
|
$seriesOrder = self::getAttribute($seriesDetail, 'val', 'integer');
|
||||||
|
$plotOrder[$seriesIndex] = $seriesOrder;
|
||||||
|
break;
|
||||||
|
case "tx":
|
||||||
|
$seriesLabel[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
|
||||||
|
break;
|
||||||
|
case "marker":
|
||||||
|
$marker = self::getAttribute($seriesDetail->symbol, 'val', 'string');
|
||||||
|
break;
|
||||||
|
case "smooth":
|
||||||
|
$smoothLine = self::getAttribute($seriesDetail, 'val', 'boolean');
|
||||||
|
break;
|
||||||
|
case "cat":
|
||||||
|
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
|
||||||
|
break;
|
||||||
|
case "val":
|
||||||
|
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
|
||||||
|
break;
|
||||||
|
case "xVal":
|
||||||
|
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
|
||||||
|
break;
|
||||||
|
case "yVal":
|
||||||
|
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new PHPExcel_Chart_DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function readChart($chartElements,$chartName) {
|
private static function chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false)
|
||||||
$namespacesChartMeta = $chartElements->getNamespaces(true);
|
{
|
||||||
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
|
if (isset($seriesDetail->strRef)) {
|
||||||
|
$seriesSource = (string) $seriesDetail->strRef->f;
|
||||||
|
$seriesData = self::chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']), 's');
|
||||||
|
|
||||||
$XaxisLabel = $YaxisLabel = $legend = $title = NULL;
|
return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
|
||||||
$dispBlanksAs = $plotVisOnly = NULL;
|
} elseif (isset($seriesDetail->numRef)) {
|
||||||
|
$seriesSource = (string) $seriesDetail->numRef->f;
|
||||||
|
$seriesData = self::chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
|
||||||
|
|
||||||
foreach($chartElementsC as $chartElementKey => $chartElement) {
|
return new PHPExcel_Chart_DataSeriesValues('Number', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
|
||||||
switch ($chartElementKey) {
|
} elseif (isset($seriesDetail->multiLvlStrRef)) {
|
||||||
case "chart":
|
$seriesSource = (string) $seriesDetail->multiLvlStrRef->f;
|
||||||
foreach($chartElement as $chartDetailsKey => $chartDetails) {
|
$seriesData = self::chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']), 's');
|
||||||
$chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
|
$seriesData['pointCount'] = count($seriesData['dataValues']);
|
||||||
switch ($chartDetailsKey) {
|
|
||||||
case "plotArea":
|
|
||||||
$plotAreaLayout = $XaxisLable = $YaxisLable = null;
|
|
||||||
$plotSeries = $plotAttributes = array();
|
|
||||||
foreach($chartDetails as $chartDetailKey => $chartDetail) {
|
|
||||||
switch ($chartDetailKey) {
|
|
||||||
case "layout":
|
|
||||||
$plotAreaLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'plotArea');
|
|
||||||
break;
|
|
||||||
case "catAx":
|
|
||||||
if (isset($chartDetail->title)) {
|
|
||||||
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "dateAx":
|
|
||||||
if (isset($chartDetail->title)) {
|
|
||||||
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "valAx":
|
|
||||||
if (isset($chartDetail->title)) {
|
|
||||||
$YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "barChart":
|
|
||||||
case "bar3DChart":
|
|
||||||
$barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string');
|
|
||||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
|
||||||
$plotSer->setPlotDirection($barDirection);
|
|
||||||
$plotSeries[] = $plotSer;
|
|
||||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
|
||||||
break;
|
|
||||||
case "lineChart":
|
|
||||||
case "line3DChart":
|
|
||||||
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
|
||||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
|
||||||
break;
|
|
||||||
case "areaChart":
|
|
||||||
case "area3DChart":
|
|
||||||
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
|
||||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
|
||||||
break;
|
|
||||||
case "doughnutChart":
|
|
||||||
case "pieChart":
|
|
||||||
case "pie3DChart":
|
|
||||||
$explosion = isset($chartDetail->ser->explosion);
|
|
||||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
|
||||||
$plotSer->setPlotStyle($explosion);
|
|
||||||
$plotSeries[] = $plotSer;
|
|
||||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
|
||||||
break;
|
|
||||||
case "scatterChart":
|
|
||||||
$scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string');
|
|
||||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
|
||||||
$plotSer->setPlotStyle($scatterStyle);
|
|
||||||
$plotSeries[] = $plotSer;
|
|
||||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
|
||||||
break;
|
|
||||||
case "bubbleChart":
|
|
||||||
$bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer');
|
|
||||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
|
||||||
$plotSer->setPlotStyle($bubbleScale);
|
|
||||||
$plotSeries[] = $plotSer;
|
|
||||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
|
||||||
break;
|
|
||||||
case "radarChart":
|
|
||||||
$radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string');
|
|
||||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
|
||||||
$plotSer->setPlotStyle($radarStyle);
|
|
||||||
$plotSeries[] = $plotSer;
|
|
||||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
|
||||||
break;
|
|
||||||
case "surfaceChart":
|
|
||||||
case "surface3DChart":
|
|
||||||
$wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean');
|
|
||||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
|
||||||
$plotSer->setPlotStyle($wireFrame);
|
|
||||||
$plotSeries[] = $plotSer;
|
|
||||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
|
||||||
break;
|
|
||||||
case "stockChart":
|
|
||||||
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
|
||||||
$plotAttributes = self::_readChartAttributes($plotAreaLayout);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($plotAreaLayout == NULL) {
|
|
||||||
$plotAreaLayout = new PHPExcel_Chart_Layout();
|
|
||||||
}
|
|
||||||
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout,$plotSeries);
|
|
||||||
self::_setChartAttributes($plotAreaLayout,$plotAttributes);
|
|
||||||
break;
|
|
||||||
case "plotVisOnly":
|
|
||||||
$plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string');
|
|
||||||
break;
|
|
||||||
case "dispBlanksAs":
|
|
||||||
$dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string');
|
|
||||||
break;
|
|
||||||
case "title":
|
|
||||||
$title = self::_chartTitle($chartDetails,$namespacesChartMeta,'title');
|
|
||||||
break;
|
|
||||||
case "legend":
|
|
||||||
$legendPos = 'r';
|
|
||||||
$legendLayout = null;
|
|
||||||
$legendOverlay = false;
|
|
||||||
foreach($chartDetails as $chartDetailKey => $chartDetail) {
|
|
||||||
switch ($chartDetailKey) {
|
|
||||||
case "legendPos":
|
|
||||||
$legendPos = self::_getAttribute($chartDetail, 'val', 'string');
|
|
||||||
break;
|
|
||||||
case "overlay":
|
|
||||||
$legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean');
|
|
||||||
break;
|
|
||||||
case "layout":
|
|
||||||
$legendLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'legend');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$chart = new PHPExcel_Chart($chartName,$title,$legend,$plotArea,$plotVisOnly,$dispBlanksAs,$XaxisLabel,$YaxisLabel);
|
|
||||||
|
|
||||||
return $chart;
|
return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
|
||||||
} // function readChart()
|
} elseif (isset($seriesDetail->multiLvlNumRef)) {
|
||||||
|
$seriesSource = (string) $seriesDetail->multiLvlNumRef->f;
|
||||||
|
$seriesData = self::chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']), 's');
|
||||||
|
$seriesData['pointCount'] = count($seriesData['dataValues']);
|
||||||
|
|
||||||
|
return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static function _chartTitle($titleDetails,$namespacesChartMeta,$type) {
|
private static function chartDataSeriesValues($seriesValueSet, $dataType = 'n')
|
||||||
$caption = array();
|
{
|
||||||
$titleLayout = null;
|
$seriesVal = array();
|
||||||
foreach($titleDetails as $titleDetailKey => $chartDetail) {
|
$formatCode = '';
|
||||||
switch ($titleDetailKey) {
|
$pointCount = 0;
|
||||||
case "tx":
|
|
||||||
$titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
|
|
||||||
foreach($titleDetails as $titleKey => $titleDetail) {
|
|
||||||
switch ($titleKey) {
|
|
||||||
case "p":
|
|
||||||
$titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
|
|
||||||
$caption[] = self::_parseRichText($titleDetailPart);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "layout":
|
|
||||||
$titleLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PHPExcel_Chart_Title($caption, $titleLayout);
|
foreach ($seriesValueSet as $seriesValueIdx => $seriesValue) {
|
||||||
} // function _chartTitle()
|
switch ($seriesValueIdx) {
|
||||||
|
case 'ptCount':
|
||||||
|
$pointCount = self::getAttribute($seriesValue, 'val', 'integer');
|
||||||
|
break;
|
||||||
|
case 'formatCode':
|
||||||
|
$formatCode = (string) $seriesValue;
|
||||||
|
break;
|
||||||
|
case 'pt':
|
||||||
|
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
|
||||||
|
if ($dataType == 's') {
|
||||||
|
$seriesVal[$pointVal] = (string) $seriesValue->v;
|
||||||
|
} else {
|
||||||
|
$seriesVal[$pointVal] = (float) $seriesValue->v;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'formatCode' => $formatCode,
|
||||||
|
'pointCount' => $pointCount,
|
||||||
|
'dataValues' => $seriesVal
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private static function _chartLayoutDetails($chartDetail,$namespacesChartMeta) {
|
private static function chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType = 'n')
|
||||||
if (!isset($chartDetail->manualLayout)) {
|
{
|
||||||
return null;
|
$seriesVal = array();
|
||||||
}
|
$formatCode = '';
|
||||||
$details = $chartDetail->manualLayout->children($namespacesChartMeta['c']);
|
$pointCount = 0;
|
||||||
if (is_null($details)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$layout = array();
|
|
||||||
foreach($details as $detailKey => $detail) {
|
|
||||||
// echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL;
|
|
||||||
$layout[$detailKey] = self::_getAttribute($detail, 'val', 'string');
|
|
||||||
}
|
|
||||||
return new PHPExcel_Chart_Layout($layout);
|
|
||||||
} // function _chartLayoutDetails()
|
|
||||||
|
|
||||||
|
foreach ($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
|
||||||
|
foreach ($seriesLevel as $seriesValueIdx => $seriesValue) {
|
||||||
|
switch ($seriesValueIdx) {
|
||||||
|
case 'ptCount':
|
||||||
|
$pointCount = self::getAttribute($seriesValue, 'val', 'integer');
|
||||||
|
break;
|
||||||
|
case 'formatCode':
|
||||||
|
$formatCode = (string) $seriesValue;
|
||||||
|
break;
|
||||||
|
case 'pt':
|
||||||
|
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
|
||||||
|
if ($dataType == 's') {
|
||||||
|
$seriesVal[$pointVal][] = (string) $seriesValue->v;
|
||||||
|
} else {
|
||||||
|
$seriesVal[$pointVal][] = (float) $seriesValue->v;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static function _chartDataSeries($chartDetail,$namespacesChartMeta,$plotType) {
|
return array(
|
||||||
$multiSeriesType = NULL;
|
'formatCode' => $formatCode,
|
||||||
$smoothLine = false;
|
'pointCount' => $pointCount,
|
||||||
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
|
'dataValues' => $seriesVal
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']);
|
private static function parseRichText($titleDetailPart = null)
|
||||||
foreach($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
|
{
|
||||||
switch ($seriesDetailKey) {
|
$value = new PHPExcel_RichText();
|
||||||
case "grouping":
|
|
||||||
$multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string');
|
|
||||||
break;
|
|
||||||
case "ser":
|
|
||||||
$marker = NULL;
|
|
||||||
foreach($seriesDetails as $seriesKey => $seriesDetail) {
|
|
||||||
switch ($seriesKey) {
|
|
||||||
case "idx":
|
|
||||||
$seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer');
|
|
||||||
break;
|
|
||||||
case "order":
|
|
||||||
$seriesOrder = self::_getAttribute($seriesDetail, 'val', 'integer');
|
|
||||||
$plotOrder[$seriesIndex] = $seriesOrder;
|
|
||||||
break;
|
|
||||||
case "tx":
|
|
||||||
$seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
|
|
||||||
break;
|
|
||||||
case "marker":
|
|
||||||
$marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string');
|
|
||||||
break;
|
|
||||||
case "smooth":
|
|
||||||
$smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean');
|
|
||||||
break;
|
|
||||||
case "cat":
|
|
||||||
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
|
|
||||||
break;
|
|
||||||
case "val":
|
|
||||||
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
|
|
||||||
break;
|
|
||||||
case "xVal":
|
|
||||||
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
|
|
||||||
break;
|
|
||||||
case "yVal":
|
|
||||||
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new PHPExcel_Chart_DataSeries($plotType,$multiSeriesType,$plotOrder,$seriesLabel,$seriesCategory,$seriesValues,$smoothLine);
|
|
||||||
} // function _chartDataSeries()
|
|
||||||
|
|
||||||
|
foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
|
||||||
|
if (isset($titleDetailElement->t)) {
|
||||||
|
$objText = $value->createTextRun((string) $titleDetailElement->t);
|
||||||
|
}
|
||||||
|
if (isset($titleDetailElement->rPr)) {
|
||||||
|
if (isset($titleDetailElement->rPr->rFont["val"])) {
|
||||||
|
$objText->getFont()->setName((string) $titleDetailElement->rPr->rFont["val"]);
|
||||||
|
}
|
||||||
|
|
||||||
private static function _chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) {
|
$fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
|
||||||
if (isset($seriesDetail->strRef)) {
|
if (!is_null($fontSize)) {
|
||||||
$seriesSource = (string) $seriesDetail->strRef->f;
|
$objText->getFont()->setSize(floor($fontSize / 100));
|
||||||
$seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s');
|
}
|
||||||
|
|
||||||
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
|
$fontColor = (self::getAttribute($titleDetailElement->rPr, 'color', 'string'));
|
||||||
} elseif (isset($seriesDetail->numRef)) {
|
if (!is_null($fontColor)) {
|
||||||
$seriesSource = (string) $seriesDetail->numRef->f;
|
$objText->getFont()->setColor(new PHPExcel_Style_Color(self::readColor($fontColor)));
|
||||||
$seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
|
}
|
||||||
|
|
||||||
return new PHPExcel_Chart_DataSeriesValues('Number',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
|
$bold = self::getAttribute($titleDetailElement->rPr, 'b', 'boolean');
|
||||||
} elseif (isset($seriesDetail->multiLvlStrRef)) {
|
if (!is_null($bold)) {
|
||||||
$seriesSource = (string) $seriesDetail->multiLvlStrRef->f;
|
$objText->getFont()->setBold($bold);
|
||||||
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s');
|
}
|
||||||
$seriesData['pointCount'] = count($seriesData['dataValues']);
|
|
||||||
|
|
||||||
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
|
$italic = self::getAttribute($titleDetailElement->rPr, 'i', 'boolean');
|
||||||
} elseif (isset($seriesDetail->multiLvlNumRef)) {
|
if (!is_null($italic)) {
|
||||||
$seriesSource = (string) $seriesDetail->multiLvlNumRef->f;
|
$objText->getFont()->setItalic($italic);
|
||||||
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s');
|
}
|
||||||
$seriesData['pointCount'] = count($seriesData['dataValues']);
|
|
||||||
|
|
||||||
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
|
$baseline = self::getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
|
||||||
}
|
if (!is_null($baseline)) {
|
||||||
return null;
|
if ($baseline > 0) {
|
||||||
} // function _chartDataSeriesValueSet()
|
$objText->getFont()->setSuperScript(true);
|
||||||
|
} elseif ($baseline < 0) {
|
||||||
|
$objText->getFont()->setSubScript(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$underscore = (self::getAttribute($titleDetailElement->rPr, 'u', 'string'));
|
||||||
|
if (!is_null($underscore)) {
|
||||||
|
if ($underscore == 'sng') {
|
||||||
|
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
|
||||||
|
} elseif ($underscore == 'dbl') {
|
||||||
|
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
|
||||||
|
} else {
|
||||||
|
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static function _chartDataSeriesValues($seriesValueSet,$dataType='n') {
|
$strikethrough = (self::getAttribute($titleDetailElement->rPr, 's', 'string'));
|
||||||
$seriesVal = array();
|
if (!is_null($strikethrough)) {
|
||||||
$formatCode = '';
|
if ($strikethrough == 'noStrike') {
|
||||||
$pointCount = 0;
|
$objText->getFont()->setStrikethrough(false);
|
||||||
|
} else {
|
||||||
|
$objText->getFont()->setStrikethrough(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach($seriesValueSet as $seriesValueIdx => $seriesValue) {
|
return $value;
|
||||||
switch ($seriesValueIdx) {
|
}
|
||||||
case 'ptCount':
|
|
||||||
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
|
|
||||||
break;
|
|
||||||
case 'formatCode':
|
|
||||||
$formatCode = (string) $seriesValue;
|
|
||||||
break;
|
|
||||||
case 'pt':
|
|
||||||
$pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
|
|
||||||
if ($dataType == 's') {
|
|
||||||
$seriesVal[$pointVal] = (string) $seriesValue->v;
|
|
||||||
} else {
|
|
||||||
$seriesVal[$pointVal] = (float) $seriesValue->v;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($seriesVal)) {
|
private static function readChartAttributes($chartDetail)
|
||||||
$seriesVal = NULL;
|
{
|
||||||
}
|
$plotAttributes = array();
|
||||||
|
if (isset($chartDetail->dLbls)) {
|
||||||
|
if (isset($chartDetail->dLbls->howLegendKey)) {
|
||||||
|
$plotAttributes['showLegendKey'] = self::getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string');
|
||||||
|
}
|
||||||
|
if (isset($chartDetail->dLbls->showVal)) {
|
||||||
|
$plotAttributes['showVal'] = self::getAttribute($chartDetail->dLbls->showVal, 'val', 'string');
|
||||||
|
}
|
||||||
|
if (isset($chartDetail->dLbls->showCatName)) {
|
||||||
|
$plotAttributes['showCatName'] = self::getAttribute($chartDetail->dLbls->showCatName, 'val', 'string');
|
||||||
|
}
|
||||||
|
if (isset($chartDetail->dLbls->showSerName)) {
|
||||||
|
$plotAttributes['showSerName'] = self::getAttribute($chartDetail->dLbls->showSerName, 'val', 'string');
|
||||||
|
}
|
||||||
|
if (isset($chartDetail->dLbls->showPercent)) {
|
||||||
|
$plotAttributes['showPercent'] = self::getAttribute($chartDetail->dLbls->showPercent, 'val', 'string');
|
||||||
|
}
|
||||||
|
if (isset($chartDetail->dLbls->showBubbleSize)) {
|
||||||
|
$plotAttributes['showBubbleSize'] = self::getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string');
|
||||||
|
}
|
||||||
|
if (isset($chartDetail->dLbls->showLeaderLines)) {
|
||||||
|
$plotAttributes['showLeaderLines'] = self::getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return array( 'formatCode' => $formatCode,
|
return $plotAttributes;
|
||||||
'pointCount' => $pointCount,
|
}
|
||||||
'dataValues' => $seriesVal
|
|
||||||
);
|
|
||||||
} // function _chartDataSeriesValues()
|
|
||||||
|
|
||||||
|
|
||||||
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet,$dataType='n') {
|
|
||||||
$seriesVal = array();
|
|
||||||
$formatCode = '';
|
|
||||||
$pointCount = 0;
|
|
||||||
|
|
||||||
foreach($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
|
|
||||||
foreach($seriesLevel as $seriesValueIdx => $seriesValue) {
|
|
||||||
switch ($seriesValueIdx) {
|
|
||||||
case 'ptCount':
|
|
||||||
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
|
|
||||||
break;
|
|
||||||
case 'formatCode':
|
|
||||||
$formatCode = (string) $seriesValue;
|
|
||||||
break;
|
|
||||||
case 'pt':
|
|
||||||
$pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
|
|
||||||
if ($dataType == 's') {
|
|
||||||
$seriesVal[$pointVal][] = (string) $seriesValue->v;
|
|
||||||
} else {
|
|
||||||
$seriesVal[$pointVal][] = (float) $seriesValue->v;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return array( 'formatCode' => $formatCode,
|
|
||||||
'pointCount' => $pointCount,
|
|
||||||
'dataValues' => $seriesVal
|
|
||||||
);
|
|
||||||
} // function _chartDataSeriesValuesMultiLevel()
|
|
||||||
|
|
||||||
private static function _parseRichText($titleDetailPart = null) {
|
|
||||||
$value = new PHPExcel_RichText();
|
|
||||||
|
|
||||||
foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
|
|
||||||
if (isset($titleDetailElement->t)) {
|
|
||||||
$objText = $value->createTextRun( (string) $titleDetailElement->t );
|
|
||||||
}
|
|
||||||
if (isset($titleDetailElement->rPr)) {
|
|
||||||
if (isset($titleDetailElement->rPr->rFont["val"])) {
|
|
||||||
$objText->getFont()->setName((string) $titleDetailElement->rPr->rFont["val"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$fontSize = (self::_getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
|
|
||||||
if (!is_null($fontSize)) {
|
|
||||||
$objText->getFont()->setSize(floor($fontSize / 100));
|
|
||||||
}
|
|
||||||
|
|
||||||
$fontColor = (self::_getAttribute($titleDetailElement->rPr, 'color', 'string'));
|
|
||||||
if (!is_null($fontColor)) {
|
|
||||||
$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($fontColor) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
$bold = self::_getAttribute($titleDetailElement->rPr, 'b', 'boolean');
|
|
||||||
if (!is_null($bold)) {
|
|
||||||
$objText->getFont()->setBold($bold);
|
|
||||||
}
|
|
||||||
|
|
||||||
$italic = self::_getAttribute($titleDetailElement->rPr, 'i', 'boolean');
|
|
||||||
if (!is_null($italic)) {
|
|
||||||
$objText->getFont()->setItalic($italic);
|
|
||||||
}
|
|
||||||
|
|
||||||
$baseline = self::_getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
|
|
||||||
if (!is_null($baseline)) {
|
|
||||||
if ($baseline > 0) {
|
|
||||||
$objText->getFont()->setSuperScript(true);
|
|
||||||
} elseif($baseline < 0) {
|
|
||||||
$objText->getFont()->setSubScript(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$underscore = (self::_getAttribute($titleDetailElement->rPr, 'u', 'string'));
|
|
||||||
if (!is_null($underscore)) {
|
|
||||||
if ($underscore == 'sng') {
|
|
||||||
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
|
|
||||||
} elseif($underscore == 'dbl') {
|
|
||||||
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
|
|
||||||
} else {
|
|
||||||
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$strikethrough = (self::_getAttribute($titleDetailElement->rPr, 's', 'string'));
|
|
||||||
if (!is_null($strikethrough)) {
|
|
||||||
if ($strikethrough == 'noStrike') {
|
|
||||||
$objText->getFont()->setStrikethrough(false);
|
|
||||||
} else {
|
|
||||||
$objText->getFont()->setStrikethrough(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function _readChartAttributes($chartDetail) {
|
|
||||||
$plotAttributes = array();
|
|
||||||
if (isset($chartDetail->dLbls)) {
|
|
||||||
if (isset($chartDetail->dLbls->howLegendKey)) {
|
|
||||||
$plotAttributes['showLegendKey'] = self::_getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string');
|
|
||||||
}
|
|
||||||
if (isset($chartDetail->dLbls->showVal)) {
|
|
||||||
$plotAttributes['showVal'] = self::_getAttribute($chartDetail->dLbls->showVal, 'val', 'string');
|
|
||||||
}
|
|
||||||
if (isset($chartDetail->dLbls->showCatName)) {
|
|
||||||
$plotAttributes['showCatName'] = self::_getAttribute($chartDetail->dLbls->showCatName, 'val', 'string');
|
|
||||||
}
|
|
||||||
if (isset($chartDetail->dLbls->showSerName)) {
|
|
||||||
$plotAttributes['showSerName'] = self::_getAttribute($chartDetail->dLbls->showSerName, 'val', 'string');
|
|
||||||
}
|
|
||||||
if (isset($chartDetail->dLbls->showPercent)) {
|
|
||||||
$plotAttributes['showPercent'] = self::_getAttribute($chartDetail->dLbls->showPercent, 'val', 'string');
|
|
||||||
}
|
|
||||||
if (isset($chartDetail->dLbls->showBubbleSize)) {
|
|
||||||
$plotAttributes['showBubbleSize'] = self::_getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string');
|
|
||||||
}
|
|
||||||
if (isset($chartDetail->dLbls->showLeaderLines)) {
|
|
||||||
$plotAttributes['showLeaderLines'] = self::_getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $plotAttributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function _setChartAttributes($plotArea,$plotAttributes)
|
|
||||||
{
|
|
||||||
foreach($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
|
|
||||||
switch($plotAttributeKey) {
|
|
||||||
case 'showLegendKey' :
|
|
||||||
$plotArea->setShowLegendKey($plotAttributeValue);
|
|
||||||
break;
|
|
||||||
case 'showVal' :
|
|
||||||
$plotArea->setShowVal($plotAttributeValue);
|
|
||||||
break;
|
|
||||||
case 'showCatName' :
|
|
||||||
$plotArea->setShowCatName($plotAttributeValue);
|
|
||||||
break;
|
|
||||||
case 'showSerName' :
|
|
||||||
$plotArea->setShowSerName($plotAttributeValue);
|
|
||||||
break;
|
|
||||||
case 'showPercent' :
|
|
||||||
$plotArea->setShowPercent($plotAttributeValue);
|
|
||||||
break;
|
|
||||||
case 'showBubbleSize' :
|
|
||||||
$plotArea->setShowBubbleSize($plotAttributeValue);
|
|
||||||
break;
|
|
||||||
case 'showLeaderLines' :
|
|
||||||
$plotArea->setShowLeaderLines($plotAttributeValue);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private static function setChartAttributes($plotArea, $plotAttributes)
|
||||||
|
{
|
||||||
|
foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
|
||||||
|
switch ($plotAttributeKey) {
|
||||||
|
case 'showLegendKey':
|
||||||
|
$plotArea->setShowLegendKey($plotAttributeValue);
|
||||||
|
break;
|
||||||
|
case 'showVal':
|
||||||
|
$plotArea->setShowVal($plotAttributeValue);
|
||||||
|
break;
|
||||||
|
case 'showCatName':
|
||||||
|
$plotArea->setShowCatName($plotAttributeValue);
|
||||||
|
break;
|
||||||
|
case 'showSerName':
|
||||||
|
$plotArea->setShowSerName($plotAttributeValue);
|
||||||
|
break;
|
||||||
|
case 'showPercent':
|
||||||
|
$plotArea->setShowPercent($plotAttributeValue);
|
||||||
|
break;
|
||||||
|
case 'showBubbleSize':
|
||||||
|
$plotArea->setShowBubbleSize($plotAttributeValue);
|
||||||
|
break;
|
||||||
|
case 'showLeaderLines':
|
||||||
|
$plotArea->setShowLeaderLines($plotAttributeValue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,8 +20,8 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader_Excel2007
|
* @package PHPExcel_Reader_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -31,69 +31,70 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader_Excel2007
|
* @package PHPExcel_Reader_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Reader_Excel2007_Theme
|
class PHPExcel_Reader_Excel2007_Theme
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Theme Name
|
* Theme Name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_themeName;
|
private $themeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Colour Scheme Name
|
* Colour Scheme Name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_colourSchemeName;
|
private $colourSchemeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Colour Map indexed by position
|
* Colour Map indexed by position
|
||||||
*
|
*
|
||||||
* @var array of string
|
* @var array of string
|
||||||
*/
|
*/
|
||||||
private $_colourMapValues;
|
private $colourMapValues;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Colour Map
|
* Colour Map
|
||||||
*
|
*
|
||||||
* @var array of string
|
* @var array of string
|
||||||
*/
|
*/
|
||||||
private $_colourMap;
|
private $colourMap;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Theme
|
* Create a new PHPExcel_Theme
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct($themeName,$colourSchemeName,$colourMap)
|
public function __construct($themeName, $colourSchemeName, $colourMap)
|
||||||
{
|
{
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_themeName = $themeName;
|
$this->themeName = $themeName;
|
||||||
$this->_colourSchemeName = $colourSchemeName;
|
$this->colourSchemeName = $colourSchemeName;
|
||||||
$this->_colourMap = $colourMap;
|
$this->colourMap = $colourMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Theme Name
|
* Get Theme Name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getThemeName()
|
public function getThemeName()
|
||||||
{
|
{
|
||||||
return $this->_themeName;
|
return $this->themeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get colour Scheme Name
|
* Get colour Scheme Name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getColourSchemeName() {
|
public function getColourSchemeName()
|
||||||
return $this->_colourSchemeName;
|
{
|
||||||
|
return $this->colourSchemeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,24 +102,26 @@ class PHPExcel_Reader_Excel2007_Theme
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getColourByIndex($index=0) {
|
public function getColourByIndex($index = 0)
|
||||||
if (isset($this->_colourMap[$index])) {
|
{
|
||||||
return $this->_colourMap[$index];
|
if (isset($this->colourMap[$index])) {
|
||||||
}
|
return $this->colourMap[$index];
|
||||||
return null;
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
$vars = get_object_vars($this);
|
{
|
||||||
foreach ($vars as $key => $value) {
|
$vars = get_object_vars($this);
|
||||||
if ((is_object($value)) && ($key != '_parent')) {
|
foreach ($vars as $key => $value) {
|
||||||
$this->$key = clone $value;
|
if ((is_object($value)) && ($key != '_parent')) {
|
||||||
} else {
|
$this->$key = clone $value;
|
||||||
$this->$key = $value;
|
} else {
|
||||||
}
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
32
Classes/PHPExcel/Reader/Excel5/Color.php
Normal file
32
Classes/PHPExcel/Reader/Excel5/Color.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PHPExcel_Reader_Excel5_Color
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Read color
|
||||||
|
*
|
||||||
|
* @param int $color Indexed color
|
||||||
|
* @param array $palette Color palette
|
||||||
|
* @return array RGB color value, example: array('rgb' => 'FF0000')
|
||||||
|
*/
|
||||||
|
public static function map($color, $palette, $version)
|
||||||
|
{
|
||||||
|
if ($color <= 0x07 || $color >= 0x40) {
|
||||||
|
// special built-in color
|
||||||
|
return PHPExcel_Reader_Excel5_Color_BuiltIn::lookup($color);
|
||||||
|
} elseif (isset($palette) && isset($palette[$color - 8])) {
|
||||||
|
// palette color, color index 0x08 maps to pallete index 0
|
||||||
|
return $palette[$color - 8];
|
||||||
|
} else {
|
||||||
|
// default color table
|
||||||
|
if ($version == PHPExcel_Reader_Excel5::XLS_BIFF8) {
|
||||||
|
return PHPExcel_Reader_Excel5_Color_BIFF8::lookup($color);
|
||||||
|
} else {
|
||||||
|
// BIFF5
|
||||||
|
return PHPExcel_Reader_Excel5_Color_BIFF5::lookup($color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $color;
|
||||||
|
}
|
||||||
|
}
|
77
Classes/PHPExcel/Reader/Excel5/Color/BIFF5.php
Normal file
77
Classes/PHPExcel/Reader/Excel5/Color/BIFF5.php
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PHPExcel_Reader_Excel5_Color_BIFF5
|
||||||
|
{
|
||||||
|
protected static $map = array(
|
||||||
|
0x08 => '000000',
|
||||||
|
0x09 => 'FFFFFF',
|
||||||
|
0x0A => 'FF0000',
|
||||||
|
0x0B => '00FF00',
|
||||||
|
0x0C => '0000FF',
|
||||||
|
0x0D => 'FFFF00',
|
||||||
|
0x0E => 'FF00FF',
|
||||||
|
0x0F => '00FFFF',
|
||||||
|
0x10 => '800000',
|
||||||
|
0x11 => '008000',
|
||||||
|
0x12 => '000080',
|
||||||
|
0x13 => '808000',
|
||||||
|
0x14 => '800080',
|
||||||
|
0x15 => '008080',
|
||||||
|
0x16 => 'C0C0C0',
|
||||||
|
0x17 => '808080',
|
||||||
|
0x18 => '8080FF',
|
||||||
|
0x19 => '802060',
|
||||||
|
0x1A => 'FFFFC0',
|
||||||
|
0x1B => 'A0E0F0',
|
||||||
|
0x1C => '600080',
|
||||||
|
0x1D => 'FF8080',
|
||||||
|
0x1E => '0080C0',
|
||||||
|
0x1F => 'C0C0FF',
|
||||||
|
0x20 => '000080',
|
||||||
|
0x21 => 'FF00FF',
|
||||||
|
0x22 => 'FFFF00',
|
||||||
|
0x23 => '00FFFF',
|
||||||
|
0x24 => '800080',
|
||||||
|
0x25 => '800000',
|
||||||
|
0x26 => '008080',
|
||||||
|
0x27 => '0000FF',
|
||||||
|
0x28 => '00CFFF',
|
||||||
|
0x29 => '69FFFF',
|
||||||
|
0x2A => 'E0FFE0',
|
||||||
|
0x2B => 'FFFF80',
|
||||||
|
0x2C => 'A6CAF0',
|
||||||
|
0x2D => 'DD9CB3',
|
||||||
|
0x2E => 'B38FEE',
|
||||||
|
0x2F => 'E3E3E3',
|
||||||
|
0x30 => '2A6FF9',
|
||||||
|
0x31 => '3FB8CD',
|
||||||
|
0x32 => '488436',
|
||||||
|
0x33 => '958C41',
|
||||||
|
0x34 => '8E5E42',
|
||||||
|
0x35 => 'A0627A',
|
||||||
|
0x36 => '624FAC',
|
||||||
|
0x37 => '969696',
|
||||||
|
0x38 => '1D2FBE',
|
||||||
|
0x39 => '286676',
|
||||||
|
0x3A => '004500',
|
||||||
|
0x3B => '453E01',
|
||||||
|
0x3C => '6A2813',
|
||||||
|
0x3D => '85396A',
|
||||||
|
0x3E => '4A3285',
|
||||||
|
0x3F => '424242',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map color array from BIFF5 built-in color index
|
||||||
|
*
|
||||||
|
* @param int $color
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function lookup($color)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$color])) {
|
||||||
|
return array('rgb' => self::$map[$color]);
|
||||||
|
}
|
||||||
|
return array('rgb' => '000000');
|
||||||
|
}
|
||||||
|
}
|
77
Classes/PHPExcel/Reader/Excel5/Color/BIFF8.php
Normal file
77
Classes/PHPExcel/Reader/Excel5/Color/BIFF8.php
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PHPExcel_Reader_Excel5_Color_BIFF8
|
||||||
|
{
|
||||||
|
protected static $map = array(
|
||||||
|
0x08 => '000000',
|
||||||
|
0x09 => 'FFFFFF',
|
||||||
|
0x0A => 'FF0000',
|
||||||
|
0x0B => '00FF00',
|
||||||
|
0x0C => '0000FF',
|
||||||
|
0x0D => 'FFFF00',
|
||||||
|
0x0E => 'FF00FF',
|
||||||
|
0x0F => '00FFFF',
|
||||||
|
0x10 => '800000',
|
||||||
|
0x11 => '008000',
|
||||||
|
0x12 => '000080',
|
||||||
|
0x13 => '808000',
|
||||||
|
0x14 => '800080',
|
||||||
|
0x15 => '008080',
|
||||||
|
0x16 => 'C0C0C0',
|
||||||
|
0x17 => '808080',
|
||||||
|
0x18 => '9999FF',
|
||||||
|
0x19 => '993366',
|
||||||
|
0x1A => 'FFFFCC',
|
||||||
|
0x1B => 'CCFFFF',
|
||||||
|
0x1C => '660066',
|
||||||
|
0x1D => 'FF8080',
|
||||||
|
0x1E => '0066CC',
|
||||||
|
0x1F => 'CCCCFF',
|
||||||
|
0x20 => '000080',
|
||||||
|
0x21 => 'FF00FF',
|
||||||
|
0x22 => 'FFFF00',
|
||||||
|
0x23 => '00FFFF',
|
||||||
|
0x24 => '800080',
|
||||||
|
0x25 => '800000',
|
||||||
|
0x26 => '008080',
|
||||||
|
0x27 => '0000FF',
|
||||||
|
0x28 => '00CCFF',
|
||||||
|
0x29 => 'CCFFFF',
|
||||||
|
0x2A => 'CCFFCC',
|
||||||
|
0x2B => 'FFFF99',
|
||||||
|
0x2C => '99CCFF',
|
||||||
|
0x2D => 'FF99CC',
|
||||||
|
0x2E => 'CC99FF',
|
||||||
|
0x2F => 'FFCC99',
|
||||||
|
0x30 => '3366FF',
|
||||||
|
0x31 => '33CCCC',
|
||||||
|
0x32 => '99CC00',
|
||||||
|
0x33 => 'FFCC00',
|
||||||
|
0x34 => 'FF9900',
|
||||||
|
0x35 => 'FF6600',
|
||||||
|
0x36 => '666699',
|
||||||
|
0x37 => '969696',
|
||||||
|
0x38 => '003366',
|
||||||
|
0x39 => '339966',
|
||||||
|
0x3A => '003300',
|
||||||
|
0x3B => '333300',
|
||||||
|
0x3C => '993300',
|
||||||
|
0x3D => '993366',
|
||||||
|
0x3E => '333399',
|
||||||
|
0x3F => '333333',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map color array from BIFF8 built-in color index
|
||||||
|
*
|
||||||
|
* @param int $color
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function lookup($color)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$color])) {
|
||||||
|
return array('rgb' => self::$map[$color]);
|
||||||
|
}
|
||||||
|
return array('rgb' => '000000');
|
||||||
|
}
|
||||||
|
}
|
31
Classes/PHPExcel/Reader/Excel5/Color/BuiltIn.php
Normal file
31
Classes/PHPExcel/Reader/Excel5/Color/BuiltIn.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PHPExcel_Reader_Excel5_Color_BuiltIn
|
||||||
|
{
|
||||||
|
protected static $map = array(
|
||||||
|
0x00 => '000000',
|
||||||
|
0x01 => 'FFFFFF',
|
||||||
|
0x02 => 'FF0000',
|
||||||
|
0x03 => '00FF00',
|
||||||
|
0x04 => '0000FF',
|
||||||
|
0x05 => 'FFFF00',
|
||||||
|
0x06 => 'FF00FF',
|
||||||
|
0x07 => '00FFFF',
|
||||||
|
0x40 => '000000', // system window text color
|
||||||
|
0x41 => 'FFFFFF', // system window background color
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map built-in color to RGB value
|
||||||
|
*
|
||||||
|
* @param int $color Indexed color
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function lookup($color)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$color])) {
|
||||||
|
return array('rgb' => self::$map[$color]);
|
||||||
|
}
|
||||||
|
return array('rgb' => '000000');
|
||||||
|
}
|
||||||
|
}
|
28
Classes/PHPExcel/Reader/Excel5/ErrorCode.php
Normal file
28
Classes/PHPExcel/Reader/Excel5/ErrorCode.php
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PHPExcel_Reader_Excel5_ErrorCode
|
||||||
|
{
|
||||||
|
protected static $map = array(
|
||||||
|
0x00 => '#NULL!',
|
||||||
|
0x07 => '#DIV/0!',
|
||||||
|
0x0F => '#VALUE!',
|
||||||
|
0x17 => '#REF!',
|
||||||
|
0x1D => '#NAME?',
|
||||||
|
0x24 => '#NUM!',
|
||||||
|
0x2A => '#N/A',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map error code, e.g. '#N/A'
|
||||||
|
*
|
||||||
|
* @param int $code
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function lookup($code)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$code])) {
|
||||||
|
return self::$map[$code];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_Excel5_MD5
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,19 +21,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader_Excel5
|
* @package PHPExcel_Reader_Excel5
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_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
|
class PHPExcel_Reader_Excel5_MD5
|
||||||
{
|
{
|
||||||
// Context
|
// Context
|
||||||
|
@ -41,7 +33,6 @@ class PHPExcel_Reader_Excel5_MD5
|
||||||
private $c;
|
private $c;
|
||||||
private $d;
|
private $d;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MD5 stream constructor
|
* MD5 stream constructor
|
||||||
*/
|
*/
|
||||||
|
@ -50,7 +41,6 @@ class PHPExcel_Reader_Excel5_MD5
|
||||||
$this->reset();
|
$this->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the MD5 stream context
|
* Reset the MD5 stream context
|
||||||
*/
|
*/
|
||||||
|
@ -62,10 +52,9 @@ class PHPExcel_Reader_Excel5_MD5
|
||||||
$this->d = 0x10325476;
|
$this->d = 0x10325476;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get MD5 stream context
|
* Get MD5 stream context
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getContext()
|
public function getContext()
|
||||||
|
@ -82,10 +71,9 @@ class PHPExcel_Reader_Excel5_MD5
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add data to context
|
* Add data to context
|
||||||
*
|
*
|
||||||
* @param string $data Data to add
|
* @param string $data Data to add
|
||||||
*/
|
*/
|
||||||
public function add($data)
|
public function add($data)
|
||||||
|
@ -97,10 +85,10 @@ class PHPExcel_Reader_Excel5_MD5
|
||||||
$C = $this->c;
|
$C = $this->c;
|
||||||
$D = $this->d;
|
$D = $this->d;
|
||||||
|
|
||||||
$F = array('PHPExcel_Reader_Excel5_MD5','F');
|
$F = array('PHPExcel_Reader_Excel5_MD5','f');
|
||||||
$G = array('PHPExcel_Reader_Excel5_MD5','G');
|
$G = array('PHPExcel_Reader_Excel5_MD5','g');
|
||||||
$H = array('PHPExcel_Reader_Excel5_MD5','H');
|
$H = array('PHPExcel_Reader_Excel5_MD5','h');
|
||||||
$I = array('PHPExcel_Reader_Excel5_MD5','I');
|
$I = array('PHPExcel_Reader_Excel5_MD5','i');
|
||||||
|
|
||||||
/* ROUND 1 */
|
/* ROUND 1 */
|
||||||
self::step($F, $A, $B, $C, $D, $words[0], 7, 0xd76aa478);
|
self::step($F, $A, $B, $C, $D, $words[0], 7, 0xd76aa478);
|
||||||
|
@ -180,31 +168,26 @@ class PHPExcel_Reader_Excel5_MD5
|
||||||
$this->d = ($this->d + $D) & 0xffffffff;
|
$this->d = ($this->d + $D) & 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function f($X, $Y, $Z)
|
||||||
private static function F($X, $Y, $Z)
|
|
||||||
{
|
{
|
||||||
return (($X & $Y) | ((~ $X) & $Z)); // X AND Y OR NOT X AND Z
|
return (($X & $Y) | ((~ $X) & $Z)); // X AND Y OR NOT X AND Z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function g($X, $Y, $Z)
|
||||||
private static function G($X, $Y, $Z)
|
|
||||||
{
|
{
|
||||||
return (($X & $Z) | ($Y & (~ $Z))); // X AND Z OR Y AND NOT Z
|
return (($X & $Z) | ($Y & (~ $Z))); // X AND Z OR Y AND NOT Z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function h($X, $Y, $Z)
|
||||||
private static function H($X, $Y, $Z)
|
|
||||||
{
|
{
|
||||||
return ($X ^ $Y ^ $Z); // X XOR Y XOR Z
|
return ($X ^ $Y ^ $Z); // X XOR Y XOR Z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function i($X, $Y, $Z)
|
||||||
private static function I($X, $Y, $Z)
|
|
||||||
{
|
{
|
||||||
return ($Y ^ ($X | (~ $Z))) ; // Y XOR (X OR NOT Z)
|
return ($Y ^ ($X | (~ $Z))) ; // Y XOR (X OR NOT Z)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static function step($func, &$A, $B, $C, $D, $M, $s, $t)
|
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 = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff;
|
||||||
|
@ -212,10 +195,9 @@ class PHPExcel_Reader_Excel5_MD5
|
||||||
$A = ($B + $A) & 0xffffffff;
|
$A = ($B + $A) & 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static function rotate($decimal, $bits)
|
private static function rotate($decimal, $bits)
|
||||||
{
|
{
|
||||||
$binary = str_pad(decbin($decimal), 32, "0", STR_PAD_LEFT);
|
$binary = str_pad(decbin($decimal), 32, "0", STR_PAD_LEFT);
|
||||||
return bindec(substr($binary, $bits).substr($binary, 0, $bits));
|
return bindec(substr($binary, $bits).substr($binary, 0, $bits));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_Excel5_RC4
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,69 +21,61 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader_Excel5
|
* @package PHPExcel_Reader_Excel5
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_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
|
class PHPExcel_Reader_Excel5_RC4
|
||||||
{
|
{
|
||||||
// Context
|
// Context
|
||||||
var $s = array();
|
protected $s = array();
|
||||||
var $i = 0;
|
protected $i = 0;
|
||||||
var $j = 0;
|
protected $j = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RC4 stream decryption/encryption constrcutor
|
* RC4 stream decryption/encryption constrcutor
|
||||||
*
|
*
|
||||||
* @param string $key Encryption key/passphrase
|
* @param string $key Encryption key/passphrase
|
||||||
*/
|
*/
|
||||||
public function __construct($key)
|
public function __construct($key)
|
||||||
{
|
{
|
||||||
$len = strlen($key);
|
$len = strlen($key);
|
||||||
|
|
||||||
for ($this->i = 0; $this->i < 256; $this->i++) {
|
for ($this->i = 0; $this->i < 256; $this->i++) {
|
||||||
$this->s[$this->i] = $this->i;
|
$this->s[$this->i] = $this->i;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->j = 0;
|
$this->j = 0;
|
||||||
for ($this->i = 0; $this->i < 256; $this->i++) {
|
for ($this->i = 0; $this->i < 256; $this->i++) {
|
||||||
$this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256;
|
$this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256;
|
||||||
$t = $this->s[$this->i];
|
$t = $this->s[$this->i];
|
||||||
$this->s[$this->i] = $this->s[$this->j];
|
$this->s[$this->i] = $this->s[$this->j];
|
||||||
$this->s[$this->j] = $t;
|
$this->s[$this->j] = $t;
|
||||||
}
|
}
|
||||||
$this->i = $this->j = 0;
|
$this->i = $this->j = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Symmetric decryption/encryption function
|
* Symmetric decryption/encryption function
|
||||||
*
|
*
|
||||||
* @param string $data Data to encrypt/decrypt
|
* @param string $data Data to encrypt/decrypt
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function RC4($data)
|
public function RC4($data)
|
||||||
{
|
{
|
||||||
$len = strlen($data);
|
$len = strlen($data);
|
||||||
for ($c = 0; $c < $len; $c++) {
|
for ($c = 0; $c < $len; $c++) {
|
||||||
$this->i = ($this->i + 1) % 256;
|
$this->i = ($this->i + 1) % 256;
|
||||||
$this->j = ($this->j + $this->s[$this->i]) % 256;
|
$this->j = ($this->j + $this->s[$this->i]) % 256;
|
||||||
$t = $this->s[$this->i];
|
$t = $this->s[$this->i];
|
||||||
$this->s[$this->i] = $this->s[$this->j];
|
$this->s[$this->i] = $this->s[$this->j];
|
||||||
$this->s[$this->j] = $t;
|
$this->s[$this->j] = $t;
|
||||||
|
|
||||||
$t = ($this->s[$this->i] + $this->s[$this->j]) % 256;
|
$t = ($this->s[$this->i] + $this->s[$this->j]) % 256;
|
||||||
|
|
||||||
$data[$c] = chr(ord($data[$c]) ^ $this->s[$t]);
|
$data[$c] = chr(ord($data[$c]) ^ $this->s[$t]);
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
36
Classes/PHPExcel/Reader/Excel5/Style/Border.php
Normal file
36
Classes/PHPExcel/Reader/Excel5/Style/Border.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PHPExcel_Reader_Excel5_Style_Border
|
||||||
|
{
|
||||||
|
protected static $map = array(
|
||||||
|
0x00 => PHPExcel_Style_Border::BORDER_NONE,
|
||||||
|
0x01 => PHPExcel_Style_Border::BORDER_THIN,
|
||||||
|
0x02 => PHPExcel_Style_Border::BORDER_MEDIUM,
|
||||||
|
0x03 => PHPExcel_Style_Border::BORDER_DASHED,
|
||||||
|
0x04 => PHPExcel_Style_Border::BORDER_DOTTED,
|
||||||
|
0x05 => PHPExcel_Style_Border::BORDER_THICK,
|
||||||
|
0x06 => PHPExcel_Style_Border::BORDER_DOUBLE,
|
||||||
|
0x07 => PHPExcel_Style_Border::BORDER_HAIR,
|
||||||
|
0x08 => PHPExcel_Style_Border::BORDER_MEDIUMDASHED,
|
||||||
|
0x09 => PHPExcel_Style_Border::BORDER_DASHDOT,
|
||||||
|
0x0A => PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT,
|
||||||
|
0x0B => PHPExcel_Style_Border::BORDER_DASHDOTDOT,
|
||||||
|
0x0C => PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT,
|
||||||
|
0x0D => PHPExcel_Style_Border::BORDER_SLANTDASHDOT,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map border style
|
||||||
|
* OpenOffice documentation: 2.5.11
|
||||||
|
*
|
||||||
|
* @param int $index
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function lookup($index)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$index])) {
|
||||||
|
return self::$map[$index];
|
||||||
|
}
|
||||||
|
return PHPExcel_Style_Border::BORDER_NONE;
|
||||||
|
}
|
||||||
|
}
|
41
Classes/PHPExcel/Reader/Excel5/Style/FillPattern.php
Normal file
41
Classes/PHPExcel/Reader/Excel5/Style/FillPattern.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PHPExcel_Reader_Excel5_Style_FillPattern
|
||||||
|
{
|
||||||
|
protected static $map = array(
|
||||||
|
0x00 => PHPExcel_Style_Fill::FILL_NONE,
|
||||||
|
0x01 => PHPExcel_Style_Fill::FILL_SOLID,
|
||||||
|
0x02 => PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY,
|
||||||
|
0x03 => PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY,
|
||||||
|
0x04 => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY,
|
||||||
|
0x05 => PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL,
|
||||||
|
0x06 => PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL,
|
||||||
|
0x07 => PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN,
|
||||||
|
0x08 => PHPExcel_Style_Fill::FILL_PATTERN_DARKUP,
|
||||||
|
0x09 => PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID,
|
||||||
|
0x0A => PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS,
|
||||||
|
0x0B => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL,
|
||||||
|
0x0C => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL,
|
||||||
|
0x0D => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN,
|
||||||
|
0x0E => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP,
|
||||||
|
0x0F => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID,
|
||||||
|
0x10 => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS,
|
||||||
|
0x11 => PHPExcel_Style_Fill::FILL_PATTERN_GRAY125,
|
||||||
|
0x12 => PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get fill pattern from index
|
||||||
|
* OpenOffice documentation: 2.5.12
|
||||||
|
*
|
||||||
|
* @param int $index
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function lookup($index)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$index])) {
|
||||||
|
return self::$map[$index];
|
||||||
|
}
|
||||||
|
return PHPExcel_Style_Fill::FILL_NONE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_Exception
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,33 +21,26 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Reader_Exception extends PHPExcel_Exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Reader_Exception
|
* Error handler callback
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @param mixed $code
|
||||||
* @package PHPExcel_Reader
|
* @param mixed $string
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @param mixed $file
|
||||||
*/
|
* @param mixed $line
|
||||||
class PHPExcel_Reader_Exception extends PHPExcel_Exception {
|
* @param mixed $context
|
||||||
/**
|
*/
|
||||||
* Error handler callback
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
*
|
{
|
||||||
* @param mixed $code
|
$e = new self($string, $code);
|
||||||
* @param mixed $string
|
$e->line = $line;
|
||||||
* @param mixed $file
|
$e->file = $file;
|
||||||
* @param mixed $line
|
throw $e;
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_HTML
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -21,26 +29,11 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
/** PHPExcel root directory */
|
/** 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
|
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -49,56 +42,75 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $_inputEncoding = 'ANSI';
|
protected $inputEncoding = 'ANSI';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sheet index to read
|
* Sheet index to read
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $_sheetIndex = 0;
|
protected $sheetIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats
|
* Formats
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $_formats = array(
|
protected $formats = array(
|
||||||
'h1' => array('font' => array('bold' => true,
|
'h1' => array(
|
||||||
|
'font' => array(
|
||||||
|
'bold' => true,
|
||||||
'size' => 24,
|
'size' => 24,
|
||||||
),
|
),
|
||||||
), // Bold, 24pt
|
), // Bold, 24pt
|
||||||
'h2' => array('font' => array('bold' => true,
|
'h2' => array(
|
||||||
|
'font' => array(
|
||||||
|
'bold' => true,
|
||||||
'size' => 18,
|
'size' => 18,
|
||||||
),
|
),
|
||||||
), // Bold, 18pt
|
), // Bold, 18pt
|
||||||
'h3' => array('font' => array('bold' => true,
|
'h3' => array(
|
||||||
|
'font' => array(
|
||||||
|
'bold' => true,
|
||||||
'size' => 13.5,
|
'size' => 13.5,
|
||||||
),
|
),
|
||||||
), // Bold, 13.5pt
|
), // Bold, 13.5pt
|
||||||
'h4' => array('font' => array('bold' => true,
|
'h4' => array(
|
||||||
|
'font' => array(
|
||||||
|
'bold' => true,
|
||||||
'size' => 12,
|
'size' => 12,
|
||||||
),
|
),
|
||||||
), // Bold, 12pt
|
), // Bold, 12pt
|
||||||
'h5' => array('font' => array('bold' => true,
|
'h5' => array(
|
||||||
|
'font' => array(
|
||||||
|
'bold' => true,
|
||||||
'size' => 10,
|
'size' => 10,
|
||||||
),
|
),
|
||||||
), // Bold, 10pt
|
), // Bold, 10pt
|
||||||
'h6' => array('font' => array('bold' => true,
|
'h6' => array(
|
||||||
|
'font' => array(
|
||||||
|
'bold' => true,
|
||||||
'size' => 7.5,
|
'size' => 7.5,
|
||||||
),
|
),
|
||||||
), // Bold, 7.5pt
|
), // Bold, 7.5pt
|
||||||
'a' => array('font' => array('underline' => true,
|
'a' => array(
|
||||||
'color' => array('argb' => PHPExcel_Style_Color::COLOR_BLUE,
|
'font' => array(
|
||||||
|
'underline' => true,
|
||||||
|
'color' => array(
|
||||||
|
'argb' => PHPExcel_Style_Color::COLOR_BLUE,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), // Blue underlined
|
), // Blue underlined
|
||||||
'hr' => array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN,
|
'hr' => array(
|
||||||
'color' => array(\PHPExcel_Style_Color::COLOR_BLACK,
|
'borders' => array(
|
||||||
|
'bottom' => array(
|
||||||
|
'style' => PHPExcel_Style_Border::BORDER_THIN,
|
||||||
|
'color' => array(
|
||||||
|
PHPExcel_Style_Color::COLOR_BLACK,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), // Bottom border
|
), // Bottom border
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $rowspan = array();
|
protected $rowspan = array();
|
||||||
|
@ -108,7 +120,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,16 +128,16 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function _isValidFormat()
|
protected function isValidFormat()
|
||||||
{
|
{
|
||||||
// Reading 2048 bytes should be enough to validate that the format is HTML
|
// Reading 2048 bytes should be enough to validate that the format is HTML
|
||||||
$data = fread($this->_fileHandle, 2048);
|
$data = fread($this->fileHandle, 2048);
|
||||||
if ((strpos($data, '<') !== FALSE) &&
|
if ((strpos($data, '<') !== false) &&
|
||||||
(strlen($data) !== strlen(strip_tags($data)))) {
|
(strlen($data) !== strlen(strip_tags($data)))) {
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,7 +163,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
||||||
*/
|
*/
|
||||||
public function setInputEncoding($pValue = 'ANSI')
|
public function setInputEncoding($pValue = 'ANSI')
|
||||||
{
|
{
|
||||||
$this->_inputEncoding = $pValue;
|
$this->inputEncoding = $pValue;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -163,237 +175,242 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
||||||
*/
|
*/
|
||||||
public function getInputEncoding()
|
public function getInputEncoding()
|
||||||
{
|
{
|
||||||
return $this->_inputEncoding;
|
return $this->inputEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data Array used for testing only, should write to PHPExcel object on completion of tests
|
// Data Array used for testing only, should write to PHPExcel object on completion of tests
|
||||||
protected $_dataArray = array();
|
protected $dataArray = array();
|
||||||
protected $_tableLevel = 0;
|
protected $tableLevel = 0;
|
||||||
protected $_nestedColumn = array('A');
|
protected $nestedColumn = array('A');
|
||||||
|
|
||||||
protected function _setTableStartColumn($column)
|
protected function setTableStartColumn($column)
|
||||||
{
|
{
|
||||||
if ($this->_tableLevel == 0)
|
if ($this->tableLevel == 0) {
|
||||||
$column = 'A';
|
$column = 'A';
|
||||||
++$this->_tableLevel;
|
}
|
||||||
$this->_nestedColumn[$this->_tableLevel] = $column;
|
++$this->tableLevel;
|
||||||
|
$this->nestedColumn[$this->tableLevel] = $column;
|
||||||
|
|
||||||
return $this->_nestedColumn[$this->_tableLevel];
|
return $this->nestedColumn[$this->tableLevel];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getTableStartColumn()
|
protected function getTableStartColumn()
|
||||||
{
|
{
|
||||||
return $this->_nestedColumn[$this->_tableLevel];
|
return $this->nestedColumn[$this->tableLevel];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _releaseTableStartColumn()
|
protected function releaseTableStartColumn()
|
||||||
{
|
{
|
||||||
--$this->_tableLevel;
|
--$this->tableLevel;
|
||||||
|
|
||||||
return array_pop($this->_nestedColumn);
|
return array_pop($this->nestedColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _flushCell($sheet, $column, $row, &$cellContent)
|
protected function flushCell($sheet, $column, $row, &$cellContent)
|
||||||
{
|
{
|
||||||
if (is_string($cellContent)) {
|
if (is_string($cellContent)) {
|
||||||
// Simple String content
|
// Simple String content
|
||||||
if (trim($cellContent) > '') {
|
if (trim($cellContent) > '') {
|
||||||
// Only actually write it if there's content in the string
|
// Only actually write it if there's content in the string
|
||||||
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
|
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
|
||||||
// Write to worksheet to be done here...
|
// Write to worksheet to be done here...
|
||||||
// ... we return the cell so we can mess about with styles more easily
|
// ... we return the cell so we can mess about with styles more easily
|
||||||
$sheet->setCellValue($column . $row, $cellContent, true);
|
$sheet->setCellValue($column . $row, $cellContent, true);
|
||||||
$this->_dataArray[$row][$column] = $cellContent;
|
$this->dataArray[$row][$column] = $cellContent;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// We have a Rich Text run
|
// We have a Rich Text run
|
||||||
// TODO
|
// TODO
|
||||||
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
|
$this->dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
|
||||||
}
|
}
|
||||||
$cellContent = (string) '';
|
$cellContent = (string) '';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null)
|
protected function processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null)
|
||||||
{
|
{
|
||||||
foreach ($element->childNodes as $child) {
|
foreach ($element->childNodes as $child) {
|
||||||
if ($child instanceof DOMText) {
|
if ($child instanceof DOMText) {
|
||||||
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue));
|
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue));
|
||||||
if (is_string($cellContent)) {
|
if (is_string($cellContent)) {
|
||||||
// simply append the text if the cell content is a plain text string
|
// simply append the text if the cell content is a plain text string
|
||||||
$cellContent .= $domText;
|
$cellContent .= $domText;
|
||||||
} else {
|
} else {
|
||||||
// but if we have a rich text run instead, we need to append it correctly
|
// but if we have a rich text run instead, we need to append it correctly
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
} elseif ($child instanceof DOMElement) {
|
} elseif ($child instanceof DOMElement) {
|
||||||
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
|
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
|
||||||
|
|
||||||
$attributeArray = array();
|
$attributeArray = array();
|
||||||
foreach ($child->attributes as $attribute) {
|
foreach ($child->attributes as $attribute) {
|
||||||
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
|
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
|
||||||
$attributeArray[$attribute->name] = $attribute->value;
|
$attributeArray[$attribute->name] = $attribute->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($child->nodeName) {
|
switch ($child->nodeName) {
|
||||||
case 'meta' :
|
case 'meta':
|
||||||
foreach ($attributeArray as $attributeName => $attributeValue) {
|
foreach ($attributeArray as $attributeName => $attributeValue) {
|
||||||
switch ($attributeName) {
|
switch ($attributeName) {
|
||||||
case 'content':
|
case 'content':
|
||||||
// TODO
|
// TODO
|
||||||
// Extract character set, so we can convert to UTF-8 if required
|
// Extract character set, so we can convert to UTF-8 if required
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
break;
|
break;
|
||||||
case 'title' :
|
case 'title':
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
$sheet->setTitle($cellContent);
|
$sheet->setTitle($cellContent);
|
||||||
$cellContent = '';
|
$cellContent = '';
|
||||||
break;
|
break;
|
||||||
case 'span' :
|
case 'span':
|
||||||
case 'div' :
|
case 'div':
|
||||||
case 'font' :
|
case 'font':
|
||||||
case 'i' :
|
case 'i':
|
||||||
case 'em' :
|
case 'em':
|
||||||
case 'strong':
|
case 'strong':
|
||||||
case 'b' :
|
case 'b':
|
||||||
// echo 'STYLING, SPAN OR DIV<br />';
|
// echo 'STYLING, SPAN OR DIV<br />';
|
||||||
if ($cellContent > '')
|
if ($cellContent > '') {
|
||||||
$cellContent .= ' ';
|
$cellContent .= ' ';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
}
|
||||||
if ($cellContent > '')
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
|
if ($cellContent > '') {
|
||||||
$cellContent .= ' ';
|
$cellContent .= ' ';
|
||||||
// echo 'END OF STYLING, SPAN OR DIV<br />';
|
}
|
||||||
|
// echo 'END OF STYLING, SPAN OR DIV<br />';
|
||||||
break;
|
break;
|
||||||
case 'hr' :
|
case 'hr':
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||||
++$row;
|
++$row;
|
||||||
if (isset($this->_formats[$child->nodeName])) {
|
if (isset($this->formats[$child->nodeName])) {
|
||||||
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
|
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
|
||||||
} else {
|
} else {
|
||||||
$cellContent = '----------';
|
$cellContent = '----------';
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||||
}
|
}
|
||||||
++$row;
|
++$row;
|
||||||
case 'br' :
|
// Add a break after a horizontal rule, simply by allowing the code to dropthru
|
||||||
if ($this->_tableLevel > 0) {
|
case 'br':
|
||||||
// If we're inside a table, replace with a \n
|
if ($this->tableLevel > 0) {
|
||||||
|
// If we're inside a table, replace with a \n
|
||||||
$cellContent .= "\n";
|
$cellContent .= "\n";
|
||||||
} else {
|
} else {
|
||||||
// Otherwise flush our existing content and move the row cursor on
|
// Otherwise flush our existing content and move the row cursor on
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||||
++$row;
|
++$row;
|
||||||
}
|
}
|
||||||
// echo 'HARD LINE BREAK: ' , '<br />';
|
// echo 'HARD LINE BREAK: ' , '<br />';
|
||||||
break;
|
break;
|
||||||
case 'a' :
|
case 'a':
|
||||||
// echo 'START OF HYPERLINK: ' , '<br />';
|
// echo 'START OF HYPERLINK: ' , '<br />';
|
||||||
foreach ($attributeArray as $attributeName => $attributeValue) {
|
foreach ($attributeArray as $attributeName => $attributeValue) {
|
||||||
switch ($attributeName) {
|
switch ($attributeName) {
|
||||||
case 'href':
|
case 'href':
|
||||||
// echo 'Link to ' , $attributeValue , '<br />';
|
// echo 'Link to ' , $attributeValue , '<br />';
|
||||||
$sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue);
|
$sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue);
|
||||||
if (isset($this->_formats[$child->nodeName])) {
|
if (isset($this->formats[$child->nodeName])) {
|
||||||
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
|
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$cellContent .= ' ';
|
$cellContent .= ' ';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF HYPERLINK:' , '<br />';
|
// echo 'END OF HYPERLINK:' , '<br />';
|
||||||
break;
|
break;
|
||||||
case 'h1' :
|
case 'h1':
|
||||||
case 'h2' :
|
case 'h2':
|
||||||
case 'h3' :
|
case 'h3':
|
||||||
case 'h4' :
|
case 'h4':
|
||||||
case 'h5' :
|
case 'h5':
|
||||||
case 'h6' :
|
case 'h6':
|
||||||
case 'ol' :
|
case 'ol':
|
||||||
case 'ul' :
|
case 'ul':
|
||||||
case 'p' :
|
case 'p':
|
||||||
if ($this->_tableLevel > 0) {
|
if ($this->tableLevel > 0) {
|
||||||
// If we're inside a table, replace with a \n
|
// If we're inside a table, replace with a \n
|
||||||
$cellContent .= "\n";
|
$cellContent .= "\n";
|
||||||
// echo 'LIST ENTRY: ' , '<br />';
|
// echo 'LIST ENTRY: ' , '<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF LIST ENTRY:' , '<br />';
|
// echo 'END OF LIST ENTRY:' , '<br />';
|
||||||
} else {
|
} else {
|
||||||
if ($cellContent > '') {
|
if ($cellContent > '') {
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||||
$row++;
|
$row++;
|
||||||
}
|
}
|
||||||
// echo 'START OF PARAGRAPH: ' , '<br />';
|
// echo 'START OF PARAGRAPH: ' , '<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF PARAGRAPH:' , '<br />';
|
// echo 'END OF PARAGRAPH:' , '<br />';
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||||
|
|
||||||
if (isset($this->_formats[$child->nodeName])) {
|
if (isset($this->formats[$child->nodeName])) {
|
||||||
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
|
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row++;
|
$row++;
|
||||||
$column = 'A';
|
$column = 'A';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'li' :
|
case 'li':
|
||||||
if ($this->_tableLevel > 0) {
|
if ($this->tableLevel > 0) {
|
||||||
// If we're inside a table, replace with a \n
|
// If we're inside a table, replace with a \n
|
||||||
$cellContent .= "\n";
|
$cellContent .= "\n";
|
||||||
// echo 'LIST ENTRY: ' , '<br />';
|
// echo 'LIST ENTRY: ' , '<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF LIST ENTRY:' , '<br />';
|
// echo 'END OF LIST ENTRY:' , '<br />';
|
||||||
} else {
|
} else {
|
||||||
if ($cellContent > '') {
|
if ($cellContent > '') {
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||||
}
|
}
|
||||||
++$row;
|
++$row;
|
||||||
// echo 'LIST ENTRY: ' , '<br />';
|
// echo 'LIST ENTRY: ' , '<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF LIST ENTRY:' , '<br />';
|
// echo 'END OF LIST ENTRY:' , '<br />';
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||||
$column = 'A';
|
$column = 'A';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'table' :
|
case 'table':
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||||
$column = $this->_setTableStartColumn($column);
|
$column = $this->setTableStartColumn($column);
|
||||||
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
// echo 'START OF TABLE LEVEL ' , $this->tableLevel , '<br />';
|
||||||
if ($this->_tableLevel > 1)
|
if ($this->tableLevel > 1) {
|
||||||
--$row;
|
--$row;
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
}
|
||||||
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
$column = $this->_releaseTableStartColumn();
|
// echo 'END OF TABLE LEVEL ' , $this->tableLevel , '<br />';
|
||||||
if ($this->_tableLevel > 1) {
|
$column = $this->releaseTableStartColumn();
|
||||||
|
if ($this->tableLevel > 1) {
|
||||||
++$column;
|
++$column;
|
||||||
} else {
|
} else {
|
||||||
++$row;
|
++$row;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'thead' :
|
case 'thead':
|
||||||
case 'tbody' :
|
case 'tbody':
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
break;
|
break;
|
||||||
case 'tr' :
|
case 'tr':
|
||||||
$column = $this->_getTableStartColumn();
|
$column = $this->getTableStartColumn();
|
||||||
$cellContent = '';
|
$cellContent = '';
|
||||||
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
// echo 'START OF TABLE ' , $this->tableLevel , ' ROW<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
++$row;
|
++$row;
|
||||||
// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
// echo 'END OF TABLE ' , $this->tableLevel , ' ROW<br />';
|
||||||
break;
|
break;
|
||||||
case 'th' :
|
case 'th':
|
||||||
case 'td' :
|
case 'td':
|
||||||
// echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
// echo 'START OF TABLE ' , $this->tableLevel , ' CELL<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
// echo 'END OF TABLE ' , $this->tableLevel , ' CELL<br />';
|
||||||
|
|
||||||
while (isset($this->rowspan[$column . $row])) {
|
while (isset($this->rowspan[$column . $row])) {
|
||||||
++$column;
|
++$column;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||||
|
|
||||||
// if (isset($attributeArray['style']) && !empty($attributeArray['style'])) {
|
// if (isset($attributeArray['style']) && !empty($attributeArray['style'])) {
|
||||||
// $styleAry = $this->getPhpExcelStyleArray($attributeArray['style']);
|
// $styleAry = $this->getPhpExcelStyleArray($attributeArray['style']);
|
||||||
|
@ -433,15 +450,15 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
||||||
}
|
}
|
||||||
++$column;
|
++$column;
|
||||||
break;
|
break;
|
||||||
case 'body' :
|
case 'body':
|
||||||
$row = 1;
|
$row = 1;
|
||||||
$column = 'A';
|
$column = 'A';
|
||||||
$content = '';
|
$content = '';
|
||||||
$this->_tableLevel = 0;
|
$this->tableLevel = 0;
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,37 +475,37 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
||||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||||
{
|
{
|
||||||
// Open file to validate
|
// Open file to validate
|
||||||
$this->_openFile($pFilename);
|
$this->openFile($pFilename);
|
||||||
if (!$this->_isValidFormat()) {
|
if (!$this->isValidFormat()) {
|
||||||
fclose($this->_fileHandle);
|
fclose($this->fileHandle);
|
||||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
|
||||||
}
|
}
|
||||||
// Close after validating
|
// Close after validating
|
||||||
fclose($this->_fileHandle);
|
fclose($this->fileHandle);
|
||||||
|
|
||||||
// Create new PHPExcel
|
// Create new PHPExcel
|
||||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
|
||||||
$objPHPExcel->createSheet();
|
$objPHPExcel->createSheet();
|
||||||
}
|
}
|
||||||
$objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
|
$objPHPExcel->setActiveSheetIndex($this->sheetIndex);
|
||||||
|
|
||||||
// Create a new DOM object
|
// Create a new DOM object
|
||||||
$dom = new domDocument;
|
$dom = new domDocument;
|
||||||
// Reload the HTML file into the DOM object
|
// Reload the HTML file into the DOM object
|
||||||
$loaded = $dom->loadHTML($this->securityScanFile($pFilename));
|
$loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanFile($pFilename), 'HTML-ENTITIES', 'UTF-8'));
|
||||||
if ($loaded === FALSE) {
|
if ($loaded === false) {
|
||||||
throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
|
throw new PHPExcel_Reader_Exception('Failed to load ' . $pFilename . ' as a DOM Document');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard white space
|
// Discard white space
|
||||||
$dom->preserveWhiteSpace = false;
|
$dom->preserveWhiteSpace = false;
|
||||||
|
|
||||||
$row = 0;
|
$row = 0;
|
||||||
$column = 'A';
|
$column = 'A';
|
||||||
$content = '';
|
$content = '';
|
||||||
$this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
|
$this->processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objPHPExcel;
|
return $objPHPExcel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +516,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
||||||
*/
|
*/
|
||||||
public function getSheetIndex()
|
public function getSheetIndex()
|
||||||
{
|
{
|
||||||
return $this->_sheetIndex;
|
return $this->sheetIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -510,25 +527,23 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
||||||
*/
|
*/
|
||||||
public function setSheetIndex($pValue = 0)
|
public function setSheetIndex($pValue = 0)
|
||||||
{
|
{
|
||||||
$this->_sheetIndex = $pValue;
|
$this->sheetIndex = $pValue;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param string $xml
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function securityScan($xml)
|
public function securityScan($xml)
|
||||||
{
|
{
|
||||||
$pattern = '/\\0?' . implode('\\0?', str_split('<!ENTITY')) . '\\0?/';
|
$pattern = '/\\0?' . implode('\\0?', str_split('<!ENTITY')) . '\\0?/';
|
||||||
if (preg_match($pattern, $xml)) {
|
if (preg_match($pattern, $xml)) {
|
||||||
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
||||||
}
|
}
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_IReadFilter
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,28 +21,19 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Reader_IReadFilter
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Reader
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
interface PHPExcel_Reader_IReadFilter
|
interface PHPExcel_Reader_IReadFilter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Should this cell be read?
|
* Should this cell be read?
|
||||||
*
|
*
|
||||||
* @param $column String column index
|
* @param $column Column address (as a string value like "A", or "IV")
|
||||||
* @param $row Row index
|
* @param $row Row number
|
||||||
* @param $worksheetName Optional worksheet name
|
* @param $worksheetName Optional worksheet name
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function readCell($column, $row, $worksheetName = '');
|
public function readCell($column, $row, $worksheetName = '');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_IReader
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,35 +21,26 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Reader_IReader
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Reader
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
interface PHPExcel_Reader_IReader
|
interface PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Can the current PHPExcel_Reader_IReader read the file?
|
* Can the current PHPExcel_Reader_IReader read the file?
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function canRead($pFilename);
|
public function canRead($pFilename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file
|
* Loads PHPExcel from file
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function load($pFilename);
|
public function load($pFilename);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_SYLK
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,431 +30,449 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel 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
|
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Input encoding
|
* Input encoding
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_inputEncoding = 'ANSI';
|
private $inputEncoding = 'ANSI';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sheet index to read
|
* Sheet index to read
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_sheetIndex = 0;
|
private $sheetIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats
|
* Formats
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_formats = array();
|
private $formats = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format Count
|
* Format Count
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_format = 0;
|
private $format = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Reader_SYLK
|
* Create a new PHPExcel_Reader_SYLK
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
{
|
||||||
}
|
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that the current file is a SYLK file
|
* Validate that the current file is a SYLK file
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function _isValidFormat()
|
protected function isValidFormat()
|
||||||
{
|
{
|
||||||
// Read sample data (first 2 KB will do)
|
// Read sample data (first 2 KB will do)
|
||||||
$data = fread($this->_fileHandle, 2048);
|
$data = fread($this->fileHandle, 2048);
|
||||||
|
|
||||||
// Count delimiters in file
|
// Count delimiters in file
|
||||||
$delimiterCount = substr_count($data, ';');
|
$delimiterCount = substr_count($data, ';');
|
||||||
if ($delimiterCount < 1) {
|
if ($delimiterCount < 1) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Analyze first line looking for ID; signature
|
// Analyze first line looking for ID; signature
|
||||||
$lines = explode("\n", $data);
|
$lines = explode("\n", $data);
|
||||||
if (substr($lines[0],0,4) != 'ID;P') {
|
if (substr($lines[0], 0, 4) != 'ID;P') {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set input encoding
|
* Set input encoding
|
||||||
*
|
*
|
||||||
* @param string $pValue Input encoding
|
* @param string $pValue Input encoding
|
||||||
*/
|
*/
|
||||||
public function setInputEncoding($pValue = 'ANSI')
|
public function setInputEncoding($pValue = 'ANSI')
|
||||||
{
|
{
|
||||||
$this->_inputEncoding = $pValue;
|
$this->inputEncoding = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get input encoding
|
* Get input encoding
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getInputEncoding()
|
public function getInputEncoding()
|
||||||
{
|
{
|
||||||
return $this->_inputEncoding;
|
return $this->inputEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function listWorksheetInfo($pFilename)
|
public function listWorksheetInfo($pFilename)
|
||||||
{
|
{
|
||||||
// Open file
|
// Open file
|
||||||
$this->_openFile($pFilename);
|
$this->openFile($pFilename);
|
||||||
if (!$this->_isValidFormat()) {
|
if (!$this->isValidFormat()) {
|
||||||
fclose ($this->_fileHandle);
|
fclose($this->fileHandle);
|
||||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||||
}
|
}
|
||||||
$fileHandle = $this->_fileHandle;
|
$fileHandle = $this->fileHandle;
|
||||||
rewind($fileHandle);
|
rewind($fileHandle);
|
||||||
|
|
||||||
$worksheetInfo = array();
|
$worksheetInfo = array();
|
||||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||||
$worksheetInfo[0]['totalRows'] = 0;
|
$worksheetInfo[0]['totalRows'] = 0;
|
||||||
$worksheetInfo[0]['totalColumns'] = 0;
|
$worksheetInfo[0]['totalColumns'] = 0;
|
||||||
|
|
||||||
// Loop through file
|
// Loop through file
|
||||||
$rowData = array();
|
$rowData = array();
|
||||||
|
|
||||||
// loop through one row (line) at a time in the file
|
// loop through one row (line) at a time in the file
|
||||||
$rowIndex = 0;
|
$rowIndex = 0;
|
||||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
while (($rowData = fgets($fileHandle)) !== false) {
|
||||||
$columnIndex = 0;
|
$columnIndex = 0;
|
||||||
|
|
||||||
// convert SYLK encoded $rowData to UTF-8
|
// convert SYLK encoded $rowData to UTF-8
|
||||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||||
|
|
||||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||||
// is escaped like this (;;)
|
// is escaped like this (;;)
|
||||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
|
||||||
|
|
||||||
$dataType = array_shift($rowData);
|
$dataType = array_shift($rowData);
|
||||||
if ($dataType == 'C') {
|
if ($dataType == 'C') {
|
||||||
// Read cell value data
|
// Read cell value data
|
||||||
foreach($rowData as $rowDatum) {
|
foreach ($rowData as $rowDatum) {
|
||||||
switch($rowDatum{0}) {
|
switch ($rowDatum{0}) {
|
||||||
case 'C' :
|
case 'C':
|
||||||
case 'X' :
|
case 'X':
|
||||||
$columnIndex = substr($rowDatum,1) - 1;
|
$columnIndex = substr($rowDatum, 1) - 1;
|
||||||
break;
|
break;
|
||||||
case 'R' :
|
case 'R':
|
||||||
case 'Y' :
|
case 'Y':
|
||||||
$rowIndex = substr($rowDatum,1);
|
$rowIndex = substr($rowDatum, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
|
$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
|
||||||
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
|
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
||||||
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
fclose($fileHandle);
|
fclose($fileHandle);
|
||||||
|
|
||||||
return $worksheetInfo;
|
return $worksheetInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file
|
* Loads PHPExcel from file
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function load($pFilename)
|
public function load($pFilename)
|
||||||
{
|
{
|
||||||
// Create new PHPExcel
|
// Create new PHPExcel
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Load into this instance
|
// Load into this instance
|
||||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file into PHPExcel instance
|
* Loads PHPExcel from file into PHPExcel instance
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @param PHPExcel $objPHPExcel
|
* @param PHPExcel $objPHPExcel
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||||
{
|
{
|
||||||
// Open file
|
// Open file
|
||||||
$this->_openFile($pFilename);
|
$this->openFile($pFilename);
|
||||||
if (!$this->_isValidFormat()) {
|
if (!$this->isValidFormat()) {
|
||||||
fclose ($this->_fileHandle);
|
fclose($this->fileHandle);
|
||||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||||
}
|
}
|
||||||
$fileHandle = $this->_fileHandle;
|
$fileHandle = $this->fileHandle;
|
||||||
rewind($fileHandle);
|
rewind($fileHandle);
|
||||||
|
|
||||||
// Create new PHPExcel
|
// Create new PHPExcel
|
||||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
|
||||||
$objPHPExcel->createSheet();
|
$objPHPExcel->createSheet();
|
||||||
}
|
}
|
||||||
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
$objPHPExcel->setActiveSheetIndex($this->sheetIndex);
|
||||||
|
|
||||||
$fromFormats = array('\-', '\ ');
|
$fromFormats = array('\-', '\ ');
|
||||||
$toFormats = array('-', ' ');
|
$toFormats = array('-', ' ');
|
||||||
|
|
||||||
// Loop through file
|
// Loop through file
|
||||||
$rowData = array();
|
$rowData = array();
|
||||||
$column = $row = '';
|
$column = $row = '';
|
||||||
|
|
||||||
// loop through one row (line) at a time in the file
|
// loop through one row (line) at a time in the file
|
||||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
while (($rowData = fgets($fileHandle)) !== false) {
|
||||||
|
// convert SYLK encoded $rowData to UTF-8
|
||||||
|
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||||
|
|
||||||
// convert SYLK encoded $rowData to UTF-8
|
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
// is escaped like this (;;)
|
||||||
|
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
|
||||||
|
|
||||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
$dataType = array_shift($rowData);
|
||||||
// is escaped like this (;;)
|
// Read shared styles
|
||||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
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;
|
||||||
|
|
||||||
$dataType = array_shift($rowData);
|
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
|
||||||
// Read shared styles
|
}
|
||||||
if ($dataType == 'P') {
|
}
|
||||||
$formatArray = array();
|
}
|
||||||
foreach($rowData as $rowDatum) {
|
unset($value);
|
||||||
switch($rowDatum{0}) {
|
// Then rebuild the formula string
|
||||||
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1));
|
$cellDataFormula = implode('"', $temp);
|
||||||
break;
|
$hasCalculatedValue = true;
|
||||||
case 'E' :
|
break;
|
||||||
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
|
}
|
||||||
break;
|
}
|
||||||
case 'L' : $formatArray['font']['size'] = substr($rowDatum,1);
|
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||||
break;
|
$cellData = PHPExcel_Calculation::unwrapResult($cellData);
|
||||||
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]));
|
// Set cell value
|
||||||
}
|
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
|
||||||
}
|
if ($hasCalculatedValue) {
|
||||||
}
|
$cellData = PHPExcel_Calculation::unwrapResult($cellData);
|
||||||
unset($value);
|
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
|
||||||
// Then rebuild the formula string
|
}
|
||||||
$cellDataFormula = implode('"',$temp);
|
// Read cell formatting
|
||||||
$hasCalculatedValue = true;
|
} elseif ($dataType == 'F') {
|
||||||
break;
|
$formatStyle = $columnWidth = $styleSettings = '';
|
||||||
}
|
$styleData = array();
|
||||||
}
|
foreach ($rowData as $rowDatum) {
|
||||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
switch ($rowDatum{0}) {
|
||||||
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set cell value
|
// Close file
|
||||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
|
fclose($fileHandle);
|
||||||
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
|
// Return
|
||||||
fclose($fileHandle);
|
return $objPHPExcel;
|
||||||
|
}
|
||||||
|
|
||||||
// Return
|
/**
|
||||||
return $objPHPExcel;
|
* Get sheet index
|
||||||
}
|
*
|
||||||
|
* @return int
|
||||||
/**
|
*/
|
||||||
* Get sheet index
|
public function getSheetIndex()
|
||||||
*
|
{
|
||||||
* @return int
|
return $this->sheetIndex;
|
||||||
*/
|
}
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set sheet index
|
||||||
|
*
|
||||||
|
* @param int $pValue Sheet index
|
||||||
|
* @return PHPExcel_Reader_SYLK
|
||||||
|
*/
|
||||||
|
public function setSheetIndex($pValue = 0)
|
||||||
|
{
|
||||||
|
$this->sheetIndex = $pValue;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_RichText
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,19 +21,10 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_RichText
|
* @package PHPExcel_RichText
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_RichText
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_RichText
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_RichText implements PHPExcel_IComparable
|
class PHPExcel_RichText implements PHPExcel_IComparable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +32,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var PHPExcel_RichText_ITextElement[]
|
* @var PHPExcel_RichText_ITextElement[]
|
||||||
*/
|
*/
|
||||||
private $_richTextElements;
|
private $richTextElements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_RichText instance
|
* Create a new PHPExcel_RichText instance
|
||||||
|
@ -51,10 +43,10 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||||
public function __construct(PHPExcel_Cell $pCell = null)
|
public function __construct(PHPExcel_Cell $pCell = null)
|
||||||
{
|
{
|
||||||
// Initialise variables
|
// Initialise variables
|
||||||
$this->_richTextElements = array();
|
$this->richTextElements = array();
|
||||||
|
|
||||||
// Rich-Text string attached to cell?
|
// Rich-Text string attached to cell?
|
||||||
if ($pCell !== NULL) {
|
if ($pCell !== null) {
|
||||||
// Add cell text and style
|
// Add cell text and style
|
||||||
if ($pCell->getValue() != "") {
|
if ($pCell->getValue() != "") {
|
||||||
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
|
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
|
||||||
|
@ -76,7 +68,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||||
*/
|
*/
|
||||||
public function addText(PHPExcel_RichText_ITextElement $pText = null)
|
public function addText(PHPExcel_RichText_ITextElement $pText = null)
|
||||||
{
|
{
|
||||||
$this->_richTextElements[] = $pText;
|
$this->richTextElements[] = $pText;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +111,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||||
$returnValue = '';
|
$returnValue = '';
|
||||||
|
|
||||||
// Loop through all PHPExcel_RichText_ITextElement
|
// Loop through all PHPExcel_RichText_ITextElement
|
||||||
foreach ($this->_richTextElements as $text) {
|
foreach ($this->richTextElements as $text) {
|
||||||
$returnValue .= $text->getText();
|
$returnValue .= $text->getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +136,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||||
*/
|
*/
|
||||||
public function getRichTextElements()
|
public function getRichTextElements()
|
||||||
{
|
{
|
||||||
return $this->_richTextElements;
|
return $this->richTextElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,7 +149,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||||
public function setRichTextElements($pElements = null)
|
public function setRichTextElements($pElements = null)
|
||||||
{
|
{
|
||||||
if (is_array($pElements)) {
|
if (is_array($pElements)) {
|
||||||
$this->_richTextElements = $pElements;
|
$this->richTextElements = $pElements;
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
|
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
|
||||||
}
|
}
|
||||||
|
@ -172,13 +164,13 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||||
public function getHashCode()
|
public function getHashCode()
|
||||||
{
|
{
|
||||||
$hashElements = '';
|
$hashElements = '';
|
||||||
foreach ($this->_richTextElements as $element) {
|
foreach ($this->richTextElements as $element) {
|
||||||
$hashElements .= $element->getHashCode();
|
$hashElements .= $element->getHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
return md5(
|
return md5(
|
||||||
$hashElements
|
$hashElements .
|
||||||
. __CLASS__
|
__CLASS__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_RichText_ITextElement
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,47 +19,38 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_RichText
|
* @package PHPExcel_RichText
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_RichText_ITextElement
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_RichText
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
interface PHPExcel_RichText_ITextElement
|
interface PHPExcel_RichText_ITextElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get text
|
* Get text
|
||||||
*
|
*
|
||||||
* @return string Text
|
* @return string Text
|
||||||
*/
|
*/
|
||||||
public function getText();
|
public function getText();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set text
|
* Set text
|
||||||
*
|
*
|
||||||
* @param $pText string Text
|
* @param $pText string Text
|
||||||
* @return PHPExcel_RichText_ITextElement
|
* @return PHPExcel_RichText_ITextElement
|
||||||
*/
|
*/
|
||||||
public function setText($pText = '');
|
public function setText($pText = '');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get font
|
* Get font
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Style_Font
|
* @return PHPExcel_Style_Font
|
||||||
*/
|
*/
|
||||||
public function getFont();
|
public function getFont();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get hash code
|
* Get hash code
|
||||||
*
|
*
|
||||||
* @return string Hash code
|
* @return string Hash code
|
||||||
*/
|
*/
|
||||||
public function getHashCode();
|
public function getHashCode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_RichText_Run
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,85 +19,80 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_RichText
|
* @package PHPExcel_RichText
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_RichText_Run
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_RichText
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Font
|
* Font
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Font
|
* @var PHPExcel_Style_Font
|
||||||
*/
|
*/
|
||||||
private $_font;
|
private $font;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_RichText_Run instance
|
* Create a new PHPExcel_RichText_Run instance
|
||||||
*
|
*
|
||||||
* @param string $pText Text
|
* @param string $pText Text
|
||||||
*/
|
*/
|
||||||
public function __construct($pText = '')
|
public function __construct($pText = '')
|
||||||
{
|
{
|
||||||
// Initialise variables
|
// Initialise variables
|
||||||
$this->setText($pText);
|
$this->setText($pText);
|
||||||
$this->_font = new PHPExcel_Style_Font();
|
$this->font = new PHPExcel_Style_Font();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get font
|
* Get font
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Style_Font
|
* @return PHPExcel_Style_Font
|
||||||
*/
|
*/
|
||||||
public function getFont() {
|
public function getFont()
|
||||||
return $this->_font;
|
{
|
||||||
}
|
return $this->font;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set font
|
|
||||||
*
|
|
||||||
* @param PHPExcel_Style_Font $pFont Font
|
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
* @return PHPExcel_RichText_ITextElement
|
|
||||||
*/
|
|
||||||
public function setFont(PHPExcel_Style_Font $pFont = null) {
|
|
||||||
$this->_font = $pFont;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get hash code
|
|
||||||
*
|
|
||||||
* @return string Hash code
|
|
||||||
*/
|
|
||||||
public function getHashCode() {
|
|
||||||
return md5(
|
|
||||||
$this->getText()
|
|
||||||
. $this->_font->getHashCode()
|
|
||||||
. __CLASS__
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Set font
|
||||||
*/
|
*
|
||||||
public function __clone() {
|
* @param PHPExcel_Style_Font $pFont Font
|
||||||
$vars = get_object_vars($this);
|
* @throws PHPExcel_Exception
|
||||||
foreach ($vars as $key => $value) {
|
* @return PHPExcel_RichText_ITextElement
|
||||||
if (is_object($value)) {
|
*/
|
||||||
$this->$key = clone $value;
|
public function setFont(PHPExcel_Style_Font $pFont = null)
|
||||||
} else {
|
{
|
||||||
$this->$key = $value;
|
$this->font = $pFont;
|
||||||
}
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Get hash code
|
||||||
|
*
|
||||||
|
* @return string Hash code
|
||||||
|
*/
|
||||||
|
public function getHashCode()
|
||||||
|
{
|
||||||
|
return md5(
|
||||||
|
$this->getText() .
|
||||||
|
$this->font->getHashCode() .
|
||||||
|
__CLASS__
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$vars = get_object_vars($this);
|
||||||
|
foreach ($vars as $key => $value) {
|
||||||
|
if (is_object($value)) {
|
||||||
|
$this->$key = clone $value;
|
||||||
|
} else {
|
||||||
|
$this->$key = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_RichText_TextElement
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,91 +19,87 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_RichText
|
* @package PHPExcel_RichText
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_RichText_TextElement
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_RichText
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Text
|
* Text
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_text;
|
private $text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_RichText_TextElement instance
|
* Create a new PHPExcel_RichText_TextElement instance
|
||||||
*
|
*
|
||||||
* @param string $pText Text
|
* @param string $pText Text
|
||||||
*/
|
*/
|
||||||
public function __construct($pText = '')
|
public function __construct($pText = '')
|
||||||
{
|
{
|
||||||
// Initialise variables
|
// Initialise variables
|
||||||
$this->_text = $pText;
|
$this->text = $pText;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get text
|
* Get text
|
||||||
*
|
*
|
||||||
* @return string Text
|
* @return string Text
|
||||||
*/
|
*/
|
||||||
public function getText() {
|
public function getText()
|
||||||
return $this->_text;
|
{
|
||||||
}
|
return $this->text;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set text
|
|
||||||
*
|
|
||||||
* @param $pText string Text
|
|
||||||
* @return PHPExcel_RichText_ITextElement
|
|
||||||
*/
|
|
||||||
public function setText($pText = '') {
|
|
||||||
$this->_text = $pText;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get font
|
|
||||||
*
|
|
||||||
* @return PHPExcel_Style_Font
|
|
||||||
*/
|
|
||||||
public function getFont() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get hash code
|
|
||||||
*
|
|
||||||
* @return string Hash code
|
|
||||||
*/
|
|
||||||
public function getHashCode() {
|
|
||||||
return md5(
|
|
||||||
$this->_text
|
|
||||||
. __CLASS__
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Set text
|
||||||
*/
|
*
|
||||||
public function __clone() {
|
* @param $pText string Text
|
||||||
$vars = get_object_vars($this);
|
* @return PHPExcel_RichText_ITextElement
|
||||||
foreach ($vars as $key => $value) {
|
*/
|
||||||
if (is_object($value)) {
|
public function setText($pText = '')
|
||||||
$this->$key = clone $value;
|
{
|
||||||
} else {
|
$this->text = $pText;
|
||||||
$this->$key = $value;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
|
* Get font
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Style_Font
|
||||||
|
*/
|
||||||
|
public function getFont()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get hash code
|
||||||
|
*
|
||||||
|
* @return string Hash code
|
||||||
|
*/
|
||||||
|
public function getHashCode()
|
||||||
|
{
|
||||||
|
return md5(
|
||||||
|
$this->text .
|
||||||
|
__CLASS__
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$vars = get_object_vars($this);
|
||||||
|
foreach ($vars as $key => $value) {
|
||||||
|
if (is_object($value)) {
|
||||||
|
$this->$key = clone $value;
|
||||||
|
} else {
|
||||||
|
$this->$key = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Settings
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,42 +30,31 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Settings
|
* @package PHPExcel_Settings
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** PHPExcel root directory */
|
|
||||||
if (!defined('PHPEXCEL_ROOT')) {
|
|
||||||
/**
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
|
||||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class PHPExcel_Settings
|
class PHPExcel_Settings
|
||||||
{
|
{
|
||||||
/** constants */
|
/** constants */
|
||||||
/** Available Zip library classes */
|
/** Available Zip library classes */
|
||||||
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
|
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
|
||||||
const ZIPARCHIVE = 'ZipArchive';
|
const ZIPARCHIVE = 'ZipArchive';
|
||||||
|
|
||||||
/** Optional Chart Rendering libraries */
|
/** Optional Chart Rendering libraries */
|
||||||
const CHART_RENDERER_JPGRAPH = 'jpgraph';
|
const CHART_RENDERER_JPGRAPH = 'jpgraph';
|
||||||
|
|
||||||
/** Optional PDF Rendering libraries */
|
/** Optional PDF Rendering libraries */
|
||||||
const PDF_RENDERER_TCPDF = 'tcPDF';
|
const PDF_RENDERER_TCPDF = 'tcPDF';
|
||||||
const PDF_RENDERER_DOMPDF = 'DomPDF';
|
const PDF_RENDERER_DOMPDF = 'DomPDF';
|
||||||
const PDF_RENDERER_MPDF = 'mPDF';
|
const PDF_RENDERER_MPDF = 'mPDF';
|
||||||
|
|
||||||
|
|
||||||
private static $_chartRenderers = array(
|
private static $chartRenderers = array(
|
||||||
self::CHART_RENDERER_JPGRAPH,
|
self::CHART_RENDERER_JPGRAPH,
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $_pdfRenderers = array(
|
private static $pdfRenderers = array(
|
||||||
self::PDF_RENDERER_TCPDF,
|
self::PDF_RENDERER_TCPDF,
|
||||||
self::PDF_RENDERER_DOMPDF,
|
self::PDF_RENDERER_DOMPDF,
|
||||||
self::PDF_RENDERER_MPDF,
|
self::PDF_RENDERER_MPDF,
|
||||||
|
@ -64,84 +63,84 @@ class PHPExcel_Settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the class used for Zip file management
|
* Name of the class used for Zip file management
|
||||||
* e.g.
|
* e.g.
|
||||||
* ZipArchive
|
* ZipArchive
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $_zipClass = self::ZIPARCHIVE;
|
private static $zipClass = self::ZIPARCHIVE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the external Library used for rendering charts
|
* Name of the external Library used for rendering charts
|
||||||
* e.g.
|
* e.g.
|
||||||
* jpgraph
|
* jpgraph
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $_chartRendererName = NULL;
|
private static $chartRendererName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory Path to the external Library used for rendering charts
|
* Directory Path to the external Library used for rendering charts
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $_chartRendererPath = NULL;
|
private static $chartRendererPath;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the external Library used for rendering PDF files
|
* Name of the external Library used for rendering PDF files
|
||||||
* e.g.
|
* e.g.
|
||||||
* mPDF
|
* mPDF
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $_pdfRendererName = NULL;
|
private static $pdfRendererName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory Path to the external Library used for rendering PDF files
|
* Directory Path to the external Library used for rendering PDF files
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $_pdfRendererPath = NULL;
|
private static $pdfRendererPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default options for libxml loader
|
* Default options for libxml loader
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private static $_libXmlLoaderOptions = null;
|
private static $libXmlLoaderOptions = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
|
* Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
|
||||||
*
|
*
|
||||||
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
|
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
|
||||||
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setZipClass($zipClass)
|
public static function setZipClass($zipClass)
|
||||||
{
|
{
|
||||||
if (($zipClass === self::PCLZIP) ||
|
if (($zipClass === self::PCLZIP) ||
|
||||||
($zipClass === self::ZIPARCHIVE)) {
|
($zipClass === self::ZIPARCHIVE)) {
|
||||||
self::$_zipClass = $zipClass;
|
self::$zipClass = $zipClass;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
} // function setZipClass()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
|
* Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
|
||||||
* or Zip file management
|
* or Zip file management
|
||||||
*
|
*
|
||||||
* @return string Name of the Zip handler Class that PHPExcel is configured to use
|
* @return string Name of the Zip handler Class that PHPExcel is configured to use
|
||||||
* for Zip file management
|
* for Zip file management
|
||||||
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
||||||
*/
|
*/
|
||||||
public static function getZipClass()
|
public static function getZipClass()
|
||||||
{
|
{
|
||||||
return self::$_zipClass;
|
return self::$zipClass;
|
||||||
} // function getZipClass()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,7 +151,7 @@ class PHPExcel_Settings
|
||||||
public static function getCacheStorageMethod()
|
public static function getCacheStorageMethod()
|
||||||
{
|
{
|
||||||
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
|
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
|
||||||
} // function getCacheStorageMethod()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +162,7 @@ class PHPExcel_Settings
|
||||||
public static function getCacheStorageClass()
|
public static function getCacheStorageClass()
|
||||||
{
|
{
|
||||||
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
|
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
|
||||||
} // function getCacheStorageClass()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,13 +172,10 @@ class PHPExcel_Settings
|
||||||
* @param array $arguments Optional configuration arguments for the cacheing method
|
* @param array $arguments Optional configuration arguments for the cacheing method
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setCacheStorageMethod(
|
public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments = array())
|
||||||
$method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
|
|
||||||
$arguments = array()
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
|
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
|
||||||
} // function setCacheStorageMethod()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -188,97 +184,97 @@ class PHPExcel_Settings
|
||||||
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
|
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setLocale($locale='en_us')
|
public static function setLocale($locale = 'en_us')
|
||||||
{
|
{
|
||||||
return PHPExcel_Calculation::getInstance()->setLocale($locale);
|
return PHPExcel_Calculation::getInstance()->setLocale($locale);
|
||||||
} // function setLocale()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set details of the external library that PHPExcel should use for rendering charts
|
* Set details of the external library that PHPExcel should use for rendering charts
|
||||||
*
|
*
|
||||||
* @param string $libraryName Internal reference name of the library
|
* @param string $libraryName Internal reference name of the library
|
||||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||||
*
|
*
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setChartRenderer($libraryName, $libraryBaseDir)
|
public static function setChartRenderer($libraryName, $libraryBaseDir)
|
||||||
{
|
{
|
||||||
if (!self::setChartRendererName($libraryName))
|
if (!self::setChartRendererName($libraryName)) {
|
||||||
return FALSE;
|
return false;
|
||||||
|
}
|
||||||
return self::setChartRendererPath($libraryBaseDir);
|
return self::setChartRendererPath($libraryBaseDir);
|
||||||
} // function setChartRenderer()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify to PHPExcel the external library to use for rendering charts
|
* Identify to PHPExcel the external library to use for rendering charts
|
||||||
*
|
*
|
||||||
* @param string $libraryName Internal reference name of the library
|
* @param string $libraryName Internal reference name of the library
|
||||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||||
*
|
*
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setChartRendererName($libraryName)
|
public static function setChartRendererName($libraryName)
|
||||||
{
|
{
|
||||||
if (!in_array($libraryName,self::$_chartRenderers)) {
|
if (!in_array($libraryName, self::$chartRenderers)) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
self::$chartRendererName = $libraryName;
|
||||||
|
|
||||||
self::$_chartRendererName = $libraryName;
|
return true;
|
||||||
|
}
|
||||||
return TRUE;
|
|
||||||
} // function setChartRendererName()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell PHPExcel where to find the external library to use for rendering charts
|
* Tell PHPExcel where to find the external library to use for rendering charts
|
||||||
*
|
*
|
||||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setChartRendererPath($libraryBaseDir)
|
public static function setChartRendererPath($libraryBaseDir)
|
||||||
{
|
{
|
||||||
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
self::$_chartRendererPath = $libraryBaseDir;
|
self::$chartRendererPath = $libraryBaseDir;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
} // function setChartRendererPath()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph)
|
* Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph)
|
||||||
*
|
*
|
||||||
* @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is
|
* @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is
|
||||||
* currently configured to use
|
* currently configured to use
|
||||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||||
*/
|
*/
|
||||||
public static function getChartRendererName()
|
public static function getChartRendererName()
|
||||||
{
|
{
|
||||||
return self::$_chartRendererName;
|
return self::$chartRendererName;
|
||||||
} // function getChartRendererName()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use
|
* Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use
|
||||||
*
|
*
|
||||||
* @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is
|
* @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is
|
||||||
* currently configured to use
|
* currently configured to use
|
||||||
*/
|
*/
|
||||||
public static function getChartRendererPath()
|
public static function getChartRendererPath()
|
||||||
{
|
{
|
||||||
return self::$_chartRendererPath;
|
return self::$chartRendererPath;
|
||||||
} // function getChartRendererPath()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set details of the external library that PHPExcel should use for rendering PDF files
|
* Set details of the external library that PHPExcel should use for rendering PDF files
|
||||||
*
|
*
|
||||||
* @param string $libraryName Internal reference name of the library
|
* @param string $libraryName Internal reference name of the library
|
||||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||||
*
|
*
|
||||||
|
@ -286,32 +282,32 @@ class PHPExcel_Settings
|
||||||
*/
|
*/
|
||||||
public static function setPdfRenderer($libraryName, $libraryBaseDir)
|
public static function setPdfRenderer($libraryName, $libraryBaseDir)
|
||||||
{
|
{
|
||||||
if (!self::setPdfRendererName($libraryName))
|
if (!self::setPdfRendererName($libraryName)) {
|
||||||
return FALSE;
|
return false;
|
||||||
|
}
|
||||||
return self::setPdfRendererPath($libraryBaseDir);
|
return self::setPdfRendererPath($libraryBaseDir);
|
||||||
} // function setPdfRenderer()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify to PHPExcel the external library to use for rendering PDF files
|
* Identify to PHPExcel the external library to use for rendering PDF files
|
||||||
*
|
*
|
||||||
* @param string $libraryName Internal reference name of the library
|
* @param string $libraryName Internal reference name of the library
|
||||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||||
*
|
*
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setPdfRendererName($libraryName)
|
public static function setPdfRendererName($libraryName)
|
||||||
{
|
{
|
||||||
if (!in_array($libraryName,self::$_pdfRenderers)) {
|
if (!in_array($libraryName, self::$pdfRenderers)) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
self::$pdfRendererName = $libraryName;
|
||||||
|
|
||||||
self::$_pdfRendererName = $libraryName;
|
return true;
|
||||||
|
}
|
||||||
return TRUE;
|
|
||||||
} // function setPdfRendererName()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -323,69 +319,71 @@ class PHPExcel_Settings
|
||||||
public static function setPdfRendererPath($libraryBaseDir)
|
public static function setPdfRendererPath($libraryBaseDir)
|
||||||
{
|
{
|
||||||
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
self::$_pdfRendererPath = $libraryBaseDir;
|
self::$pdfRendererPath = $libraryBaseDir;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
} // function setPdfRendererPath()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf)
|
* Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf)
|
||||||
*
|
*
|
||||||
* @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is
|
* @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is
|
||||||
* currently configured to use
|
* currently configured to use
|
||||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||||
*/
|
*/
|
||||||
public static function getPdfRendererName()
|
public static function getPdfRendererName()
|
||||||
{
|
{
|
||||||
return self::$_pdfRendererName;
|
return self::$pdfRendererName;
|
||||||
} // function getPdfRendererName()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
|
* Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
|
||||||
*
|
*
|
||||||
* @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is
|
* @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is
|
||||||
* currently configured to use
|
* currently configured to use
|
||||||
*/
|
*/
|
||||||
public static function getPdfRendererPath()
|
public static function getPdfRendererPath()
|
||||||
{
|
{
|
||||||
return self::$_pdfRendererPath;
|
return self::$pdfRendererPath;
|
||||||
} // function getPdfRendererPath()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set default options for libxml loader
|
* Set options for libxml loader
|
||||||
*
|
*
|
||||||
* @param int $options Default options for libxml loader
|
* @param int $options Options for libxml loader
|
||||||
*/
|
*/
|
||||||
public static function setLibXmlLoaderOptions($options = null)
|
public static function setLibXmlLoaderOptions($options = null)
|
||||||
{
|
{
|
||||||
if (is_null($options) && defined(LIBXML_DTDLOAD)) {
|
if (is_null($options) && defined('LIBXML_DTDLOAD')) {
|
||||||
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
|
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
|
||||||
}
|
}
|
||||||
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
|
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
|
||||||
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
|
@libxml_disable_entity_loader((bool) $options);
|
||||||
}
|
}
|
||||||
self::$_libXmlLoaderOptions = $options;
|
self::$libXmlLoaderOptions = $options;
|
||||||
} // function setLibXmlLoaderOptions
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get default options for libxml loader.
|
* Get defined options for libxml loader.
|
||||||
* Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly.
|
* Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly.
|
||||||
*
|
*
|
||||||
* @return int Default options for libxml loader
|
* @return int Default options for libxml loader
|
||||||
*/
|
*/
|
||||||
public static function getLibXmlLoaderOptions()
|
public static function getLibXmlLoaderOptions()
|
||||||
{
|
{
|
||||||
if (is_null(self::$_libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) {
|
if (is_null(self::$libXmlLoaderOptions) && defined('LIBXML_DTDLOAD')) {
|
||||||
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
|
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
|
||||||
|
} elseif (is_null(self::$libXmlLoaderOptions)) {
|
||||||
|
self::$libXmlLoaderOptions = true;
|
||||||
}
|
}
|
||||||
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
|
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
|
||||||
@libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
|
@libxml_disable_entity_loader((bool) self::$libXmlLoaderOptions);
|
||||||
}
|
}
|
||||||
return self::$_libXmlLoaderOptions;
|
return self::$libXmlLoaderOptions;
|
||||||
} // function getLibXmlLoaderOptions
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Shared_CodePage
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,87 +21,136 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Shared
|
* @package PHPExcel_Shared
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Shared_CodePage
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Shared
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Shared_CodePage
|
class PHPExcel_Shared_CodePage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
|
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
|
||||||
* and mbstring understands
|
* and mbstring understands
|
||||||
*
|
*
|
||||||
* @param integer $codePage Microsoft Code Page Indentifier
|
* @param integer $codePage Microsoft Code Page Indentifier
|
||||||
* @return string Code Page Name
|
* @return string Code Page Name
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public static function NumberToName($codePage = 1252)
|
public static function NumberToName($codePage = 1252)
|
||||||
{
|
{
|
||||||
switch ($codePage) {
|
switch ($codePage) {
|
||||||
case 367: return 'ASCII'; break; // ASCII
|
case 367:
|
||||||
case 437: return 'CP437'; break; // OEM US
|
return 'ASCII'; // ASCII
|
||||||
case 720: throw new PHPExcel_Exception('Code page 720 not supported.');
|
case 437:
|
||||||
break; // OEM Arabic
|
return 'CP437'; // OEM US
|
||||||
case 737: return 'CP737'; break; // OEM Greek
|
case 720:
|
||||||
case 775: return 'CP775'; break; // OEM Baltic
|
throw new PHPExcel_Exception('Code page 720 not supported.'); // OEM Arabic
|
||||||
case 850: return 'CP850'; break; // OEM Latin I
|
case 737:
|
||||||
case 852: return 'CP852'; break; // OEM Latin II (Central European)
|
return 'CP737'; // OEM Greek
|
||||||
case 855: return 'CP855'; break; // OEM Cyrillic
|
case 775:
|
||||||
case 857: return 'CP857'; break; // OEM Turkish
|
return 'CP775'; // OEM Baltic
|
||||||
case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro
|
case 850:
|
||||||
case 860: return 'CP860'; break; // OEM Portugese
|
return 'CP850'; // OEM Latin I
|
||||||
case 861: return 'CP861'; break; // OEM Icelandic
|
case 852:
|
||||||
case 862: return 'CP862'; break; // OEM Hebrew
|
return 'CP852'; // OEM Latin II (Central European)
|
||||||
case 863: return 'CP863'; break; // OEM Canadian (French)
|
case 855:
|
||||||
case 864: return 'CP864'; break; // OEM Arabic
|
return 'CP855'; // OEM Cyrillic
|
||||||
case 865: return 'CP865'; break; // OEM Nordic
|
case 857:
|
||||||
case 866: return 'CP866'; break; // OEM Cyrillic (Russian)
|
return 'CP857'; // OEM Turkish
|
||||||
case 869: return 'CP869'; break; // OEM Greek (Modern)
|
case 858:
|
||||||
case 874: return 'CP874'; break; // ANSI Thai
|
return 'CP858'; // OEM Multilingual Latin I with Euro
|
||||||
case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS
|
case 860:
|
||||||
case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK
|
return 'CP860'; // OEM Portugese
|
||||||
case 949: return 'CP949'; break; // ANSI Korean (Wansung)
|
case 861:
|
||||||
case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5
|
return 'CP861'; // OEM Icelandic
|
||||||
case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8)
|
case 862:
|
||||||
case 1250: return 'CP1250'; break; // ANSI Latin II (Central European)
|
return 'CP862'; // OEM Hebrew
|
||||||
case 1251: return 'CP1251'; break; // ANSI Cyrillic
|
case 863:
|
||||||
case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
|
return 'CP863'; // OEM Canadian (French)
|
||||||
case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7)
|
case 864:
|
||||||
case 1253: return 'CP1253'; break; // ANSI Greek
|
return 'CP864'; // OEM Arabic
|
||||||
case 1254: return 'CP1254'; break; // ANSI Turkish
|
case 865:
|
||||||
case 1255: return 'CP1255'; break; // ANSI Hebrew
|
return 'CP865'; // OEM Nordic
|
||||||
case 1256: return 'CP1256'; break; // ANSI Arabic
|
case 866:
|
||||||
case 1257: return 'CP1257'; break; // ANSI Baltic
|
return 'CP866'; // OEM Cyrillic (Russian)
|
||||||
case 1258: return 'CP1258'; break; // ANSI Vietnamese
|
case 869:
|
||||||
case 1361: return 'CP1361'; break; // ANSI Korean (Johab)
|
return 'CP869'; // OEM Greek (Modern)
|
||||||
case 10000: return 'MAC'; break; // Apple Roman
|
case 874:
|
||||||
case 10001: return 'CP932'; break; // Macintosh Japanese
|
return 'CP874'; // ANSI Thai
|
||||||
case 10002: return 'CP950'; break; // Macintosh Chinese Traditional
|
case 932:
|
||||||
case 10003: return 'CP1361'; break; // Macintosh Korean
|
return 'CP932'; // ANSI Japanese Shift-JIS
|
||||||
case 10006: return 'MACGREEK'; break; // Macintosh Greek
|
case 936:
|
||||||
case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic
|
return 'CP936'; // ANSI Chinese Simplified GBK
|
||||||
case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312)
|
case 949:
|
||||||
case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe
|
return 'CP949'; // ANSI Korean (Wansung)
|
||||||
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
|
case 950:
|
||||||
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
|
return 'CP950'; // ANSI Chinese Traditional BIG5
|
||||||
case 21010: return 'UTF-16LE'; break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
|
case 1200:
|
||||||
case 32768: return 'MAC'; break; // Apple Roman
|
return 'UTF-16LE'; // UTF-16 (BIFF8)
|
||||||
case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.');
|
case 1250:
|
||||||
break; // ANSI Latin I (BIFF2-BIFF3)
|
return 'CP1250'; // ANSI Latin II (Central European)
|
||||||
case 65000: return 'UTF-7'; break; // Unicode (UTF-7)
|
case 1251:
|
||||||
case 65001: return 'UTF-8'; break; // Unicode (UTF-8)
|
return 'CP1251'; // ANSI Cyrillic
|
||||||
}
|
case 0:
|
||||||
|
// CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
|
||||||
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
|
case 1252:
|
||||||
}
|
return 'CP1252'; // ANSI Latin I (BIFF4-BIFF7)
|
||||||
|
case 1253:
|
||||||
|
return 'CP1253'; // ANSI Greek
|
||||||
|
case 1254:
|
||||||
|
return 'CP1254'; // ANSI Turkish
|
||||||
|
case 1255:
|
||||||
|
return 'CP1255'; // ANSI Hebrew
|
||||||
|
case 1256:
|
||||||
|
return 'CP1256'; // ANSI Arabic
|
||||||
|
case 1257:
|
||||||
|
return 'CP1257'; // ANSI Baltic
|
||||||
|
case 1258:
|
||||||
|
return 'CP1258'; // ANSI Vietnamese
|
||||||
|
case 1361:
|
||||||
|
return 'CP1361'; // ANSI Korean (Johab)
|
||||||
|
case 10000:
|
||||||
|
return 'MAC'; // Apple Roman
|
||||||
|
case 10001:
|
||||||
|
return 'CP932'; // Macintosh Japanese
|
||||||
|
case 10002:
|
||||||
|
return 'CP950'; // Macintosh Chinese Traditional
|
||||||
|
case 10003:
|
||||||
|
return 'CP1361'; // Macintosh Korean
|
||||||
|
case 10004:
|
||||||
|
return 'MACARABIC'; // Apple Arabic
|
||||||
|
case 10005:
|
||||||
|
return 'MACHEBREW'; // Apple Hebrew
|
||||||
|
case 10006:
|
||||||
|
return 'MACGREEK'; // Macintosh Greek
|
||||||
|
case 10007:
|
||||||
|
return 'MACCYRILLIC'; // Macintosh Cyrillic
|
||||||
|
case 10008:
|
||||||
|
return 'CP936'; // Macintosh - Simplified Chinese (GB 2312)
|
||||||
|
case 10010:
|
||||||
|
return 'MACROMANIA'; // Macintosh Romania
|
||||||
|
case 10017:
|
||||||
|
return 'MACUKRAINE'; // Macintosh Ukraine
|
||||||
|
case 10021:
|
||||||
|
return 'MACTHAI'; // Macintosh Thai
|
||||||
|
case 10029:
|
||||||
|
return 'MACCENTRALEUROPE'; // Macintosh Central Europe
|
||||||
|
case 10079:
|
||||||
|
return 'MACICELAND'; // Macintosh Icelandic
|
||||||
|
case 10081:
|
||||||
|
return 'MACTURKISH'; // Macintosh Turkish
|
||||||
|
case 10082:
|
||||||
|
return 'MACCROATIAN'; // Macintosh Croatian
|
||||||
|
case 21010:
|
||||||
|
return 'UTF-16LE'; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
|
||||||
|
case 32768:
|
||||||
|
return 'MAC'; // Apple Roman
|
||||||
|
case 32769:
|
||||||
|
throw new PHPExcel_Exception('Code page 32769 not supported.'); // ANSI Latin I (BIFF2-BIFF3)
|
||||||
|
case 65000:
|
||||||
|
return 'UTF-7'; // Unicode (UTF-7)
|
||||||
|
case 65001:
|
||||||
|
return 'UTF-8'; // Unicode (UTF-8)
|
||||||
|
}
|
||||||
|
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Shared_Date
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,360 +20,379 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Shared
|
* @package PHPExcel_Shared
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Shared_Date
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Shared
|
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Shared_Date
|
class PHPExcel_Shared_Date
|
||||||
{
|
{
|
||||||
/** constants */
|
/** constants */
|
||||||
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
|
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
|
||||||
const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 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
|
* Names of the months of the year, indexed by shortname
|
||||||
* Planned usage for locale settings
|
* Planned usage for locale settings
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public static $_monthNames = array( 'Jan' => 'January',
|
public static $monthNames = array(
|
||||||
'Feb' => 'February',
|
'Jan' => 'January',
|
||||||
'Mar' => 'March',
|
'Feb' => 'February',
|
||||||
'Apr' => 'April',
|
'Mar' => 'March',
|
||||||
'May' => 'May',
|
'Apr' => 'April',
|
||||||
'Jun' => 'June',
|
'May' => 'May',
|
||||||
'Jul' => 'July',
|
'Jun' => 'June',
|
||||||
'Aug' => 'August',
|
'Jul' => 'July',
|
||||||
'Sep' => 'September',
|
'Aug' => 'August',
|
||||||
'Oct' => 'October',
|
'Sep' => 'September',
|
||||||
'Nov' => 'November',
|
'Oct' => 'October',
|
||||||
'Dec' => 'December',
|
'Nov' => 'November',
|
||||||
);
|
'Dec' => 'December',
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Names of the months of the year, indexed by shortname
|
* Names of the months of the year, indexed by shortname
|
||||||
* Planned usage for locale settings
|
* Planned usage for locale settings
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public static $_numberSuffixes = array( 'st',
|
public static $numberSuffixes = array(
|
||||||
'nd',
|
'st',
|
||||||
'rd',
|
'nd',
|
||||||
'th',
|
'rd',
|
||||||
);
|
'th',
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Base calendar year to use for calculations
|
* Base calendar year to use for calculations
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected static $_excelBaseDate = self::CALENDAR_WINDOWS_1900;
|
protected static $excelBaseDate = self::CALENDAR_WINDOWS_1900;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Excel calendar (Windows 1900 or Mac 1904)
|
* Set the Excel calendar (Windows 1900 or Mac 1904)
|
||||||
*
|
*
|
||||||
* @param integer $baseDate Excel base date (1900 or 1904)
|
* @param integer $baseDate Excel base date (1900 or 1904)
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setExcelCalendar($baseDate) {
|
public static function setExcelCalendar($baseDate)
|
||||||
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
|
{
|
||||||
($baseDate == self::CALENDAR_MAC_1904)) {
|
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
|
||||||
self::$_excelBaseDate = $baseDate;
|
($baseDate == self::CALENDAR_MAC_1904)) {
|
||||||
return TRUE;
|
self::$excelBaseDate = $baseDate;
|
||||||
}
|
return true;
|
||||||
return FALSE;
|
}
|
||||||
} // function setExcelCalendar()
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Excel calendar (Windows 1900 or Mac 1904)
|
* Return the Excel calendar (Windows 1900 or Mac 1904)
|
||||||
*
|
*
|
||||||
* @return integer Excel base date (1900 or 1904)
|
* @return integer Excel base date (1900 or 1904)
|
||||||
*/
|
*/
|
||||||
public static function getExcelCalendar() {
|
public static function getExcelCalendar()
|
||||||
return self::$_excelBaseDate;
|
{
|
||||||
} // function getExcelCalendar()
|
return self::$excelBaseDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a date from Excel to PHP
|
* Convert a date from Excel to PHP
|
||||||
*
|
*
|
||||||
* @param long $dateValue Excel date/time value
|
* @param integer $dateValue Excel date/time value
|
||||||
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
|
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
|
||||||
* a UST timestamp, or adjusted to UST
|
* a UST timestamp, or adjusted to UST
|
||||||
* @param string $timezone The timezone for finding the adjustment from UST
|
* @param string $timezone The timezone for finding the adjustment from UST
|
||||||
* @return long PHP serialized date/time
|
* @return integer PHP serialized date/time
|
||||||
*/
|
*/
|
||||||
public static function ExcelToPHP($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
|
public static function ExcelToPHP($dateValue = 0, $adjustToTimezone = false, $timezone = null)
|
||||||
if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {
|
{
|
||||||
$my_excelBaseDate = 25569;
|
if (self::$excelBaseDate == self::CALENDAR_WINDOWS_1900) {
|
||||||
// Adjust for the spurious 29-Feb-1900 (Day 60)
|
$myexcelBaseDate = 25569;
|
||||||
if ($dateValue < 60) {
|
// Adjust for the spurious 29-Feb-1900 (Day 60)
|
||||||
--$my_excelBaseDate;
|
if ($dateValue < 60) {
|
||||||
}
|
--$myexcelBaseDate;
|
||||||
} else {
|
}
|
||||||
$my_excelBaseDate = 24107;
|
} else {
|
||||||
}
|
$myexcelBaseDate = 24107;
|
||||||
|
}
|
||||||
|
|
||||||
// Perform conversion
|
// Perform conversion
|
||||||
if ($dateValue >= 1) {
|
if ($dateValue >= 1) {
|
||||||
$utcDays = $dateValue - $my_excelBaseDate;
|
$utcDays = $dateValue - $myexcelBaseDate;
|
||||||
$returnValue = round($utcDays * 86400);
|
$returnValue = round($utcDays * 86400);
|
||||||
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
|
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
|
||||||
$returnValue = (integer) $returnValue;
|
$returnValue = (integer) $returnValue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$hours = round($dateValue * 24);
|
$hours = round($dateValue * 24);
|
||||||
$mins = round($dateValue * 1440) - round($hours * 60);
|
$mins = round($dateValue * 1440) - round($hours * 60);
|
||||||
$secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
|
$secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
|
||||||
$returnValue = (integer) gmmktime($hours, $mins, $secs);
|
$returnValue = (integer) gmmktime($hours, $mins, $secs);
|
||||||
}
|
}
|
||||||
|
|
||||||
$timezoneAdjustment = ($adjustToTimezone) ?
|
$timezoneAdjustment = ($adjustToTimezone) ?
|
||||||
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) :
|
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) :
|
||||||
0;
|
0;
|
||||||
|
|
||||||
// Return
|
return $returnValue + $timezoneAdjustment;
|
||||||
return $returnValue + $timezoneAdjustment;
|
}
|
||||||
} // function ExcelToPHP()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a date from Excel to a PHP Date/Time object
|
* Convert a date from Excel to a PHP Date/Time object
|
||||||
*
|
*
|
||||||
* @param integer $dateValue Excel date/time value
|
* @param integer $dateValue Excel date/time value
|
||||||
* @return DateTime PHP date/time object
|
* @return DateTime PHP date/time object
|
||||||
*/
|
*/
|
||||||
public static function ExcelToPHPObject($dateValue = 0) {
|
public static function ExcelToPHPObject($dateValue = 0)
|
||||||
$dateTime = self::ExcelToPHP($dateValue);
|
{
|
||||||
$days = floor($dateTime / 86400);
|
$dateTime = self::ExcelToPHP($dateValue);
|
||||||
$time = round((($dateTime / 86400) - $days) * 86400);
|
$days = floor($dateTime / 86400);
|
||||||
$hours = round($time / 3600);
|
$time = round((($dateTime / 86400) - $days) * 86400);
|
||||||
$minutes = round($time / 60) - ($hours * 60);
|
$hours = round($time / 3600);
|
||||||
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
|
$minutes = round($time / 60) - ($hours * 60);
|
||||||
|
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
|
||||||
|
|
||||||
$dateObj = date_create('1-Jan-1970+'.$days.' days');
|
$dateObj = date_create('1-Jan-1970+'.$days.' days');
|
||||||
$dateObj->setTime($hours,$minutes,$seconds);
|
$dateObj->setTime($hours, $minutes, $seconds);
|
||||||
|
|
||||||
return $dateObj;
|
return $dateObj;
|
||||||
} // function ExcelToPHPObject()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a date from PHP to Excel
|
* Convert a date from PHP to Excel
|
||||||
*
|
*
|
||||||
* @param mixed $dateValue PHP serialized date/time or date object
|
* @param mixed $dateValue PHP serialized date/time or date object
|
||||||
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
|
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
|
||||||
* a UST timestamp, or adjusted to UST
|
* a UST timestamp, or adjusted to UST
|
||||||
* @param string $timezone The timezone for finding the adjustment from UST
|
* @param string $timezone The timezone for finding the adjustment from UST
|
||||||
* @return mixed Excel date/time value
|
* @return mixed Excel date/time value
|
||||||
* or boolean FALSE on failure
|
* or boolean FALSE on failure
|
||||||
*/
|
*/
|
||||||
public static function PHPToExcel($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
|
public static function PHPToExcel($dateValue = 0, $adjustToTimezone = false, $timezone = null)
|
||||||
$saveTimeZone = date_default_timezone_get();
|
{
|
||||||
date_default_timezone_set('UTC');
|
$saveTimeZone = date_default_timezone_get();
|
||||||
$retValue = FALSE;
|
date_default_timezone_set('UTC');
|
||||||
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;
|
$timezoneAdjustment = ($adjustToTimezone) ?
|
||||||
} // function PHPToExcel()
|
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone ? $timezone : $saveTimeZone, $dateValue) :
|
||||||
|
0;
|
||||||
|
|
||||||
|
$retValue = false;
|
||||||
|
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
|
||||||
|
$dateValue->add(new DateInterval('PT' . $timezoneAdjustment . 'S'));
|
||||||
|
$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)) {
|
||||||
|
$dateValue += $timezoneAdjustment;
|
||||||
|
$retValue = self::FormattedPHPToExcel(date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), date('H', $dateValue), date('i', $dateValue), date('s', $dateValue));
|
||||||
|
} elseif (is_string($dateValue)) {
|
||||||
|
$retValue = self::stringToExcel($dateValue);
|
||||||
|
}
|
||||||
|
date_default_timezone_set($saveTimeZone);
|
||||||
|
|
||||||
|
return $retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FormattedPHPToExcel
|
* FormattedPHPToExcel
|
||||||
*
|
*
|
||||||
* @param long $year
|
* @param integer $year
|
||||||
* @param long $month
|
* @param integer $month
|
||||||
* @param long $day
|
* @param integer $day
|
||||||
* @param long $hours
|
* @param integer $hours
|
||||||
* @param long $minutes
|
* @param integer $minutes
|
||||||
* @param long $seconds
|
* @param integer $seconds
|
||||||
* @return long Excel date/time value
|
* @return integer Excel date/time value
|
||||||
*/
|
*/
|
||||||
public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) {
|
public static function FormattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0)
|
||||||
if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {
|
{
|
||||||
//
|
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
|
// 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; }
|
$excel1900isLeapYear = true;
|
||||||
$my_excelBaseDate = 2415020;
|
if (($year == 1900) && ($month <= 2)) {
|
||||||
} else {
|
$excel1900isLeapYear = false;
|
||||||
$my_excelBaseDate = 2416481;
|
}
|
||||||
$excel1900isLeapYear = FALSE;
|
$myexcelBaseDate = 2415020;
|
||||||
}
|
} else {
|
||||||
|
$myexcelBaseDate = 2416481;
|
||||||
|
$excel1900isLeapYear = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Julian base date Adjustment
|
// Julian base date Adjustment
|
||||||
if ($month > 2) {
|
if ($month > 2) {
|
||||||
$month -= 3;
|
$month -= 3;
|
||||||
} else {
|
} else {
|
||||||
$month += 9;
|
$month += 9;
|
||||||
--$year;
|
--$year;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0)
|
// 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);
|
$century = substr($year, 0, 2);
|
||||||
$decade = substr($year,2,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;
|
$excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $myexcelBaseDate + $excel1900isLeapYear;
|
||||||
|
|
||||||
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
|
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
|
||||||
|
|
||||||
return (float) $excelDate + $excelTime;
|
return (float) $excelDate + $excelTime;
|
||||||
} // function FormattedPHPToExcel()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a given cell a date/time?
|
* Is a given cell a date/time?
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Cell $pCell
|
* @param PHPExcel_Cell $pCell
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function isDateTime(PHPExcel_Cell $pCell) {
|
public static function isDateTime(PHPExcel_Cell $pCell)
|
||||||
return self::isDateTimeFormat(
|
{
|
||||||
$pCell->getWorksheet()->getStyle(
|
return self::isDateTimeFormat(
|
||||||
$pCell->getCoordinate()
|
$pCell->getWorksheet()->getStyle(
|
||||||
)->getNumberFormat()
|
$pCell->getCoordinate()
|
||||||
);
|
)->getNumberFormat()
|
||||||
} // function isDateTime()
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a given number format a date/time?
|
* Is a given number format a date/time?
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Style_NumberFormat $pFormat
|
* @param PHPExcel_Style_NumberFormat $pFormat
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat) {
|
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat)
|
||||||
return self::isDateTimeFormatCode($pFormat->getFormatCode());
|
{
|
||||||
} // function isDateTimeFormat()
|
return self::isDateTimeFormatCode($pFormat->getFormatCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static $possibleDateFormatCharacters = 'eymdHs';
|
private static $possibleDateFormatCharacters = 'eymdHs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a given number format code a date/time?
|
* Is a given number format code a date/time?
|
||||||
*
|
*
|
||||||
* @param string $pFormatCode
|
* @param string $pFormatCode
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function isDateTimeFormatCode($pFormatCode = '') {
|
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)
|
if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL)) {
|
||||||
return FALSE;
|
// "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check)
|
||||||
if (preg_match('/[0#]E[+-]0/i', $pFormatCode))
|
return false;
|
||||||
// Scientific format
|
}
|
||||||
return FALSE;
|
if (preg_match('/[0#]E[+-]0/i', $pFormatCode)) {
|
||||||
// Switch on formatcode
|
// Scientific format
|
||||||
switch ($pFormatCode) {
|
return false;
|
||||||
// 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
|
// Switch on formatcode
|
||||||
if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) {
|
switch ($pFormatCode) {
|
||||||
return FALSE;
|
// Explicitly defined date formats
|
||||||
}
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD:
|
||||||
// Try checking for any of the date formatting characters that don't appear within square braces
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
|
||||||
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
|
||||||
// We might also have a format mask containing quoted strings...
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH:
|
||||||
// we don't want to test for any of our characters within the quoted blocks
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS:
|
||||||
if (strpos($pFormatCode,'"') !== FALSE) {
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS:
|
||||||
$segMatcher = FALSE;
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS:
|
||||||
foreach(explode('"',$pFormatCode) as $subVal) {
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME:
|
||||||
// Only test in alternate array entries (the non-quoted blocks)
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1:
|
||||||
if (($segMatcher = !$segMatcher) &&
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2:
|
||||||
(preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) {
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3:
|
||||||
return TRUE;
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4:
|
||||||
}
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5:
|
||||||
}
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6:
|
||||||
return FALSE;
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7:
|
||||||
}
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8:
|
||||||
return TRUE;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// No date...
|
// Typically number, currency or accounting (or occasionally fraction) formats
|
||||||
return FALSE;
|
if ((substr($pFormatCode, 0, 1) == '_') || (substr($pFormatCode, 0, 2) == '0 ')) {
|
||||||
} // function isDateTimeFormatCode()
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a date/time string to Excel time
|
* 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'
|
* @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
|
* @return float|FALSE Excel date/time serial value
|
||||||
*/
|
*/
|
||||||
public static function stringToExcel($dateValue = '') {
|
public static function stringToExcel($dateValue = '')
|
||||||
if (strlen($dateValue) < 2)
|
{
|
||||||
return FALSE;
|
if (strlen($dateValue) < 2) {
|
||||||
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue))
|
return false;
|
||||||
return FALSE;
|
}
|
||||||
|
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);
|
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
|
||||||
|
|
||||||
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
|
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
|
||||||
return FALSE;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (strpos($dateValue, ':') !== false) {
|
||||||
|
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
|
||||||
|
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$dateValueNew += $timeValue;
|
||||||
|
}
|
||||||
|
return $dateValueNew;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* Converts a month name (either a long or a short name) to a month number
|
||||||
public static function monthStringToNumber($month) {
|
*
|
||||||
|
* @param string $month Month name or abbreviation
|
||||||
|
* @return integer|string Month number (1 - 12), or the original string argument if it isn't a valid month name
|
||||||
|
*/
|
||||||
|
public static function monthStringToNumber($month)
|
||||||
|
{
|
||||||
$monthIndex = 1;
|
$monthIndex = 1;
|
||||||
foreach(self::$_monthNames as $shortMonthName => $longMonthName) {
|
foreach (self::$monthNames as $shortMonthName => $longMonthName) {
|
||||||
if (($month === $longMonthName) || ($month === $shortMonthName)) {
|
if (($month === $longMonthName) || ($month === $shortMonthName)) {
|
||||||
return $monthIndex;
|
return $monthIndex;
|
||||||
}
|
}
|
||||||
|
@ -382,12 +401,18 @@ class PHPExcel_Shared_Date
|
||||||
return $month;
|
return $month;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function dayStringToNumber($day) {
|
/**
|
||||||
$strippedDayValue = (str_replace(self::$_numberSuffixes,'',$day));
|
* Strips an ordinal froma numeric value
|
||||||
if (is_numeric($strippedDayValue)) {
|
*
|
||||||
return $strippedDayValue;
|
* @param string $day Day number with an ordinal
|
||||||
}
|
* @return integer|string The integer value with any ordinal stripped, or the original string argument if it isn't a valid numeric
|
||||||
return $day;
|
*/
|
||||||
|
public static function dayStringToNumber($day)
|
||||||
|
{
|
||||||
|
$strippedDayValue = (str_replace(self::$numberSuffixes, '', $day));
|
||||||
|
if (is_numeric($strippedDayValue)) {
|
||||||
|
return (integer) $strippedDayValue;
|
||||||
|
}
|
||||||
|
return $day;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2014 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,8 +20,8 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Shared
|
* @package PHPExcel_Shared
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -31,242 +31,240 @@
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Shared
|
* @package PHPExcel_Shared
|
||||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Shared_Drawing
|
class PHPExcel_Shared_Drawing
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Convert pixels to EMU
|
* Convert pixels to EMU
|
||||||
*
|
*
|
||||||
* @param int $pValue Value in pixels
|
* @param int $pValue Value in pixels
|
||||||
* @return int Value in EMU
|
* @return int Value in EMU
|
||||||
*/
|
*/
|
||||||
public static function pixelsToEMU($pValue = 0) {
|
public static function pixelsToEMU($pValue = 0)
|
||||||
return round($pValue * 9525);
|
{
|
||||||
}
|
return round($pValue * 9525);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert EMU to pixels
|
* Convert EMU to pixels
|
||||||
*
|
*
|
||||||
* @param int $pValue Value in EMU
|
* @param int $pValue Value in EMU
|
||||||
* @return int Value in pixels
|
* @return int Value in pixels
|
||||||
*/
|
*/
|
||||||
public static function EMUToPixels($pValue = 0) {
|
public static function EMUToPixels($pValue = 0)
|
||||||
if ($pValue != 0) {
|
{
|
||||||
return round($pValue / 9525);
|
if ($pValue != 0) {
|
||||||
} else {
|
return round($pValue / 9525);
|
||||||
return 0;
|
} else {
|
||||||
}
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert pixels to column width. Exact algorithm not known.
|
* Convert pixels to column width. Exact algorithm not known.
|
||||||
* By inspection of a real Excel file using Calibri 11, one finds 1000px ~ 142.85546875
|
* 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.
|
* This gives a conversion factor of 7. Also, we assume that pixels and font size are proportional.
|
||||||
*
|
*
|
||||||
* @param int $pValue Value in pixels
|
* @param int $pValue Value in pixels
|
||||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||||
* @return int Value in cell dimension
|
* @return int Value in cell dimension
|
||||||
*/
|
*/
|
||||||
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont)
|
||||||
// Font name and size
|
{
|
||||||
$name = $pDefaultFont->getName();
|
// Font name and size
|
||||||
$size = $pDefaultFont->getSize();
|
$name = $pDefaultFont->getName();
|
||||||
|
$size = $pDefaultFont->getSize();
|
||||||
|
|
||||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||||
// Exact width can be determined
|
// Exact width can be determined
|
||||||
$colWidth = $pValue
|
$colWidth = $pValue * PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'] / PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
|
||||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width']
|
} else {
|
||||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
|
// We don't have data for this particular font and size, use approximation by
|
||||||
} else {
|
// extrapolating from Calibri 11
|
||||||
// We don't have data for this particular font and size, use approximation by
|
$colWidth = $pValue * 11 * PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
|
||||||
// extrapolating from Calibri 11
|
}
|
||||||
$colWidth = $pValue * 11
|
|
||||||
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width']
|
|
||||||
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $colWidth;
|
return $colWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert column width from (intrinsic) Excel units to pixels
|
* Convert column width from (intrinsic) Excel units to pixels
|
||||||
*
|
*
|
||||||
* @param float $pValue Value in cell dimension
|
* @param float $pValue Value in cell dimension
|
||||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||||
* @return int Value in pixels
|
* @return int Value in pixels
|
||||||
*/
|
*/
|
||||||
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont)
|
||||||
// Font name and size
|
{
|
||||||
$name = $pDefaultFont->getName();
|
// Font name and size
|
||||||
$size = $pDefaultFont->getSize();
|
$name = $pDefaultFont->getName();
|
||||||
|
$size = $pDefaultFont->getSize();
|
||||||
|
|
||||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||||
// Exact width can be determined
|
// Exact width can be determined
|
||||||
$colWidth = $pValue
|
$colWidth = $pValue * PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'] / PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
|
||||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px']
|
} else {
|
||||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
// Round pixels to closest integer
|
||||||
// We don't have data for this particular font and size, use approximation by
|
$colWidth = (int) round($colWidth);
|
||||||
// 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
|
return $colWidth;
|
||||||
$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 pixels to points
|
* Convert points to pixels
|
||||||
*
|
*
|
||||||
* @param int $pValue Value in pixels
|
* @param int $pValue Value in points
|
||||||
* @return int Value in points
|
* @return int Value in pixels
|
||||||
*/
|
*/
|
||||||
public static function pixelsToPoints($pValue = 0) {
|
public static function pointsToPixels($pValue = 0)
|
||||||
return $pValue * 0.67777777;
|
{
|
||||||
}
|
if ($pValue != 0) {
|
||||||
|
return (int) ceil($pValue * 1.333333333);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert points to pixels
|
* Convert degrees to angle
|
||||||
*
|
*
|
||||||
* @param int $pValue Value in points
|
* @param int $pValue Degrees
|
||||||
* @return int Value in pixels
|
* @return int Angle
|
||||||
*/
|
*/
|
||||||
public static function pointsToPixels($pValue = 0) {
|
public static function degreesToAngle($pValue = 0)
|
||||||
if ($pValue != 0) {
|
{
|
||||||
return (int) ceil($pValue * 1.333333333);
|
return (int)round($pValue * 60000);
|
||||||
} else {
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert degrees to angle
|
* Convert angle to degrees
|
||||||
*
|
*
|
||||||
* @param int $pValue Degrees
|
* @param int $pValue Angle
|
||||||
* @return int Angle
|
* @return int Degrees
|
||||||
*/
|
*/
|
||||||
public static function degreesToAngle($pValue = 0) {
|
public static function angleToDegrees($pValue = 0)
|
||||||
return (int)round($pValue * 60000);
|
{
|
||||||
}
|
if ($pValue != 0) {
|
||||||
|
return round($pValue / 60000);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert angle to degrees
|
* Create a new image from file. By alexander at alexauto dot nl
|
||||||
*
|
*
|
||||||
* @param int $pValue Angle
|
* @link http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
|
||||||
* @return int Degrees
|
* @param string $filename Path to Windows DIB (BMP) image
|
||||||
*/
|
* @return resource
|
||||||
public static function angleToDegrees($pValue = 0) {
|
*/
|
||||||
if ($pValue != 0) {
|
public static function imagecreatefrombmp($p_sFile)
|
||||||
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
|
// Load the image into a string
|
||||||
$file = fopen($p_sFile,"rb");
|
$file = fopen($p_sFile, "rb");
|
||||||
$read = fread($file,10);
|
$read = fread($file, 10);
|
||||||
while(!feof($file)&&($read<>""))
|
while (!feof($file) && ($read<>"")) {
|
||||||
$read .= fread($file,1024);
|
$read .= fread($file, 1024);
|
||||||
|
}
|
||||||
|
|
||||||
$temp = unpack("H*",$read);
|
$temp = unpack("H*", $read);
|
||||||
$hex = $temp[1];
|
$hex = $temp[1];
|
||||||
$header = substr($hex,0,108);
|
$header = substr($hex, 0, 108);
|
||||||
|
|
||||||
// Process the header
|
// Process the header
|
||||||
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
|
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
|
||||||
if (substr($header,0,4)=="424d")
|
if (substr($header, 0, 4)=="424d") {
|
||||||
{
|
|
||||||
// Cut it in parts of 2 bytes
|
// Cut it in parts of 2 bytes
|
||||||
$header_parts = str_split($header,2);
|
$header_parts = str_split($header, 2);
|
||||||
|
|
||||||
// Get the width 4 bytes
|
// Get the width 4 bytes
|
||||||
$width = hexdec($header_parts[19].$header_parts[18]);
|
$width = hexdec($header_parts[19].$header_parts[18]);
|
||||||
|
|
||||||
// Get the height 4 bytes
|
// Get the height 4 bytes
|
||||||
$height = hexdec($header_parts[23].$header_parts[22]);
|
$height = hexdec($header_parts[23].$header_parts[22]);
|
||||||
|
|
||||||
// Unset the header params
|
// Unset the header params
|
||||||
unset($header_parts);
|
unset($header_parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define starting X and Y
|
// Define starting X and Y
|
||||||
$x = 0;
|
$x = 0;
|
||||||
$y = 1;
|
$y = 1;
|
||||||
|
|
||||||
// Create newimage
|
// Create newimage
|
||||||
$image = imagecreatetruecolor($width,$height);
|
$image = imagecreatetruecolor($width, $height);
|
||||||
|
|
||||||
// Grab the body from the image
|
// Grab the body from the image
|
||||||
$body = substr($hex,108);
|
$body = substr($hex, 108);
|
||||||
|
|
||||||
// Calculate if padding at the end-line is needed
|
// Calculate if padding at the end-line is needed
|
||||||
// Divided by two to keep overview.
|
// Divided by two to keep overview.
|
||||||
// 1 byte = 2 HEX-chars
|
// 1 byte = 2 HEX-chars
|
||||||
$body_size = (strlen($body)/2);
|
$body_size = (strlen($body)/2);
|
||||||
$header_size = ($width*$height);
|
$header_size = ($width*$height);
|
||||||
|
|
||||||
// Use end-line padding? Only when needed
|
// Use end-line padding? Only when needed
|
||||||
$usePadding = ($body_size>($header_size*3)+4);
|
$usePadding = ($body_size>($header_size*3)+4);
|
||||||
|
|
||||||
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
|
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
|
||||||
// Calculate the next DWORD-position in the body
|
// Calculate the next DWORD-position in the body
|
||||||
for ($i=0;$i<$body_size;$i+=3)
|
for ($i = 0; $i < $body_size; $i += 3) {
|
||||||
{
|
|
||||||
// Calculate line-ending and padding
|
// Calculate line-ending and padding
|
||||||
if ($x>=$width)
|
if ($x >= $width) {
|
||||||
{
|
// If padding needed, ignore image-padding
|
||||||
// If padding needed, ignore image-padding
|
// Shift i to the ending of the current 32-bit-block
|
||||||
// Shift i to the ending of the current 32-bit-block
|
if ($usePadding) {
|
||||||
if ($usePadding)
|
$i += $width%4;
|
||||||
$i += $width%4;
|
}
|
||||||
|
|
||||||
// Reset horizontal position
|
// Reset horizontal position
|
||||||
$x = 0;
|
$x = 0;
|
||||||
|
|
||||||
// Raise the height-position (bottom-up)
|
// Raise the height-position (bottom-up)
|
||||||
$y++;
|
$y++;
|
||||||
|
|
||||||
// Reached the image-height? Break the for-loop
|
// Reached the image-height? Break the for-loop
|
||||||
if ($y>$height)
|
if ($y > $height) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculation of the RGB-pixel (defined as BGR in image-data)
|
// Calculation of the RGB-pixel (defined as BGR in image-data)
|
||||||
// Define $i_pos as absolute position in the body
|
// Define $i_pos as absolute position in the body
|
||||||
$i_pos = $i*2;
|
$i_pos = $i * 2;
|
||||||
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
|
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
|
||||||
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
|
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
|
||||||
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
|
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
|
||||||
|
|
||||||
// Calculate and draw the pixel
|
// Calculate and draw the pixel
|
||||||
$color = imagecolorallocate($image,$r,$g,$b);
|
$color = imagecolorallocate($image, $r, $g, $b);
|
||||||
imagesetpixel($image,$x,$height-$y,$color);
|
imagesetpixel($image, $x, $height-$y, $color);
|
||||||
|
|
||||||
// Raise the horizontal position
|
// Raise the horizontal position
|
||||||
$x++;
|
$x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unset the body / free the memory
|
// Unset the body / free the memory
|
||||||
unset($body);
|
unset($body);
|
||||||
|
|
||||||
// Return image-object
|
// Return image-object
|
||||||
return $image;
|
return $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue