Introduce PHP-CS-Fixer for stricter code style rules
PHP-CS-Fixer allow to check different things than phpcs and it allows code to be more consistent. Configuration can be changed in `.php_cs`
This commit is contained in:
parent
685e29d8ff
commit
09d456e477
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
||||
->exclude('vendor')
|
||||
->in('src')
|
||||
->in('tests');
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->level(Symfony\CS\FixerInterface::NONE_LEVEL)
|
||||
->fixers([
|
||||
// 'align_double_arrow', // Waste of time
|
||||
// 'align_equals', // Waste of time
|
||||
'array_element_no_space_before_comma',
|
||||
'array_element_white_space_after_comma',
|
||||
'blankline_after_open_tag',
|
||||
'braces',
|
||||
// 'concat_without_spaces', // This make it less readable
|
||||
'concat_with_spaces',
|
||||
'double_arrow_multiline_whitespaces',
|
||||
'duplicate_semicolon',
|
||||
// 'echo_to_print', // We prefer echo
|
||||
'elseif',
|
||||
// 'empty_return', // even if technically useless, we prefer to be explicit with our intent to return null
|
||||
'encoding',
|
||||
'eof_ending',
|
||||
'ereg_to_preg',
|
||||
'extra_empty_lines',
|
||||
'function_call_space',
|
||||
'function_declaration',
|
||||
'function_typehint_space',
|
||||
// 'header_comment', // We don't use common header in all our files
|
||||
'include',
|
||||
'indentation',
|
||||
'join_function',
|
||||
'line_after_namespace',
|
||||
'linefeed',
|
||||
'list_commas',
|
||||
// 'logical_not_operators_with_spaces', // No we prefer to keep "!" without spaces
|
||||
// 'logical_not_operators_with_successor_space', // idem
|
||||
// 'long_array_syntax', // We opted in for the short syntax
|
||||
'lowercase_constants',
|
||||
'lowercase_keywords',
|
||||
'method_argument_space',
|
||||
'multiline_array_trailing_comma',
|
||||
'multiline_spaces_before_semicolon',
|
||||
'multiple_use',
|
||||
'namespace_no_leading_whitespace',
|
||||
'newline_after_open_tag',
|
||||
'new_with_braces',
|
||||
'no_blank_lines_after_class_opening',
|
||||
// 'no_blank_lines_before_namespace', // we want 1 blank line before namespace
|
||||
'no_empty_lines_after_phpdocs',
|
||||
'object_operator',
|
||||
'operators_spaces',
|
||||
'ordered_use',
|
||||
'parenthesis',
|
||||
'php4_constructor',
|
||||
'php_closing_tag',
|
||||
'phpdoc_indent',
|
||||
'phpdoc_inline_tag',
|
||||
'phpdoc_no_access',
|
||||
'phpdoc_no_empty_return',
|
||||
'phpdoc_no_package',
|
||||
'phpdoc_order',
|
||||
// 'phpdoc_params', // Waste of time
|
||||
'phpdoc_scalar',
|
||||
// 'phpdoc_separation', // Nope, annotations are easy to read enough, no need to split them with blank lines
|
||||
// 'phpdoc_short_description', // We usually don't generate documentation so punctuation is not important
|
||||
'phpdoc_to_comment',
|
||||
'phpdoc_trim',
|
||||
'phpdoc_types',
|
||||
'phpdoc_type_to_var',
|
||||
// 'phpdoc_var_to_type', // This is not supported by phpDoc2 anymore
|
||||
'phpdoc_var_without_name',
|
||||
'php_unit_construct',
|
||||
// 'php_unit_strict', // We sometime actually need assertEquals
|
||||
'pre_increment',
|
||||
'print_to_echo',
|
||||
'psr0',
|
||||
'remove_leading_slash_use',
|
||||
'remove_lines_between_uses',
|
||||
'return',
|
||||
'self_accessor',
|
||||
'short_array_syntax',
|
||||
'short_bool_cast',
|
||||
'short_echo_tag',
|
||||
'short_tag',
|
||||
'single_array_no_trailing_comma',
|
||||
'single_blank_line_before_namespace',
|
||||
'single_line_after_imports',
|
||||
'single_quote',
|
||||
'spaces_before_semicolon',
|
||||
'spaces_cast',
|
||||
'standardize_not_equal',
|
||||
// 'strict', // No, too dangerous to change that
|
||||
// 'strict_param', // No, too dangerous to change that
|
||||
// 'ternary_spaces', // That would be nice, but NetBeans does not cooperate :-(
|
||||
'trailing_spaces',
|
||||
'trim_array_spaces',
|
||||
'unalign_double_arrow',
|
||||
'unalign_equals',
|
||||
'unary_operators_spaces',
|
||||
'unneeded_control_parentheses',
|
||||
'unused_use',
|
||||
'visibility',
|
||||
'whitespacy_lines',
|
||||
])
|
||||
->finder($finder);
|
|
@ -27,6 +27,8 @@ before_script:
|
|||
script:
|
||||
## PHP_CodeSniffer
|
||||
- ./vendor/bin/phpcs --report-width=200 --report-summary --report-full src/ tests/ --standard=PSR2 -n
|
||||
## PHP-CS-Fixer
|
||||
- ./vendor/bin/php-cs-fixer fix . --diff
|
||||
## PHPUnit
|
||||
- ./vendor/bin/phpunit --coverage-clover coverage-clover.xml
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "2.*",
|
||||
"phpunit/phpunit": "4.6.*",
|
||||
"mikey179/vfsStream": "1.5.*"
|
||||
"mikey179/vfsStream": "1.5.*",
|
||||
"friendsofphp/php-cs-fixer": "^1.11"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-zip": "*",
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace PhpSpreadsheet;
|
||||
|
||||
/**
|
||||
*
|
||||
* Autoloader for PhpSpreadsheet classes
|
||||
*
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
|
@ -31,7 +30,6 @@ class Autoloader
|
|||
{
|
||||
/**
|
||||
* Register the Autoloader with SPL
|
||||
*
|
||||
*/
|
||||
public static function register()
|
||||
{
|
||||
|
@ -40,10 +38,9 @@ class Autoloader
|
|||
spl_autoload_register('__autoload');
|
||||
}
|
||||
// Register ourselves with SPL
|
||||
return spl_autoload_register(array(\PhpSpreadsheet\Autoloader::class, 'load'));
|
||||
return spl_autoload_register([\PhpSpreadsheet\Autoloader::class, 'load']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Autoload a class identified by name
|
||||
*
|
||||
|
@ -65,6 +62,6 @@ class Autoloader
|
|||
// Can't load
|
||||
return false;
|
||||
}
|
||||
require($classFilePath);
|
||||
require $classFilePath;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Bootstrap for PhpSpreadsheet classes
|
||||
*
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
|
@ -25,7 +24,6 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
include_once __DIR__ . '/Autoloader.php';
|
||||
|
||||
\PhpSpreadsheet\Autoloader::register();
|
||||
|
|
|
@ -29,7 +29,6 @@ class APC extends CacheBase implements ICache
|
|||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $cachePrefix = null;
|
||||
|
@ -37,8 +36,7 @@ class APC extends CacheBase implements ICache
|
|||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @access private
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $cacheTime = 600;
|
||||
|
||||
|
@ -46,7 +44,6 @@ class APC extends CacheBase implements ICache
|
|||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @access private
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
|
@ -70,11 +67,10 @@ class APC extends CacheBase implements ICache
|
|||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -93,10 +89,9 @@ class APC extends CacheBase implements ICache
|
|||
/**
|
||||
* Is a value set in the current \PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
|
@ -112,15 +107,16 @@ class APC extends CacheBase implements ICache
|
|||
parent::deleteCacheData($pCoord);
|
||||
throw new \PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in APC cache');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
|
@ -172,7 +168,6 @@ class APC extends CacheBase implements ICache
|
|||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
*/
|
||||
|
@ -188,7 +183,6 @@ class APC extends CacheBase implements ICache
|
|||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @access public
|
||||
* @param \PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
*/
|
||||
|
@ -218,8 +212,6 @@ class APC extends CacheBase implements ICache
|
|||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -231,7 +223,7 @@ class APC extends CacheBase implements ICache
|
|||
// Flush the APC cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->cellCache = array();
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
@ -271,7 +263,7 @@ class APC extends CacheBase implements ICache
|
|||
* 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 bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ abstract class CacheBase
|
|||
/**
|
||||
* Flag indicating whether the currently active Cell requires saving
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $currentCellIsDirty = true;
|
||||
|
||||
|
@ -60,7 +60,7 @@ abstract class CacheBase
|
|||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
protected $cellCache = array();
|
||||
protected $cellCache = [];
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
|
@ -89,7 +89,7 @@ abstract class CacheBase
|
|||
* Is a value set in the current \PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ abstract class CacheBase
|
|||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
|
@ -125,8 +125,8 @@ abstract class CacheBase
|
|||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function updateCacheData(\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -170,7 +170,7 @@ abstract class CacheBase
|
|||
*/
|
||||
public function getSortedCellList()
|
||||
{
|
||||
$sortKeys = array();
|
||||
$sortKeys = [];
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $column, $row);
|
||||
$sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
|
||||
|
@ -188,8 +188,8 @@ abstract class CacheBase
|
|||
public function getHighestRowAndColumn()
|
||||
{
|
||||
// Lookup highest column and highest row
|
||||
$col = array('A' => '1A');
|
||||
$row = array(1);
|
||||
$col = ['A' => '1A'];
|
||||
$row = [1];
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
$row[$r] = $r;
|
||||
|
@ -201,10 +201,10 @@ abstract class CacheBase
|
|||
$highestColumn = substr(max($col), 1);
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'row' => $highestRow,
|
||||
'column' => $highestColumn
|
||||
);
|
||||
'column' => $highestColumn,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,17 +225,19 @@ abstract class CacheBase
|
|||
public function getCurrentColumn()
|
||||
{
|
||||
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
|
||||
return $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the row address of the currently active cell object
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrentRow()
|
||||
{
|
||||
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
|
||||
return (integer) $row;
|
||||
}
|
||||
|
||||
|
@ -250,10 +252,11 @@ abstract class CacheBase
|
|||
{
|
||||
if ($row == null) {
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
|
||||
return $colRow['column'];
|
||||
}
|
||||
|
||||
$columnList = array(1);
|
||||
$columnList = [1];
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($r != $row) {
|
||||
|
@ -261,6 +264,7 @@ abstract class CacheBase
|
|||
}
|
||||
$columnList[] = \PhpSpreadsheet\Cell::columnIndexFromString($c);
|
||||
}
|
||||
|
||||
return \PhpSpreadsheet\Cell::stringFromColumnIndex(max($columnList) - 1);
|
||||
}
|
||||
|
||||
|
@ -275,10 +279,11 @@ abstract class CacheBase
|
|||
{
|
||||
if ($column == null) {
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
|
||||
return $colRow['row'];
|
||||
}
|
||||
|
||||
$rowList = array(0);
|
||||
$rowList = [0];
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($c != $column) {
|
||||
|
@ -302,6 +307,7 @@ abstract class CacheBase
|
|||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
|
||||
return uniqid($baseUnique, true);
|
||||
}
|
||||
|
||||
|
@ -325,7 +331,6 @@ abstract class CacheBase
|
|||
* Remove a row, deleting all cells in that row
|
||||
*
|
||||
* @param string $row Row number to remove
|
||||
* @return void
|
||||
*/
|
||||
public function removeRow($row)
|
||||
{
|
||||
|
@ -341,7 +346,6 @@ abstract class CacheBase
|
|||
* Remove a column, deleting all cells in that column
|
||||
*
|
||||
* @param string $column Column ID to remove
|
||||
* @return void
|
||||
*/
|
||||
public function removeColumn($column)
|
||||
{
|
||||
|
@ -357,7 +361,7 @@ abstract class CacheBase
|
|||
* 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 bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
|
|
|
@ -51,7 +51,6 @@ class DiscISAM extends CacheBase implements ICache
|
|||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
|
@ -61,10 +60,10 @@ class DiscISAM extends CacheBase implements ICache
|
|||
|
||||
fseek($this->fileHandle, 0, SEEK_END);
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = array(
|
||||
$this->cellCache[$this->currentObjectID] = [
|
||||
'ptr' => ftell($this->fileHandle),
|
||||
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
|
||||
);
|
||||
'sz' => fwrite($this->fileHandle, serialize($this->currentObject)),
|
||||
];
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
|
@ -75,8 +74,8 @@ class DiscISAM extends CacheBase implements ICache
|
|||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -156,7 +155,6 @@ class DiscISAM extends CacheBase implements ICache
|
|||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -164,7 +162,7 @@ class DiscISAM extends CacheBase implements ICache
|
|||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
|
|
@ -31,8 +31,8 @@ interface ICache
|
|||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell);
|
||||
|
||||
|
@ -40,8 +40,8 @@ interface ICache
|
|||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function updateCacheData(\PhpSpreadsheet\Cell $cell);
|
||||
|
||||
|
@ -49,8 +49,8 @@ interface ICache
|
|||
* Fetch a cell from cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to retrieve
|
||||
* @return \PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord);
|
||||
|
||||
|
@ -66,7 +66,7 @@ interface ICache
|
|||
* Is a value set in the current \PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord);
|
||||
|
||||
|
@ -95,7 +95,7 @@ interface ICache
|
|||
* 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 bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ class Igbinary extends CacheBase implements ICache
|
|||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
|
@ -44,14 +43,13 @@ class Igbinary extends CacheBase implements ICache
|
|||
$this->currentObjectID = $this->currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -66,7 +64,6 @@ class Igbinary extends CacheBase implements ICache
|
|||
return $cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
|
@ -97,7 +94,6 @@ class Igbinary extends CacheBase implements ICache
|
|||
return $this->currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
|
@ -112,11 +108,8 @@ class Igbinary extends CacheBase implements ICache
|
|||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -124,18 +117,17 @@ class Igbinary extends CacheBase implements ICache
|
|||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ class Memcache extends CacheBase implements ICache
|
|||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $cacheTime = 600;
|
||||
|
||||
|
@ -47,7 +47,6 @@ class Memcache extends CacheBase implements ICache
|
|||
*/
|
||||
private $memcache = null;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
|
@ -71,14 +70,13 @@ class Memcache extends CacheBase implements ICache
|
|||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -94,13 +92,12 @@ class Memcache extends CacheBase implements ICache
|
|||
return $cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current \PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
|
@ -116,12 +113,13 @@ class Memcache extends CacheBase implements ICache
|
|||
parent::deleteCacheData($pCoord);
|
||||
throw new \PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in MemCache');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
|
@ -220,8 +218,6 @@ class Memcache extends CacheBase implements ICache
|
|||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -233,7 +229,7 @@ class Memcache extends CacheBase implements ICache
|
|||
// Flush the Memcache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->cellCache = array();
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
@ -257,8 +253,8 @@ class Memcache extends CacheBase implements ICache
|
|||
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
|
||||
// Set a new Memcache object and connect to the Memcache server
|
||||
$this->memcache = new Memcache();
|
||||
if (!$this->memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
|
||||
$this->memcache = new self();
|
||||
if (!$this->memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, [$this, 'failureCallback'])) {
|
||||
throw new \PhpSpreadsheet\Exception("Could not connect to MemCache server at {$memcacheServer}:{$memcachePort}");
|
||||
}
|
||||
$this->cacheTime = $cacheTime;
|
||||
|
@ -271,7 +267,7 @@ class Memcache extends CacheBase implements ICache
|
|||
* Memcache error handler
|
||||
*
|
||||
* @param string $host Memcache server
|
||||
* @param integer $port Memcache port
|
||||
* @param int $port Memcache port
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function failureCallback($host, $port)
|
||||
|
@ -294,7 +290,7 @@ class Memcache extends CacheBase implements ICache
|
|||
* 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 bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
|
|
|
@ -28,8 +28,6 @@ class Memory extends CacheBase implements ICache
|
|||
{
|
||||
/**
|
||||
* Dummy method callable from CacheBase, but unused by Memory cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
|
@ -40,8 +38,8 @@ class Memory extends CacheBase implements ICache
|
|||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -53,7 +51,6 @@ class Memory extends CacheBase implements ICache
|
|||
return $cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
|
@ -77,7 +74,6 @@ class Memory extends CacheBase implements ICache
|
|||
return $this->cellCache[$pCoord];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
|
@ -87,7 +83,7 @@ class Memory extends CacheBase implements ICache
|
|||
{
|
||||
parent::copyCellCollection($parent);
|
||||
|
||||
$newCollection = array();
|
||||
$newCollection = [];
|
||||
foreach ($this->cellCache as $k => &$cell) {
|
||||
$newCollection[$k] = clone $cell;
|
||||
$newCollection[$k]->attach($this);
|
||||
|
@ -98,7 +94,6 @@ class Memory extends CacheBase implements ICache
|
|||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -109,7 +104,7 @@ class Memory extends CacheBase implements ICache
|
|||
}
|
||||
unset($cell);
|
||||
|
||||
$this->cellCache = array();
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
|
|
@ -30,7 +30,6 @@ class MemoryGZip extends CacheBase implements ICache
|
|||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
|
@ -44,14 +43,13 @@ class MemoryGZip extends CacheBase implements ICache
|
|||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -66,7 +64,6 @@ class MemoryGZip extends CacheBase implements ICache
|
|||
return $cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
|
@ -97,7 +94,6 @@ class MemoryGZip extends CacheBase implements ICache
|
|||
return $this->currentObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
|
@ -112,11 +108,8 @@ class MemoryGZip extends CacheBase implements ICache
|
|||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -124,7 +117,7 @@ class MemoryGZip extends CacheBase implements ICache
|
|||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
|
|
@ -30,7 +30,6 @@ class MemorySerialized extends CacheBase implements ICache
|
|||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
|
@ -49,8 +48,8 @@ class MemorySerialized extends CacheBase implements ICache
|
|||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -111,8 +110,6 @@ class MemorySerialized extends CacheBase implements ICache
|
|||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -120,7 +117,7 @@ class MemorySerialized extends CacheBase implements ICache
|
|||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
|
|
@ -36,7 +36,7 @@ class PHPTemp extends CacheBase implements ICache
|
|||
/**
|
||||
* Memory limit to use before reverting to file cache
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $memoryCacheSize = null;
|
||||
|
||||
|
@ -53,23 +53,22 @@ class PHPTemp extends CacheBase implements ICache
|
|||
|
||||
fseek($this->fileHandle, 0, SEEK_END);
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = array(
|
||||
$this->cellCache[$this->currentObjectID] = [
|
||||
'ptr' => ftell($this->fileHandle),
|
||||
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
|
||||
);
|
||||
'sz' => fwrite($this->fileHandle, serialize($this->currentObject)),
|
||||
];
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -84,7 +83,6 @@ class PHPTemp extends CacheBase implements ICache
|
|||
return $cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
|
@ -150,8 +148,6 @@ class PHPTemp extends CacheBase implements ICache
|
|||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -159,7 +155,7 @@ class PHPTemp extends CacheBase implements ICache
|
|||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
|
|
@ -51,7 +51,7 @@ class SQLite extends CacheBase implements ICache
|
|||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
if (!$this->DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES('".$this->currentObjectID."','".sqlite_escape_string(serialize($this->currentObject))."')")) {
|
||||
if (!$this->DBHandle->queryExec('INSERT OR REPLACE INTO kvp_' . $this->TableName . " VALUES('" . $this->currentObjectID . "','" . sqlite_escape_string(serialize($this->currentObject)) . "')")) {
|
||||
throw new \PhpSpreadsheet\Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
|
@ -64,8 +64,8 @@ class SQLite extends CacheBase implements ICache
|
|||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ class SQLite extends CacheBase implements ICache
|
|||
}
|
||||
$this->storeData();
|
||||
|
||||
$query = "SELECT value FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||
$query = 'SELECT value FROM kvp_' . $this->TableName . " WHERE id='" . $pCoord . "'";
|
||||
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new \PhpSpreadsheet\Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
|
@ -119,8 +119,8 @@ class SQLite extends CacheBase implements ICache
|
|||
* Is a value set for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ class SQLite extends CacheBase implements ICache
|
|||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "SELECT id FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||
$query = 'SELECT id FROM kvp_' . $this->TableName . " WHERE id='" . $pCoord . "'";
|
||||
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new \PhpSpreadsheet\Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
|
@ -137,6 +137,7 @@ class SQLite extends CacheBase implements ICache
|
|||
// Return null if requested entry doesn't exist in cache
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -154,7 +155,7 @@ class SQLite extends CacheBase implements ICache
|
|||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||
$query = 'DELETE FROM kvp_' . $this->TableName . " WHERE id='" . $pCoord . "'";
|
||||
if (!$this->DBHandle->queryExec($query)) {
|
||||
throw new \PhpSpreadsheet\Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
|
@ -168,7 +169,7 @@ class SQLite extends CacheBase implements ICache
|
|||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
|
@ -176,13 +177,13 @@ class SQLite extends CacheBase implements ICache
|
|||
$this->currentObjectID = $toAddress;
|
||||
}
|
||||
|
||||
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
|
||||
$query = 'DELETE FROM kvp_' . $this->TableName . " WHERE id='" . $toAddress . "'";
|
||||
$result = $this->DBHandle->exec($query);
|
||||
if ($result === false) {
|
||||
throw new \PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
||||
$query = 'UPDATE kvp_' . $this->TableName . " SET id='" . $toAddress . "' WHERE id='" . $fromAddress . "'";
|
||||
$result = $this->DBHandle->exec($query);
|
||||
if ($result === false) {
|
||||
throw new \PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
|
@ -194,8 +195,8 @@ class SQLite extends CacheBase implements ICache
|
|||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
|
@ -203,13 +204,13 @@ class SQLite extends CacheBase implements ICache
|
|||
$this->storeData();
|
||||
}
|
||||
|
||||
$query = "SELECT id FROM kvp_".$this->TableName;
|
||||
$query = 'SELECT id FROM kvp_' . $this->TableName;
|
||||
$cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC);
|
||||
if ($cellIdsResult === false) {
|
||||
throw new \PhpSpreadsheet\Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
|
||||
$cellKeys = array();
|
||||
$cellKeys = [];
|
||||
foreach ($cellIdsResult as $row) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
@ -242,8 +243,6 @@ class SQLite extends CacheBase implements ICache
|
|||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -296,7 +295,7 @@ class SQLite extends CacheBase implements ICache
|
|||
* 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 bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
|
|
|
@ -95,8 +95,8 @@ class SQLite3 extends CacheBase implements ICache
|
|||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -116,8 +116,8 @@ class SQLite3 extends CacheBase implements ICache
|
|||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
|
@ -152,8 +152,8 @@ class SQLite3 extends CacheBase implements ICache
|
|||
* Is a value set for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
|
@ -200,8 +200,8 @@ class SQLite3 extends CacheBase implements ICache
|
|||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
|
@ -228,8 +228,8 @@ class SQLite3 extends CacheBase implements ICache
|
|||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
|
@ -237,13 +237,13 @@ class SQLite3 extends CacheBase implements ICache
|
|||
$this->storeData();
|
||||
}
|
||||
|
||||
$query = "SELECT id FROM kvp_".$this->TableName;
|
||||
$query = 'SELECT id FROM kvp_' . $this->TableName;
|
||||
$cellIdsResult = $this->DBHandle->query($query);
|
||||
if ($cellIdsResult === false) {
|
||||
throw new \PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$cellKeys = array();
|
||||
$cellKeys = [];
|
||||
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
@ -276,8 +276,6 @@ class SQLite3 extends CacheBase implements ICache
|
|||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -314,10 +312,10 @@ class SQLite3 extends CacheBase implements ICache
|
|||
}
|
||||
}
|
||||
|
||||
$this->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_".$this->TableName." WHERE id = :id");
|
||||
$this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES(:id,:data)");
|
||||
$this->updateQuery = $this->DBHandle->prepare("UPDATE kvp_".$this->TableName." SET id=:toId WHERE id=:fromId");
|
||||
$this->deleteQuery = $this->DBHandle->prepare("DELETE FROM kvp_".$this->TableName." WHERE id = :id");
|
||||
$this->selectQuery = $this->DBHandle->prepare('SELECT value FROM kvp_' . $this->TableName . ' WHERE id = :id');
|
||||
$this->insertQuery = $this->DBHandle->prepare('INSERT OR REPLACE INTO kvp_' . $this->TableName . ' VALUES(:id,:data)');
|
||||
$this->updateQuery = $this->DBHandle->prepare('UPDATE kvp_' . $this->TableName . ' SET id=:toId WHERE id=:fromId');
|
||||
$this->deleteQuery = $this->DBHandle->prepare('DELETE FROM kvp_' . $this->TableName . ' WHERE id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,7 +334,7 @@ class SQLite3 extends CacheBase implements ICache
|
|||
* 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 bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
|
|
|
@ -36,16 +36,14 @@ class Wincache extends CacheBase implements ICache
|
|||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $cacheTime = 600;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
|
@ -76,8 +74,8 @@ class Wincache extends CacheBase implements ICache
|
|||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to update
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return \PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
|
@ -97,8 +95,8 @@ class Wincache extends CacheBase implements ICache
|
|||
* Is a value set in the current \PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
|
@ -114,12 +112,13 @@ class Wincache extends CacheBase implements ICache
|
|||
parent::deleteCacheData($pCoord);
|
||||
throw new \PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in WinCache');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
|
@ -159,7 +158,6 @@ class Wincache extends CacheBase implements ICache
|
|||
return $this->currentObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
|
@ -220,11 +218,8 @@ class Wincache extends CacheBase implements ICache
|
|||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
|
@ -236,7 +231,7 @@ class Wincache extends CacheBase implements ICache
|
|||
// Flush the WinCache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->cellCache = array();
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
@ -276,7 +271,7 @@ class Wincache extends CacheBase implements ICache
|
|||
* 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 bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
|
|
|
@ -109,7 +109,6 @@ class CachedObjectStorageFactory
|
|||
*/
|
||||
private static $storageMethodParameters = [];
|
||||
|
||||
|
||||
/**
|
||||
* Return the current cache storage method
|
||||
*
|
||||
|
@ -147,13 +146,14 @@ class CachedObjectStorageFactory
|
|||
**/
|
||||
public static function getCacheStorageMethods()
|
||||
{
|
||||
$activeMethods = array();
|
||||
$activeMethods = [];
|
||||
foreach (self::$storageMethods as $storageMethod) {
|
||||
$cacheStorageClass = '\\PhpSpreadsheet\\CachedObjectStorage\\' . $storageMethod;
|
||||
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
|
||||
if (call_user_func([$cacheStorageClass, 'cacheMethodIsAvailable'])) {
|
||||
$activeMethods[] = $storageMethod;
|
||||
}
|
||||
}
|
||||
|
||||
return $activeMethods;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ class CachedObjectStorageFactory
|
|||
* @param string $method Name of the method to use for cell cacheing
|
||||
* @param mixed[] $arguments Additional arguments to pass to the cell caching class
|
||||
* when instantiating
|
||||
* @return boolean
|
||||
* @return bool
|
||||
**/
|
||||
public static function initialize($method = self::CACHE_IN_MEMORY, $arguments = [])
|
||||
{
|
||||
|
@ -187,6 +187,7 @@ class CachedObjectStorageFactory
|
|||
self::$cacheStorageClass = '\\PhpSpreadsheet\\CachedObjectStorage\\' . $method;
|
||||
self::$cacheStorageMethod = $method;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -218,12 +219,11 @@ class CachedObjectStorageFactory
|
|||
|
||||
/**
|
||||
* Clear the cache storage
|
||||
*
|
||||
**/
|
||||
public static function finalize()
|
||||
{
|
||||
self::$cacheStorageMethod = null;
|
||||
self::$cacheStorageClass = null;
|
||||
self::$storageMethodParameters = array();
|
||||
self::$storageMethodParameters = [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ class CyclicReferenceStack
|
|||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $stack = array();
|
||||
private $stack = [];
|
||||
|
||||
/**
|
||||
* Return the number of entries on the stack
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ class CyclicReferenceStack
|
|||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->stack = array();
|
||||
$this->stack = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,7 +31,7 @@ class Logger
|
|||
* If true, then a debug log will be generated
|
||||
* If false, then a debug log will not be generated
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $writeDebugLog = false;
|
||||
|
||||
|
@ -41,7 +41,7 @@ class Logger
|
|||
* If false, then a debug log will not be echoed
|
||||
* A debug log can only be echoed if it is generated
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $echoDebugLog = false;
|
||||
|
||||
|
@ -50,7 +50,7 @@ class Logger
|
|||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $debugLog = array();
|
||||
private $debugLog = [];
|
||||
|
||||
/**
|
||||
* The calculation engine cell reference stack
|
||||
|
@ -72,7 +72,7 @@ class Logger
|
|||
/**
|
||||
* Enable/Disable Calculation engine logging
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param bool $pValue
|
||||
*/
|
||||
public function setWriteDebugLog($pValue = false)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ class Logger
|
|||
/**
|
||||
* Return whether calculation engine logging is enabled or disabled
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getWriteDebugLog()
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ class Logger
|
|||
/**
|
||||
* Enable/Disable echoing of debug log information
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param bool $pValue
|
||||
*/
|
||||
public function setEchoDebugLog($pValue = false)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ class Logger
|
|||
/**
|
||||
* Return whether echoing of debug log information is enabled or disabled
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getEchoDebugLog()
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ class Logger
|
|||
*/
|
||||
public function clearLog()
|
||||
{
|
||||
$this->debugLog = array();
|
||||
$this->debugLog = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -75,7 +75,7 @@ class Categories
|
|||
$this->excelName = $pExcelName;
|
||||
$this->spreadsheetName = $spreadsheetName;
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
throw new Exception('Invalid parameters passed.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class Categories
|
|||
if (!is_null($value)) {
|
||||
$this->category = $value;
|
||||
} else {
|
||||
throw new Exception("Invalid parameter passed.");
|
||||
throw new Exception('Invalid parameter passed.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ class Database
|
|||
*
|
||||
* Extracts the column ID to use for the data field.
|
||||
*
|
||||
* @access private
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
|
@ -41,8 +40,7 @@ class Database
|
|||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @return string|NULL
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private static function fieldExtract($database, $field)
|
||||
{
|
||||
|
@ -51,9 +49,11 @@ class Database
|
|||
|
||||
if (is_numeric($field)) {
|
||||
$keys = array_keys($fieldNames);
|
||||
|
||||
return $keys[$field - 1];
|
||||
}
|
||||
$key = array_search($field, $fieldNames);
|
||||
|
||||
return ($key) ? $key : null;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,6 @@ class Database
|
|||
* Parses the selection criteria, extracts the database rows that match those criteria, and
|
||||
* returns that subset of rows.
|
||||
*
|
||||
* @access private
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
|
@ -74,7 +73,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return array of mixed
|
||||
*
|
||||
*/
|
||||
private static function filter($database, $criteria)
|
||||
{
|
||||
|
@ -82,23 +80,23 @@ class Database
|
|||
$criteriaNames = array_shift($criteria);
|
||||
|
||||
// Convert the criteria into a set of AND/OR conditions with [:placeholders]
|
||||
$testConditions = $testValues = array();
|
||||
$testConditions = $testValues = [];
|
||||
$testConditionsCount = 0;
|
||||
foreach ($criteriaNames as $key => $criteriaName) {
|
||||
$testCondition = array();
|
||||
$testCondition = [];
|
||||
$testConditionCount = 0;
|
||||
foreach ($criteria as $row => $criterion) {
|
||||
if ($criterion[$key] > '') {
|
||||
$testCondition[] = '[:' . $criteriaName . ']' . Functions::ifCondition($criterion[$key]);
|
||||
$testConditionCount++;
|
||||
++$testConditionCount;
|
||||
}
|
||||
}
|
||||
if ($testConditionCount > 1) {
|
||||
$testConditions[] = 'OR(' . implode(',', $testCondition) . ')';
|
||||
$testConditionsCount++;
|
||||
++$testConditionsCount;
|
||||
} elseif ($testConditionCount == 1) {
|
||||
$testConditions[] = $testCondition[0];
|
||||
$testConditionsCount++;
|
||||
++$testConditionsCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,13 +129,12 @@ class Database
|
|||
return $database;
|
||||
}
|
||||
|
||||
|
||||
private static function getFilteredColumn($database, $field, $criteria)
|
||||
{
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::filter($database, $criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
$colData = [];
|
||||
foreach ($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
@ -153,13 +150,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DAVERAGE(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -170,7 +166,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DAVERAGE($database, $field, $criteria)
|
||||
{
|
||||
|
@ -185,7 +180,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DCOUNT
|
||||
*
|
||||
|
@ -198,13 +192,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DAVERAGE(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -214,11 +207,10 @@ class Database
|
|||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the
|
||||
* database that match the criteria.
|
||||
*
|
||||
*/
|
||||
public static function DCOUNT($database, $field, $criteria)
|
||||
{
|
||||
|
@ -233,7 +225,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DCOUNTA
|
||||
*
|
||||
|
@ -242,13 +233,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DCOUNTA(database,[field],criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -258,11 +248,10 @@ class Database
|
|||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @TODO The field argument is optional. If field is omitted, DCOUNTA counts all records in the
|
||||
* database that match the criteria.
|
||||
*
|
||||
*/
|
||||
public static function DCOUNTA($database, $field, $criteria)
|
||||
{
|
||||
|
@ -274,7 +263,7 @@ class Database
|
|||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::filter($database, $criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
$colData = [];
|
||||
foreach ($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
@ -285,7 +274,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DGET
|
||||
*
|
||||
|
@ -295,13 +283,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DGET(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -312,7 +299,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return mixed
|
||||
*
|
||||
*/
|
||||
public static function DGET($database, $field, $criteria)
|
||||
{
|
||||
|
@ -330,7 +316,6 @@ class Database
|
|||
return $colData[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DMAX
|
||||
*
|
||||
|
@ -340,13 +325,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DMAX(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -357,7 +341,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DMAX($database, $field, $criteria)
|
||||
{
|
||||
|
@ -372,7 +355,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DMIN
|
||||
*
|
||||
|
@ -382,13 +364,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DMIN(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -399,7 +380,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DMIN($database, $field, $criteria)
|
||||
{
|
||||
|
@ -414,7 +394,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DPRODUCT
|
||||
*
|
||||
|
@ -423,13 +402,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DPRODUCT(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -440,7 +418,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DPRODUCT($database, $field, $criteria)
|
||||
{
|
||||
|
@ -455,7 +432,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DSTDEV
|
||||
*
|
||||
|
@ -465,13 +441,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DSTDEV(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -482,7 +457,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DSTDEV($database, $field, $criteria)
|
||||
{
|
||||
|
@ -497,7 +471,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DSTDEVP
|
||||
*
|
||||
|
@ -507,13 +480,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DSTDEVP(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -524,7 +496,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DSTDEVP($database, $field, $criteria)
|
||||
{
|
||||
|
@ -539,7 +510,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DSUM
|
||||
*
|
||||
|
@ -548,13 +518,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DSUM(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -565,7 +534,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DSUM($database, $field, $criteria)
|
||||
{
|
||||
|
@ -580,7 +548,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DVAR
|
||||
*
|
||||
|
@ -590,13 +557,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DVAR(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -607,7 +573,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DVAR($database, $field, $criteria)
|
||||
{
|
||||
|
@ -622,7 +587,6 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DVARP
|
||||
*
|
||||
|
@ -632,13 +596,12 @@ class Database
|
|||
* Excel Function:
|
||||
* DVARP(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* @param string|int $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
|
@ -649,7 +612,6 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DVARP($database, $field, $criteria)
|
||||
{
|
||||
|
|
|
@ -29,26 +29,25 @@ class DateTime
|
|||
/**
|
||||
* Identify if a year is a leap year or not
|
||||
*
|
||||
* @param integer $year The year to test
|
||||
* @return boolean TRUE if the year is a leap year, otherwise FALSE
|
||||
* @param int $year The year to test
|
||||
* @return bool TRUE if the year is a leap year, otherwise FALSE
|
||||
*/
|
||||
public static function isLeapYear($year)
|
||||
{
|
||||
return ((($year % 4) == 0) && (($year % 100) != 0) || (($year % 400) == 0));
|
||||
return (($year % 4) == 0) && (($year % 100) != 0) || (($year % 400) == 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of days between two dates based on a 360 day calendar
|
||||
*
|
||||
* @param integer $startDay Day of month of the start date
|
||||
* @param integer $startMonth Month of the start date
|
||||
* @param integer $startYear Year of the start date
|
||||
* @param integer $endDay Day of month of the start date
|
||||
* @param integer $endMonth Month of the start date
|
||||
* @param integer $endYear Year of the start date
|
||||
* @param boolean $methodUS Whether to use the US method or the European method of calculation
|
||||
* @return integer Number of days between the start date and the end date
|
||||
* @param int $startDay Day of month of the start date
|
||||
* @param int $startMonth Month of the start date
|
||||
* @param int $startYear Year of the start date
|
||||
* @param int $endDay Day of month of the start date
|
||||
* @param int $endMonth Month of the start date
|
||||
* @param int $endYear Year of the start date
|
||||
* @param bool $methodUS Whether to use the US method or the European method of calculation
|
||||
* @return int Number of days between the start date and the end date
|
||||
*/
|
||||
private static function dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS)
|
||||
{
|
||||
|
@ -74,7 +73,6 @@ class DateTime
|
|||
return $endDay + $endMonth * 30 + $endYear * 360 - $startDay - $startMonth * 30 - $startYear * 360;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getDateValue
|
||||
*
|
||||
|
@ -97,10 +95,10 @@ class DateTime
|
|||
Functions::setReturnDateType($saveReturnDateType);
|
||||
}
|
||||
}
|
||||
|
||||
return $dateValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getTimeValue
|
||||
*
|
||||
|
@ -113,10 +111,10 @@ class DateTime
|
|||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
$timeValue = self::TIMEVALUE($timeValue);
|
||||
Functions::setReturnDateType($saveReturnDateType);
|
||||
|
||||
return $timeValue;
|
||||
}
|
||||
|
||||
|
||||
private static function adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0)
|
||||
{
|
||||
// Execute function
|
||||
|
@ -140,10 +138,10 @@ class DateTime
|
|||
$adjustDaysString = '-' . $adjustDays . ' days';
|
||||
$PHPDateObject->modify($adjustDaysString);
|
||||
}
|
||||
|
||||
return $PHPDateObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DATETIMENOW
|
||||
*
|
||||
|
@ -158,7 +156,6 @@ class DateTime
|
|||
* Excel Function:
|
||||
* NOW()
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
|
@ -184,7 +181,6 @@ class DateTime
|
|||
return $retValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DATENOW
|
||||
*
|
||||
|
@ -199,7 +195,6 @@ class DateTime
|
|||
* Excel Function:
|
||||
* TODAY()
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
|
@ -226,7 +221,6 @@ class DateTime
|
|||
return $retValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DATE
|
||||
*
|
||||
|
@ -242,9 +236,8 @@ class DateTime
|
|||
* A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted,
|
||||
* as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language.
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @param integer $year The value of the year argument can include one to four digits.
|
||||
* @param int $year The value of the year argument can include one to four digits.
|
||||
* Excel interprets the year argument according to the configured
|
||||
* date system: 1900 or 1904.
|
||||
* If year is between 0 (zero) and 1899 (inclusive), Excel adds that
|
||||
|
@ -255,7 +248,7 @@ class DateTime
|
|||
* 2008.
|
||||
* If year is less than 0 or is 10000 or greater, Excel returns the
|
||||
* #NUM! error value.
|
||||
* @param integer $month A positive or negative integer representing the month of the year
|
||||
* @param int $month A positive or negative integer representing the month of the year
|
||||
* from 1 to 12 (January to December).
|
||||
* If month is greater than 12, month adds that number of months to
|
||||
* the first month in the year specified. For example, DATE(2008,14,2)
|
||||
|
@ -264,7 +257,7 @@ class DateTime
|
|||
* number of months, plus 1, from the first month in the year
|
||||
* specified. For example, DATE(2008,-3,2) returns the serial number
|
||||
* representing September 2, 2007.
|
||||
* @param integer $day A positive or negative integer representing the day of the month
|
||||
* @param int $day A positive or negative integer representing the day of the month
|
||||
* from 1 to 31.
|
||||
* If day is greater than the number of days in the month specified,
|
||||
* day adds that number of days to the first day in the month. For
|
||||
|
@ -344,7 +337,6 @@ class DateTime
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TIME
|
||||
*
|
||||
|
@ -356,16 +348,15 @@ class DateTime
|
|||
* Excel Function:
|
||||
* TIME(hour,minute,second)
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @param integer $hour A number from 0 (zero) to 32767 representing the hour.
|
||||
* @param int $hour A number from 0 (zero) to 32767 representing the hour.
|
||||
* Any value greater than 23 will be divided by 24 and the remainder
|
||||
* will be treated as the hour value. For example, TIME(27,0,0) =
|
||||
* TIME(3,0,0) = .125 or 3:00 AM.
|
||||
* @param integer $minute A number from 0 to 32767 representing the minute.
|
||||
* @param int $minute A number from 0 to 32767 representing the minute.
|
||||
* Any value greater than 59 will be converted to hours and minutes.
|
||||
* For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM.
|
||||
* @param integer $second A number from 0 to 32767 representing the second.
|
||||
* @param int $second A number from 0 to 32767 representing the second.
|
||||
* Any value greater than 59 will be converted to hours, minutes,
|
||||
* and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148
|
||||
* or 12:33:20 AM
|
||||
|
@ -430,6 +421,7 @@ class DateTime
|
|||
if ($calendar != \PhpSpreadsheet\Shared\Date::CALENDAR_WINDOWS_1900) {
|
||||
$date = 1;
|
||||
}
|
||||
|
||||
return (float) \PhpSpreadsheet\Shared\Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
|
||||
case Functions::RETURNDATE_PHP_NUMERIC:
|
||||
return (integer) \PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600
|
||||
|
@ -449,11 +441,11 @@ class DateTime
|
|||
if ($dayAdjust != 0) {
|
||||
$phpDateObject->modify($dayAdjust . ' days');
|
||||
}
|
||||
|
||||
return $phpDateObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DATEVALUE
|
||||
*
|
||||
|
@ -467,7 +459,6 @@ class DateTime
|
|||
* Excel Function:
|
||||
* DATEVALUE(dateValue)
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @param string $dateValue Text that represents a date in a Microsoft Excel date format.
|
||||
* For example, "1/30/2008" or "30-Jan-2008" are text strings within
|
||||
|
@ -487,7 +478,7 @@ class DateTime
|
|||
// Strip any ordinals because they're allowed in Excel (English only)
|
||||
$dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue);
|
||||
// Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany)
|
||||
$dateValue = str_replace(array('/', '.', '-', ' '), array(' ', ' ', ' ', ' '), $dateValue);
|
||||
$dateValue = str_replace(['/', '.', '-', ' '], [' ', ' ', ' ', ' '], $dateValue);
|
||||
|
||||
$yearFound = false;
|
||||
$t1 = explode(' ', $dateValue);
|
||||
|
@ -586,10 +577,10 @@ class DateTime
|
|||
return new \DateTime($PHPDateArray['year'] . '-' . $PHPDateArray['month'] . '-' . $PHPDateArray['day'] . ' 00:00:00');
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TIMEVALUE
|
||||
*
|
||||
|
@ -603,7 +594,6 @@ class DateTime
|
|||
* Excel Function:
|
||||
* TIMEVALUE(timeValue)
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @param string $timeValue A text string that represents a time in any one of the Microsoft
|
||||
* Excel time formats; for example, "6:45 PM" and "18:45" text strings
|
||||
|
@ -615,7 +605,7 @@ class DateTime
|
|||
public static function TIMEVALUE($timeValue)
|
||||
{
|
||||
$timeValue = trim(Functions::flattenSingleValue($timeValue), '"');
|
||||
$timeValue = str_replace(array('/', '.'), array('-', '-'), $timeValue);
|
||||
$timeValue = str_replace(['/', '.'], ['-', '-'], $timeValue);
|
||||
|
||||
$arraySplit = preg_split('/[\/:\-\s]/', $timeValue);
|
||||
if ((count($arraySplit) == 2 || count($arraySplit) == 3) && $arraySplit[0] > 24) {
|
||||
|
@ -647,10 +637,10 @@ class DateTime
|
|||
return new \DateTime('1900-01-01 ' . $PHPDateArray['hour'] . ':' . $PHPDateArray['minute'] . ':' . $PHPDateArray['second']);
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DATEDIF
|
||||
*
|
||||
|
@ -659,7 +649,7 @@ class DateTime
|
|||
* @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object
|
||||
* or a standard date string
|
||||
* @param string $unit
|
||||
* @return integer Interval between the dates
|
||||
* @return int Interval between the dates
|
||||
*/
|
||||
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D')
|
||||
{
|
||||
|
@ -752,10 +742,10 @@ class DateTime
|
|||
default:
|
||||
$retVal = Functions::VALUE();
|
||||
}
|
||||
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DAYS360
|
||||
*
|
||||
|
@ -766,13 +756,12 @@ class DateTime
|
|||
* Excel Function:
|
||||
* DAYS360(startDate,endDate[,method])
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @param boolean $method US or European Method
|
||||
* @param bool $method US or European Method
|
||||
* FALSE or omitted: U.S. (NASD) method. If the starting date is
|
||||
* the last day of a month, it becomes equal to the 30th of the
|
||||
* same month. If the ending date is the last day of a month and
|
||||
|
@ -783,7 +772,7 @@ class DateTime
|
|||
* TRUE: European method. Starting dates and ending dates that
|
||||
* occur on the 31st of a month become equal to the 30th of the
|
||||
* same month.
|
||||
* @return integer Number of days between start date and end date
|
||||
* @return int Number of days between start date and end date
|
||||
*/
|
||||
public static function DAYS360($startDate = 0, $endDate = 0, $method = false)
|
||||
{
|
||||
|
@ -815,7 +804,6 @@ class DateTime
|
|||
return self::dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, !$method);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* YEARFRAC
|
||||
*
|
||||
|
@ -827,13 +815,12 @@ class DateTime
|
|||
* Excel Function:
|
||||
* YEARFRAC(startDate,endDate[,method])
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @param integer $method Method used for the calculation
|
||||
* @param int $method Method used for the calculation
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -901,6 +888,7 @@ class DateTime
|
|||
}
|
||||
$leapDays /= $years;
|
||||
}
|
||||
|
||||
return $days / (365 + $leapDays);
|
||||
case 2:
|
||||
return self::DATEDIF($startDate, $endDate) / 360;
|
||||
|
@ -910,10 +898,10 @@ class DateTime
|
|||
return self::DAYS360($startDate, $endDate, true) / 360;
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NETWORKDAYS
|
||||
*
|
||||
|
@ -925,7 +913,6 @@ class DateTime
|
|||
* Excel Function:
|
||||
* NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]])
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
|
@ -935,7 +922,7 @@ class DateTime
|
|||
* timestamp (integer), PHP DateTime object, or a standard date
|
||||
* strings that will be excluded from the working calendar, such
|
||||
* as state and federal holidays and floating holidays.
|
||||
* @return integer Interval between the dates
|
||||
* @return int Interval between the dates
|
||||
*/
|
||||
public static function NETWORKDAYS($startDate, $endDate)
|
||||
{
|
||||
|
@ -979,7 +966,7 @@ class DateTime
|
|||
}
|
||||
|
||||
// Test any extra holiday parameters
|
||||
$holidayCountedArray = array();
|
||||
$holidayCountedArray = [];
|
||||
foreach ($dateArgs as $holidayDate) {
|
||||
if (is_string($holidayDate = self::getDateValue($holidayDate))) {
|
||||
return Functions::VALUE();
|
||||
|
@ -995,10 +982,10 @@ class DateTime
|
|||
if ($sDate > $eDate) {
|
||||
return 0 - ($wholeWeekDays + $partWeekDays);
|
||||
}
|
||||
|
||||
return $wholeWeekDays + $partWeekDays;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WORKDAY
|
||||
*
|
||||
|
@ -1010,11 +997,10 @@ class DateTime
|
|||
* Excel Function:
|
||||
* WORKDAY(startDate,endDays[,holidays[,holiday[,...]]])
|
||||
*
|
||||
* @access public
|
||||
* @category Date/Time Functions
|
||||
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @param integer $endDays The number of nonweekend and nonholiday days before or after
|
||||
* @param int $endDays The number of nonweekend and nonholiday days before or after
|
||||
* startDate. A positive value for days yields a future date; a
|
||||
* negative value yields a past date.
|
||||
* @param mixed $holidays,... Optional series of Excel date serial value (float), PHP date
|
||||
|
@ -1065,7 +1051,7 @@ class DateTime
|
|||
|
||||
// Test any extra holiday parameters
|
||||
if (!empty($dateArgs)) {
|
||||
$holidayCountedArray = $holidayDates = array();
|
||||
$holidayCountedArray = $holidayDates = [];
|
||||
foreach ($dateArgs as $holidayDate) {
|
||||
if (($holidayDate !== null) && (trim($holidayDate) > '')) {
|
||||
if (is_string($holidayDate = self::getDateValue($holidayDate))) {
|
||||
|
@ -1115,7 +1101,6 @@ class DateTime
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DAYOFMONTH
|
||||
*
|
||||
|
@ -1149,7 +1134,6 @@ class DateTime
|
|||
return (int) $PHPDateObject->format('j');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DAYOFWEEK
|
||||
*
|
||||
|
@ -1222,7 +1206,6 @@ class DateTime
|
|||
return (int) $DoW;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WEEKOFYEAR
|
||||
*
|
||||
|
@ -1238,7 +1221,7 @@ class DateTime
|
|||
*
|
||||
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @param boolean $method Week begins on Sunday or Monday
|
||||
* @param bool $method Week begins on Sunday or Monday
|
||||
* 1 or omitted Week begins on Sunday.
|
||||
* 2 Week begins on Monday.
|
||||
* @return int Week Number
|
||||
|
@ -1275,7 +1258,6 @@ class DateTime
|
|||
return (int) $weekOfYear;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MONTHOFYEAR
|
||||
*
|
||||
|
@ -1308,7 +1290,6 @@ class DateTime
|
|||
return (int) $PHPDateObject->format('n');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* YEAR
|
||||
*
|
||||
|
@ -1340,7 +1321,6 @@ class DateTime
|
|||
return (int) $PHPDateObject->format('Y');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HOUROFDAY
|
||||
*
|
||||
|
@ -1381,7 +1361,6 @@ class DateTime
|
|||
return (int) gmdate('G', $timeValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MINUTEOFHOUR
|
||||
*
|
||||
|
@ -1422,7 +1401,6 @@ class DateTime
|
|||
return (int) gmdate('i', $timeValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SECONDOFMINUTE
|
||||
*
|
||||
|
@ -1463,7 +1441,6 @@ class DateTime
|
|||
return (int) gmdate('s', $timeValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EDATE
|
||||
*
|
||||
|
@ -1510,7 +1487,6 @@ class DateTime
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EOMONTH
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,7 +31,7 @@ class ExceptionHandler
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
set_error_handler(array('\\PhpSpreadsheet\\Calculation\\Exception', 'errorHandlerCallback'), E_ALL);
|
||||
set_error_handler(['\\PhpSpreadsheet\\Calculation\\Exception', 'errorHandlerCallback'], E_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace PhpSpreadsheet\Calculation;
|
||||
|
||||
/** FINANCIAL_MAX_ITERATIONS */
|
||||
/* FINANCIAL_MAX_ITERATIONS */
|
||||
define('FINANCIAL_MAX_ITERATIONS', 128);
|
||||
|
||||
/** FINANCIAL_PRECISION */
|
||||
/* FINANCIAL_PRECISION */
|
||||
define('FINANCIAL_PRECISION', 1.0e-08);
|
||||
|
||||
/**
|
||||
|
@ -38,28 +38,26 @@ class Financial
|
|||
* Returns a boolean TRUE/FALSE indicating if this date is the last date of the month
|
||||
*
|
||||
* @param DateTime $testDate The date for testing
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
private static function isLastDayOfMonth($testDate)
|
||||
{
|
||||
return ($testDate->format('d') == $testDate->format('t'));
|
||||
return $testDate->format('d') == $testDate->format('t');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* isFirstDayOfMonth
|
||||
*
|
||||
* Returns a boolean TRUE/FALSE indicating if this date is the first date of the month
|
||||
*
|
||||
* @param DateTime $testDate The date for testing
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
private static function isFirstDayOfMonth($testDate)
|
||||
{
|
||||
return ($testDate->format('d') == 1);
|
||||
return $testDate->format('d') == 1;
|
||||
}
|
||||
|
||||
|
||||
private static function couponFirstPeriodDate($settlement, $maturity, $frequency, $next)
|
||||
{
|
||||
$months = 12 / $frequency;
|
||||
|
@ -81,7 +79,6 @@ class Financial
|
|||
return \PhpSpreadsheet\Shared\Date::PHPToExcel($result);
|
||||
}
|
||||
|
||||
|
||||
private static function isValidFrequency($frequency)
|
||||
{
|
||||
if (($frequency == 1) || ($frequency == 2) || ($frequency == 4)) {
|
||||
|
@ -91,23 +88,23 @@ class Financial
|
|||
(($frequency == 6) || ($frequency == 12))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* daysPerYear
|
||||
*
|
||||
* Returns the number of days in a specified year, as defined by the "basis" value
|
||||
*
|
||||
* @param integer $year The year against which we're testing
|
||||
* @param integer $basis The type of day count:
|
||||
* @param int $year The year against which we're testing
|
||||
* @param int $basis The type of day count:
|
||||
* 0 or omitted US (NASD) 360
|
||||
* 1 Actual (365 or 366 in a leap year)
|
||||
* 2 360
|
||||
* 3 365
|
||||
* 4 European 360
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
private static function daysPerYear($year, $basis = 0)
|
||||
{
|
||||
|
@ -126,10 +123,10 @@ class Financial
|
|||
default:
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return $daysPerYear;
|
||||
}
|
||||
|
||||
|
||||
private static function interestAndPrincipal($rate = 0, $per = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0)
|
||||
{
|
||||
$pmt = self::PMT($rate, $nper, $pv, $fv, $type);
|
||||
|
@ -139,9 +136,9 @@ class Financial
|
|||
$principal = $pmt - $interest;
|
||||
$capital += $principal;
|
||||
}
|
||||
return array($interest, $principal);
|
||||
}
|
||||
|
||||
return [$interest, $principal];
|
||||
}
|
||||
|
||||
/**
|
||||
* ACCRINT
|
||||
|
@ -151,7 +148,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* ACCRINT(issue,firstinterest,settlement,rate,par,frequency[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param mixed $issue The security's issue date.
|
||||
* @param mixed $firstinterest The security's first interest date.
|
||||
|
@ -161,7 +157,7 @@ class Financial
|
|||
* @param float $rate The security's annual coupon rate.
|
||||
* @param float $par The security's par value.
|
||||
* If you omit par, ACCRINT uses $1,000.
|
||||
* @param integer $frequency the number of coupon payments per year.
|
||||
* @param int $frequency the number of coupon payments per year.
|
||||
* Valid frequency values are:
|
||||
* 1 Annual
|
||||
* 2 Semi-Annual
|
||||
|
@ -170,7 +166,7 @@ class Financial
|
|||
* also available
|
||||
* 6 Bimonthly
|
||||
* 12 Monthly
|
||||
* @param integer $basis The type of day count to use.
|
||||
* @param int $basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -203,10 +199,10 @@ class Financial
|
|||
|
||||
return $par * $rate * $daysBetweenIssueAndSettlement;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ACCRINTM
|
||||
*
|
||||
|
@ -215,14 +211,13 @@ class Financial
|
|||
* Excel Function:
|
||||
* ACCRINTM(issue,settlement,rate[,par[,basis]])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param mixed issue The security's issue date.
|
||||
* @param mixed settlement The security's settlement (or maturity) date.
|
||||
* @param float rate The security's annual coupon rate.
|
||||
* @param float par The security's par value.
|
||||
* If you omit par, ACCRINT uses $1,000.
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -250,12 +245,13 @@ class Financial
|
|||
// return date error
|
||||
return $daysBetweenIssueAndSettlement;
|
||||
}
|
||||
|
||||
return $par * $rate * $daysBetweenIssueAndSettlement;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AMORDEGRC
|
||||
*
|
||||
|
@ -271,7 +267,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* AMORDEGRC(cost,purchased,firstPeriod,salvage,period,rate[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float cost The cost of the asset.
|
||||
* @param mixed purchased Date of the purchase of the asset.
|
||||
|
@ -279,7 +274,7 @@ class Financial
|
|||
* @param mixed salvage The salvage value at the end of the life of the asset.
|
||||
* @param float period The period.
|
||||
* @param float rate Rate of depreciation.
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -334,10 +329,10 @@ class Financial
|
|||
}
|
||||
$cost -= $fNRate;
|
||||
}
|
||||
|
||||
return $fNRate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AMORLINC
|
||||
*
|
||||
|
@ -348,7 +343,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* AMORLINC(cost,purchased,firstPeriod,salvage,period,rate[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float cost The cost of the asset.
|
||||
* @param mixed purchased Date of the purchase of the asset.
|
||||
|
@ -356,7 +350,7 @@ class Financial
|
|||
* @param mixed salvage The salvage value at the end of the life of the asset.
|
||||
* @param float period The period.
|
||||
* @param float rate Rate of depreciation.
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -392,13 +386,12 @@ class Financial
|
|||
} elseif ($period <= $nNumOfFullPeriods) {
|
||||
return $fOneRate;
|
||||
} elseif ($period == ($nNumOfFullPeriods + 1)) {
|
||||
return ($fCostDelta - $fOneRate * $nNumOfFullPeriods - $f0Rate);
|
||||
return $fCostDelta - $fOneRate * $nNumOfFullPeriods - $f0Rate;
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COUPDAYBS
|
||||
*
|
||||
|
@ -407,7 +400,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* COUPDAYBS(settlement,maturity,frequency[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param mixed settlement The security's settlement date.
|
||||
* The security settlement date is the date after the issue
|
||||
|
@ -423,7 +415,7 @@ class Financial
|
|||
* also available
|
||||
* 6 Bimonthly
|
||||
* 12 Monthly
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -457,7 +449,6 @@ class Financial
|
|||
return DateTime::YEARFRAC($prev, $settlement, $basis) * $daysPerYear;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COUPDAYS
|
||||
*
|
||||
|
@ -466,7 +457,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* COUPDAYS(settlement,maturity,frequency[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param mixed settlement The security's settlement date.
|
||||
* The security settlement date is the date after the issue
|
||||
|
@ -482,7 +472,7 @@ class Financial
|
|||
* also available
|
||||
* 6 Bimonthly
|
||||
* 12 Monthly
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -518,19 +508,21 @@ class Financial
|
|||
// Actual/actual
|
||||
if ($frequency == 1) {
|
||||
$daysPerYear = self::daysPerYear(DateTime::YEAR($maturity), $basis);
|
||||
return ($daysPerYear / $frequency);
|
||||
|
||||
return $daysPerYear / $frequency;
|
||||
}
|
||||
$prev = self::couponFirstPeriodDate($settlement, $maturity, $frequency, false);
|
||||
$next = self::couponFirstPeriodDate($settlement, $maturity, $frequency, true);
|
||||
return ($next - $prev);
|
||||
|
||||
return $next - $prev;
|
||||
default:
|
||||
// US (NASD) 30/360, Actual/360 or European 30/360
|
||||
return 360 / $frequency;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COUPDAYSNC
|
||||
*
|
||||
|
@ -539,7 +531,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* COUPDAYSNC(settlement,maturity,frequency[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param mixed settlement The security's settlement date.
|
||||
* The security settlement date is the date after the issue
|
||||
|
@ -555,7 +546,7 @@ class Financial
|
|||
* also available
|
||||
* 6 Bimonthly
|
||||
* 12 Monthly
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -589,7 +580,6 @@ class Financial
|
|||
return DateTime::YEARFRAC($settlement, $next, $basis) * $daysPerYear;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COUPNCD
|
||||
*
|
||||
|
@ -598,7 +588,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* COUPNCD(settlement,maturity,frequency[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param mixed settlement The security's settlement date.
|
||||
* The security settlement date is the date after the issue
|
||||
|
@ -614,7 +603,7 @@ class Financial
|
|||
* also available
|
||||
* 6 Bimonthly
|
||||
* 12 Monthly
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -646,7 +635,6 @@ class Financial
|
|||
return self::couponFirstPeriodDate($settlement, $maturity, $frequency, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COUPNUM
|
||||
*
|
||||
|
@ -656,7 +644,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* COUPNUM(settlement,maturity,frequency[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param mixed settlement The security's settlement date.
|
||||
* The security settlement date is the date after the issue
|
||||
|
@ -672,13 +659,13 @@ class Financial
|
|||
* also available
|
||||
* 6 Bimonthly
|
||||
* 12 Monthly
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
* 3 Actual/365
|
||||
* 4 European 30/360
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public static function COUPNUM($settlement, $maturity, $frequency, $basis = 0)
|
||||
{
|
||||
|
@ -715,10 +702,10 @@ class Financial
|
|||
case 12: // monthly
|
||||
return ceil($daysBetweenSettlementAndMaturity / 30);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COUPPCD
|
||||
*
|
||||
|
@ -727,7 +714,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* COUPPCD(settlement,maturity,frequency[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param mixed settlement The security's settlement date.
|
||||
* The security settlement date is the date after the issue
|
||||
|
@ -743,7 +729,7 @@ class Financial
|
|||
* also available
|
||||
* 6 Bimonthly
|
||||
* 12 Monthly
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -775,7 +761,6 @@ class Financial
|
|||
return self::couponFirstPeriodDate($settlement, $maturity, $frequency, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CUMIPMT
|
||||
*
|
||||
|
@ -784,15 +769,14 @@ class Financial
|
|||
* Excel Function:
|
||||
* CUMIPMT(rate,nper,pv,start,end[,type])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float $rate The Interest rate
|
||||
* @param integer $nper The total number of payment periods
|
||||
* @param int $nper The total number of payment periods
|
||||
* @param float $pv Present Value
|
||||
* @param integer $start The first period in the calculation.
|
||||
* @param int $start The first period in the calculation.
|
||||
* Payment periods are numbered beginning with 1.
|
||||
* @param integer $end The last period in the calculation.
|
||||
* @param integer $type A number 0 or 1 and indicates when payments are due:
|
||||
* @param int $end The last period in the calculation.
|
||||
* @param int $type A number 0 or 1 and indicates when payments are due:
|
||||
* 0 or omitted At the end of the period.
|
||||
* 1 At the beginning of the period.
|
||||
* @return float
|
||||
|
@ -823,7 +807,6 @@ class Financial
|
|||
return $interest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CUMPRINC
|
||||
*
|
||||
|
@ -832,15 +815,14 @@ class Financial
|
|||
* Excel Function:
|
||||
* CUMPRINC(rate,nper,pv,start,end[,type])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float $rate The Interest rate
|
||||
* @param integer $nper The total number of payment periods
|
||||
* @param int $nper The total number of payment periods
|
||||
* @param float $pv Present Value
|
||||
* @param integer $start The first period in the calculation.
|
||||
* @param int $start The first period in the calculation.
|
||||
* Payment periods are numbered beginning with 1.
|
||||
* @param integer $end The last period in the calculation.
|
||||
* @param integer $type A number 0 or 1 and indicates when payments are due:
|
||||
* @param int $end The last period in the calculation.
|
||||
* @param int $type A number 0 or 1 and indicates when payments are due:
|
||||
* 0 or omitted At the end of the period.
|
||||
* 1 At the beginning of the period.
|
||||
* @return float
|
||||
|
@ -871,7 +853,6 @@ class Financial
|
|||
return $principal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DB
|
||||
*
|
||||
|
@ -885,16 +866,15 @@ class Financial
|
|||
* Excel Function:
|
||||
* DB(cost,salvage,life,period[,month])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float cost Initial cost of the asset.
|
||||
* @param float salvage Value at the end of the depreciation.
|
||||
* (Sometimes called the salvage value of the asset)
|
||||
* @param integer life Number of periods over which the asset is depreciated.
|
||||
* @param int life Number of periods over which the asset is depreciated.
|
||||
* (Sometimes called the useful life of the asset)
|
||||
* @param integer period The period for which you want to calculate the
|
||||
* @param int period The period for which you want to calculate the
|
||||
* depreciation. Period must use the same units as life.
|
||||
* @param integer month Number of months in the first year. If month is omitted,
|
||||
* @param int month Number of months in the first year. If month is omitted,
|
||||
* it defaults to 12.
|
||||
* @return float
|
||||
*/
|
||||
|
@ -937,12 +917,13 @@ class Financial
|
|||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||
$depreciation = round($depreciation, 2);
|
||||
}
|
||||
|
||||
return $depreciation;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DDB
|
||||
*
|
||||
|
@ -952,14 +933,13 @@ class Financial
|
|||
* Excel Function:
|
||||
* DDB(cost,salvage,life,period[,factor])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float cost Initial cost of the asset.
|
||||
* @param float salvage Value at the end of the depreciation.
|
||||
* (Sometimes called the salvage value of the asset)
|
||||
* @param integer life Number of periods over which the asset is depreciated.
|
||||
* @param int life Number of periods over which the asset is depreciated.
|
||||
* (Sometimes called the useful life of the asset)
|
||||
* @param integer period The period for which you want to calculate the
|
||||
* @param int period The period for which you want to calculate the
|
||||
* depreciation. Period must use the same units as life.
|
||||
* @param float factor The rate at which the balance declines.
|
||||
* If factor is omitted, it is assumed to be 2 (the
|
||||
|
@ -997,12 +977,13 @@ class Financial
|
|||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||
$depreciation = round($depreciation, 2);
|
||||
}
|
||||
|
||||
return $depreciation;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DISC
|
||||
*
|
||||
|
@ -1011,16 +992,15 @@ class Financial
|
|||
* Excel Function:
|
||||
* DISC(settlement,maturity,price,redemption[,basis])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param mixed settlement The security's settlement date.
|
||||
* The security settlement date is the date after the issue
|
||||
* date when the security is traded to the buyer.
|
||||
* @param mixed maturity The security's maturity date.
|
||||
* The maturity date is the date when the security expires.
|
||||
* @param integer price The security's price per $100 face value.
|
||||
* @param integer redemption The security's redemption value per $100 face value.
|
||||
* @param integer basis The type of day count to use.
|
||||
* @param int price The security's price per $100 face value.
|
||||
* @param int redemption The security's redemption value per $100 face value.
|
||||
* @param int basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -1050,11 +1030,11 @@ class Financial
|
|||
return $daysBetweenSettlementAndMaturity;
|
||||
}
|
||||
|
||||
return ((1 - $price / $redemption) / $daysBetweenSettlementAndMaturity);
|
||||
}
|
||||
return Functions::VALUE();
|
||||
return (1 - $price / $redemption) / $daysBetweenSettlementAndMaturity;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
/**
|
||||
* DOLLARDE
|
||||
|
@ -1066,10 +1046,9 @@ class Financial
|
|||
* Excel Function:
|
||||
* DOLLARDE(fractional_dollar,fraction)
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float $fractional_dollar Fractional Dollar
|
||||
* @param integer $fraction Fraction
|
||||
* @param int $fraction Fraction
|
||||
* @return float
|
||||
*/
|
||||
public static function DOLLARDE($fractional_dollar = null, $fraction = 0)
|
||||
|
@ -1089,10 +1068,10 @@ class Financial
|
|||
$cents = fmod($fractional_dollar, 1);
|
||||
$cents /= $fraction;
|
||||
$cents *= pow(10, ceil(log10($fraction)));
|
||||
|
||||
return $dollars + $cents;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DOLLARFR
|
||||
*
|
||||
|
@ -1103,10 +1082,9 @@ class Financial
|
|||
* Excel Function:
|
||||
* DOLLARFR(decimal_dollar,fraction)
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float $decimal_dollar Decimal Dollar
|
||||
* @param integer $fraction Fraction
|
||||
* @param int $fraction Fraction
|
||||
* @return float
|
||||
*/
|
||||
public static function DOLLARFR($decimal_dollar = null, $fraction = 0)
|
||||
|
@ -1126,10 +1104,10 @@ class Financial
|
|||
$cents = fmod($decimal_dollar, 1);
|
||||
$cents *= $fraction;
|
||||
$cents *= pow(10, -ceil(log10($fraction)));
|
||||
|
||||
return $dollars + $cents;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EFFECT
|
||||
*
|
||||
|
@ -1139,10 +1117,9 @@ class Financial
|
|||
* Excel Function:
|
||||
* EFFECT(nominal_rate,npery)
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float $nominal_rate Nominal interest rate
|
||||
* @param integer $npery Number of compounding payments per year
|
||||
* @param int $npery Number of compounding payments per year
|
||||
* @return float
|
||||
*/
|
||||
public static function EFFECT($nominal_rate = 0, $npery = 0)
|
||||
|
@ -1158,7 +1135,6 @@ class Financial
|
|||
return pow((1 + $nominal_rate / $npery), $npery) - 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FV
|
||||
*
|
||||
|
@ -1167,7 +1143,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* FV(rate,nper,pmt[,pv[,type]])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float $rate The interest rate per period
|
||||
* @param int $nper Total number of payment periods in an annuity
|
||||
|
@ -1176,7 +1151,7 @@ class Financial
|
|||
* and interest but no other fees or taxes.
|
||||
* @param float $pv Present Value, or the lump-sum amount that a series of
|
||||
* future payments is worth right now.
|
||||
* @param integer $type A number 0 or 1 and indicates when payments are due:
|
||||
* @param int $type A number 0 or 1 and indicates when payments are due:
|
||||
* 0 or omitted At the end of the period.
|
||||
* 1 At the beginning of the period.
|
||||
* @return float
|
||||
|
@ -1198,10 +1173,10 @@ class Financial
|
|||
if (!is_null($rate) && $rate != 0) {
|
||||
return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate;
|
||||
}
|
||||
|
||||
return -$pv - $pmt * $nper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FVSCHEDULE
|
||||
*
|
||||
|
@ -1227,7 +1202,6 @@ class Financial
|
|||
return $principal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* INTRATE
|
||||
*
|
||||
|
@ -1240,9 +1214,9 @@ class Financial
|
|||
* The security settlement date is the date after the issue date when the security is traded to the buyer.
|
||||
* @param mixed $maturity The security's maturity date.
|
||||
* The maturity date is the date when the security expires.
|
||||
* @param integer $investment The amount invested in the security.
|
||||
* @param integer $redemption The amount to be received at maturity.
|
||||
* @param integer $basis The type of day count to use.
|
||||
* @param int $investment The amount invested in the security.
|
||||
* @param int $redemption The amount to be received at maturity.
|
||||
* @param int $basis The type of day count to use.
|
||||
* 0 or omitted US (NASD) 30/360
|
||||
* 1 Actual/actual
|
||||
* 2 Actual/360
|
||||
|
@ -1274,10 +1248,10 @@ class Financial
|
|||
|
||||
return (($redemption / $investment) - 1) / ($daysBetweenSettlementAndMaturity);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IPMT
|
||||
*
|
||||
|
@ -1313,6 +1287,7 @@ class Financial
|
|||
|
||||
// Calculate
|
||||
$interestAndPrincipal = self::interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type);
|
||||
|
||||
return $interestAndPrincipal[0];
|
||||
}
|
||||
|
||||
|
@ -1382,10 +1357,10 @@ class Financial
|
|||
return $x_mid;
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ISPMT
|
||||
*
|
||||
|
@ -1424,9 +1399,9 @@ class Financial
|
|||
$returnValue = 0;
|
||||
}
|
||||
}
|
||||
return($returnValue);
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* MIRR
|
||||
|
@ -1473,10 +1448,9 @@ class Financial
|
|||
$mirr = pow((-$npv_pos * pow($rr, $n))
|
||||
/ ($npv_neg * ($rr)), (1.0 / ($n - 1))) - 1.0;
|
||||
|
||||
return (is_finite($mirr) ? $mirr : Functions::VALUE());
|
||||
return is_finite($mirr) ? $mirr : Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NOMINAL
|
||||
*
|
||||
|
@ -1500,7 +1474,6 @@ class Financial
|
|||
return $npery * (pow($effect_rate + 1, 1 / $npery) - 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NPER
|
||||
*
|
||||
|
@ -1531,11 +1504,13 @@ class Financial
|
|||
if ($pmt == 0 && $pv == 0) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return log(($pmt * (1 + $rate * $type) / $rate - $fv) / ($pv + $pmt * (1 + $rate * $type) / $rate)) / log(1 + $rate);
|
||||
}
|
||||
if ($pmt == 0) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return (-$pv - $fv) / $pmt;
|
||||
}
|
||||
|
||||
|
@ -1596,10 +1571,10 @@ class Financial
|
|||
if (!is_null($rate) && $rate != 0) {
|
||||
return (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate);
|
||||
}
|
||||
|
||||
return (-$pv - $fv) / $nper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PPMT
|
||||
*
|
||||
|
@ -1632,10 +1607,10 @@ class Financial
|
|||
|
||||
// Calculate
|
||||
$interestAndPrincipal = self::interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type);
|
||||
|
||||
return $interestAndPrincipal[1];
|
||||
}
|
||||
|
||||
|
||||
public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis = 0)
|
||||
{
|
||||
$settlement = Functions::flattenSingleValue($settlement);
|
||||
|
@ -1677,7 +1652,6 @@ class Financial
|
|||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PRICEDISC
|
||||
*
|
||||
|
@ -1718,10 +1692,10 @@ class Financial
|
|||
|
||||
return $redemption * (1 - $discount * $daysBetweenSettlementAndMaturity);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PRICEMAT
|
||||
*
|
||||
|
@ -1779,13 +1753,13 @@ class Financial
|
|||
}
|
||||
$daysBetweenSettlementAndMaturity *= $daysPerYear;
|
||||
|
||||
return ((100 + (($daysBetweenIssueAndMaturity / $daysPerYear) * $rate * 100)) /
|
||||
return (100 + (($daysBetweenIssueAndMaturity / $daysPerYear) * $rate * 100)) /
|
||||
(1 + (($daysBetweenSettlementAndMaturity / $daysPerYear) * $yield)) -
|
||||
(($daysBetweenIssueAndSettlement / $daysPerYear) * $rate * 100));
|
||||
}
|
||||
return Functions::VALUE();
|
||||
(($daysBetweenIssueAndSettlement / $daysPerYear) * $rate * 100);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
/**
|
||||
* PV
|
||||
|
@ -1816,10 +1790,10 @@ class Financial
|
|||
if (!is_null($rate) && $rate != 0) {
|
||||
return (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper);
|
||||
}
|
||||
|
||||
return -$fv - $pmt * $nper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RATE
|
||||
*
|
||||
|
@ -1831,7 +1805,6 @@ class Financial
|
|||
* Excel Function:
|
||||
* RATE(nper,pmt,pv[,fv[,type[,guess]]])
|
||||
*
|
||||
* @access public
|
||||
* @category Financial Functions
|
||||
* @param float nper The total number of payment periods in an annuity.
|
||||
* @param float pmt The payment made each period and cannot change over the life
|
||||
|
@ -1843,7 +1816,7 @@ class Financial
|
|||
* @param float fv The future value, or a cash balance you want to attain after
|
||||
* the last payment is made. If fv is omitted, it is assumed
|
||||
* to be 0 (the future value of a loan, for example, is 0).
|
||||
* @param integer type A number 0 or 1 and indicates when payments are due:
|
||||
* @param int type A number 0 or 1 and indicates when payments are due:
|
||||
* 0 or omitted At the end of the period.
|
||||
* 1 At the beginning of the period.
|
||||
* @param float guess Your guess for what the rate will be.
|
||||
|
@ -1890,10 +1863,10 @@ class Financial
|
|||
$y1 = $y;
|
||||
++$i;
|
||||
}
|
||||
|
||||
return $rate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RECEIVED
|
||||
*
|
||||
|
@ -1934,10 +1907,10 @@ class Financial
|
|||
|
||||
return $investment / (1 - ($discount * $daysBetweenSettlementAndMaturity));
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SLN
|
||||
*
|
||||
|
@ -1959,12 +1932,13 @@ class Financial
|
|||
if ($life < 0) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return ($cost - $salvage) / $life;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SYD
|
||||
*
|
||||
|
@ -1988,12 +1962,13 @@ class Financial
|
|||
if (($life < 1) || ($period > $life)) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return (($cost - $salvage) * ($life - $period + 1) * 2) / ($life * ($life + 1));
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TBILLEQ
|
||||
*
|
||||
|
@ -2032,7 +2007,6 @@ class Financial
|
|||
return (365 * $discount) / (360 - $discount * $daysBetweenSettlementAndMaturity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TBILLPRICE
|
||||
*
|
||||
|
@ -2080,12 +2054,13 @@ class Financial
|
|||
if ($price <= 0) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return $price;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TBILLYIELD
|
||||
*
|
||||
|
@ -2127,10 +2102,10 @@ class Financial
|
|||
|
||||
return ((100 - $price) / $price) * (360 / $daysBetweenSettlementAndMaturity);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
public static function XIRR($values, $dates, $guess = 0.1)
|
||||
{
|
||||
if ((!is_array($values)) && (!is_array($dates))) {
|
||||
|
@ -2181,10 +2156,10 @@ class Financial
|
|||
return $x_mid;
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* XNPV
|
||||
*
|
||||
|
@ -2230,10 +2205,10 @@ class Financial
|
|||
}
|
||||
$xnpv += $values[$i] / pow(1 + $rate, DateTime::DATEDIF($dates[0], $dates[$i], 'd') / 365);
|
||||
}
|
||||
|
||||
return (is_finite($xnpv)) ? $xnpv : Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* YIELDDISC
|
||||
*
|
||||
|
@ -2279,10 +2254,10 @@ class Financial
|
|||
|
||||
return (($redemption - $price) / $price) * ($daysPerYear / $daysBetweenSettlementAndMaturity);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* YIELDMAT
|
||||
*
|
||||
|
@ -2344,6 +2319,7 @@ class Financial
|
|||
(($price / 100) + (($daysBetweenIssueAndSettlement / $daysPerYear) * $rate))) *
|
||||
($daysPerYear / $daysBetweenSettlementAndMaturity);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,9 +62,9 @@ class FormulaParser
|
|||
const COMMA = ',';
|
||||
const ERROR_START = '#';
|
||||
|
||||
const OPERATORS_SN = "+-";
|
||||
const OPERATORS_INFIX = "+-*/^&=><";
|
||||
const OPERATORS_POSTFIX = "%";
|
||||
const OPERATORS_SN = '+-';
|
||||
const OPERATORS_INFIX = '+-*/^&=><';
|
||||
const OPERATORS_POSTFIX = '%';
|
||||
|
||||
/**
|
||||
* Formula
|
||||
|
@ -78,7 +78,7 @@ class FormulaParser
|
|||
*
|
||||
* @var FormulaToken[]
|
||||
*/
|
||||
private $tokens = array();
|
||||
private $tokens = [];
|
||||
|
||||
/**
|
||||
* Create a new FormulaParser
|
||||
|
@ -90,7 +90,7 @@ class FormulaParser
|
|||
{
|
||||
// Check parameters
|
||||
if (is_null($pFormula)) {
|
||||
throw new Exception("Invalid parameter passed: formula");
|
||||
throw new Exception('Invalid parameter passed: formula');
|
||||
}
|
||||
|
||||
// Initialise values
|
||||
|
@ -113,8 +113,8 @@ class FormulaParser
|
|||
* Get Token
|
||||
*
|
||||
* @param int $pId Token id
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @return string
|
||||
*/
|
||||
public function getToken($pId = 0)
|
||||
{
|
||||
|
@ -160,15 +160,15 @@ class FormulaParser
|
|||
}
|
||||
|
||||
// Helper variables
|
||||
$tokens1 = $tokens2 = $stack = array();
|
||||
$tokens1 = $tokens2 = $stack = [];
|
||||
$inString = $inPath = $inRange = $inError = false;
|
||||
$token = $previousToken = $nextToken = null;
|
||||
|
||||
$index = 1;
|
||||
$value = '';
|
||||
|
||||
$ERRORS = array("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A");
|
||||
$COMPARATORS_MULTI = array(">=", "<=", "<>");
|
||||
$ERRORS = ['#NULL!', '#DIV/0!', '#VALUE!', '#REF!', '#NAME?', '#NUM!', '#N/A'];
|
||||
$COMPARATORS_MULTI = ['>=', '<=', '<>'];
|
||||
|
||||
while ($index < $formulaLength) {
|
||||
// state-dependent character evaluation (order is important)
|
||||
|
@ -184,7 +184,7 @@ class FormulaParser
|
|||
} else {
|
||||
$inString = false;
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND, FormulaToken::TOKEN_SUBTYPE_TEXT);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
} else {
|
||||
$value .= $this->formula{$index};
|
||||
|
@ -231,7 +231,7 @@ class FormulaParser
|
|||
if (in_array($value, $ERRORS)) {
|
||||
$inError = false;
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND, FormulaToken::TOKEN_SUBTYPE_ERROR);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ class FormulaParser
|
|||
if (strlen($value > 0)) {
|
||||
// unexpected
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
$inString = true;
|
||||
++$index;
|
||||
|
@ -265,7 +265,7 @@ class FormulaParser
|
|||
if (strlen($value) > 0) {
|
||||
// unexpected
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
$inPath = true;
|
||||
++$index;
|
||||
|
@ -283,7 +283,7 @@ class FormulaParser
|
|||
if (strlen($value) > 0) {
|
||||
// unexpected
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
$inError = true;
|
||||
$value .= self::ERROR_START;
|
||||
|
@ -296,14 +296,14 @@ class FormulaParser
|
|||
if (strlen($value) > 0) {
|
||||
// unexpected
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$tmp = new FormulaToken("ARRAY", FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tmp = new FormulaToken('ARRAY', FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
|
||||
$tmp = new FormulaToken("ARRAYROW", FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tmp = new FormulaToken('ARRAYROW', FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
|
||||
|
@ -314,18 +314,18 @@ class FormulaParser
|
|||
if ($this->formula{$index} == self::SEMICOLON) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setValue('');
|
||||
$tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
$tmp = new FormulaToken(",", FormulaToken::TOKEN_TYPE_ARGUMENT);
|
||||
$tmp = new FormulaToken(',', FormulaToken::TOKEN_TYPE_ARGUMENT);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
$tmp = new FormulaToken("ARRAYROW", FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tmp = new FormulaToken('ARRAYROW', FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
|
||||
|
@ -336,16 +336,16 @@ class FormulaParser
|
|||
if ($this->formula{$index} == self::BRACE_CLOSE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setValue('');
|
||||
$tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setValue('');
|
||||
$tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
|
@ -357,9 +357,9 @@ class FormulaParser
|
|||
if ($this->formula{$index} == self::WHITESPACE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
$tokens1[] = new FormulaToken("", FormulaToken::TOKEN_TYPE_WHITESPACE);
|
||||
$tokens1[] = new FormulaToken('', FormulaToken::TOKEN_TYPE_WHITESPACE);
|
||||
++$index;
|
||||
while (($this->formula{$index} == self::WHITESPACE) && ($index < $formulaLength)) {
|
||||
++$index;
|
||||
|
@ -372,7 +372,7 @@ class FormulaParser
|
|||
if (in_array(substr($this->formula, $index, 2), $COMPARATORS_MULTI)) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
$tokens1[] = new FormulaToken(substr($this->formula, $index, 2), FormulaToken::TOKEN_TYPE_OPERATORINFIX, FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
$index += 2;
|
||||
|
@ -384,7 +384,7 @@ class FormulaParser
|
|||
if (strpos(self::OPERATORS_INFIX, $this->formula{$index}) !== false) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
$tokens1[] = new FormulaToken($this->formula{$index}, FormulaToken::TOKEN_TYPE_OPERATORINFIX);
|
||||
++$index;
|
||||
|
@ -395,7 +395,7 @@ class FormulaParser
|
|||
if (strpos(self::OPERATORS_POSTFIX, $this->formula{$index}) !== false) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
$tokens1[] = new FormulaToken($this->formula{$index}, FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
|
||||
++$index;
|
||||
|
@ -408,9 +408,9 @@ class FormulaParser
|
|||
$tmp = new FormulaToken($value, FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
$value = "";
|
||||
$value = '';
|
||||
} else {
|
||||
$tmp = new FormulaToken("", FormulaToken::TOKEN_TYPE_SUBEXPRESSION, FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tmp = new FormulaToken('', FormulaToken::TOKEN_TYPE_SUBEXPRESSION, FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
}
|
||||
|
@ -422,18 +422,18 @@ class FormulaParser
|
|||
if ($this->formula{$index} == self::COMMA) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setValue('');
|
||||
$tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$stack[] = $tmp;
|
||||
|
||||
if ($tmp->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) {
|
||||
$tokens1[] = new FormulaToken(",", FormulaToken::TOKEN_TYPE_OPERATORINFIX, FormulaToken::TOKEN_SUBTYPE_UNION);
|
||||
$tokens1[] = new FormulaToken(',', FormulaToken::TOKEN_TYPE_OPERATORINFIX, FormulaToken::TOKEN_SUBTYPE_UNION);
|
||||
} else {
|
||||
$tokens1[] = new FormulaToken(",", FormulaToken::TOKEN_TYPE_ARGUMENT);
|
||||
$tokens1[] = new FormulaToken(',', FormulaToken::TOKEN_TYPE_ARGUMENT);
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
|
@ -443,11 +443,11 @@ class FormulaParser
|
|||
if ($this->formula{$index} == self::PAREN_CLOSE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setValue('');
|
||||
$tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
|
@ -518,7 +518,7 @@ class FormulaParser
|
|||
|
||||
// move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators
|
||||
// to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names
|
||||
$this->tokens = array();
|
||||
$this->tokens = [];
|
||||
|
||||
$tokenCount = count($tokens2);
|
||||
for ($i = 0; $i < $tokenCount; ++$i) {
|
||||
|
@ -538,7 +538,7 @@ class FormulaParser
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
|
||||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '-') {
|
||||
if ($i == 0) {
|
||||
$token->setTokenType(FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||
} elseif ((($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
|
@ -556,7 +556,7 @@ class FormulaParser
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
|
||||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '+') {
|
||||
if ($i == 0) {
|
||||
continue;
|
||||
} elseif ((($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
|
@ -576,9 +576,9 @@ class FormulaParser
|
|||
|
||||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX &&
|
||||
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) {
|
||||
if (strpos('<>=', substr($token->getValue(), 0, 1)) !== false) {
|
||||
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
} elseif ($token->getValue() == "&") {
|
||||
} elseif ($token->getValue() == '&') {
|
||||
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_CONCATENATION);
|
||||
} else {
|
||||
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
|
@ -591,7 +591,7 @@ class FormulaParser
|
|||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND &&
|
||||
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (!is_numeric($token->getValue())) {
|
||||
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
|
||||
if (strtoupper($token->getValue()) == 'TRUE' || strtoupper($token->getValue() == 'FALSE')) {
|
||||
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
} else {
|
||||
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_RANGE);
|
||||
|
@ -606,7 +606,7 @@ class FormulaParser
|
|||
|
||||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) {
|
||||
if (strlen($token->getValue() > 0)) {
|
||||
if (substr($token->getValue(), 0, 1) == "@") {
|
||||
if (substr($token->getValue(), 0, 1) == '@') {
|
||||
$token->setValue(substr($token->getValue(), 1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,19 +2,18 @@
|
|||
|
||||
namespace PhpSpreadsheet\Calculation;
|
||||
|
||||
/** MAX_VALUE */
|
||||
/* MAX_VALUE */
|
||||
define('MAX_VALUE', 1.2e308);
|
||||
|
||||
/** 2 / PI */
|
||||
/* 2 / PI */
|
||||
define('M_2DIVPI', 0.63661977236758134307553505349006);
|
||||
|
||||
/** MAX_ITERATIONS */
|
||||
/* MAX_ITERATIONS */
|
||||
define('MAX_ITERATIONS', 256);
|
||||
|
||||
/** PRECISION */
|
||||
/* PRECISION */
|
||||
define('PRECISION', 8.88E-016);
|
||||
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
*
|
||||
|
@ -48,11 +47,9 @@ class Functions
|
|||
const RETURNDATE_PHP_OBJECT = 'O';
|
||||
const RETURNDATE_EXCEL = 'E';
|
||||
|
||||
|
||||
/**
|
||||
* Compatibility mode to use for error checking and responses
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
protected static $compatibilityMode = self::COMPATIBILITY_EXCEL;
|
||||
|
@ -60,7 +57,6 @@ class Functions
|
|||
/**
|
||||
* Data Type to use when returning date values
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
protected static $returnDateType = self::RETURNDATE_EXCEL;
|
||||
|
@ -68,10 +64,9 @@ class Functions
|
|||
/**
|
||||
* List of error codes
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
protected static $errorCodes = array(
|
||||
protected static $errorCodes = [
|
||||
'null' => '#NULL!',
|
||||
'divisionbyzero' => '#DIV/0!',
|
||||
'value' => '#VALUE!',
|
||||
|
@ -79,21 +74,19 @@ class Functions
|
|||
'name' => '#NAME?',
|
||||
'num' => '#NUM!',
|
||||
'na' => '#N/A',
|
||||
'gettingdata' => '#GETTING_DATA'
|
||||
);
|
||||
|
||||
'gettingdata' => '#GETTING_DATA',
|
||||
];
|
||||
|
||||
/**
|
||||
* Set the Compatibility Mode
|
||||
*
|
||||
* @access public
|
||||
* @category Function Configuration
|
||||
* @param string $compatibilityMode Compatibility Mode
|
||||
* Permitted values are:
|
||||
* Functions::COMPATIBILITY_EXCEL 'Excel'
|
||||
* Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
|
||||
* Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||
* @return boolean (Success or Failure)
|
||||
* @return bool (Success or Failure)
|
||||
*/
|
||||
public static function setCompatibilityMode($compatibilityMode)
|
||||
{
|
||||
|
@ -102,16 +95,16 @@ class Functions
|
|||
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)
|
||||
) {
|
||||
self::$compatibilityMode = $compatibilityMode;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the current Compatibility Mode
|
||||
*
|
||||
* @access public
|
||||
* @category Function Configuration
|
||||
* @return string Compatibility Mode
|
||||
* Possible Return values are:
|
||||
|
@ -124,18 +117,16 @@ class Functions
|
|||
return self::$compatibilityMode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
|
||||
*
|
||||
* @access public
|
||||
* @category Function Configuration
|
||||
* @param string $returnDateType Return Date Format
|
||||
* Permitted values are:
|
||||
* Functions::RETURNDATE_PHP_NUMERIC 'P'
|
||||
* Functions::RETURNDATE_PHP_OBJECT 'O'
|
||||
* Functions::RETURNDATE_EXCEL 'E'
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setReturnDateType($returnDateType)
|
||||
{
|
||||
|
@ -144,16 +135,16 @@ class Functions
|
|||
($returnDateType == self::RETURNDATE_EXCEL)
|
||||
) {
|
||||
self::$returnDateType = $returnDateType;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
|
||||
*
|
||||
* @access public
|
||||
* @category Function Configuration
|
||||
* @return string Return Date Format
|
||||
* Possible Return values are:
|
||||
|
@ -166,11 +157,9 @@ class Functions
|
|||
return self::$returnDateType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DUMMY
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #Not Yet Implemented
|
||||
*/
|
||||
|
@ -179,11 +168,9 @@ class Functions
|
|||
return '#Not Yet Implemented';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DIV0
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #Not Yet Implemented
|
||||
*/
|
||||
|
@ -192,7 +179,6 @@ class Functions
|
|||
return self::$errorCodes['divisionbyzero'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NA
|
||||
*
|
||||
|
@ -202,7 +188,6 @@ class Functions
|
|||
* Returns the error value #N/A
|
||||
* #N/A is the error value that means "no value is available."
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return string #N/A!
|
||||
*/
|
||||
|
@ -211,13 +196,11 @@ class Functions
|
|||
return self::$errorCodes['na'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NaN
|
||||
*
|
||||
* Returns the error value #NUM!
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #NUM!
|
||||
*/
|
||||
|
@ -226,13 +209,11 @@ class Functions
|
|||
return self::$errorCodes['num'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NAME
|
||||
*
|
||||
* Returns the error value #NAME?
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #NAME?
|
||||
*/
|
||||
|
@ -241,13 +222,11 @@ class Functions
|
|||
return self::$errorCodes['name'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* REF
|
||||
*
|
||||
* Returns the error value #REF!
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #REF!
|
||||
*/
|
||||
|
@ -256,28 +235,24 @@ class Functions
|
|||
return self::$errorCodes['reference'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NULL
|
||||
*
|
||||
* Returns the error value #NULL!
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #NULL!
|
||||
*/
|
||||
public static function NULL()
|
||||
public static function null()
|
||||
{
|
||||
return self::$errorCodes['null'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* VALUE
|
||||
*
|
||||
* Returns the error value #VALUE!
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #VALUE!
|
||||
*/
|
||||
|
@ -286,35 +261,32 @@ class Functions
|
|||
return self::$errorCodes['value'];
|
||||
}
|
||||
|
||||
|
||||
public static function isMatrixValue($idx)
|
||||
{
|
||||
return ((substr_count($idx, '.') <= 1) || (preg_match('/\.[A-Z]/', $idx) > 0));
|
||||
return (substr_count($idx, '.') <= 1) || (preg_match('/\.[A-Z]/', $idx) > 0);
|
||||
}
|
||||
|
||||
|
||||
public static function isValue($idx)
|
||||
{
|
||||
return (substr_count($idx, '.') == 0);
|
||||
return substr_count($idx, '.') == 0;
|
||||
}
|
||||
|
||||
|
||||
public static function isCellValue($idx)
|
||||
{
|
||||
return (substr_count($idx, '.') > 1);
|
||||
return substr_count($idx, '.') > 1;
|
||||
}
|
||||
|
||||
|
||||
public static function ifCondition($condition)
|
||||
{
|
||||
$condition = Functions::flattenSingleValue($condition);
|
||||
$condition = self::flattenSingleValue($condition);
|
||||
if (!isset($condition{0})) {
|
||||
$condition = '=""';
|
||||
}
|
||||
if (!in_array($condition{0}, array('>', '<', '='))) {
|
||||
if (!in_array($condition{0}, ['>', '<', '='])) {
|
||||
if (!is_numeric($condition)) {
|
||||
$condition = \PhpSpreadsheet\Calculation::wrapResult(strtoupper($condition));
|
||||
}
|
||||
|
||||
return '=' . $condition;
|
||||
} else {
|
||||
preg_match('/([<>=]+)(.*)/', $condition, $matches);
|
||||
|
@ -333,7 +305,7 @@ class Functions
|
|||
* ERROR_TYPE
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function errorType($value = '')
|
||||
{
|
||||
|
@ -346,15 +318,15 @@ class Functions
|
|||
}
|
||||
++$i;
|
||||
}
|
||||
|
||||
return self::NA();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_BLANK
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isBlank($value = null)
|
||||
{
|
||||
|
@ -365,12 +337,11 @@ class Functions
|
|||
return is_null($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_ERR
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isErr($value = '')
|
||||
{
|
||||
|
@ -379,12 +350,11 @@ class Functions
|
|||
return self::isError($value) && (!self::isNa(($value)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_ERROR
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isError($value = '')
|
||||
{
|
||||
|
@ -393,29 +363,28 @@ class Functions
|
|||
if (!is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array($value, array_values(self::$errorCodes));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_NA
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isNa($value = '')
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return ($value === self::NA());
|
||||
return $value === self::NA();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_EVEN
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEven($value = null)
|
||||
{
|
||||
|
@ -427,15 +396,14 @@ class Functions
|
|||
return self::VALUE();
|
||||
}
|
||||
|
||||
return ($value % 2 == 0);
|
||||
return $value % 2 == 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_ODD
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isOdd($value = null)
|
||||
{
|
||||
|
@ -447,15 +415,14 @@ class Functions
|
|||
return self::VALUE();
|
||||
}
|
||||
|
||||
return (abs($value) % 2 == 1);
|
||||
return abs($value) % 2 == 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_NUMBER
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isNumber($value = null)
|
||||
{
|
||||
|
@ -464,15 +431,15 @@ class Functions
|
|||
if (is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return is_numeric($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_LOGICAL
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isLogical($value = null)
|
||||
{
|
||||
|
@ -481,33 +448,30 @@ class Functions
|
|||
return is_bool($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_TEXT
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isText($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return (is_string($value) && !self::isError($value));
|
||||
return is_string($value) && !self::isError($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_NONTEXT
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isNonText($value = null)
|
||||
{
|
||||
return !self::isText($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* VERSION
|
||||
*
|
||||
|
@ -518,7 +482,6 @@ class Functions
|
|||
return 'PhpSpreadsheet ##VERSION##, ##DATE##';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* N
|
||||
*
|
||||
|
@ -554,10 +517,10 @@ class Functions
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TYPE
|
||||
*
|
||||
|
@ -602,12 +565,13 @@ class Functions
|
|||
if ((strlen($value) > 0) && ($value{0} == '#')) {
|
||||
return 16;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a multi-dimensional array to a simple 1-dimensional array
|
||||
*
|
||||
|
@ -620,7 +584,7 @@ class Functions
|
|||
return (array) $array;
|
||||
}
|
||||
|
||||
$arrayValues = array();
|
||||
$arrayValues = [];
|
||||
foreach ($array as $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $val) {
|
||||
|
@ -640,7 +604,6 @@ class Functions
|
|||
return $arrayValues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing
|
||||
*
|
||||
|
@ -653,7 +616,7 @@ class Functions
|
|||
return (array) $array;
|
||||
}
|
||||
|
||||
$arrayValues = array();
|
||||
$arrayValues = [];
|
||||
foreach ($array as $k1 => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k2 => $val) {
|
||||
|
@ -673,7 +636,6 @@ class Functions
|
|||
return $arrayValues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an array to a single scalar value by extracting the first element
|
||||
*
|
||||
|
@ -690,7 +652,6 @@ class Functions
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// There are a few mathematical functions that aren't available on all versions of PHP for all platforms
|
||||
// These functions aren't available in Windows implementations of PHP prior to version 5.3.0
|
||||
|
@ -717,7 +678,6 @@ if (!function_exists('atanh')) {
|
|||
} // function atanh()
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Strangely, PHP doesn't have a mb_str_replace multibyte function
|
||||
// As we'll only ever use this function with UTF-8 characters, we can simply "hard-code" the character set
|
||||
|
@ -728,10 +688,11 @@ if ((!function_exists('mb_str_replace')) &&
|
|||
function mb_str_replace($search, $replace, $subject)
|
||||
{
|
||||
if (is_array($subject)) {
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
foreach ($subject as $key => $val) {
|
||||
$ret[$key] = mb_str_replace($search, $replace, $val);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
@ -746,6 +707,7 @@ if ((!function_exists('mb_str_replace')) &&
|
|||
$pos = mb_strpos($subject, $s, $pos + mb_strlen($r, 'UTF-8'), 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
return $subject;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,16 +34,14 @@ class Logical
|
|||
* Excel Function:
|
||||
* =TRUE()
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return boolean True
|
||||
* @return bool True
|
||||
*/
|
||||
public static function TRUE()
|
||||
public static function true()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FALSE
|
||||
*
|
||||
|
@ -52,16 +50,14 @@ class Logical
|
|||
* Excel Function:
|
||||
* =FALSE()
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return boolean False
|
||||
* @return bool False
|
||||
*/
|
||||
public static function FALSE()
|
||||
public static function false()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LOGICAL_AND
|
||||
*
|
||||
|
@ -78,10 +74,9 @@ class Logical
|
|||
* 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.
|
||||
* @return bool The logical AND of the arguments.
|
||||
*/
|
||||
public static function logicalAnd()
|
||||
{
|
||||
|
@ -114,10 +109,10 @@ class Logical
|
|||
if ($argCount < 0) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LOGICAL_OR
|
||||
*
|
||||
|
@ -134,10 +129,9 @@ class Logical
|
|||
* 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.
|
||||
* @return bool The logical OR of the arguments.
|
||||
*/
|
||||
public static function logicalOr()
|
||||
{
|
||||
|
@ -170,10 +164,10 @@ class Logical
|
|||
if ($argCount < 0) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NOT
|
||||
*
|
||||
|
@ -189,10 +183,9 @@ class Logical
|
|||
* 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.
|
||||
* @return bool The boolean inverse of the argument.
|
||||
*/
|
||||
public static function NOT($logical = false)
|
||||
{
|
||||
|
@ -236,7 +229,6 @@ class Logical
|
|||
* 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
|
||||
|
@ -252,14 +244,12 @@ class Logical
|
|||
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
|
||||
|
|
|
@ -73,6 +73,7 @@ class LookupRef
|
|||
if (($relativity == 3) || ($relativity == 4)) {
|
||||
$rowRelative = '';
|
||||
}
|
||||
|
||||
return $sheetText . $columnRelative . $column . $rowRelative . $row;
|
||||
} else {
|
||||
if (($relativity == 2) || ($relativity == 4)) {
|
||||
|
@ -81,11 +82,11 @@ class LookupRef
|
|||
if (($relativity == 3) || ($relativity == 4)) {
|
||||
$row = '[' . $row . ']';
|
||||
}
|
||||
|
||||
return $sheetText . 'R' . $row . 'C' . $column;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COLUMN
|
||||
*
|
||||
|
@ -98,7 +99,7 @@ class LookupRef
|
|||
* =COLUMN([cellAddress])
|
||||
*
|
||||
* @param cellAddress A reference to a range of cells for which you want the column numbers
|
||||
* @return integer or array of integer
|
||||
* @return int or array of integer
|
||||
*/
|
||||
public static function COLUMN($cellAddress = null)
|
||||
{
|
||||
|
@ -109,6 +110,7 @@ class LookupRef
|
|||
if (is_array($cellAddress)) {
|
||||
foreach ($cellAddress as $columnKey => $value) {
|
||||
$columnKey = preg_replace('/[^a-z]/i', '', $columnKey);
|
||||
|
||||
return (integer) \PhpSpreadsheet\Cell::columnIndexFromString($columnKey);
|
||||
}
|
||||
} else {
|
||||
|
@ -119,19 +121,20 @@ class LookupRef
|
|||
list($startAddress, $endAddress) = explode(':', $cellAddress);
|
||||
$startAddress = preg_replace('/[^a-z]/i', '', $startAddress);
|
||||
$endAddress = preg_replace('/[^a-z]/i', '', $endAddress);
|
||||
$returnValue = array();
|
||||
$returnValue = [];
|
||||
do {
|
||||
$returnValue[] = (integer) \PhpSpreadsheet\Cell::columnIndexFromString($startAddress);
|
||||
} while ($startAddress++ != $endAddress);
|
||||
|
||||
return $returnValue;
|
||||
} else {
|
||||
$cellAddress = preg_replace('/[^a-z]/i', '', $cellAddress);
|
||||
|
||||
return (integer) \PhpSpreadsheet\Cell::columnIndexFromString($cellAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COLUMNS
|
||||
*
|
||||
|
@ -141,7 +144,7 @@ class LookupRef
|
|||
* =COLUMNS(cellAddress)
|
||||
*
|
||||
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
|
||||
* @return integer The number of columns in cellAddress
|
||||
* @return int The number of columns in cellAddress
|
||||
*/
|
||||
public static function COLUMNS($cellAddress = null)
|
||||
{
|
||||
|
@ -162,7 +165,6 @@ class LookupRef
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ROW
|
||||
*
|
||||
|
@ -175,7 +177,7 @@ class LookupRef
|
|||
* =ROW([cellAddress])
|
||||
*
|
||||
* @param cellAddress A reference to a range of cells for which you want the row numbers
|
||||
* @return integer or array of integer
|
||||
* @return int or array of integer
|
||||
*/
|
||||
public static function ROW($cellAddress = null)
|
||||
{
|
||||
|
@ -197,19 +199,20 @@ class LookupRef
|
|||
list($startAddress, $endAddress) = explode(':', $cellAddress);
|
||||
$startAddress = preg_replace('/[^0-9]/', '', $startAddress);
|
||||
$endAddress = preg_replace('/[^0-9]/', '', $endAddress);
|
||||
$returnValue = array();
|
||||
$returnValue = [];
|
||||
do {
|
||||
$returnValue[][] = (integer) $startAddress;
|
||||
} while ($startAddress++ != $endAddress);
|
||||
|
||||
return $returnValue;
|
||||
} else {
|
||||
list($cellAddress) = explode(':', $cellAddress);
|
||||
|
||||
return (integer) preg_replace('/[^0-9]/', '', $cellAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ROWS
|
||||
*
|
||||
|
@ -219,7 +222,7 @@ class LookupRef
|
|||
* =ROWS(cellAddress)
|
||||
*
|
||||
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
|
||||
* @return integer The number of rows in cellAddress
|
||||
* @return int The number of rows in cellAddress
|
||||
*/
|
||||
public static function ROWS($cellAddress = null)
|
||||
{
|
||||
|
@ -240,14 +243,12 @@ class LookupRef
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HYPERLINK
|
||||
*
|
||||
* Excel Function:
|
||||
* =HYPERLINK(linkURL,displayName)
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param string $linkURL Value to check, is also the value returned when no error
|
||||
* @param string $displayName Value to return when testValue is an error condition
|
||||
|
@ -276,7 +277,6 @@ class LookupRef
|
|||
return $displayName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* INDIRECT
|
||||
*
|
||||
|
@ -293,7 +293,6 @@ class LookupRef
|
|||
* @return mixed The cells referenced by cellAddress
|
||||
*
|
||||
* @todo Support for the optional a1 parameter introduced in Excel 2010
|
||||
*
|
||||
*/
|
||||
public static function INDIRECT($cellAddress = null, \PhpSpreadsheet\Cell $pCell = null)
|
||||
{
|
||||
|
@ -336,7 +335,6 @@ class LookupRef
|
|||
return \PhpSpreadsheet\Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* OFFSET
|
||||
*
|
||||
|
@ -379,12 +377,12 @@ class LookupRef
|
|||
}
|
||||
|
||||
$sheetName = null;
|
||||
if (strpos($cellAddress, "!")) {
|
||||
list($sheetName, $cellAddress) = explode("!", $cellAddress);
|
||||
if (strpos($cellAddress, '!')) {
|
||||
list($sheetName, $cellAddress) = explode('!', $cellAddress);
|
||||
$sheetName = trim($sheetName, "'");
|
||||
}
|
||||
if (strpos($cellAddress, ":")) {
|
||||
list($startCell, $endCell) = explode(":", $cellAddress);
|
||||
if (strpos($cellAddress, ':')) {
|
||||
list($startCell, $endCell) = explode(':', $cellAddress);
|
||||
} else {
|
||||
$startCell = $endCell = $cellAddress;
|
||||
}
|
||||
|
@ -431,7 +429,6 @@ class LookupRef
|
|||
return \PhpSpreadsheet\Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CHOOSE
|
||||
*
|
||||
|
@ -476,7 +473,6 @@ class LookupRef
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MATCH
|
||||
*
|
||||
|
@ -488,7 +484,7 @@ class LookupRef
|
|||
* @param lookup_value The value that you want to match in lookup_array
|
||||
* @param lookup_array The range of cells being searched
|
||||
* @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
|
||||
* @return integer The relative position of the found item
|
||||
* @return int The relative position of the found item
|
||||
*/
|
||||
public static function MATCH($lookup_value, $lookup_array, $match_type = 1)
|
||||
{
|
||||
|
@ -573,7 +569,6 @@ class LookupRef
|
|||
return Functions::NA();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* INDEX
|
||||
*
|
||||
|
@ -607,7 +602,7 @@ class LookupRef
|
|||
return $arrayValues;
|
||||
}
|
||||
$rowNum = $rowKeys[--$rowNum];
|
||||
$returnArray = array();
|
||||
$returnArray = [];
|
||||
foreach ($arrayValues as $arrayColumn) {
|
||||
if (is_array($arrayColumn)) {
|
||||
if (isset($arrayColumn[$rowNum])) {
|
||||
|
@ -619,6 +614,7 @@ class LookupRef
|
|||
return $arrayValues[$rowNum];
|
||||
}
|
||||
}
|
||||
|
||||
return $returnArray;
|
||||
}
|
||||
$columnNum = $columnKeys[--$columnNum];
|
||||
|
@ -632,7 +628,6 @@ class LookupRef
|
|||
return $arrayValues[$rowNum][$columnNum];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TRANSPOSE
|
||||
*
|
||||
|
@ -643,9 +638,9 @@ class LookupRef
|
|||
*/
|
||||
public static function TRANSPOSE($matrixData)
|
||||
{
|
||||
$returnMatrix = array();
|
||||
$returnMatrix = [];
|
||||
if (!is_array($matrixData)) {
|
||||
$matrixData = array(array($matrixData));
|
||||
$matrixData = [[$matrixData]];
|
||||
}
|
||||
|
||||
$column = 0;
|
||||
|
@ -657,10 +652,10 @@ class LookupRef
|
|||
}
|
||||
++$column;
|
||||
}
|
||||
|
||||
return $returnMatrix;
|
||||
}
|
||||
|
||||
|
||||
private static function vlookupSort($a, $b)
|
||||
{
|
||||
reset($a);
|
||||
|
@ -668,10 +663,10 @@ class LookupRef
|
|||
if (($aLower = strtolower($a[$firstColumn])) == ($bLower = strtolower($b[$firstColumn]))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($aLower < $bLower) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* VLOOKUP
|
||||
* The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number.
|
||||
|
@ -708,7 +703,7 @@ class LookupRef
|
|||
}
|
||||
|
||||
if (!$not_exact_match) {
|
||||
uasort($lookup_array, array('self', 'vlookupSort'));
|
||||
uasort($lookup_array, ['self', 'vlookupSort']);
|
||||
}
|
||||
|
||||
$rowNumber = $rowValue = false;
|
||||
|
@ -738,7 +733,6 @@ class LookupRef
|
|||
return Functions::NA();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HLOOKUP
|
||||
* The HLOOKUP function searches for value in the top-most row of lookup_array and returns the value in the same column based on the index_number.
|
||||
|
@ -801,7 +795,6 @@ class LookupRef
|
|||
return Functions::NA();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LOOKUP
|
||||
* The LOOKUP function searches for value either from a one-row or one-column range or from an array.
|
||||
|
@ -851,7 +844,7 @@ class LookupRef
|
|||
if (is_array($value)) {
|
||||
$k = array_keys($value);
|
||||
$key1 = $key2 = array_shift($k);
|
||||
$key2++;
|
||||
++$key2;
|
||||
$dataValue1 = $value[$key1];
|
||||
} else {
|
||||
$key1 = 0;
|
||||
|
@ -862,7 +855,7 @@ class LookupRef
|
|||
if (is_array($dataValue2)) {
|
||||
$dataValue2 = array_shift($dataValue2);
|
||||
}
|
||||
$value = array($key1 => $dataValue1, $key2 => $dataValue2);
|
||||
$value = [$key1 => $dataValue1, $key2 => $dataValue2];
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class MathTrig
|
|||
{
|
||||
$startVal = floor(sqrt($value));
|
||||
|
||||
$factorArray = array();
|
||||
$factorArray = [];
|
||||
for ($i = $startVal; $i > 1; --$i) {
|
||||
if (($value % $i) == 0) {
|
||||
$factorArray = array_merge($factorArray, self::factors($value / $i));
|
||||
|
@ -45,19 +45,18 @@ class MathTrig
|
|||
}
|
||||
if (!empty($factorArray)) {
|
||||
rsort($factorArray);
|
||||
|
||||
return $factorArray;
|
||||
} else {
|
||||
return array((integer) $value);
|
||||
return [(integer) $value];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static function romanCut($num, $n)
|
||||
{
|
||||
return ($num - ($num % $n)) / $n;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ATAN2
|
||||
*
|
||||
|
@ -74,7 +73,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* ATAN2(xCoordinate,yCoordinate)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param float $xCoordinate The x-coordinate of the point.
|
||||
* @param float $yCoordinate The y-coordinate of the point.
|
||||
|
@ -99,10 +97,10 @@ class MathTrig
|
|||
|
||||
return atan2($yCoordinate, $xCoordinate);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CEILING
|
||||
*
|
||||
|
@ -114,7 +112,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* CEILING(number[,significance])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param float $number The number you want to round.
|
||||
* @param float $significance The multiple to which you want to round.
|
||||
|
@ -139,10 +136,10 @@ class MathTrig
|
|||
return Functions::NAN();
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COMBIN
|
||||
*
|
||||
|
@ -152,7 +149,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* COMBIN(numObjs,numInSet)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param int $numObjs Number of different objects
|
||||
* @param int $numInSet Number of objects in each combination
|
||||
|
@ -169,12 +165,13 @@ class MathTrig
|
|||
} elseif ($numInSet < 0) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EVEN
|
||||
*
|
||||
|
@ -187,7 +184,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* EVEN(number)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param float $number Number to round
|
||||
* @return int Rounded Number
|
||||
|
@ -204,12 +200,13 @@ class MathTrig
|
|||
|
||||
if (is_numeric($number)) {
|
||||
$significance = 2 * self::SIGN($number);
|
||||
|
||||
return (int) self::CEILING($number, $significance);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FACT
|
||||
*
|
||||
|
@ -219,7 +216,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* FACT(factVal)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param float $factVal Factorial Value
|
||||
* @return int Factorial
|
||||
|
@ -243,12 +239,13 @@ class MathTrig
|
|||
while ($factLoop > 1) {
|
||||
$factorial *= $factLoop--;
|
||||
}
|
||||
|
||||
return $factorial;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FACTDOUBLE
|
||||
*
|
||||
|
@ -257,7 +254,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* FACTDOUBLE(factVal)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param float $factVal Factorial Value
|
||||
* @return int Double Factorial
|
||||
|
@ -276,12 +272,13 @@ class MathTrig
|
|||
$factorial *= $factLoop--;
|
||||
--$factLoop;
|
||||
}
|
||||
|
||||
return $factorial;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FLOOR
|
||||
*
|
||||
|
@ -290,7 +287,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* FLOOR(number[,significance])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param float $number Number to round
|
||||
* @param float $significance Significance
|
||||
|
@ -321,7 +317,6 @@ class MathTrig
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GCD
|
||||
*
|
||||
|
@ -332,15 +327,14 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* GCD(number1[,number2[, ...]])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return integer Greatest Common Divisor
|
||||
* @return int Greatest Common Divisor
|
||||
*/
|
||||
public static function GCD()
|
||||
{
|
||||
$returnValue = 1;
|
||||
$allValuesFactors = array();
|
||||
$allValuesFactors = [];
|
||||
// Loop through arguments
|
||||
foreach (Functions::flattenArray(func_get_args()) as $value) {
|
||||
if (!is_numeric($value)) {
|
||||
|
@ -382,6 +376,7 @@ class MathTrig
|
|||
foreach ($mergedArray as $key => $value) {
|
||||
$returnValue *= pow($key, $value);
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
} else {
|
||||
$keys = array_keys($mergedArray);
|
||||
|
@ -394,11 +389,11 @@ class MathTrig
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pow($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* INT
|
||||
*
|
||||
|
@ -407,10 +402,9 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* INT(number)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param float $number Number to cast to an integer
|
||||
* @return integer Integer value
|
||||
* @return int Integer value
|
||||
*/
|
||||
public static function INT($number)
|
||||
{
|
||||
|
@ -424,10 +418,10 @@ class MathTrig
|
|||
if (is_numeric($number)) {
|
||||
return (int) floor($number);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LCM
|
||||
*
|
||||
|
@ -439,7 +433,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* LCM(number1[,number2[, ...]])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return int Lowest Common Multiplier
|
||||
|
@ -447,7 +440,7 @@ class MathTrig
|
|||
public static function LCM()
|
||||
{
|
||||
$returnValue = 1;
|
||||
$allPoweredFactors = array();
|
||||
$allPoweredFactors = [];
|
||||
// Loop through arguments
|
||||
foreach (Functions::flattenArray(func_get_args()) as $value) {
|
||||
if (!is_numeric($value)) {
|
||||
|
@ -460,7 +453,7 @@ class MathTrig
|
|||
}
|
||||
$myFactors = self::factors(floor($value));
|
||||
$myCountedFactors = array_count_values($myFactors);
|
||||
$myPoweredFactors = array();
|
||||
$myPoweredFactors = [];
|
||||
foreach ($myCountedFactors as $myCountedFactor => $myCountedPower) {
|
||||
$myPoweredFactors[$myCountedFactor] = pow($myCountedFactor, $myCountedPower);
|
||||
}
|
||||
|
@ -477,10 +470,10 @@ class MathTrig
|
|||
foreach ($allPoweredFactors as $allPoweredFactor) {
|
||||
$returnValue *= (integer) $allPoweredFactor;
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LOG_BASE
|
||||
*
|
||||
|
@ -489,7 +482,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* LOG(number[,base])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param float $number The positive real number for which you want the logarithm
|
||||
* @param float $base The base of the logarithm. If base is omitted, it is assumed to be 10.
|
||||
|
@ -506,10 +498,10 @@ class MathTrig
|
|||
if (($base <= 0) || ($number <= 0)) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return log($number, $base);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MDETERM
|
||||
*
|
||||
|
@ -518,22 +510,21 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* MDETERM(array)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param array $matrixValues A matrix of values
|
||||
* @return float
|
||||
*/
|
||||
public static function MDETERM($matrixValues)
|
||||
{
|
||||
$matrixData = array();
|
||||
$matrixData = [];
|
||||
if (!is_array($matrixValues)) {
|
||||
$matrixValues = array(array($matrixValues));
|
||||
$matrixValues = [[$matrixValues]];
|
||||
}
|
||||
|
||||
$row = $maxColumn = 0;
|
||||
foreach ($matrixValues as $matrixRow) {
|
||||
if (!is_array($matrixRow)) {
|
||||
$matrixRow = array($matrixRow);
|
||||
$matrixRow = [$matrixRow];
|
||||
}
|
||||
$column = 0;
|
||||
foreach ($matrixRow as $matrixCell) {
|
||||
|
@ -554,13 +545,13 @@ class MathTrig
|
|||
|
||||
try {
|
||||
$matrix = new \PhpSpreadsheet\Shared\JAMA\Matrix($matrixData);
|
||||
|
||||
return $matrix->det();
|
||||
} catch (\PhpSpreadsheet\Exception $ex) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MINVERSE
|
||||
*
|
||||
|
@ -569,22 +560,21 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* MINVERSE(array)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param array $matrixValues A matrix of values
|
||||
* @return array
|
||||
*/
|
||||
public static function MINVERSE($matrixValues)
|
||||
{
|
||||
$matrixData = array();
|
||||
$matrixData = [];
|
||||
if (!is_array($matrixValues)) {
|
||||
$matrixValues = array(array($matrixValues));
|
||||
$matrixValues = [[$matrixValues]];
|
||||
}
|
||||
|
||||
$row = $maxColumn = 0;
|
||||
foreach ($matrixValues as $matrixRow) {
|
||||
if (!is_array($matrixRow)) {
|
||||
$matrixRow = array($matrixRow);
|
||||
$matrixRow = [$matrixRow];
|
||||
}
|
||||
$column = 0;
|
||||
foreach ($matrixRow as $matrixCell) {
|
||||
|
@ -607,13 +597,13 @@ class MathTrig
|
|||
|
||||
try {
|
||||
$matrix = new \PhpSpreadsheet\Shared\JAMA\Matrix($matrixData);
|
||||
|
||||
return $matrix->inverse()->getArray();
|
||||
} catch (\PhpSpreadsheet\Exception $ex) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MMULT
|
||||
*
|
||||
|
@ -623,19 +613,19 @@ class MathTrig
|
|||
*/
|
||||
public static function MMULT($matrixData1, $matrixData2)
|
||||
{
|
||||
$matrixAData = $matrixBData = array();
|
||||
$matrixAData = $matrixBData = [];
|
||||
if (!is_array($matrixData1)) {
|
||||
$matrixData1 = array(array($matrixData1));
|
||||
$matrixData1 = [[$matrixData1]];
|
||||
}
|
||||
if (!is_array($matrixData2)) {
|
||||
$matrixData2 = array(array($matrixData2));
|
||||
$matrixData2 = [[$matrixData2]];
|
||||
}
|
||||
|
||||
try {
|
||||
$rowA = 0;
|
||||
foreach ($matrixData1 as $matrixRow) {
|
||||
if (!is_array($matrixRow)) {
|
||||
$matrixRow = array($matrixRow);
|
||||
$matrixRow = [$matrixRow];
|
||||
}
|
||||
$columnA = 0;
|
||||
foreach ($matrixRow as $matrixCell) {
|
||||
|
@ -651,7 +641,7 @@ class MathTrig
|
|||
$rowB = 0;
|
||||
foreach ($matrixData2 as $matrixRow) {
|
||||
if (!is_array($matrixRow)) {
|
||||
$matrixRow = array($matrixRow);
|
||||
$matrixRow = [$matrixRow];
|
||||
}
|
||||
$columnB = 0;
|
||||
foreach ($matrixRow as $matrixCell) {
|
||||
|
@ -672,11 +662,11 @@ class MathTrig
|
|||
return $matrixA->times($matrixB)->getArray();
|
||||
} catch (\PhpSpreadsheet\Exception $ex) {
|
||||
var_dump($ex->getMessage());
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MOD
|
||||
*
|
||||
|
@ -700,7 +690,6 @@ class MathTrig
|
|||
return fmod($a, $b);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MROUND
|
||||
*
|
||||
|
@ -721,14 +710,16 @@ class MathTrig
|
|||
}
|
||||
if ((self::SIGN($number)) == (self::SIGN($multiple))) {
|
||||
$multiplier = 1 / $multiple;
|
||||
|
||||
return round($number * $multiplier) / $multiplier;
|
||||
}
|
||||
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MULTINOMIAL
|
||||
*
|
||||
|
@ -758,12 +749,13 @@ class MathTrig
|
|||
// Return
|
||||
if ($summer > 0) {
|
||||
$summer = self::FACT($summer);
|
||||
|
||||
return $summer / $divisor;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ODD
|
||||
*
|
||||
|
@ -793,10 +785,10 @@ class MathTrig
|
|||
|
||||
return (int) $result;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POWER
|
||||
*
|
||||
|
@ -820,10 +812,10 @@ class MathTrig
|
|||
|
||||
// Return
|
||||
$result = pow($x, $y);
|
||||
|
||||
return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NAN();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PRODUCT
|
||||
*
|
||||
|
@ -832,7 +824,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* PRODUCT(value1[,value2[, ...]])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return float
|
||||
|
@ -858,10 +849,10 @@ class MathTrig
|
|||
if (is_null($returnValue)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* QUOTIENT
|
||||
*
|
||||
|
@ -871,7 +862,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* QUOTIENT(value1[,value2[, ...]])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return float
|
||||
|
@ -901,7 +891,6 @@ class MathTrig
|
|||
return intval($returnValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RAND
|
||||
*
|
||||
|
@ -921,7 +910,6 @@ class MathTrig
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static function ROMAN($aValue, $style = 0)
|
||||
{
|
||||
$aValue = Functions::flattenSingleValue($aValue);
|
||||
|
@ -934,10 +922,10 @@ class MathTrig
|
|||
return '';
|
||||
}
|
||||
|
||||
$mill = array('', 'M', 'MM', 'MMM', 'MMMM', 'MMMMM');
|
||||
$cent = array('', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM');
|
||||
$tens = array('', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC');
|
||||
$ones = array('', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX');
|
||||
$mill = ['', 'M', 'MM', 'MMM', 'MMMM', 'MMMMM'];
|
||||
$cent = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'];
|
||||
$tens = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'];
|
||||
$ones = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
|
||||
|
||||
$roman = '';
|
||||
while ($aValue > 5999) {
|
||||
|
@ -954,7 +942,6 @@ class MathTrig
|
|||
return $roman . $mill[$m] . $cent[$c] . $tens[$t] . $ones[$aValue];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ROUNDUP
|
||||
*
|
||||
|
@ -977,10 +964,10 @@ class MathTrig
|
|||
return ceil($number * $significance) / $significance;
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ROUNDDOWN
|
||||
*
|
||||
|
@ -1003,10 +990,10 @@ class MathTrig
|
|||
return floor($number * $significance) / $significance;
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SERIESSUM
|
||||
*
|
||||
|
@ -1040,12 +1027,13 @@ class MathTrig
|
|||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SIGN
|
||||
*
|
||||
|
@ -1066,12 +1054,13 @@ class MathTrig
|
|||
if ($number == 0.0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $number / abs($number);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SQRTPI
|
||||
*
|
||||
|
@ -1088,12 +1077,13 @@ class MathTrig
|
|||
if ($number < 0) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return sqrt($number * M_PI);
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SUBTOTAL
|
||||
*
|
||||
|
@ -1137,10 +1127,10 @@ class MathTrig
|
|||
return Statistical::VARP($aArgs);
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SUM
|
||||
*
|
||||
|
@ -1149,7 +1139,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* SUM(value1[,value2[, ...]])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return float
|
||||
|
@ -1169,7 +1158,6 @@ class MathTrig
|
|||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SUMIF
|
||||
*
|
||||
|
@ -1178,13 +1166,12 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* SUMIF(value1[,value2[, ...]],condition)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @param string $condition The criteria that defines which cells will be summed.
|
||||
* @return float
|
||||
*/
|
||||
public static function SUMIF($aArgs, $condition, $sumArgs = array())
|
||||
public static function SUMIF($aArgs, $condition, $sumArgs = [])
|
||||
{
|
||||
$returnValue = 0;
|
||||
|
||||
|
@ -1219,7 +1206,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* SUMIFS(value1[,value2[, ...]],condition)
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @param string $condition The criteria that defines which cells will be summed.
|
||||
|
@ -1266,7 +1252,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* SUMPRODUCT(value1[,value2[, ...]])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return float
|
||||
|
@ -1302,7 +1287,6 @@ class MathTrig
|
|||
return array_sum($wrkArray);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SUMSQ
|
||||
*
|
||||
|
@ -1311,7 +1295,6 @@ class MathTrig
|
|||
* Excel Function:
|
||||
* SUMSQ(value1[,value2[, ...]])
|
||||
*
|
||||
* @access public
|
||||
* @category Mathematical and Trigonometric Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return float
|
||||
|
@ -1331,7 +1314,6 @@ class MathTrig
|
|||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SUMX2MY2
|
||||
*
|
||||
|
@ -1356,7 +1338,6 @@ class MathTrig
|
|||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SUMX2PY2
|
||||
*
|
||||
|
@ -1381,7 +1362,6 @@ class MathTrig
|
|||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SUMXMY2
|
||||
*
|
||||
|
@ -1406,7 +1386,6 @@ class MathTrig
|
|||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TRUNC
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -46,6 +46,7 @@ class TextData
|
|||
// error
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,6 @@ class TextData
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TRIMNONPRINTABLE
|
||||
*
|
||||
|
@ -92,10 +92,10 @@ class TextData
|
|||
if (is_string($stringValue) || is_numeric($stringValue)) {
|
||||
return str_replace(self::$invalidChars, '', trim($stringValue, "\x00..\x1F"));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TRIMSPACES
|
||||
*
|
||||
|
@ -112,10 +112,10 @@ class TextData
|
|||
if (is_string($stringValue) || is_numeric($stringValue)) {
|
||||
return trim(preg_replace('/ +/', ' ', trim($stringValue, ' ')), ' ');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ASCIICODE
|
||||
*
|
||||
|
@ -141,16 +141,17 @@ class TextData
|
|||
if (mb_strlen($characters, 'UTF-8') > 1) {
|
||||
$character = mb_substr($characters, 0, 1, 'UTF-8');
|
||||
}
|
||||
|
||||
return self::unicodeToOrd($character);
|
||||
} else {
|
||||
if (strlen($characters) > 0) {
|
||||
$character = substr($characters, 0, 1);
|
||||
}
|
||||
|
||||
return ord($character);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CONCATENATE
|
||||
*
|
||||
|
@ -176,7 +177,6 @@ class TextData
|
|||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DOLLAR
|
||||
*
|
||||
|
@ -214,7 +214,6 @@ class TextData
|
|||
return \PhpSpreadsheet\Style\NumberFormat::toFormattedString($value, $mask);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SEARCHSENSITIVE
|
||||
*
|
||||
|
@ -248,10 +247,10 @@ class TextData
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SEARCHINSENSITIVE
|
||||
*
|
||||
|
@ -285,17 +284,17 @@ class TextData
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FIXEDFORMAT
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @param integer $decimals
|
||||
* @param boolean $no_commas
|
||||
* @return boolean
|
||||
* @param int $decimals
|
||||
* @param bool $no_commas
|
||||
* @return bool
|
||||
*/
|
||||
public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = false)
|
||||
{
|
||||
|
@ -320,7 +319,6 @@ class TextData
|
|||
return (string) $valueResult;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LEFT
|
||||
*
|
||||
|
@ -348,7 +346,6 @@ class TextData
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MID
|
||||
*
|
||||
|
@ -381,7 +378,6 @@ class TextData
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RIGHT
|
||||
*
|
||||
|
@ -409,7 +405,6 @@ class TextData
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* STRINGLENGTH
|
||||
*
|
||||
|
@ -431,7 +426,6 @@ class TextData
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LOWERCASE
|
||||
*
|
||||
|
@ -451,7 +445,6 @@ class TextData
|
|||
return \PhpSpreadsheet\Shared\StringHelper::strToLower($mixedCaseString);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UPPERCASE
|
||||
*
|
||||
|
@ -471,7 +464,6 @@ class TextData
|
|||
return \PhpSpreadsheet\Shared\StringHelper::strToUpper($mixedCaseString);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PROPERCASE
|
||||
*
|
||||
|
@ -491,7 +483,6 @@ class TextData
|
|||
return \PhpSpreadsheet\Shared\StringHelper::strToTitle($mixedCaseString);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* REPLACE
|
||||
*
|
||||
|
@ -514,14 +505,13 @@ class TextData
|
|||
return $left . $newText . $right;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SUBSTITUTE
|
||||
*
|
||||
* @param string $text Value
|
||||
* @param string $fromText From Value
|
||||
* @param string $toText To Value
|
||||
* @param integer $instance Instance Number
|
||||
* @param int $instance Instance Number
|
||||
* @return string
|
||||
*/
|
||||
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0)
|
||||
|
@ -562,12 +552,11 @@ class TextData
|
|||
return $text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RETURNSTRING
|
||||
*
|
||||
* @param mixed $testValue Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function RETURNSTRING($testValue = '')
|
||||
{
|
||||
|
@ -576,16 +565,16 @@ class TextData
|
|||
if (is_string($testValue)) {
|
||||
return $testValue;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TEXTFORMAT
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @param string $format Format mask to use
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function TEXTFORMAT($value, $format)
|
||||
{
|
||||
|
@ -603,7 +592,7 @@ class TextData
|
|||
* VALUE
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function VALUE($value = '')
|
||||
{
|
||||
|
@ -626,18 +615,21 @@ class TextData
|
|||
$timeValue = DateTime::TIMEVALUE($value);
|
||||
if ($timeValue !== Functions::VALUE()) {
|
||||
Functions::setReturnDateType($dateSetting);
|
||||
|
||||
return $timeValue;
|
||||
}
|
||||
}
|
||||
$dateValue = DateTime::DATEVALUE($value);
|
||||
if ($dateValue !== Functions::VALUE()) {
|
||||
Functions::setReturnDateType($dateSetting);
|
||||
|
||||
return $dateValue;
|
||||
}
|
||||
Functions::setReturnDateType($dateSetting);
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
return (float) $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,19 +31,19 @@ class Stack
|
|||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $stack = array();
|
||||
private $stack = [];
|
||||
|
||||
/**
|
||||
* Count of entries in the parser stack
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $count = 0;
|
||||
|
||||
/**
|
||||
* Return the number of entries on the stack
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
|
@ -59,11 +59,11 @@ class Stack
|
|||
*/
|
||||
public function push($type, $value, $reference = null)
|
||||
{
|
||||
$this->stack[$this->count++] = array(
|
||||
$this->stack[$this->count++] = [
|
||||
'type' => $type,
|
||||
'value' => $value,
|
||||
'reference' => $reference
|
||||
);
|
||||
'reference' => $reference,
|
||||
];
|
||||
if ($type == 'Function') {
|
||||
$localeFunction = \PhpSpreadsheet\Calculation::localeFunc($value);
|
||||
if ($localeFunction != $value) {
|
||||
|
@ -82,13 +82,14 @@ class Stack
|
|||
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
|
||||
* @param int $n number indicating how far back in the stack we want to look
|
||||
* @return mixed
|
||||
*/
|
||||
public function last($n = 1)
|
||||
|
@ -96,6 +97,7 @@ class Stack
|
|||
if ($this->count - $n < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->stack[$this->count - $n];
|
||||
}
|
||||
|
||||
|
@ -104,7 +106,7 @@ class Stack
|
|||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->stack = array();
|
||||
$this->stack = [];
|
||||
$this->count = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,15 +82,11 @@ class Cell
|
|||
|
||||
/**
|
||||
* Attributes of the formula
|
||||
*
|
||||
*/
|
||||
private $formulaAttributes;
|
||||
|
||||
|
||||
/**
|
||||
* Send notification to the cache controller
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function notifyCacheController()
|
||||
{
|
||||
|
@ -109,7 +105,6 @@ class Cell
|
|||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Cell
|
||||
*
|
||||
|
@ -133,7 +128,7 @@ class Cell
|
|||
}
|
||||
$this->dataType = $pDataType;
|
||||
} elseif (!self::getValueBinder()->bindValue($this, $pValue)) {
|
||||
throw new Exception("Value could not be bound to cell.");
|
||||
throw new Exception('Value could not be bound to cell.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,14 +192,15 @@ class Cell
|
|||
* Sets the value for a cell, automatically determining the datatype using the value binder
|
||||
*
|
||||
* @param mixed $pValue Value
|
||||
* @return Cell
|
||||
* @throws Exception
|
||||
* @return Cell
|
||||
*/
|
||||
public function setValue($pValue = null)
|
||||
{
|
||||
if (!self::getValueBinder()->bindValue($this, $pValue)) {
|
||||
throw new Exception("Value could not be bound to cell.");
|
||||
throw new Exception('Value could not be bound to cell.');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -213,8 +209,8 @@ class Cell
|
|||
*
|
||||
* @param mixed $pValue Value
|
||||
* @param string $pDataType Explicit data type
|
||||
* @return Cell
|
||||
* @throws Exception
|
||||
* @return Cell
|
||||
*/
|
||||
public function setValueExplicit($pValue = null, $pDataType = Cell\DataType::TYPE_STRING)
|
||||
{
|
||||
|
@ -260,9 +256,9 @@ class Cell
|
|||
*
|
||||
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
|
||||
*
|
||||
* @param boolean $resetLog Whether the calculation engine logger should be reset or not
|
||||
* @return mixed
|
||||
* @param bool $resetLog Whether the calculation engine logger should be reset or not
|
||||
* @throws Exception
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCalculatedValue($resetLog = true)
|
||||
{
|
||||
|
@ -365,7 +361,7 @@ class Cell
|
|||
/**
|
||||
* Identify if the cell contains a formula
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isFormula()
|
||||
{
|
||||
|
@ -375,8 +371,8 @@ class Cell
|
|||
/**
|
||||
* Does this cell contain Data validation rules?
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDataValidation()
|
||||
{
|
||||
|
@ -390,8 +386,8 @@ class Cell
|
|||
/**
|
||||
* Get Data validation rules
|
||||
*
|
||||
* @return Cell\DataValidation
|
||||
* @throws Exception
|
||||
* @return Cell\DataValidation
|
||||
*/
|
||||
public function getDataValidation()
|
||||
{
|
||||
|
@ -406,8 +402,8 @@ class Cell
|
|||
* Set Data validation rules
|
||||
*
|
||||
* @param Cell\DataValidation $pDataValidation
|
||||
* @return Cell
|
||||
* @throws Exception
|
||||
* @return Cell
|
||||
*/
|
||||
public function setDataValidation(Cell\DataValidation $pDataValidation = null)
|
||||
{
|
||||
|
@ -423,8 +419,8 @@ class Cell
|
|||
/**
|
||||
* Does this cell contain a Hyperlink?
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function hasHyperlink()
|
||||
{
|
||||
|
@ -438,8 +434,8 @@ class Cell
|
|||
/**
|
||||
* Get Hyperlink
|
||||
*
|
||||
* @return Cell\Hyperlink
|
||||
* @throws Exception
|
||||
* @return Cell\Hyperlink
|
||||
*/
|
||||
public function getHyperlink()
|
||||
{
|
||||
|
@ -454,8 +450,8 @@ class Cell
|
|||
* Set Hyperlink
|
||||
*
|
||||
* @param Cell\Hyperlink $pHyperlink
|
||||
* @return Cell
|
||||
* @throws Exception
|
||||
* @return Cell
|
||||
*/
|
||||
public function setHyperlink(Cell\Hyperlink $pHyperlink = null)
|
||||
{
|
||||
|
@ -491,7 +487,7 @@ class Cell
|
|||
/**
|
||||
* Is this cell in a merge range
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isInMergeRange()
|
||||
{
|
||||
|
@ -501,17 +497,18 @@ class Cell
|
|||
/**
|
||||
* Is this cell the master (top left cell) in a merge range (that holds the actual data value)
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isMergeRangeValueCell()
|
||||
{
|
||||
if ($mergeRange = $this->getMergeRange()) {
|
||||
$mergeRange = Cell::splitRange($mergeRange);
|
||||
$mergeRange = self::splitRange($mergeRange);
|
||||
list($startCell) = $mergeRange[0];
|
||||
if ($this->getCoordinate() === $startCell) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -527,6 +524,7 @@ class Cell
|
|||
return $mergeRange;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -557,7 +555,7 @@ class Cell
|
|||
* Is cell in a specific range?
|
||||
*
|
||||
* @param string $pRange Cell range (e.g. A1:A1)
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isInRange($pRange = 'A1:A1')
|
||||
{
|
||||
|
@ -568,22 +566,21 @@ class Cell
|
|||
$myRow = $this->getRow();
|
||||
|
||||
// Verify if cell is in range
|
||||
return (($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) &&
|
||||
($rangeStart[1] <= $myRow) && ($rangeEnd[1] >= $myRow)
|
||||
);
|
||||
return ($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) &&
|
||||
($rangeStart[1] <= $myRow) && ($rangeEnd[1] >= $myRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Coordinate from string
|
||||
*
|
||||
* @param string $pCoordinateString
|
||||
* @return array Array containing column and row (indexes 0 and 1)
|
||||
* @throws Exception
|
||||
* @return array Array containing column and row (indexes 0 and 1)
|
||||
*/
|
||||
public static function coordinateFromString($pCoordinateString = 'A1')
|
||||
{
|
||||
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
|
||||
return array($matches[1],$matches[2]);
|
||||
return [$matches[1], $matches[2]];
|
||||
} elseif ((strpos($pCoordinateString, ':') !== false) || (strpos($pCoordinateString, ',') !== false)) {
|
||||
throw new Exception('Cell coordinate string can not be a range of cells');
|
||||
} elseif ($pCoordinateString == '') {
|
||||
|
@ -598,8 +595,8 @@ class Cell
|
|||
*
|
||||
* @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
|
||||
* Note that this value can be a row or column reference as well as a cell reference
|
||||
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
|
||||
* @throws Exception
|
||||
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
|
||||
*/
|
||||
public static function absoluteReference($pCoordinateString = 'A1')
|
||||
{
|
||||
|
@ -620,6 +617,7 @@ class Cell
|
|||
} elseif (ctype_alpha($pCoordinateString)) {
|
||||
return $worksheet . '$' . strtoupper($pCoordinateString);
|
||||
}
|
||||
|
||||
return $worksheet . self::absoluteCoordinate($pCoordinateString);
|
||||
}
|
||||
|
||||
|
@ -630,8 +628,8 @@ class Cell
|
|||
* Make string coordinate absolute
|
||||
*
|
||||
* @param string $pCoordinateString e.g. 'A1'
|
||||
* @return string Absolute coordinate e.g. '$A$1'
|
||||
* @throws Exception
|
||||
* @return string Absolute coordinate e.g. '$A$1'
|
||||
*/
|
||||
public static function absoluteCoordinate($pCoordinateString = 'A1')
|
||||
{
|
||||
|
@ -650,6 +648,7 @@ class Cell
|
|||
list($column, $row) = self::coordinateFromString($pCoordinateString);
|
||||
$column = ltrim($column, '$');
|
||||
$row = ltrim($row, '$');
|
||||
|
||||
return $worksheet . '$' . $column . '$' . $row;
|
||||
}
|
||||
|
||||
|
@ -676,6 +675,7 @@ class Cell
|
|||
for ($i = 0; $i < $counter; ++$i) {
|
||||
$exploded[$i] = explode(':', $exploded[$i]);
|
||||
}
|
||||
|
||||
return $exploded;
|
||||
}
|
||||
|
||||
|
@ -683,8 +683,8 @@ class Cell
|
|||
* Build range from coordinate strings
|
||||
*
|
||||
* @param array $pRange Array containg one or more arrays containing one or two coordinate strings
|
||||
* @return string String representation of $pRange
|
||||
* @throws Exception
|
||||
* @return string String representation of $pRange
|
||||
*/
|
||||
public static function buildRange($pRange)
|
||||
{
|
||||
|
@ -694,7 +694,7 @@ class Cell
|
|||
}
|
||||
|
||||
// Build range
|
||||
$imploded = array();
|
||||
$imploded = [];
|
||||
$counter = count($pRange);
|
||||
for ($i = 0; $i < $counter; ++$i) {
|
||||
$pRange[$i] = implode(':', $pRange[$i]);
|
||||
|
@ -736,7 +736,7 @@ class Cell
|
|||
$rangeStart[0] = self::columnIndexFromString($rangeStart[0]);
|
||||
$rangeEnd[0] = self::columnIndexFromString($rangeEnd[0]);
|
||||
|
||||
return array($rangeStart, $rangeEnd);
|
||||
return [$rangeStart, $rangeEnd];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -750,7 +750,7 @@ class Cell
|
|||
// Calculate range outer borders
|
||||
list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange);
|
||||
|
||||
return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) );
|
||||
return [($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -777,7 +777,7 @@ class Cell
|
|||
list($rangeA, $rangeB) = explode(':', $pRange);
|
||||
}
|
||||
|
||||
return array( self::coordinateFromString($rangeA), self::coordinateFromString($rangeB));
|
||||
return [self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -791,7 +791,7 @@ class Cell
|
|||
// Using a lookup cache adds a slight memory overhead, but boosts speed
|
||||
// caching using a static within the method is faster than a class static,
|
||||
// though it's additional memory overhead
|
||||
static $_indexCache = array();
|
||||
static $_indexCache = [];
|
||||
|
||||
if (isset($_indexCache[$pString])) {
|
||||
return $_indexCache[$pString];
|
||||
|
@ -799,28 +799,31 @@ class Cell
|
|||
// It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord()
|
||||
// and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant
|
||||
// memory overhead either
|
||||
static $_columnLookup = array(
|
||||
static $_columnLookup = [
|
||||
'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13,
|
||||
'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26,
|
||||
'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7, 'h' => 8, 'i' => 9, 'j' => 10, 'k' => 11, 'l' => 12, 'm' => 13,
|
||||
'n' => 14, 'o' => 15, 'p' => 16, 'q' => 17, 'r' => 18, 's' => 19, 't' => 20, 'u' => 21, 'v' => 22, 'w' => 23, 'x' => 24, 'y' => 25, 'z' => 26
|
||||
);
|
||||
'n' => 14, 'o' => 15, 'p' => 16, 'q' => 17, 'r' => 18, 's' => 19, 't' => 20, 'u' => 21, 'v' => 22, 'w' => 23, 'x' => 24, 'y' => 25, 'z' => 26,
|
||||
];
|
||||
|
||||
// We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString
|
||||
// for improved performance
|
||||
if (isset($pString{0})) {
|
||||
if (!isset($pString{1})) {
|
||||
$_indexCache[$pString] = $_columnLookup[$pString];
|
||||
|
||||
return $_indexCache[$pString];
|
||||
} elseif (!isset($pString{2})) {
|
||||
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}];
|
||||
|
||||
return $_indexCache[$pString];
|
||||
} elseif (!isset($pString{3})) {
|
||||
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}];
|
||||
|
||||
return $_indexCache[$pString];
|
||||
}
|
||||
}
|
||||
throw new Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty"));
|
||||
throw new Exception('Column string index can not be ' . ((isset($pString{0})) ? 'longer than 3 characters' : 'empty'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -834,7 +837,7 @@ class Cell
|
|||
// Using a lookup cache adds a slight memory overhead, but boosts speed
|
||||
// caching using a static within the method is faster than a class static,
|
||||
// though it's additional memory overhead
|
||||
static $_indexCache = array();
|
||||
static $_indexCache = [];
|
||||
|
||||
if (!isset($_indexCache[$pColumnIndex])) {
|
||||
// Determine column string
|
||||
|
@ -849,6 +852,7 @@ class Cell
|
|||
chr(65 + $pColumnIndex % 26);
|
||||
}
|
||||
}
|
||||
|
||||
return $_indexCache[$pColumnIndex];
|
||||
}
|
||||
|
||||
|
@ -861,7 +865,7 @@ class Cell
|
|||
public static function extractAllCellReferencesInRange($pRange = 'A1')
|
||||
{
|
||||
// Returnvalue
|
||||
$returnValue = array();
|
||||
$returnValue = [];
|
||||
|
||||
// Explode spaces
|
||||
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
|
||||
|
@ -904,7 +908,7 @@ class Cell
|
|||
}
|
||||
|
||||
// Sort the result by column and row
|
||||
$sortKeys = array();
|
||||
$sortKeys = [];
|
||||
foreach (array_unique($returnValue) as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $column, $row);
|
||||
$sortKeys[sprintf('%3s%09d', $column, $row)] = $coord;
|
||||
|
@ -958,7 +962,7 @@ class Cell
|
|||
public static function setValueBinder(Cell\IValueBinder $binder = null)
|
||||
{
|
||||
if ($binder === null) {
|
||||
throw new Exception("A \\PhpSpreadsheet\\Cell\\IValueBinder is required for PhpSpreadsheet to function correctly.");
|
||||
throw new Exception('A \\PhpSpreadsheet\\Cell\\IValueBinder is required for PhpSpreadsheet to function correctly.');
|
||||
}
|
||||
|
||||
self::$valueBinder = $binder;
|
||||
|
@ -1008,6 +1012,7 @@ class Cell
|
|||
public function setFormulaAttributes($pAttributes)
|
||||
{
|
||||
$this->formulaAttributes = $pAttributes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
*
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function bindValue(\PhpSpreadsheet\Cell $cell, $value = null)
|
||||
{
|
||||
|
@ -48,15 +48,18 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
// Test for booleans using locale-setting
|
||||
if ($value == \PhpSpreadsheet\Calculation::getTRUE()) {
|
||||
$cell->setValueExplicit(true, DataType::TYPE_BOOL);
|
||||
|
||||
return true;
|
||||
} elseif ($value == \PhpSpreadsheet\Calculation::getFALSE()) {
|
||||
$cell->setValueExplicit(false, DataType::TYPE_BOOL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for number in scientific format
|
||||
if (preg_match('/^' . \PhpSpreadsheet\Calculation::CALCULATION_REGEXP_NUMBER . '$/', $value)) {
|
||||
$cell->setValueExplicit((float) $value, DataType::TYPE_NUMERIC);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -71,6 +74,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
// Set style
|
||||
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||
->getNumberFormat()->setFormatCode('??/??');
|
||||
|
||||
return true;
|
||||
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||
// Convert value to number
|
||||
|
@ -82,6 +86,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
// Set style
|
||||
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||
->getNumberFormat()->setFormatCode('# ??/??');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -93,6 +98,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
// Set style
|
||||
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||
->getNumberFormat()->setFormatCode(\PhpSpreadsheet\Style\NumberFormat::FORMAT_PERCENTAGE_00);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -102,21 +108,23 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
$thousandsSeparator = \PhpSpreadsheet\Shared\StringHelper::getThousandsSeparator();
|
||||
if (preg_match('/^' . preg_quote($currencyCode) . ' *(\d{1,3}(' . preg_quote($thousandsSeparator) . '\d{3})*|(\d+))(' . preg_quote($decimalSeparator) . '\d{2})?$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
|
||||
$value = (float) trim(str_replace([$currencyCode, $thousandsSeparator, $decimalSeparator], ['', '', '.'], $value));
|
||||
$cell->setValueExplicit($value, DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||
->getNumberFormat()->setFormatCode(
|
||||
str_replace('$', $currencyCode, \PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE)
|
||||
);
|
||||
|
||||
return true;
|
||||
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) trim(str_replace(array('$',','), '', $value));
|
||||
$value = (float) trim(str_replace(['$', ','], '', $value));
|
||||
$cell->setValueExplicit($value, DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||
->getNumberFormat()->setFormatCode(\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -129,6 +137,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
// Set style
|
||||
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||
->getNumberFormat()->setFormatCode(\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -142,6 +151,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
// Set style
|
||||
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||
->getNumberFormat()->setFormatCode(\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -157,6 +167,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
}
|
||||
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||
->getNumberFormat()->setFormatCode($formatCode);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -167,6 +178,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
|||
// Set style
|
||||
$cell->getWorksheet()->getStyle($cell->getCoordinate())
|
||||
->getAlignment()->setWrapText(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,15 +41,15 @@ class DataType
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $errorCodes = array(
|
||||
private static $errorCodes = [
|
||||
'#NULL!' => 0,
|
||||
'#DIV/0!' => 1,
|
||||
'#VALUE!' => 2,
|
||||
'#REF!' => 3,
|
||||
'#NAME?' => 4,
|
||||
'#NUM!' => 5,
|
||||
'#N/A' => 6
|
||||
);
|
||||
'#N/A' => 6,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get list of error codes
|
||||
|
@ -90,7 +90,7 @@ class DataType
|
|||
$pValue = \PhpSpreadsheet\Shared\StringHelper::substring($pValue, 0, 32767);
|
||||
|
||||
// we require that newline is represented as "\n" in core, not as "\r\n" or "\r"
|
||||
$pValue = str_replace(array("\r\n", "\r"), "\n", $pValue);
|
||||
$pValue = str_replace(["\r\n", "\r"], "\n", $pValue);
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
|
|
|
@ -70,14 +70,14 @@ class DataValidation
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $type = DataValidation::TYPE_NONE;
|
||||
private $type = self::TYPE_NONE;
|
||||
|
||||
/**
|
||||
* Error style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $errorStyle = DataValidation::STYLE_STOP;
|
||||
private $errorStyle = self::STYLE_STOP;
|
||||
|
||||
/**
|
||||
* Operator
|
||||
|
@ -89,28 +89,28 @@ class DataValidation
|
|||
/**
|
||||
* Allow Blank
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $allowBlank = false;
|
||||
|
||||
/**
|
||||
* Show DropDown
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showDropDown = false;
|
||||
|
||||
/**
|
||||
* Show InputMessage
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showInputMessage = false;
|
||||
|
||||
/**
|
||||
* Show ErrorMessage
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showErrorMessage = false;
|
||||
|
||||
|
@ -168,6 +168,7 @@ class DataValidation
|
|||
public function setFormula1($value = '')
|
||||
{
|
||||
$this->formula1 = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -190,6 +191,7 @@ class DataValidation
|
|||
public function setFormula2($value = '')
|
||||
{
|
||||
$this->formula2 = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -212,6 +214,7 @@ class DataValidation
|
|||
public function setType($value = self::TYPE_NONE)
|
||||
{
|
||||
$this->type = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -234,6 +237,7 @@ class DataValidation
|
|||
public function setErrorStyle($value = self::STYLE_STOP)
|
||||
{
|
||||
$this->errorStyle = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -256,13 +260,14 @@ class DataValidation
|
|||
public function setOperator($value = '')
|
||||
{
|
||||
$this->operator = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Allow Blank
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getAllowBlank()
|
||||
{
|
||||
|
@ -272,19 +277,20 @@ class DataValidation
|
|||
/**
|
||||
* Set Allow Blank
|
||||
*
|
||||
* @param boolean $value
|
||||
* @param bool $value
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setAllowBlank($value = false)
|
||||
{
|
||||
$this->allowBlank = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Show DropDown
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowDropDown()
|
||||
{
|
||||
|
@ -294,19 +300,20 @@ class DataValidation
|
|||
/**
|
||||
* Set Show DropDown
|
||||
*
|
||||
* @param boolean $value
|
||||
* @param bool $value
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setShowDropDown($value = false)
|
||||
{
|
||||
$this->showDropDown = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Show InputMessage
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowInputMessage()
|
||||
{
|
||||
|
@ -316,19 +323,20 @@ class DataValidation
|
|||
/**
|
||||
* Set Show InputMessage
|
||||
*
|
||||
* @param boolean $value
|
||||
* @param bool $value
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setShowInputMessage($value = false)
|
||||
{
|
||||
$this->showInputMessage = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Show ErrorMessage
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowErrorMessage()
|
||||
{
|
||||
|
@ -338,12 +346,13 @@ class DataValidation
|
|||
/**
|
||||
* Set Show ErrorMessage
|
||||
*
|
||||
* @param boolean $value
|
||||
* @param bool $value
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setShowErrorMessage($value = false)
|
||||
{
|
||||
$this->showErrorMessage = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -366,6 +375,7 @@ class DataValidation
|
|||
public function setErrorTitle($value = '')
|
||||
{
|
||||
$this->errorTitle = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -388,6 +398,7 @@ class DataValidation
|
|||
public function setError($value = '')
|
||||
{
|
||||
$this->error = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -410,6 +421,7 @@ class DataValidation
|
|||
public function setPromptTitle($value = '')
|
||||
{
|
||||
$this->promptTitle = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -432,6 +444,7 @@ class DataValidation
|
|||
public function setPrompt($value = '')
|
||||
{
|
||||
$this->prompt = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class DefaultValueBinder implements IValueBinder
|
|||
*
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function bindValue(\PhpSpreadsheet\Cell $cell, $value = null)
|
||||
{
|
||||
|
@ -82,6 +82,7 @@ class DefaultValueBinder implements IValueBinder
|
|||
} elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
|
||||
return DataType::TYPE_STRING;
|
||||
}
|
||||
|
||||
return DataType::TYPE_NUMERIC;
|
||||
} elseif (is_string($pValue) && array_key_exists($pValue, DataType::getErrorCodes())) {
|
||||
return DataType::TYPE_ERROR;
|
||||
|
|
|
@ -72,6 +72,7 @@ class Hyperlink
|
|||
public function setUrl($value = '')
|
||||
{
|
||||
$this->url = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -94,13 +95,14 @@ class Hyperlink
|
|||
public function setTooltip($value = '')
|
||||
{
|
||||
$this->tooltip = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this hyperlink internal? (to another worksheet)
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isInternal()
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ interface IValueBinder
|
|||
*
|
||||
* @param \PhpSpreadsheet\Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function bindValue(\PhpSpreadsheet\Cell $cell, $value = null);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class Chart
|
|||
/**
|
||||
* Plot Visible Only
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $plotVisibleOnly = true;
|
||||
|
||||
|
@ -124,23 +124,20 @@ class Chart
|
|||
*/
|
||||
private $topLeftCellRef = 'A1';
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left X-Offset
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $topLeftXOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left Y-Offset
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $topLeftYOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right Cell Position
|
||||
*
|
||||
|
@ -148,23 +145,20 @@ class Chart
|
|||
*/
|
||||
private $bottomRightCellRef = 'A1';
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right X-Offset
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $bottomRightXOffset = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right Y-Offset
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $bottomRightYOffset = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Chart
|
||||
*/
|
||||
|
@ -323,7 +317,7 @@ class Chart
|
|||
/**
|
||||
* Get Plot Visible Only
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getPlotVisibleOnly()
|
||||
{
|
||||
|
@ -333,7 +327,7 @@ class Chart
|
|||
/**
|
||||
* Set Plot Visible Only
|
||||
*
|
||||
* @param boolean $plotVisibleOnly
|
||||
* @param bool $plotVisibleOnly
|
||||
* @return Chart
|
||||
*/
|
||||
public function setPlotVisibleOnly($plotVisibleOnly = true)
|
||||
|
@ -364,7 +358,6 @@ class Chart
|
|||
$this->displayBlanksAs = $displayBlanksAs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get yAxis
|
||||
*
|
||||
|
@ -421,13 +414,12 @@ class Chart
|
|||
return new Chart\GridLines();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the Top Left position for the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @param int $xOffset
|
||||
* @param int $yOffset
|
||||
* @return Chart
|
||||
*/
|
||||
public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null)
|
||||
|
@ -450,11 +442,11 @@ class Chart
|
|||
*/
|
||||
public function getTopLeftPosition()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'cell' => $this->topLeftCellRef,
|
||||
'xOffset' => $this->topLeftXOffset,
|
||||
'yOffset' => $this->topLeftYOffset
|
||||
);
|
||||
'yOffset' => $this->topLeftYOffset,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -483,8 +475,8 @@ class Chart
|
|||
/**
|
||||
* Set the offset position within the Top Left cell for the chart
|
||||
*
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @param int $xOffset
|
||||
* @param int $yOffset
|
||||
* @return Chart
|
||||
*/
|
||||
public function setTopLeftOffset($xOffset = null, $yOffset = null)
|
||||
|
@ -502,14 +494,14 @@ class Chart
|
|||
/**
|
||||
* Get the offset position within the Top Left cell for the chart
|
||||
*
|
||||
* @return integer[]
|
||||
* @return int[]
|
||||
*/
|
||||
public function getTopLeftOffset()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'X' => $this->topLeftXOffset,
|
||||
'Y' => $this->topLeftYOffset
|
||||
);
|
||||
'Y' => $this->topLeftYOffset,
|
||||
];
|
||||
}
|
||||
|
||||
public function setTopLeftXOffset($xOffset)
|
||||
|
@ -540,8 +532,8 @@ class Chart
|
|||
* Set the Bottom Right position of the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @param int $xOffset
|
||||
* @param int $yOffset
|
||||
* @return Chart
|
||||
*/
|
||||
public function setBottomRightPosition($cell, $xOffset = null, $yOffset = null)
|
||||
|
@ -564,11 +556,11 @@ class Chart
|
|||
*/
|
||||
public function getBottomRightPosition()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'cell' => $this->bottomRightCellRef,
|
||||
'xOffset' => $this->bottomRightXOffset,
|
||||
'yOffset' => $this->bottomRightYOffset
|
||||
);
|
||||
'yOffset' => $this->bottomRightYOffset,
|
||||
];
|
||||
}
|
||||
|
||||
public function setBottomRightCell($cell)
|
||||
|
@ -591,8 +583,8 @@ class Chart
|
|||
/**
|
||||
* Set the offset position within the Bottom Right cell for the chart
|
||||
*
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @param int $xOffset
|
||||
* @param int $yOffset
|
||||
* @return Chart
|
||||
*/
|
||||
public function setBottomRightOffset($xOffset = null, $yOffset = null)
|
||||
|
@ -610,14 +602,14 @@ class Chart
|
|||
/**
|
||||
* Get the offset position within the Bottom Right cell for the chart
|
||||
*
|
||||
* @return integer[]
|
||||
* @return int[]
|
||||
*/
|
||||
public function getBottomRightOffset()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'X' => $this->bottomRightXOffset,
|
||||
'Y' => $this->bottomRightYOffset
|
||||
);
|
||||
'Y' => $this->bottomRightYOffset,
|
||||
];
|
||||
}
|
||||
|
||||
public function setBottomRightXOffset($xOffset)
|
||||
|
@ -644,7 +636,6 @@ class Chart
|
|||
return $this->bottomRightYOffset;
|
||||
}
|
||||
|
||||
|
||||
public function refresh()
|
||||
{
|
||||
if ($this->worksheet !== null) {
|
||||
|
@ -674,6 +665,7 @@ class Chart
|
|||
if ($outputDestination == 'php://output') {
|
||||
$outputDestination = null;
|
||||
}
|
||||
|
||||
return $renderer->render($outputDestination);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace PhpSpreadsheet\Chart;
|
|||
* Date: 6/17/14
|
||||
* Time: 12:11 PM
|
||||
*/
|
||||
|
||||
class Axis extends Properties
|
||||
{
|
||||
/**
|
||||
|
@ -16,17 +15,17 @@ class Axis extends Properties
|
|||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $axisNumber = array(
|
||||
private $axisNumber = [
|
||||
'format' => self::FORMAT_CODE_GENERAL,
|
||||
'source_linked' => 1
|
||||
);
|
||||
'source_linked' => 1,
|
||||
];
|
||||
|
||||
/**
|
||||
* Axis Options
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $axisOptions = array(
|
||||
private $axisOptions = [
|
||||
'minimum' => null,
|
||||
'maximum' => null,
|
||||
'major_unit' => null,
|
||||
|
@ -36,101 +35,101 @@ class Axis extends Properties
|
|||
'major_tick_mark' => self::TICK_MARK_NONE,
|
||||
'axis_labels' => self::AXIS_LABELS_NEXT_TO,
|
||||
'horizontal_crosses' => self::HORIZONTAL_CROSSES_AUTOZERO,
|
||||
'horizontal_crosses_value' => null
|
||||
);
|
||||
'horizontal_crosses_value' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Fill Properties
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $fillProperties = array(
|
||||
private $fillProperties = [
|
||||
'type' => self::EXCEL_COLOR_TYPE_ARGB,
|
||||
'value' => null,
|
||||
'alpha' => 0
|
||||
);
|
||||
'alpha' => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
* Line Properties
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $lineProperties = array(
|
||||
private $lineProperties = [
|
||||
'type' => self::EXCEL_COLOR_TYPE_ARGB,
|
||||
'value' => null,
|
||||
'alpha' => 0
|
||||
);
|
||||
'alpha' => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
* Line Style Properties
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $lineStyleProperties = array(
|
||||
private $lineStyleProperties = [
|
||||
'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(
|
||||
'arrow' => [
|
||||
'head' => [
|
||||
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
||||
'size' => self::LINE_STYLE_ARROW_SIZE_5
|
||||
),
|
||||
'end' => array(
|
||||
'size' => self::LINE_STYLE_ARROW_SIZE_5,
|
||||
],
|
||||
'end' => [
|
||||
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
||||
'size' => self::LINE_STYLE_ARROW_SIZE_8
|
||||
),
|
||||
)
|
||||
);
|
||||
'size' => self::LINE_STYLE_ARROW_SIZE_8,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Shadow Properties
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $shadowProperties = array(
|
||||
private $shadowProperties = [
|
||||
'presets' => self::SHADOW_PRESETS_NOSHADOW,
|
||||
'effect' => null,
|
||||
'color' => array(
|
||||
'color' => [
|
||||
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
||||
'value' => 'black',
|
||||
'alpha' => 40,
|
||||
),
|
||||
'size' => array(
|
||||
],
|
||||
'size' => [
|
||||
'sx' => null,
|
||||
'sy' => null,
|
||||
'kx' => null
|
||||
),
|
||||
'kx' => null,
|
||||
],
|
||||
'blur' => null,
|
||||
'direction' => null,
|
||||
'distance' => null,
|
||||
'algn' => null,
|
||||
'rotWithShape' => null
|
||||
);
|
||||
'rotWithShape' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Glow Properties
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $glowProperties = array(
|
||||
private $glowProperties = [
|
||||
'size' => null,
|
||||
'color' => array(
|
||||
'color' => [
|
||||
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
||||
'value' => 'black',
|
||||
'alpha' => 40
|
||||
)
|
||||
);
|
||||
'alpha' => 40,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Soft Edge Properties
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $softEdges = array(
|
||||
'size' => null
|
||||
);
|
||||
private $softEdges = [
|
||||
'size' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Series Data Type
|
||||
|
@ -176,7 +175,6 @@ class Axis extends Properties
|
|||
* @param string $maximum
|
||||
* @param string $major_unit
|
||||
* @param string $minor_unit
|
||||
*
|
||||
*/
|
||||
public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null)
|
||||
{
|
||||
|
@ -209,7 +207,6 @@ class Axis extends Properties
|
|||
* Set Axis Orientation Property
|
||||
*
|
||||
* @param string $orientation
|
||||
*
|
||||
*/
|
||||
public function setAxisOrientation($orientation)
|
||||
{
|
||||
|
@ -222,7 +219,6 @@ class Axis extends Properties
|
|||
* @param string $color
|
||||
* @param int $alpha
|
||||
* @param string $type
|
||||
*
|
||||
*/
|
||||
public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
|
||||
{
|
||||
|
@ -235,7 +231,6 @@ class Axis extends Properties
|
|||
* @param string $color
|
||||
* @param int $alpha
|
||||
* @param string $type
|
||||
*
|
||||
*/
|
||||
public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
|
||||
{
|
||||
|
@ -278,7 +273,6 @@ class Axis extends Properties
|
|||
* @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)
|
||||
{
|
||||
|
@ -339,7 +333,6 @@ class Axis extends Properties
|
|||
* @param float $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)
|
||||
{
|
||||
|
|
|
@ -60,7 +60,6 @@ class DataSeries
|
|||
const STYLE_MARKER = 'marker';
|
||||
const STYLE_FILLED = 'filled';
|
||||
|
||||
|
||||
/**
|
||||
* Series Plot Type
|
||||
*
|
||||
|
@ -71,14 +70,14 @@ class DataSeries
|
|||
/**
|
||||
* Plot Grouping Type
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $plotGrouping;
|
||||
|
||||
/**
|
||||
* Plot Direction
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $plotDirection;
|
||||
|
||||
|
@ -94,21 +93,21 @@ class DataSeries
|
|||
*
|
||||
* @var array of integer
|
||||
*/
|
||||
private $plotOrder = array();
|
||||
private $plotOrder = [];
|
||||
|
||||
/**
|
||||
* Plot Label
|
||||
*
|
||||
* @var array of DataSeriesValues
|
||||
*/
|
||||
private $plotLabel = array();
|
||||
private $plotLabel = [];
|
||||
|
||||
/**
|
||||
* Plot Category
|
||||
*
|
||||
* @var array of DataSeriesValues
|
||||
*/
|
||||
private $plotCategory = array();
|
||||
private $plotCategory = [];
|
||||
|
||||
/**
|
||||
* Smooth Line
|
||||
|
@ -122,12 +121,12 @@ class DataSeries
|
|||
*
|
||||
* @var array of DataSeriesValues
|
||||
*/
|
||||
private $plotValues = array();
|
||||
private $plotValues = [];
|
||||
|
||||
/**
|
||||
* Create a new 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 = [], $plotLabel = [], $plotCategory = [], $plotValues = [], $plotDirection = null, $smoothLine = null, $plotStyle = null)
|
||||
{
|
||||
$this->plotType = $plotType;
|
||||
$this->plotGrouping = $plotGrouping;
|
||||
|
@ -171,6 +170,7 @@ class DataSeries
|
|||
public function setPlotType($plotType = '')
|
||||
{
|
||||
$this->plotType = $plotType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -193,6 +193,7 @@ class DataSeries
|
|||
public function setPlotGrouping($groupingType = null)
|
||||
{
|
||||
$this->plotGrouping = $groupingType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -215,6 +216,7 @@ class DataSeries
|
|||
public function setPlotDirection($plotDirection = null)
|
||||
{
|
||||
$this->plotDirection = $plotDirection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -251,6 +253,7 @@ class DataSeries
|
|||
} elseif (isset($keys[$index])) {
|
||||
return $this->plotLabel[$keys[$index]];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -277,6 +280,7 @@ class DataSeries
|
|||
} elseif (isset($keys[$index])) {
|
||||
return $this->plotCategory[$keys[$index]];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -299,6 +303,7 @@ class DataSeries
|
|||
public function setPlotStyle($plotStyle = null)
|
||||
{
|
||||
$this->plotStyle = $plotStyle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -325,13 +330,14 @@ class DataSeries
|
|||
} elseif (isset($keys[$index])) {
|
||||
return $this->plotValues[$keys[$index]];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Series
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getPlotSeriesCount()
|
||||
{
|
||||
|
@ -341,7 +347,7 @@ class DataSeries
|
|||
/**
|
||||
* Get Smooth Line
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getSmoothLine()
|
||||
{
|
||||
|
@ -351,12 +357,13 @@ class DataSeries
|
|||
/**
|
||||
* Set Smooth Line
|
||||
*
|
||||
* @param boolean $smoothLine
|
||||
* @param bool $smoothLine
|
||||
* @return DataSeries
|
||||
*/
|
||||
public function setSmoothLine($smoothLine = true)
|
||||
{
|
||||
$this->smoothLine = $smoothLine;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,14 +28,13 @@ namespace PhpSpreadsheet\Chart;
|
|||
*/
|
||||
class DataSeriesValues
|
||||
{
|
||||
|
||||
const DATASERIES_TYPE_STRING = 'String';
|
||||
const DATASERIES_TYPE_NUMBER = 'Number';
|
||||
|
||||
private static $dataTypeValues = array(
|
||||
private static $dataTypeValues = [
|
||||
self::DATASERIES_TYPE_STRING,
|
||||
self::DATASERIES_TYPE_NUMBER,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Series Data Type
|
||||
|
@ -68,7 +67,7 @@ class DataSeriesValues
|
|||
/**
|
||||
* Point Count (The number of datapoints in the dataseries)
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $pointCount = 0;
|
||||
|
||||
|
@ -77,12 +76,12 @@ class DataSeriesValues
|
|||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $dataValues = array();
|
||||
private $dataValues = [];
|
||||
|
||||
/**
|
||||
* Create a new 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 = [], $marker = null)
|
||||
{
|
||||
$this->setDataType($dataType);
|
||||
$this->dataSource = $dataSource;
|
||||
|
@ -111,8 +110,8 @@ class DataSeriesValues
|
|||
* Normally used for axis point values
|
||||
* \PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_NUMBER
|
||||
* Normally used for chart data values
|
||||
* @return DataSeriesValues
|
||||
* @throws Exception
|
||||
* @return DataSeriesValues
|
||||
*/
|
||||
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER)
|
||||
{
|
||||
|
@ -200,7 +199,7 @@ class DataSeriesValues
|
|||
/**
|
||||
* Get Series Point Count
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getPointCount()
|
||||
{
|
||||
|
@ -210,20 +209,21 @@ class DataSeriesValues
|
|||
/**
|
||||
* Identify if the Data Series is a multi-level or a simple series
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isMultiLevelSeries()
|
||||
{
|
||||
if (count($this->dataValues) > 0) {
|
||||
return is_array($this->dataValues[0]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the level count of a multi-level Data Series
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function multiLevelCount()
|
||||
{
|
||||
|
@ -231,6 +231,7 @@ class DataSeriesValues
|
|||
foreach ($this->dataValues as $dataValueSet) {
|
||||
$levelCount = max($levelCount, count($dataValueSet));
|
||||
}
|
||||
|
||||
return $levelCount;
|
||||
}
|
||||
|
||||
|
@ -257,6 +258,7 @@ class DataSeriesValues
|
|||
} elseif ($count == 1) {
|
||||
return $this->dataValues[0];
|
||||
}
|
||||
|
||||
return $this->dataValues;
|
||||
}
|
||||
|
||||
|
@ -264,12 +266,12 @@ class DataSeriesValues
|
|||
* Set Series Data Values
|
||||
*
|
||||
* @param array $dataValues
|
||||
* @param boolean $refreshDataSource
|
||||
* @param bool $refreshDataSource
|
||||
* TRUE - refresh the value of dataSource based on the values of $dataValues
|
||||
* FALSE - don't change the value of dataSource
|
||||
* @return DataSeriesValues
|
||||
*/
|
||||
public function setDataValues($dataValues = array(), $refreshDataSource = true)
|
||||
public function setDataValues($dataValues = [], $refreshDataSource = true)
|
||||
{
|
||||
$this->dataValues = \PhpSpreadsheet\Calculation\Functions::flattenArray($dataValues);
|
||||
$this->pointCount = count($dataValues);
|
||||
|
@ -317,7 +319,7 @@ class DataSeriesValues
|
|||
} else {
|
||||
$newArray = array_values(array_shift($newDataValues));
|
||||
foreach ($newArray as $i => $newDataSet) {
|
||||
$newArray[$i] = array($newDataSet);
|
||||
$newArray[$i] = [$newDataSet];
|
||||
}
|
||||
|
||||
foreach ($newDataValues as $newDataSet) {
|
||||
|
|
|
@ -8,10 +8,8 @@ namespace PhpSpreadsheet\Chart;
|
|||
* Date: 7/2/14
|
||||
* Time: 2:36 PM
|
||||
*/
|
||||
|
||||
class GridLines extends Properties
|
||||
{
|
||||
|
||||
/**
|
||||
* Properties of Class:
|
||||
* Object State (State for Minor Tick Mark) @var bool
|
||||
|
@ -19,75 +17,72 @@ class GridLines extends Properties
|
|||
* Shadow Properties @var array of mixed
|
||||
* Glow Properties @var array of mixed
|
||||
* Soft Properties @var array of mixed
|
||||
*
|
||||
*/
|
||||
|
||||
private $objectState = false;
|
||||
|
||||
private $lineProperties = array(
|
||||
'color' => array(
|
||||
private $lineProperties = [
|
||||
'color' => [
|
||||
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
||||
'value' => null,
|
||||
'alpha' => 0
|
||||
),
|
||||
'style' => array(
|
||||
'alpha' => 0,
|
||||
],
|
||||
'style' => [
|
||||
'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(
|
||||
'arrow' => [
|
||||
'head' => [
|
||||
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
||||
'size' => self::LINE_STYLE_ARROW_SIZE_5
|
||||
),
|
||||
'end' => array(
|
||||
'size' => self::LINE_STYLE_ARROW_SIZE_5,
|
||||
],
|
||||
'end' => [
|
||||
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
||||
'size' => self::LINE_STYLE_ARROW_SIZE_8
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
'size' => self::LINE_STYLE_ARROW_SIZE_8,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
private $shadowProperties = array(
|
||||
private $shadowProperties = [
|
||||
'presets' => self::SHADOW_PRESETS_NOSHADOW,
|
||||
'effect' => null,
|
||||
'color' => array(
|
||||
'color' => [
|
||||
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
||||
'value' => 'black',
|
||||
'alpha' => 85,
|
||||
),
|
||||
'size' => array(
|
||||
],
|
||||
'size' => [
|
||||
'sx' => null,
|
||||
'sy' => null,
|
||||
'kx' => null
|
||||
),
|
||||
'kx' => null,
|
||||
],
|
||||
'blur' => null,
|
||||
'direction' => null,
|
||||
'distance' => null,
|
||||
'algn' => null,
|
||||
'rotWithShape' => null
|
||||
);
|
||||
'rotWithShape' => null,
|
||||
];
|
||||
|
||||
private $glowProperties = array(
|
||||
private $glowProperties = [
|
||||
'size' => null,
|
||||
'color' => array(
|
||||
'color' => [
|
||||
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
|
||||
'value' => 'black',
|
||||
'alpha' => 40
|
||||
)
|
||||
);
|
||||
'alpha' => 40,
|
||||
],
|
||||
];
|
||||
|
||||
private $softEdges = array(
|
||||
'size' => null
|
||||
);
|
||||
private $softEdges = [
|
||||
'size' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Object State
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
public function getObjectState()
|
||||
{
|
||||
return $this->objectState;
|
||||
|
@ -98,7 +93,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return GridLines
|
||||
*/
|
||||
|
||||
private function activateObject()
|
||||
{
|
||||
$this->objectState = true;
|
||||
|
@ -113,7 +107,6 @@ class GridLines extends Properties
|
|||
* @param int $alpha
|
||||
* @param string $type
|
||||
*/
|
||||
|
||||
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD)
|
||||
{
|
||||
$this->activateObject()
|
||||
|
@ -137,7 +130,6 @@ class GridLines extends Properties
|
|||
* @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();
|
||||
|
@ -177,7 +169,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function getLineColorProperty($parameter)
|
||||
{
|
||||
return $this->lineProperties['color'][$parameter];
|
||||
|
@ -190,7 +181,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function getLineStyleProperty($elements)
|
||||
{
|
||||
return $this->getArrayElementsValue($this->lineProperties['style'], $elements);
|
||||
|
@ -203,9 +193,7 @@ class GridLines extends Properties
|
|||
* @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
|
||||
|
@ -221,7 +209,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function getGlowColor($property)
|
||||
{
|
||||
return $this->glowProperties['color'][$property];
|
||||
|
@ -232,7 +219,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function getGlowSize()
|
||||
{
|
||||
return $this->glowProperties['size'];
|
||||
|
@ -245,7 +231,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return GridLines
|
||||
*/
|
||||
|
||||
private function setGlowSize($size)
|
||||
{
|
||||
$this->glowProperties['size'] = $this->getExcelPointsWidth((float) $size);
|
||||
|
@ -262,7 +247,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return GridLines
|
||||
*/
|
||||
|
||||
private function setGlowColor($color, $alpha, $type)
|
||||
{
|
||||
if (!is_null($color)) {
|
||||
|
@ -286,7 +270,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function getLineStyleArrowParameters($arrow_selector, $property_selector)
|
||||
{
|
||||
return $this->getLineStyleArrowSize($this->lineProperties['style']['arrow'][$arrow_selector]['size'], $property_selector);
|
||||
|
@ -302,9 +285,7 @@ class GridLines extends Properties
|
|||
* @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)
|
||||
{
|
||||
$this->activateObject()
|
||||
|
@ -326,7 +307,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return GridLines
|
||||
*/
|
||||
|
||||
private function setShadowPresetsProperties($shadow_presets)
|
||||
{
|
||||
$this->shadowProperties['presets'] = $shadow_presets;
|
||||
|
@ -343,7 +323,6 @@ class GridLines extends Properties
|
|||
*
|
||||
* @return GridLines
|
||||
*/
|
||||
|
||||
private function setShadowProperiesMapValues(array $properties_map, &$reference = null)
|
||||
{
|
||||
$base_reference = $reference;
|
||||
|
@ -412,7 +391,6 @@ class GridLines extends Properties
|
|||
* @param int $angle
|
||||
* @return GridLines
|
||||
*/
|
||||
|
||||
private function setShadowAngle($angle)
|
||||
{
|
||||
if ($angle !== null) {
|
||||
|
|
|
@ -81,7 +81,7 @@ class Layout
|
|||
* show legend key
|
||||
* Specifies that legend keys should be shown in data labels
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showLegendKey;
|
||||
|
||||
|
@ -89,7 +89,7 @@ class Layout
|
|||
* show value
|
||||
* Specifies that the value should be shown in a data label.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showVal;
|
||||
|
||||
|
@ -97,7 +97,7 @@ class Layout
|
|||
* show category name
|
||||
* Specifies that the category name should be shown in the data label.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showCatName;
|
||||
|
||||
|
@ -105,7 +105,7 @@ class Layout
|
|||
* show data series name
|
||||
* Specifies that the series name should be shown in the data label.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showSerName;
|
||||
|
||||
|
@ -113,14 +113,14 @@ class Layout
|
|||
* show percentage
|
||||
* Specifies that the percentage should be shown in the data label.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showPercent;
|
||||
|
||||
/**
|
||||
* show bubble size
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showBubbleSize;
|
||||
|
||||
|
@ -128,15 +128,14 @@ class Layout
|
|||
* show leader lines
|
||||
* Specifies that leader lines should be shown for the data label.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $showLeaderLines;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Layout
|
||||
*/
|
||||
public function __construct($layout = array())
|
||||
public function __construct($layout = [])
|
||||
{
|
||||
if (isset($layout['layoutTarget'])) {
|
||||
$this->layoutTarget = $layout['layoutTarget'];
|
||||
|
@ -180,6 +179,7 @@ class Layout
|
|||
public function setLayoutTarget($value)
|
||||
{
|
||||
$this->layoutTarget = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -202,6 +202,7 @@ class Layout
|
|||
public function setXMode($value)
|
||||
{
|
||||
$this->xMode = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -224,6 +225,7 @@ class Layout
|
|||
public function setYMode($value)
|
||||
{
|
||||
$this->yMode = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -246,6 +248,7 @@ class Layout
|
|||
public function setXPosition($value)
|
||||
{
|
||||
$this->xPos = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -268,6 +271,7 @@ class Layout
|
|||
public function setYPosition($value)
|
||||
{
|
||||
$this->yPos = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -290,6 +294,7 @@ class Layout
|
|||
public function setWidth($value)
|
||||
{
|
||||
$this->width = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -312,14 +317,14 @@ class Layout
|
|||
public function setHeight($value)
|
||||
{
|
||||
$this->height = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get show legend key
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowLegendKey()
|
||||
{
|
||||
|
@ -330,19 +335,20 @@ class Layout
|
|||
* Set show legend key
|
||||
* Specifies that legend keys should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show legend key
|
||||
* @param bool $value Show legend key
|
||||
* @return Layout
|
||||
*/
|
||||
public function setShowLegendKey($value)
|
||||
{
|
||||
$this->showLegendKey = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show value
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowVal()
|
||||
{
|
||||
|
@ -353,19 +359,20 @@ class Layout
|
|||
* Set show val
|
||||
* Specifies that the value should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show val
|
||||
* @param bool $value Show val
|
||||
* @return Layout
|
||||
*/
|
||||
public function setShowVal($value)
|
||||
{
|
||||
$this->showVal = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show category name
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowCatName()
|
||||
{
|
||||
|
@ -376,19 +383,20 @@ class Layout
|
|||
* Set show cat name
|
||||
* Specifies that the category name should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show cat name
|
||||
* @param bool $value Show cat name
|
||||
* @return Layout
|
||||
*/
|
||||
public function setShowCatName($value)
|
||||
{
|
||||
$this->showCatName = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show data series name
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowSerName()
|
||||
{
|
||||
|
@ -399,19 +407,20 @@ class Layout
|
|||
* Set show ser name
|
||||
* Specifies that the series name should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show series name
|
||||
* @param bool $value Show series name
|
||||
* @return Layout
|
||||
*/
|
||||
public function setShowSerName($value)
|
||||
{
|
||||
$this->showSerName = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show percentage
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowPercent()
|
||||
{
|
||||
|
@ -422,19 +431,20 @@ class Layout
|
|||
* Set show percentage
|
||||
* Specifies that the percentage should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show percentage
|
||||
* @param bool $value Show percentage
|
||||
* @return Layout
|
||||
*/
|
||||
public function setShowPercent($value)
|
||||
{
|
||||
$this->showPercent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show bubble size
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowBubbleSize()
|
||||
{
|
||||
|
@ -445,19 +455,20 @@ class Layout
|
|||
* Set show bubble size
|
||||
* Specifies that the bubble size should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show bubble size
|
||||
* @param bool $value Show bubble size
|
||||
* @return Layout
|
||||
*/
|
||||
public function setShowBubbleSize($value)
|
||||
{
|
||||
$this->showBubbleSize = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show leader lines
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getShowLeaderLines()
|
||||
{
|
||||
|
@ -468,12 +479,13 @@ class Layout
|
|||
* Set show leader lines
|
||||
* Specifies that leader lines should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show leader lines
|
||||
* @param bool $value Show leader lines
|
||||
* @return Layout
|
||||
*/
|
||||
public function setShowLeaderLines($value)
|
||||
{
|
||||
$this->showLeaderLines = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,14 +42,14 @@ class Legend
|
|||
const POSITION_TOP = 't';
|
||||
const POSITION_TOPRIGHT = 'tr';
|
||||
|
||||
private static $positionXLref = array(
|
||||
private static $positionXLref = [
|
||||
self::XL_LEGEND_POSITION_BOTTOM => self::POSITION_BOTTOM,
|
||||
self::XL_LEGEND_POSITION_CORNER => self::POSITION_TOPRIGHT,
|
||||
self::XL_LEGEND_POSITION_CUSTOM => '??',
|
||||
self::XL_LEGEND_POSITION_LEFT => self::POSITION_LEFT,
|
||||
self::XL_LEGEND_POSITION_RIGHT => self::POSITION_RIGHT,
|
||||
self::XL_LEGEND_POSITION_TOP => self::POSITION_TOP
|
||||
);
|
||||
self::XL_LEGEND_POSITION_TOP => self::POSITION_TOP,
|
||||
];
|
||||
|
||||
/**
|
||||
* Legend position
|
||||
|
@ -61,7 +61,7 @@ class Legend
|
|||
/**
|
||||
* Allow overlay of other elements?
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $overlay = true;
|
||||
|
||||
|
@ -72,7 +72,6 @@ class Legend
|
|||
*/
|
||||
private $layout = null;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Legend
|
||||
*/
|
||||
|
@ -105,6 +104,7 @@ class Legend
|
|||
}
|
||||
|
||||
$this->position = $position;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -130,13 +130,14 @@ class Legend
|
|||
}
|
||||
|
||||
$this->position = self::$positionXLref[$positionXL];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allow overlay of other elements?
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getOverlay()
|
||||
{
|
||||
|
@ -146,8 +147,8 @@ class Legend
|
|||
/**
|
||||
* Set allow overlay of other elements?
|
||||
*
|
||||
* @param boolean $overlay
|
||||
* @return boolean
|
||||
* @param bool $overlay
|
||||
* @return bool
|
||||
*/
|
||||
public function setOverlay($overlay = false)
|
||||
{
|
||||
|
@ -156,6 +157,7 @@ class Legend
|
|||
}
|
||||
|
||||
$this->overlay = $overlay;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,12 +38,12 @@ class PlotArea
|
|||
*
|
||||
* @var array of DataSeries
|
||||
*/
|
||||
private $plotSeries = array();
|
||||
private $plotSeries = [];
|
||||
|
||||
/**
|
||||
* Create a new PlotArea
|
||||
*/
|
||||
public function __construct(Layout $layout = null, $plotSeries = array())
|
||||
public function __construct(Layout $layout = null, $plotSeries = [])
|
||||
{
|
||||
$this->layout = $layout;
|
||||
$this->plotSeries = $plotSeries;
|
||||
|
@ -72,7 +72,7 @@ class PlotArea
|
|||
/**
|
||||
* Get Number of Plot Series
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getPlotSeriesCount()
|
||||
{
|
||||
|
@ -80,6 +80,7 @@ class PlotArea
|
|||
foreach ($this->plotSeries as $plot) {
|
||||
$seriesCount += $plot->getPlotSeriesCount();
|
||||
}
|
||||
|
||||
return $seriesCount;
|
||||
}
|
||||
|
||||
|
@ -109,7 +110,7 @@ class PlotArea
|
|||
* @param DataSeries[]
|
||||
* @return PlotArea
|
||||
*/
|
||||
public function setPlotSeries($plotSeries = array())
|
||||
public function setPlotSeries($plotSeries = [])
|
||||
{
|
||||
$this->plotSeries = $plotSeries;
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace PhpSpreadsheet\Chart;
|
|||
* Date: 7/2/14
|
||||
* Time: 5:45 PM
|
||||
*/
|
||||
|
||||
abstract class Properties
|
||||
{
|
||||
const
|
||||
|
@ -133,219 +132,218 @@ abstract class Properties
|
|||
|
||||
protected function setColorProperties($color, $alpha, $type)
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'type' => (string) $type,
|
||||
'value' => (string) $color,
|
||||
'alpha' => (string) $this->getTrueAlpha($alpha)
|
||||
);
|
||||
'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')
|
||||
);
|
||||
$sizes = [
|
||||
1 => ['w' => 'sm', 'len' => 'sm'],
|
||||
2 => ['w' => 'sm', 'len' => 'med'],
|
||||
3 => ['w' => 'sm', 'len' => 'lg'],
|
||||
4 => ['w' => 'med', 'len' => 'sm'],
|
||||
5 => ['w' => 'med', 'len' => 'med'],
|
||||
6 => ['w' => 'med', 'len' => 'lg'],
|
||||
7 => ['w' => 'lg', 'len' => 'sm'],
|
||||
8 => ['w' => 'lg', 'len' => 'med'],
|
||||
9 => ['w' => 'lg', 'len' => 'lg'],
|
||||
];
|
||||
|
||||
return $sizes[$array_selector][$array_kay_selector];
|
||||
}
|
||||
|
||||
protected function getShadowPresetsMap($shadow_presets_option)
|
||||
{
|
||||
$presets_options = array(
|
||||
$presets_options = [
|
||||
//OUTER
|
||||
1 => array(
|
||||
1 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '50800',
|
||||
'distance' => '38100',
|
||||
'direction' => '2700000',
|
||||
'algn' => 'tl',
|
||||
'rotWithShape' => '0'
|
||||
),
|
||||
2 => array(
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
2 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '50800',
|
||||
'distance' => '38100',
|
||||
'direction' => '5400000',
|
||||
'algn' => 't',
|
||||
'rotWithShape' => '0'
|
||||
),
|
||||
3 => array(
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
3 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '50800',
|
||||
'distance' => '38100',
|
||||
'direction' => '8100000',
|
||||
'algn' => 'tr',
|
||||
'rotWithShape' => '0'
|
||||
),
|
||||
4 => array(
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
4 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '50800',
|
||||
'distance' => '38100',
|
||||
'algn' => 'l',
|
||||
'rotWithShape' => '0'
|
||||
),
|
||||
5 => array(
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
5 => [
|
||||
'effect' => 'outerShdw',
|
||||
'size' => array(
|
||||
'size' => [
|
||||
'sx' => '102000',
|
||||
'sy' => '102000'
|
||||
)
|
||||
,
|
||||
'sy' => '102000',
|
||||
],
|
||||
'blur' => '63500',
|
||||
'distance' => '38100',
|
||||
'algn' => 'ctr',
|
||||
'rotWithShape' => '0'
|
||||
),
|
||||
6 => array(
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
6 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '50800',
|
||||
'distance' => '38100',
|
||||
'direction' => '10800000',
|
||||
'algn' => 'r',
|
||||
'rotWithShape' => '0'
|
||||
),
|
||||
7 => array(
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
7 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '50800',
|
||||
'distance' => '38100',
|
||||
'direction' => '18900000',
|
||||
'algn' => 'bl',
|
||||
'rotWithShape' => '0'
|
||||
),
|
||||
8 => array(
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
8 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '50800',
|
||||
'distance' => '38100',
|
||||
'direction' => '16200000',
|
||||
'rotWithShape' => '0'
|
||||
),
|
||||
9 => array(
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
9 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '50800',
|
||||
'distance' => '38100',
|
||||
'direction' => '13500000',
|
||||
'algn' => 'br',
|
||||
'rotWithShape' => '0'
|
||||
),
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
//INNER
|
||||
10 => array(
|
||||
10 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => '63500',
|
||||
'distance' => '50800',
|
||||
'direction' => '2700000',
|
||||
),
|
||||
11 => array(
|
||||
],
|
||||
11 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => '63500',
|
||||
'distance' => '50800',
|
||||
'direction' => '5400000',
|
||||
),
|
||||
12 => array(
|
||||
],
|
||||
12 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => '63500',
|
||||
'distance' => '50800',
|
||||
'direction' => '8100000',
|
||||
),
|
||||
13 => array(
|
||||
],
|
||||
13 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => '63500',
|
||||
'distance' => '50800',
|
||||
),
|
||||
14 => array(
|
||||
],
|
||||
14 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => '114300',
|
||||
),
|
||||
15 => array(
|
||||
],
|
||||
15 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => '63500',
|
||||
'distance' => '50800',
|
||||
'direction' => '10800000',
|
||||
),
|
||||
16 => array(
|
||||
],
|
||||
16 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => '63500',
|
||||
'distance' => '50800',
|
||||
'direction' => '18900000',
|
||||
),
|
||||
17 => array(
|
||||
],
|
||||
17 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => '63500',
|
||||
'distance' => '50800',
|
||||
'direction' => '16200000',
|
||||
),
|
||||
18 => array(
|
||||
],
|
||||
18 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => '63500',
|
||||
'distance' => '50800',
|
||||
'direction' => '13500000',
|
||||
),
|
||||
],
|
||||
//perspective
|
||||
19 => array(
|
||||
19 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '152400',
|
||||
'distance' => '317500',
|
||||
'size' => array(
|
||||
'size' => [
|
||||
'sx' => '90000',
|
||||
'sy' => '-19000',
|
||||
),
|
||||
],
|
||||
'direction' => '5400000',
|
||||
'rotWithShape' => '0',
|
||||
),
|
||||
20 => array(
|
||||
],
|
||||
20 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '76200',
|
||||
'direction' => '18900000',
|
||||
'size' => array(
|
||||
'size' => [
|
||||
'sy' => '23000',
|
||||
'kx' => '-1200000',
|
||||
),
|
||||
],
|
||||
'algn' => 'bl',
|
||||
'rotWithShape' => '0',
|
||||
),
|
||||
21 => array(
|
||||
],
|
||||
21 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '76200',
|
||||
'direction' => '13500000',
|
||||
'size' => array(
|
||||
'size' => [
|
||||
'sy' => '23000',
|
||||
'kx' => '1200000',
|
||||
),
|
||||
],
|
||||
'algn' => 'br',
|
||||
'rotWithShape' => '0',
|
||||
),
|
||||
22 => array(
|
||||
],
|
||||
22 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '76200',
|
||||
'distance' => '12700',
|
||||
'direction' => '2700000',
|
||||
'size' => array(
|
||||
'size' => [
|
||||
'sy' => '-23000',
|
||||
'kx' => '-800400',
|
||||
),
|
||||
],
|
||||
'algn' => 'bl',
|
||||
'rotWithShape' => '0',
|
||||
),
|
||||
23 => array(
|
||||
],
|
||||
23 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => '76200',
|
||||
'distance' => '12700',
|
||||
'direction' => '8100000',
|
||||
'size' => array(
|
||||
'size' => [
|
||||
'sy' => '-23000',
|
||||
'kx' => '800400',
|
||||
),
|
||||
],
|
||||
'algn' => 'br',
|
||||
'rotWithShape' => '0',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return $presets_options[$shadow_presets_option];
|
||||
}
|
||||
|
@ -359,8 +357,10 @@ abstract class Properties
|
|||
foreach ($elements as $keys) {
|
||||
$reference = &$reference[$keys];
|
||||
}
|
||||
|
||||
return $reference;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpSpreadsheet\Chart\Renderer;
|
||||
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'/jpgraph.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . '/jpgraph.php';
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
|
@ -37,7 +37,7 @@ class JpGraph
|
|||
'darkmagenta', 'coral', 'dodgerblue3', 'eggplant',
|
||||
'mediumblue', 'magenta', 'sandybrown', 'cyan',
|
||||
'firebrick1', 'forestgreen', 'deeppink4', 'darkolivegreen',
|
||||
'goldenrod2'
|
||||
'goldenrod2',
|
||||
];
|
||||
|
||||
private static $markSet = [
|
||||
|
@ -49,10 +49,9 @@ class JpGraph
|
|||
'dot' => MARK_FILLEDCIRCLE,
|
||||
'dash' => MARK_DTRIANGLE,
|
||||
'circle' => MARK_CIRCLE,
|
||||
'plus' => MARK_CROSS
|
||||
'plus' => MARK_CROSS,
|
||||
];
|
||||
|
||||
|
||||
private $chart;
|
||||
|
||||
private $graph;
|
||||
|
@ -61,7 +60,6 @@ class JpGraph
|
|||
|
||||
private static $plotMark = 0;
|
||||
|
||||
|
||||
private function formatPointMarker($seriesPlot, $markerID)
|
||||
{
|
||||
$plotMarkKeys = array_keys(self::$markSet);
|
||||
|
@ -89,7 +87,6 @@ class JpGraph
|
|||
return $seriesPlot;
|
||||
}
|
||||
|
||||
|
||||
private function formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '')
|
||||
{
|
||||
$datasetLabelFormatCode = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode();
|
||||
|
@ -102,7 +99,7 @@ class JpGraph
|
|||
foreach ($datasetLabels as $i => $datasetLabel) {
|
||||
if (is_array($datasetLabel)) {
|
||||
if ($rotation == 'bar') {
|
||||
$datasetLabels[$i] = implode(" ", $datasetLabel);
|
||||
$datasetLabels[$i] = implode(' ', $datasetLabel);
|
||||
} else {
|
||||
$datasetLabel = array_reverse($datasetLabel);
|
||||
$datasetLabels[$i] = implode("\n", $datasetLabel);
|
||||
|
@ -119,7 +116,6 @@ class JpGraph
|
|||
return $datasetLabels;
|
||||
}
|
||||
|
||||
|
||||
private function percentageSumCalculation($groupID, $seriesCount)
|
||||
{
|
||||
// Adjust our values to a percentage value across all series in the group
|
||||
|
@ -141,7 +137,6 @@ class JpGraph
|
|||
return $sumValues;
|
||||
}
|
||||
|
||||
|
||||
private function percentageAdjustValues($dataValues, $sumValues)
|
||||
{
|
||||
foreach ($dataValues as $k => $dataValue) {
|
||||
|
@ -151,7 +146,6 @@ class JpGraph
|
|||
return $dataValues;
|
||||
}
|
||||
|
||||
|
||||
private function getCaption($captionElement)
|
||||
{
|
||||
// Read any caption
|
||||
|
@ -164,10 +158,10 @@ class JpGraph
|
|||
$caption = implode('', $caption);
|
||||
}
|
||||
}
|
||||
|
||||
return $caption;
|
||||
}
|
||||
|
||||
|
||||
private function renderTitle()
|
||||
{
|
||||
$title = $this->getCaption($this->chart->getTitle());
|
||||
|
@ -176,7 +170,6 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderLegend()
|
||||
{
|
||||
$legend = $this->chart->getLegend();
|
||||
|
@ -208,7 +201,6 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderCartesianPlotArea($type = 'textlin')
|
||||
{
|
||||
$this->graph = new Graph(self::$width, self::$height);
|
||||
|
@ -246,7 +238,6 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderPiePlotArea($doughnut = false)
|
||||
{
|
||||
$this->graph = new PieGraph(self::$width, self::$height);
|
||||
|
@ -254,7 +245,6 @@ class JpGraph
|
|||
$this->renderTitle();
|
||||
}
|
||||
|
||||
|
||||
private function renderRadarPlotArea()
|
||||
{
|
||||
$this->graph = new RadarGraph(self::$width, self::$height);
|
||||
|
@ -263,7 +253,6 @@ class JpGraph
|
|||
$this->renderTitle();
|
||||
}
|
||||
|
||||
|
||||
private function renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d')
|
||||
{
|
||||
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
|
@ -276,7 +265,7 @@ class JpGraph
|
|||
}
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
$seriesPlots = [];
|
||||
if ($grouping == 'percentStacked') {
|
||||
$sumValues = $this->percentageSumCalculation($groupID, $seriesCount);
|
||||
}
|
||||
|
@ -327,7 +316,6 @@ class JpGraph
|
|||
$this->graph->Add($groupPlot);
|
||||
}
|
||||
|
||||
|
||||
private function renderPlotBar($groupID, $dimensions = '2d')
|
||||
{
|
||||
$rotation = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
|
||||
|
@ -351,9 +339,8 @@ class JpGraph
|
|||
$this->graph->xaxis->SetTickLabels($datasetLabels);
|
||||
}
|
||||
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
$seriesPlots = [];
|
||||
if ($grouping == 'percentStacked') {
|
||||
$sumValues = $this->percentageSumCalculation($groupID, $seriesCount);
|
||||
}
|
||||
|
@ -413,14 +400,13 @@ class JpGraph
|
|||
$this->graph->Add($groupPlot);
|
||||
}
|
||||
|
||||
|
||||
private function renderPlotScatter($groupID, $bubble)
|
||||
{
|
||||
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
$scatterStyle = $bubbleSize = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
$seriesPlots = [];
|
||||
|
||||
// Loop through each data series in turn
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
|
@ -459,13 +445,12 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderPlotRadar($groupID)
|
||||
{
|
||||
$radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
$seriesPlots = [];
|
||||
|
||||
// Loop through each data series in turn
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
|
@ -473,7 +458,7 @@ class JpGraph
|
|||
$dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
$marker = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
||||
|
||||
$dataValues = array();
|
||||
$dataValues = [];
|
||||
foreach ($dataValuesY as $k => $dataValueY) {
|
||||
$dataValues[$k] = implode(' ', array_reverse($dataValueY));
|
||||
}
|
||||
|
@ -498,15 +483,14 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderPlotContour($groupID)
|
||||
{
|
||||
$contourStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
$seriesPlots = [];
|
||||
|
||||
$dataValues = array();
|
||||
$dataValues = [];
|
||||
// Loop through each data series in turn
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
|
@ -519,13 +503,12 @@ class JpGraph
|
|||
$this->graph->Add($seriesPlot);
|
||||
}
|
||||
|
||||
|
||||
private function renderPlotStock($groupID)
|
||||
{
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$plotOrder = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
|
||||
|
||||
$dataValues = array();
|
||||
$dataValues = [];
|
||||
// Loop through each data series in turn and build the plot arrays
|
||||
foreach ($plotOrder as $i => $v) {
|
||||
$dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues();
|
||||
|
@ -537,7 +520,7 @@ class JpGraph
|
|||
return;
|
||||
}
|
||||
|
||||
$dataValuesPlot = array();
|
||||
$dataValuesPlot = [];
|
||||
// Flatten the plot arrays to a single dimensional array to work with jpgraph
|
||||
for ($j = 0; $j < count($dataValues[0]); ++$j) {
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
|
@ -559,10 +542,9 @@ class JpGraph
|
|||
$this->graph->Add($seriesPlot);
|
||||
}
|
||||
|
||||
|
||||
private function renderAreaChart($groupCount, $dimensions = '2d')
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_line.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php';
|
||||
|
||||
$this->renderCartesianPlotArea();
|
||||
|
||||
|
@ -571,10 +553,9 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderLineChart($groupCount, $dimensions = '2d')
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_line.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php';
|
||||
|
||||
$this->renderCartesianPlotArea();
|
||||
|
||||
|
@ -583,10 +564,9 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderBarChart($groupCount, $dimensions = '2d')
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_bar.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_bar.php';
|
||||
|
||||
$this->renderCartesianPlotArea();
|
||||
|
||||
|
@ -595,12 +575,11 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderScatterChart($groupCount)
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_scatter.php');
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_regstat.php');
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_line.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_scatter.php';
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_regstat.php';
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php';
|
||||
|
||||
$this->renderCartesianPlotArea('linlin');
|
||||
|
||||
|
@ -609,10 +588,9 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderBubbleChart($groupCount)
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_scatter.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_scatter.php';
|
||||
|
||||
$this->renderCartesianPlotArea('linlin');
|
||||
|
||||
|
@ -621,12 +599,11 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = false, $multiplePlots = false)
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_pie.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_pie.php';
|
||||
if ($dimensions == '3d') {
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_pie3d.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_pie3d.php';
|
||||
}
|
||||
|
||||
$this->renderPiePlotArea($doughnut);
|
||||
|
@ -644,7 +621,7 @@ class JpGraph
|
|||
}
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
$seriesPlots = [];
|
||||
// For pie charts, we only display the first series: doughnut charts generally display all series
|
||||
$jLimit = ($multiplePlots) ? $seriesCount : 1;
|
||||
// Loop through each data series in turn
|
||||
|
@ -698,10 +675,9 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderRadarChart($groupCount)
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_radar.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_radar.php';
|
||||
|
||||
$this->renderRadarPlotArea();
|
||||
|
||||
|
@ -710,10 +686,9 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderStockChart($groupCount)
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_stock.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_stock.php';
|
||||
|
||||
$this->renderCartesianPlotArea('intint');
|
||||
|
||||
|
@ -722,10 +697,9 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderContourChart($groupCount, $dimensions)
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_contour.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_contour.php';
|
||||
|
||||
$this->renderCartesianPlotArea('intint');
|
||||
|
||||
|
@ -734,14 +708,13 @@ class JpGraph
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function renderCombinationChart($groupCount, $dimensions, $outputDestination)
|
||||
{
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_line.php');
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_bar.php');
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_scatter.php');
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_regstat.php');
|
||||
require_once(\PhpSpreadsheet\Settings::getChartRendererPath().'jpgraph_line.php');
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php';
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_bar.php';
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_scatter.php';
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_regstat.php';
|
||||
require_once \PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php';
|
||||
|
||||
$this->renderCartesianPlotArea();
|
||||
|
||||
|
@ -775,6 +748,7 @@ class JpGraph
|
|||
break;
|
||||
default:
|
||||
$this->graph = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -782,10 +756,10 @@ class JpGraph
|
|||
$this->renderLegend();
|
||||
|
||||
$this->graph->Stroke($outputDestination);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function render($outputDestination)
|
||||
{
|
||||
self::$plotColour = 0;
|
||||
|
@ -796,7 +770,7 @@ class JpGraph
|
|||
if ($groupCount == 1) {
|
||||
$chartType = $this->chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
||||
} else {
|
||||
$chartTypes = array();
|
||||
$chartTypes = [];
|
||||
for ($i = 0; $i < $groupCount; ++$i) {
|
||||
$chartTypes[] = $this->chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
}
|
||||
|
@ -805,6 +779,7 @@ class JpGraph
|
|||
$chartType = array_pop($chartTypes);
|
||||
} elseif (count($chartTypes) == 0) {
|
||||
echo 'Chart is not yet implemented<br />';
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return $this->renderCombinationChart($groupCount, $dimensions, $outputDestination);
|
||||
|
@ -862,15 +837,16 @@ class JpGraph
|
|||
break;
|
||||
default:
|
||||
echo $chartType . ' is not yet implemented<br />';
|
||||
|
||||
return false;
|
||||
}
|
||||
$this->renderLegend();
|
||||
|
||||
$this->graph->Stroke($outputDestination);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new jpgraph
|
||||
*/
|
||||
|
|
|
@ -26,7 +26,6 @@ namespace PhpSpreadsheet\Chart;
|
|||
*/
|
||||
class Title
|
||||
{
|
||||
|
||||
/**
|
||||
* Title Caption
|
||||
*
|
||||
|
|
|
@ -64,7 +64,7 @@ class Comment implements IComparable
|
|||
/**
|
||||
* Visible
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $visible = false;
|
||||
|
||||
|
@ -122,6 +122,7 @@ class Comment implements IComparable
|
|||
public function setAuthor($pValue = '')
|
||||
{
|
||||
$this->author = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -144,6 +145,7 @@ class Comment implements IComparable
|
|||
public function setText(RichText $pValue)
|
||||
{
|
||||
$this->text = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -166,6 +168,7 @@ class Comment implements IComparable
|
|||
public function setWidth($value = '96pt')
|
||||
{
|
||||
$this->width = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -188,6 +191,7 @@ class Comment implements IComparable
|
|||
public function setHeight($value = '55.5pt')
|
||||
{
|
||||
$this->height = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -210,6 +214,7 @@ class Comment implements IComparable
|
|||
public function setMarginLeft($value = '59.25pt')
|
||||
{
|
||||
$this->marginLeft = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -232,13 +237,14 @@ class Comment implements IComparable
|
|||
public function setMarginTop($value = '1.5pt')
|
||||
{
|
||||
$this->marginTop = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the comment visible by default?
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getVisible()
|
||||
{
|
||||
|
@ -248,12 +254,13 @@ class Comment implements IComparable
|
|||
/**
|
||||
* Set comment default visibility
|
||||
*
|
||||
* @param boolean $value
|
||||
* @param bool $value
|
||||
* @return Comment
|
||||
*/
|
||||
public function setVisible($value = false)
|
||||
{
|
||||
$this->visible = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -276,6 +283,7 @@ class Comment implements IComparable
|
|||
public function setAlignment($pValue = Style\Alignment::HORIZONTAL_GENERAL)
|
||||
{
|
||||
$this->alignment = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,8 +116,7 @@ class Properties
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $customProperties = array();
|
||||
|
||||
private $customProperties = [];
|
||||
|
||||
/**
|
||||
* Create a new Document Properties instance
|
||||
|
@ -149,6 +148,7 @@ class Properties
|
|||
public function setCreator($pValue = '')
|
||||
{
|
||||
$this->creator = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -171,6 +171,7 @@ class Properties
|
|||
public function setLastModifiedBy($pValue = '')
|
||||
{
|
||||
$this->lastModifiedBy = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -203,6 +204,7 @@ class Properties
|
|||
}
|
||||
|
||||
$this->created = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -235,6 +237,7 @@ class Properties
|
|||
}
|
||||
|
||||
$this->modified = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -257,6 +260,7 @@ class Properties
|
|||
public function setTitle($pValue = '')
|
||||
{
|
||||
$this->title = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -279,6 +283,7 @@ class Properties
|
|||
public function setDescription($pValue = '')
|
||||
{
|
||||
$this->description = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -301,6 +306,7 @@ class Properties
|
|||
public function setSubject($pValue = '')
|
||||
{
|
||||
$this->subject = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -323,6 +329,7 @@ class Properties
|
|||
public function setKeywords($pValue = '')
|
||||
{
|
||||
$this->keywords = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -345,6 +352,7 @@ class Properties
|
|||
public function setCategory($pValue = '')
|
||||
{
|
||||
$this->category = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -367,6 +375,7 @@ class Properties
|
|||
public function setCompany($pValue = '')
|
||||
{
|
||||
$this->company = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -389,6 +398,7 @@ class Properties
|
|||
public function setManager($pValue = '')
|
||||
{
|
||||
$this->manager = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -406,7 +416,7 @@ class Properties
|
|||
* Check if a Custom Property is defined
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isCustomPropertySet($propertyName)
|
||||
{
|
||||
|
@ -454,11 +464,11 @@ class Properties
|
|||
*/
|
||||
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)
|
||||
{
|
||||
if (($propertyType === null) || (!in_array($propertyType, array(self::PROPERTY_TYPE_INTEGER,
|
||||
if (($propertyType === null) || (!in_array($propertyType, [self::PROPERTY_TYPE_INTEGER,
|
||||
self::PROPERTY_TYPE_FLOAT,
|
||||
self::PROPERTY_TYPE_STRING,
|
||||
self::PROPERTY_TYPE_DATE,
|
||||
self::PROPERTY_TYPE_BOOLEAN)))) {
|
||||
self::PROPERTY_TYPE_BOOLEAN, ]))) {
|
||||
if ($propertyValue === null) {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
} elseif (is_float($propertyValue)) {
|
||||
|
@ -472,10 +482,11 @@ class Properties
|
|||
}
|
||||
}
|
||||
|
||||
$this->customProperties[$propertyName] = array(
|
||||
$this->customProperties[$propertyName] = [
|
||||
'value' => $propertyValue,
|
||||
'type' => $propertyType
|
||||
);
|
||||
'type' => $propertyType,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -550,6 +561,7 @@ class Properties
|
|||
return $propertyValue;
|
||||
break;
|
||||
}
|
||||
|
||||
return $propertyValue;
|
||||
}
|
||||
|
||||
|
@ -603,6 +615,7 @@ class Properties
|
|||
return self::PROPERTY_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
return self::PROPERTY_TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,21 +29,21 @@ class Security
|
|||
/**
|
||||
* LockRevision
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $lockRevision = false;
|
||||
|
||||
/**
|
||||
* LockStructure
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $lockStructure = false;
|
||||
|
||||
/**
|
||||
* LockWindows
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $lockWindows = false;
|
||||
|
||||
|
@ -71,7 +71,7 @@ class Security
|
|||
/**
|
||||
* Is some sort of document security enabled?
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isSecurityEnabled()
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ class Security
|
|||
/**
|
||||
* Get LockRevision
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getLockRevision()
|
||||
{
|
||||
|
@ -93,19 +93,20 @@ class Security
|
|||
/**
|
||||
* Set LockRevision
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param bool $pValue
|
||||
* @return Security
|
||||
*/
|
||||
public function setLockRevision($pValue = false)
|
||||
{
|
||||
$this->lockRevision = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockStructure
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getLockStructure()
|
||||
{
|
||||
|
@ -115,19 +116,20 @@ class Security
|
|||
/**
|
||||
* Set LockStructure
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param bool $pValue
|
||||
* @return Security
|
||||
*/
|
||||
public function setLockStructure($pValue = false)
|
||||
{
|
||||
$this->lockStructure = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockWindows
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getLockWindows()
|
||||
{
|
||||
|
@ -137,12 +139,13 @@ class Security
|
|||
/**
|
||||
* Set LockWindows
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param bool $pValue
|
||||
* @return Security
|
||||
*/
|
||||
public function setLockWindows($pValue = false)
|
||||
{
|
||||
$this->lockWindows = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -160,7 +163,7 @@ class Security
|
|||
* Set RevisionsPassword
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @param bool $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @return Security
|
||||
*/
|
||||
public function setRevisionsPassword($pValue = '', $pAlreadyHashed = false)
|
||||
|
@ -169,6 +172,7 @@ class Security
|
|||
$pValue = \PhpSpreadsheet\Shared\PasswordHasher::hashPassword($pValue);
|
||||
}
|
||||
$this->revisionsPassword = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -186,7 +190,7 @@ class Security
|
|||
* Set WorkbookPassword
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @param bool $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @return Security
|
||||
*/
|
||||
public function setWorkbookPassword($pValue = '', $pAlreadyHashed = false)
|
||||
|
@ -195,6 +199,7 @@ class Security
|
|||
$pValue = \PhpSpreadsheet\Shared\PasswordHasher::hashPassword($pValue);
|
||||
}
|
||||
$this->workbookPassword = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,12 +119,11 @@ class HashTable
|
|||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->items = array();
|
||||
$this->keyMap = array();
|
||||
$this->items = [];
|
||||
$this->keyMap = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,7 +152,6 @@ class HashTable
|
|||
*
|
||||
* @param int $pIndex
|
||||
* @return IComparable
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0)
|
||||
{
|
||||
|
@ -169,7 +167,6 @@ class HashTable
|
|||
*
|
||||
* @param string $pHashCode
|
||||
* @return IComparable
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '')
|
||||
{
|
||||
|
|
|
@ -557,7 +557,7 @@ class HTML
|
|||
protected $subscript = false;
|
||||
protected $strikethrough = false;
|
||||
|
||||
protected $startTagCallbacks = array(
|
||||
protected $startTagCallbacks = [
|
||||
'font' => 'startFontTag',
|
||||
'b' => 'startBoldTag',
|
||||
'strong' => 'startBoldTag',
|
||||
|
@ -568,9 +568,9 @@ class HTML
|
|||
'del' => 'startStrikethruTag',
|
||||
'sup' => 'startSuperscriptTag',
|
||||
'sub' => 'startSubscriptTag',
|
||||
);
|
||||
];
|
||||
|
||||
protected $endTagCallbacks = array(
|
||||
protected $endTagCallbacks = [
|
||||
'font' => 'endFontTag',
|
||||
'b' => 'endBoldTag',
|
||||
'strong' => 'endBoldTag',
|
||||
|
@ -589,9 +589,9 @@ class HTML
|
|||
'h4' => 'breakTag',
|
||||
'h5' => 'breakTag',
|
||||
'h6' => 'breakTag',
|
||||
);
|
||||
];
|
||||
|
||||
protected $stack = array();
|
||||
protected $stack = [];
|
||||
|
||||
protected $stringData = '';
|
||||
|
||||
|
@ -602,7 +602,7 @@ class HTML
|
|||
$this->face = $this->size = $this->color = null;
|
||||
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
|
||||
|
||||
$this->stack = array();
|
||||
$this->stack = [];
|
||||
|
||||
$this->stringData = '';
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ class HTML
|
|||
$this->initialise();
|
||||
|
||||
// Create a new DOM object
|
||||
$dom = new \DOMDocument;
|
||||
$dom = new \DOMDocument();
|
||||
// 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
|
||||
$loaded = @$dom->loadHTML($html);
|
||||
|
@ -687,6 +687,7 @@ class HTML
|
|||
foreach ($values[0] as &$value) {
|
||||
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
return implode($values[0]);
|
||||
}
|
||||
|
||||
|
@ -801,7 +802,7 @@ class HTML
|
|||
if (isset($callbacks[$callbackTag])) {
|
||||
$elementHandler = $callbacks[$callbackTag];
|
||||
if (method_exists($this, $elementHandler)) {
|
||||
call_user_func(array($this, $elementHandler), $element);
|
||||
call_user_func([$this, $elementHandler], $element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,22 +30,20 @@ class IOFactory
|
|||
* Search locations
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
private static $searchLocations = array(
|
||||
array( 'type' => 'IWriter', 'path' => 'PhpSpreadsheet/Writer/{0}.php', 'class' => '\\PhpSpreadsheet\\Writer\\{0}' ),
|
||||
array( 'type' => 'IReader', 'path' => 'PhpSpreadsheet/Reader/{0}.php', 'class' => '\\PhpSpreadsheet\\Reader\\{0}' )
|
||||
);
|
||||
private static $searchLocations = [
|
||||
['type' => 'IWriter', 'path' => 'PhpSpreadsheet/Writer/{0}.php', 'class' => '\\PhpSpreadsheet\\Writer\\{0}'],
|
||||
['type' => 'IReader', 'path' => 'PhpSpreadsheet/Reader/{0}.php', 'class' => '\\PhpSpreadsheet\\Reader\\{0}'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
private static $autoResolveClasses = array(
|
||||
private static $autoResolveClasses = [
|
||||
'Excel2007',
|
||||
'Excel5',
|
||||
'Excel2003XML',
|
||||
|
@ -54,7 +52,7 @@ class IOFactory
|
|||
'Gnumeric',
|
||||
'HTML',
|
||||
'CSV',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Private constructor for IOFactory
|
||||
|
@ -67,7 +65,6 @@ class IOFactory
|
|||
* Get search locations
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations()
|
||||
|
@ -79,7 +76,6 @@ class IOFactory
|
|||
* Set search locations
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param array $value
|
||||
* @throws Reader\Exception
|
||||
*/
|
||||
|
@ -96,25 +92,23 @@ class IOFactory
|
|||
* Add search location
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PhpSpreadsheet/Writer/{0}.php
|
||||
* @param string $classname Example: Writer\{0}
|
||||
*/
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '')
|
||||
{
|
||||
self::$searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||
self::$searchLocations[] = ['type' => $type, 'path' => $location, 'class' => $classname];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Writer\IWriter
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param string $writerType Example: Excel2007
|
||||
* @return Writer\IWriter
|
||||
* @throws Writer\Exception
|
||||
* @return Writer\IWriter
|
||||
*/
|
||||
public static function createWriter(Spreadsheet $spreadsheet, $writerType = '')
|
||||
{
|
||||
|
@ -141,10 +135,9 @@ class IOFactory
|
|||
* Create Reader\IReader
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $readerType Example: Excel2007
|
||||
* @return Reader\IReader
|
||||
* @throws Reader\Exception
|
||||
* @return Reader\IReader
|
||||
*/
|
||||
public static function createReader($readerType = '')
|
||||
{
|
||||
|
@ -171,14 +164,14 @@ class IOFactory
|
|||
* Loads Spreadsheet from file using automatic Reader\IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFilename The name of the spreadsheet file
|
||||
* @return Spreadsheet
|
||||
* @throws Reader\Exception
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public static function load($pFilename)
|
||||
{
|
||||
$reader = self::createReaderForFile($pFilename);
|
||||
|
||||
return $reader->load($pFilename);
|
||||
}
|
||||
|
||||
|
@ -186,10 +179,9 @@ class IOFactory
|
|||
* Identify file type using automatic Reader\IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFilename The name of the spreadsheet file to identify
|
||||
* @return string
|
||||
* @throws Reader\Exception
|
||||
* @return string
|
||||
*/
|
||||
public static function identify($pFilename)
|
||||
{
|
||||
|
@ -197,6 +189,7 @@ class IOFactory
|
|||
$className = get_class($reader);
|
||||
$classType = explode('\\', $className);
|
||||
unset($reader);
|
||||
|
||||
return array_pop($classType);
|
||||
}
|
||||
|
||||
|
@ -204,10 +197,9 @@ class IOFactory
|
|||
* Create Reader\IReader for file using automatic Reader\IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFilename The name of the spreadsheet file
|
||||
* @return Reader\IReader
|
||||
* @throws Reader\Exception
|
||||
* @return Reader\IReader
|
||||
*/
|
||||
public static function createReaderForFile($pFilename)
|
||||
{
|
||||
|
|
|
@ -124,6 +124,7 @@ class NamedRange
|
|||
$newTitle = $this->name;
|
||||
ReferenceHelper::getInstance()->updateNamedFormulas($this->worksheet->getParent(), $oldTitle, $newTitle);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -148,6 +149,7 @@ class NamedRange
|
|||
if ($value !== null) {
|
||||
$this->worksheet = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -172,6 +174,7 @@ class NamedRange
|
|||
if ($value !== null) {
|
||||
$this->range = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -195,6 +198,7 @@ class NamedRange
|
|||
{
|
||||
$this->localOnly = $value;
|
||||
$this->scope = $value ? $this->worksheet : null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -218,6 +222,7 @@ class NamedRange
|
|||
{
|
||||
$this->scope = $value;
|
||||
$this->localOnly = ($value == null) ? false : true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ abstract class BaseReader implements IReader
|
|||
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
|
||||
* or whether it should read both data and formatting
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $readDataOnly = false;
|
||||
|
||||
|
@ -40,7 +40,7 @@ abstract class BaseReader implements IReader
|
|||
* 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 bool
|
||||
*/
|
||||
protected $readEmptyCells = true;
|
||||
|
||||
|
@ -48,7 +48,7 @@ abstract class BaseReader implements IReader
|
|||
* Read charts that are defined in the workbook?
|
||||
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $includeCharts = false;
|
||||
|
||||
|
@ -69,13 +69,12 @@ abstract class BaseReader implements IReader
|
|||
|
||||
protected $fileHandle = null;
|
||||
|
||||
|
||||
/**
|
||||
* Read data only?
|
||||
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
|
||||
* If false (the default) it will read data and formatting.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getReadDataOnly()
|
||||
{
|
||||
|
@ -87,13 +86,14 @@ abstract class BaseReader implements IReader
|
|||
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
|
||||
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param bool $pValue
|
||||
*
|
||||
* @return IReader
|
||||
*/
|
||||
public function setReadDataOnly($pValue = false)
|
||||
{
|
||||
$this->readDataOnly = (boolean) $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ abstract class BaseReader implements IReader
|
|||
* If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
|
||||
* If false it will not read data for cells containing a null value or an empty string.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getReadEmptyCells()
|
||||
{
|
||||
|
@ -114,13 +114,14 @@ abstract class BaseReader implements IReader
|
|||
* Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
|
||||
* Set to false to advise the Reader to ignore cells containing a null value or an empty string.
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param bool $pValue
|
||||
*
|
||||
* @return IReader
|
||||
*/
|
||||
public function setReadEmptyCells($pValue = true)
|
||||
{
|
||||
$this->readEmptyCells = (boolean) $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -130,7 +131,7 @@ abstract class BaseReader implements IReader
|
|||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||
* If false (the default) it will ignore any charts defined in the workbook file.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getIncludeCharts()
|
||||
{
|
||||
|
@ -143,13 +144,14 @@ abstract class BaseReader implements IReader
|
|||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||
* Set to false (the default) to discard charts.
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param bool $pValue
|
||||
*
|
||||
* @return IReader
|
||||
*/
|
||||
public function setIncludeCharts($pValue = false)
|
||||
{
|
||||
$this->includeCharts = (boolean) $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -180,7 +182,8 @@ abstract class BaseReader implements IReader
|
|||
return $this->setLoadAllSheets();
|
||||
}
|
||||
|
||||
$this->loadSheetsOnly = is_array($value) ? $value : array($value);
|
||||
$this->loadSheetsOnly = is_array($value) ? $value : [$value];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -193,6 +196,7 @@ abstract class BaseReader implements IReader
|
|||
public function setLoadAllSheets()
|
||||
{
|
||||
$this->loadSheetsOnly = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -215,6 +219,7 @@ abstract class BaseReader implements IReader
|
|||
public function setReadFilter(IReadFilter $pValue)
|
||||
{
|
||||
$this->readFilter = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -229,13 +234,13 @@ abstract class BaseReader implements IReader
|
|||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename) || !is_readable($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
// Open file
|
||||
$this->fileHandle = fopen($pFilename, 'r');
|
||||
if ($this->fileHandle === false) {
|
||||
throw new Exception("Could not open file " . $pFilename . " for reading.");
|
||||
throw new Exception('Could not open file ' . $pFilename . ' for reading.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,8 +248,8 @@ abstract class BaseReader implements IReader
|
|||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
|
@ -257,6 +262,7 @@ abstract class BaseReader implements IReader
|
|||
|
||||
$readable = $this->isValidFormat();
|
||||
fclose($this->fileHandle);
|
||||
|
||||
return $readable;
|
||||
}
|
||||
|
||||
|
@ -272,6 +278,7 @@ abstract class BaseReader implements IReader
|
|||
if (preg_match($pattern, $xml)) {
|
||||
throw new Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ class CSV extends BaseReader implements IReader
|
|||
/**
|
||||
* Input encoding
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $inputEncoding = 'UTF-8';
|
||||
|
@ -39,7 +38,6 @@ class CSV extends BaseReader implements IReader
|
|||
/**
|
||||
* Delimiter
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $delimiter = ',';
|
||||
|
@ -47,7 +45,6 @@ class CSV extends BaseReader implements IReader
|
|||
/**
|
||||
* Enclosure
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $enclosure = '"';
|
||||
|
@ -55,7 +52,6 @@ class CSV extends BaseReader implements IReader
|
|||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $sheetIndex = 0;
|
||||
|
@ -63,7 +59,6 @@ class CSV extends BaseReader implements IReader
|
|||
/**
|
||||
* Load rows contiguously
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $contiguous = false;
|
||||
|
@ -75,7 +70,6 @@ class CSV extends BaseReader implements IReader
|
|||
*/
|
||||
private $contiguousRow = -1;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new CSV Reader instance
|
||||
*/
|
||||
|
@ -87,7 +81,7 @@ class CSV extends BaseReader implements IReader
|
|||
/**
|
||||
* Validate that the current file is a CSV file
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidFormat()
|
||||
{
|
||||
|
@ -102,6 +96,7 @@ class CSV extends BaseReader implements IReader
|
|||
public function setInputEncoding($pValue = 'UTF-8')
|
||||
{
|
||||
$this->inputEncoding = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -117,7 +112,6 @@ class CSV extends BaseReader implements IReader
|
|||
|
||||
/**
|
||||
* Move filepointer past any BOM marker
|
||||
*
|
||||
*/
|
||||
protected function skipBOM()
|
||||
{
|
||||
|
@ -151,7 +145,6 @@ class CSV extends BaseReader implements IReader
|
|||
|
||||
/**
|
||||
* Identify any separator that is explicitly set in the file
|
||||
*
|
||||
*/
|
||||
protected function checkSeparator()
|
||||
{
|
||||
|
@ -162,8 +155,10 @@ class CSV extends BaseReader implements IReader
|
|||
|
||||
if ((strlen(trim($line, "\r\n")) == 5) && (stripos($line, 'sep=') === 0)) {
|
||||
$this->delimiter = substr($line, 4, 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->skipBOM();
|
||||
}
|
||||
|
||||
|
@ -179,7 +174,7 @@ class CSV extends BaseReader implements IReader
|
|||
$this->openFile($pFilename);
|
||||
if (!$this->isValidFormat()) {
|
||||
fclose($this->fileHandle);
|
||||
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
$fileHandle = $this->fileHandle;
|
||||
|
||||
|
@ -187,9 +182,9 @@ class CSV extends BaseReader implements IReader
|
|||
$this->skipBOM();
|
||||
$this->checkSeparator();
|
||||
|
||||
$escapeEnclosures = array( "\\" . $this->enclosure, $this->enclosure . $this->enclosure );
|
||||
$escapeEnclosures = ['\\' . $this->enclosure, $this->enclosure . $this->enclosure];
|
||||
|
||||
$worksheetInfo = array();
|
||||
$worksheetInfo = [];
|
||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||
|
@ -198,7 +193,7 @@ class CSV extends BaseReader implements IReader
|
|||
|
||||
// Loop through each line of the file in turn
|
||||
while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure)) !== false) {
|
||||
$worksheetInfo[0]['totalRows']++;
|
||||
++$worksheetInfo[0]['totalRows'];
|
||||
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
|
||||
}
|
||||
|
||||
|
@ -215,8 +210,8 @@ class CSV extends BaseReader implements IReader
|
|||
* Loads Spreadsheet from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
* @throws Exception
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
|
@ -232,8 +227,8 @@ class CSV extends BaseReader implements IReader
|
|||
*
|
||||
* @param string $pFilename
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @return Spreadsheet
|
||||
* @throws Exception
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
|
||||
{
|
||||
|
@ -244,7 +239,7 @@ class CSV extends BaseReader implements IReader
|
|||
$this->openFile($pFilename);
|
||||
if (!$this->isValidFormat()) {
|
||||
fclose($this->fileHandle);
|
||||
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
$fileHandle = $this->fileHandle;
|
||||
|
||||
|
@ -258,9 +253,9 @@ class CSV extends BaseReader implements IReader
|
|||
}
|
||||
$sheet = $spreadsheet->setActiveSheetIndex($this->sheetIndex);
|
||||
|
||||
$escapeEnclosures = array( "\\" . $this->enclosure,
|
||||
$this->enclosure . $this->enclosure
|
||||
);
|
||||
$escapeEnclosures = ['\\' . $this->enclosure,
|
||||
$this->enclosure . $this->enclosure,
|
||||
];
|
||||
|
||||
// Set our starting row based on whether we're in contiguous mode or not
|
||||
$currentRow = 1;
|
||||
|
@ -321,6 +316,7 @@ class CSV extends BaseReader implements IReader
|
|||
public function setDelimiter($pValue = ',')
|
||||
{
|
||||
$this->delimiter = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -346,13 +342,14 @@ class CSV extends BaseReader implements IReader
|
|||
$pValue = '"';
|
||||
}
|
||||
$this->enclosure = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex()
|
||||
{
|
||||
|
@ -362,19 +359,20 @@ class CSV extends BaseReader implements IReader
|
|||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param integer $pValue Sheet index
|
||||
* @param int $pValue Sheet index
|
||||
* @return CSV
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0)
|
||||
{
|
||||
$this->sheetIndex = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Contiguous
|
||||
*
|
||||
* @param boolean $contiguous
|
||||
* @param bool $contiguous
|
||||
*/
|
||||
public function setContiguous($contiguous = false)
|
||||
{
|
||||
|
@ -389,7 +387,7 @@ class CSV extends BaseReader implements IReader
|
|||
/**
|
||||
* Get Contiguous
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getContiguous()
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ class DefaultReadFilter implements IReadFilter
|
|||
* @param $column Column address (as a string value like "A", or "IV")
|
||||
* @param $row Row number
|
||||
* @param $worksheetName Optional worksheet name
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $styles = array();
|
||||
protected $styles = [];
|
||||
|
||||
/**
|
||||
* Character set used in the file
|
||||
|
@ -48,13 +48,12 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
$this->readFilter = new DefaultReadFilter();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
|
@ -69,10 +68,10 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
// Rowset xmlns:z="#RowsetSchema"
|
||||
//
|
||||
|
||||
$signature = array(
|
||||
$signature = [
|
||||
'<?xml version="1.0"',
|
||||
'<?mso-application progid="Excel.Sheet"?>'
|
||||
);
|
||||
'<?mso-application progid="Excel.Sheet"?>',
|
||||
];
|
||||
|
||||
// Open file
|
||||
$this->openFile($pFilename);
|
||||
|
@ -100,7 +99,6 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
return $valid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads names of the worksheets from a file, without parsing the whole file to a PhpSpreadsheet object
|
||||
*
|
||||
|
@ -111,13 +109,13 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
if (!$this->canRead($pFilename)) {
|
||||
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
|
||||
$worksheetNames = array();
|
||||
$worksheetNames = [];
|
||||
|
||||
$xml = simplexml_load_string(
|
||||
$this->securityScan(file_get_contents($pFilename)),
|
||||
|
@ -135,7 +133,6 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
return $worksheetNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
|
@ -146,10 +143,10 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
$worksheetInfo = array();
|
||||
$worksheetInfo = [];
|
||||
|
||||
$xml = simplexml_load_string(
|
||||
$this->securityScan(file_get_contents($pFilename)),
|
||||
|
@ -163,7 +160,7 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
foreach ($xml_ss->Worksheet as $worksheet) {
|
||||
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
|
||||
|
||||
$tmpInfo = array();
|
||||
$tmpInfo = [];
|
||||
$tmpInfo['worksheetName'] = '';
|
||||
$tmpInfo['lastColumnLetter'] = 'A';
|
||||
$tmpInfo['lastColumnIndex'] = 0;
|
||||
|
@ -210,13 +207,12 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PhpSpreadsheet from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
* @throws Exception
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
|
@ -234,9 +230,11 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
foreach ($styleList as $style) {
|
||||
if ($styleAttributeValue == strtolower($style)) {
|
||||
$styleAttributeValue = $style;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -247,10 +245,11 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
*/
|
||||
protected static function pixel2WidthUnits($pxs)
|
||||
{
|
||||
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
|
||||
$UNIT_OFFSET_MAP = [0, 36, 73, 109, 146, 182, 219];
|
||||
|
||||
$widthUnits = 256 * ($pxs / 7);
|
||||
$widthUnits += $UNIT_OFFSET_MAP[($pxs % 7)];
|
||||
|
||||
return $widthUnits;
|
||||
}
|
||||
|
||||
|
@ -264,6 +263,7 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
$pixels = ($widthUnits / 256) * 7;
|
||||
$offsetWidthUnits = $widthUnits % 256;
|
||||
$pixels += round($offsetWidthUnits / (256 / 7));
|
||||
|
||||
return $pixels;
|
||||
}
|
||||
|
||||
|
@ -277,46 +277,46 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
*
|
||||
* @param string $pFilename
|
||||
* @param \PhpSpreadsheet\Spreadsheet $spreadsheet
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
* @throws Exception
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, \PhpSpreadsheet\Spreadsheet $spreadsheet)
|
||||
{
|
||||
$fromFormats = array('\-', '\ ');
|
||||
$toFormats = array('-', ' ');
|
||||
$fromFormats = ['\-', '\ '];
|
||||
$toFormats = ['-', ' '];
|
||||
|
||||
$underlineStyles = array (
|
||||
$underlineStyles = [
|
||||
\PhpSpreadsheet\Style\Font::UNDERLINE_NONE,
|
||||
\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE,
|
||||
\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLEACCOUNTING,
|
||||
\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE,
|
||||
\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLEACCOUNTING
|
||||
);
|
||||
$verticalAlignmentStyles = array (
|
||||
\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLEACCOUNTING,
|
||||
];
|
||||
$verticalAlignmentStyles = [
|
||||
\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM,
|
||||
\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP,
|
||||
\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
||||
\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY
|
||||
);
|
||||
$horizontalAlignmentStyles = array (
|
||||
\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY,
|
||||
];
|
||||
$horizontalAlignmentStyles = [
|
||||
\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL,
|
||||
\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT,
|
||||
\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT,
|
||||
\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
||||
\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS,
|
||||
\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY
|
||||
);
|
||||
\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY,
|
||||
];
|
||||
|
||||
$timezoneObj = new \DateTimeZone('Europe/London');
|
||||
$GMT = new \DateTimeZone('UTC');
|
||||
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
if (!$this->canRead($pFilename)) {
|
||||
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
|
||||
$xml = simplexml_load_string(
|
||||
|
@ -403,7 +403,7 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
$style_ss = $style->attributes($namespaces['ss']);
|
||||
$styleID = (string) $style_ss['ID'];
|
||||
// echo 'Style ID = '.$styleID.'<br />';
|
||||
$this->styles[$styleID] = (isset($this->styles['Default'])) ? $this->styles['Default'] : array();
|
||||
$this->styles[$styleID] = (isset($this->styles['Default'])) ? $this->styles['Default'] : [];
|
||||
foreach ($style as $styleType => $styleData) {
|
||||
$styleAttributes = $styleData->attributes($namespaces['ss']);
|
||||
// echo $styleType.'<br />';
|
||||
|
@ -432,7 +432,7 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
case 'Borders':
|
||||
foreach ($styleData->Border as $borderStyle) {
|
||||
$borderAttributes = $borderStyle->attributes($namespaces['ss']);
|
||||
$thisBorder = array();
|
||||
$thisBorder = [];
|
||||
foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) {
|
||||
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
|
||||
switch ($borderStyleKey) {
|
||||
|
@ -666,7 +666,7 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($key = !$key) {
|
||||
$value = str_replace(array('[.', '.', ']'), '', $value);
|
||||
$value = str_replace(['[.', '.', ']'], '', $value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -757,7 +757,7 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
++$columnID;
|
||||
while ($additionalMergedCells > 0) {
|
||||
++$columnID;
|
||||
$additionalMergedCells--;
|
||||
--$additionalMergedCells;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -782,16 +782,15 @@ class Excel2003XML extends BaseReader implements IReader
|
|||
return $spreadsheet;
|
||||
}
|
||||
|
||||
|
||||
protected static function convertStringEncoding($string, $charset)
|
||||
{
|
||||
if ($charset != 'UTF-8') {
|
||||
return \PhpSpreadsheet\Shared\StringHelper::convertEncoding($string, 'UTF-8', $charset);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
protected function parseRichText($is = '')
|
||||
{
|
||||
$value = new \PhpSpreadsheet\RichText();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,16 +40,16 @@ class Chart
|
|||
return (float) $attributes[$name];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static function readColor($color, $background = false)
|
||||
{
|
||||
if (isset($color["rgb"])) {
|
||||
return (string)$color["rgb"];
|
||||
} elseif (isset($color["indexed"])) {
|
||||
return \PhpSpreadsheet\Style\Color::indexedColor($color["indexed"]-7, $background)->getARGB();
|
||||
if (isset($color['rgb'])) {
|
||||
return (string) $color['rgb'];
|
||||
} elseif (isset($color['indexed'])) {
|
||||
return \PhpSpreadsheet\Style\Color::indexedColor($color['indexed'] - 7, $background)->getARGB();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,90 +63,90 @@ class Chart
|
|||
|
||||
foreach ($chartElementsC as $chartElementKey => $chartElement) {
|
||||
switch ($chartElementKey) {
|
||||
case "chart":
|
||||
case 'chart':
|
||||
foreach ($chartElement as $chartDetailsKey => $chartDetails) {
|
||||
$chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
|
||||
switch ($chartDetailsKey) {
|
||||
case "plotArea":
|
||||
case 'plotArea':
|
||||
$plotAreaLayout = $XaxisLable = $YaxisLable = null;
|
||||
$plotSeries = $plotAttributes = array();
|
||||
$plotSeries = $plotAttributes = [];
|
||||
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
|
||||
switch ($chartDetailKey) {
|
||||
case "layout":
|
||||
case 'layout':
|
||||
$plotAreaLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta, 'plotArea');
|
||||
break;
|
||||
case "catAx":
|
||||
case 'catAx':
|
||||
if (isset($chartDetail->title)) {
|
||||
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
|
||||
}
|
||||
break;
|
||||
case "dateAx":
|
||||
case 'dateAx':
|
||||
if (isset($chartDetail->title)) {
|
||||
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
|
||||
}
|
||||
break;
|
||||
case "valAx":
|
||||
case 'valAx':
|
||||
if (isset($chartDetail->title)) {
|
||||
$YaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
|
||||
}
|
||||
break;
|
||||
case "barChart":
|
||||
case "bar3DChart":
|
||||
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":
|
||||
case 'lineChart':
|
||||
case 'line3DChart':
|
||||
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "areaChart":
|
||||
case "area3DChart":
|
||||
case 'areaChart':
|
||||
case 'area3DChart':
|
||||
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||
$plotAttributes = self::readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "doughnutChart":
|
||||
case "pieChart":
|
||||
case "pie3DChart":
|
||||
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":
|
||||
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":
|
||||
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":
|
||||
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":
|
||||
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":
|
||||
case 'stockChart':
|
||||
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
|
||||
$plotAttributes = self::readChartAttributes($plotAreaLayout);
|
||||
break;
|
||||
|
@ -158,28 +158,28 @@ class Chart
|
|||
$plotArea = new \PhpSpreadsheet\Chart\PlotArea($plotAreaLayout, $plotSeries);
|
||||
self::setChartAttributes($plotAreaLayout, $plotAttributes);
|
||||
break;
|
||||
case "plotVisOnly":
|
||||
case 'plotVisOnly':
|
||||
$plotVisOnly = self::getAttribute($chartDetails, 'val', 'string');
|
||||
break;
|
||||
case "dispBlanksAs":
|
||||
case 'dispBlanksAs':
|
||||
$dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string');
|
||||
break;
|
||||
case "title":
|
||||
case 'title':
|
||||
$title = self::chartTitle($chartDetails, $namespacesChartMeta, 'title');
|
||||
break;
|
||||
case "legend":
|
||||
case 'legend':
|
||||
$legendPos = 'r';
|
||||
$legendLayout = null;
|
||||
$legendOverlay = false;
|
||||
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
|
||||
switch ($chartDetailKey) {
|
||||
case "legendPos":
|
||||
case 'legendPos':
|
||||
$legendPos = self::getAttribute($chartDetail, 'val', 'string');
|
||||
break;
|
||||
case "overlay":
|
||||
case 'overlay':
|
||||
$legendOverlay = self::getAttribute($chartDetail, 'val', 'boolean');
|
||||
break;
|
||||
case "layout":
|
||||
case 'layout':
|
||||
$legendLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta, 'legend');
|
||||
break;
|
||||
}
|
||||
|
@ -197,21 +197,21 @@ class Chart
|
|||
|
||||
private static function chartTitle($titleDetails, $namespacesChartMeta, $type)
|
||||
{
|
||||
$caption = array();
|
||||
$caption = [];
|
||||
$titleLayout = null;
|
||||
foreach ($titleDetails as $titleDetailKey => $chartDetail) {
|
||||
switch ($titleDetailKey) {
|
||||
case "tx":
|
||||
case 'tx':
|
||||
$titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
|
||||
foreach ($titleDetails as $titleKey => $titleDetail) {
|
||||
switch ($titleKey) {
|
||||
case "p":
|
||||
case 'p':
|
||||
$titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
|
||||
$caption[] = self::parseRichText($titleDetailPart);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "layout":
|
||||
case 'layout':
|
||||
$titleLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
|
||||
break;
|
||||
}
|
||||
|
@ -229,11 +229,12 @@ class Chart
|
|||
if (is_null($details)) {
|
||||
return null;
|
||||
}
|
||||
$layout = array();
|
||||
$layout = [];
|
||||
foreach ($details as $detailKey => $detail) {
|
||||
// echo $detailKey, ' => ',self::getAttribute($detail, 'val', 'string'),PHP_EOL;
|
||||
$layout[$detailKey] = self::getAttribute($detail, 'val', 'string');
|
||||
}
|
||||
|
||||
return new \PhpSpreadsheet\Chart\Layout($layout);
|
||||
}
|
||||
|
||||
|
@ -241,54 +242,54 @@ class Chart
|
|||
{
|
||||
$multiSeriesType = null;
|
||||
$smoothLine = false;
|
||||
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
|
||||
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = [];
|
||||
|
||||
$seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']);
|
||||
foreach ($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
|
||||
switch ($seriesDetailKey) {
|
||||
case "grouping":
|
||||
case 'grouping':
|
||||
$multiSeriesType = self::getAttribute($chartDetail->grouping, 'val', 'string');
|
||||
break;
|
||||
case "ser":
|
||||
case 'ser':
|
||||
$marker = null;
|
||||
foreach ($seriesDetails as $seriesKey => $seriesDetail) {
|
||||
switch ($seriesKey) {
|
||||
case "idx":
|
||||
case 'idx':
|
||||
$seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer');
|
||||
break;
|
||||
case "order":
|
||||
case 'order':
|
||||
$seriesOrder = self::getAttribute($seriesDetail, 'val', 'integer');
|
||||
$plotOrder[$seriesIndex] = $seriesOrder;
|
||||
break;
|
||||
case "tx":
|
||||
case 'tx':
|
||||
$seriesLabel[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
|
||||
break;
|
||||
case "marker":
|
||||
case 'marker':
|
||||
$marker = self::getAttribute($seriesDetail->symbol, 'val', 'string');
|
||||
break;
|
||||
case "smooth":
|
||||
case 'smooth':
|
||||
$smoothLine = self::getAttribute($seriesDetail, 'val', 'boolean');
|
||||
break;
|
||||
case "cat":
|
||||
case 'cat':
|
||||
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
|
||||
break;
|
||||
case "val":
|
||||
case 'val':
|
||||
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
|
||||
break;
|
||||
case "xVal":
|
||||
case 'xVal':
|
||||
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
|
||||
break;
|
||||
case "yVal":
|
||||
case 'yVal':
|
||||
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new \PhpSpreadsheet\Chart\DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine);
|
||||
}
|
||||
|
||||
|
||||
private static function chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false)
|
||||
{
|
||||
if (isset($seriesDetail->strRef)) {
|
||||
|
@ -314,13 +315,13 @@ class Chart
|
|||
|
||||
return new \PhpSpreadsheet\Chart\DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static function chartDataSeriesValues($seriesValueSet, $dataType = 'n')
|
||||
{
|
||||
$seriesVal = array();
|
||||
$seriesVal = [];
|
||||
$formatCode = '';
|
||||
$pointCount = 0;
|
||||
|
||||
|
@ -343,16 +344,16 @@ class Chart
|
|||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'formatCode' => $formatCode,
|
||||
'pointCount' => $pointCount,
|
||||
'dataValues' => $seriesVal
|
||||
);
|
||||
'dataValues' => $seriesVal,
|
||||
];
|
||||
}
|
||||
|
||||
private static function chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType = 'n')
|
||||
{
|
||||
$seriesVal = array();
|
||||
$seriesVal = [];
|
||||
$formatCode = '';
|
||||
$pointCount = 0;
|
||||
|
||||
|
@ -377,11 +378,11 @@ class Chart
|
|||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'formatCode' => $formatCode,
|
||||
'pointCount' => $pointCount,
|
||||
'dataValues' => $seriesVal
|
||||
);
|
||||
'dataValues' => $seriesVal,
|
||||
];
|
||||
}
|
||||
|
||||
private static function parseRichText($titleDetailPart = null)
|
||||
|
@ -393,8 +394,8 @@ class Chart
|
|||
$objText = $value->createTextRun((string) $titleDetailElement->t);
|
||||
}
|
||||
if (isset($titleDetailElement->rPr)) {
|
||||
if (isset($titleDetailElement->rPr->rFont["val"])) {
|
||||
$objText->getFont()->setName((string) $titleDetailElement->rPr->rFont["val"]);
|
||||
if (isset($titleDetailElement->rPr->rFont['val'])) {
|
||||
$objText->getFont()->setName((string) $titleDetailElement->rPr->rFont['val']);
|
||||
}
|
||||
|
||||
$fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
|
||||
|
@ -453,7 +454,7 @@ class Chart
|
|||
|
||||
private static function readChartAttributes($chartDetail)
|
||||
{
|
||||
$plotAttributes = array();
|
||||
$plotAttributes = [];
|
||||
if (isset($chartDetail->dLbls)) {
|
||||
if (isset($chartDetail->dLbls->howLegendKey)) {
|
||||
$plotAttributes['showLegendKey'] = self::getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string');
|
||||
|
|
|
@ -47,7 +47,6 @@ class Theme
|
|||
*/
|
||||
private $colourMapValues;
|
||||
|
||||
|
||||
/**
|
||||
* Colour Map
|
||||
*
|
||||
|
@ -55,10 +54,8 @@ class Theme
|
|||
*/
|
||||
private $colourMap;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Theme
|
||||
*
|
||||
*/
|
||||
public function __construct($themeName, $colourSchemeName, $colourMap)
|
||||
{
|
||||
|
@ -98,6 +95,7 @@ class Theme
|
|||
if (isset($this->colourMap[$index])) {
|
||||
return $this->colourMap[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@ namespace PhpSpreadsheet\Reader\Excel5\Color;
|
|||
|
||||
class BIFF5
|
||||
{
|
||||
protected static $map = array(
|
||||
protected static $map = [
|
||||
0x08 => '000000',
|
||||
0x09 => 'FFFFFF',
|
||||
0x0A => 'FF0000',
|
||||
|
@ -61,7 +61,7 @@ class BIFF5
|
|||
0x3D => '85396A',
|
||||
0x3E => '4A3285',
|
||||
0x3F => '424242',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Map color array from BIFF5 built-in color index
|
||||
|
@ -72,8 +72,9 @@ class BIFF5
|
|||
public static function lookup($color)
|
||||
{
|
||||
if (isset(self::$map[$color])) {
|
||||
return array('rgb' => self::$map[$color]);
|
||||
return ['rgb' => self::$map[$color]];
|
||||
}
|
||||
return array('rgb' => '000000');
|
||||
|
||||
return ['rgb' => '000000'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace PhpSpreadsheet\Reader\Excel5\Color;
|
|||
|
||||
class BIFF8
|
||||
{
|
||||
protected static $map = array(
|
||||
protected static $map = [
|
||||
0x08 => '000000',
|
||||
0x09 => 'FFFFFF',
|
||||
0x0A => 'FF0000',
|
||||
|
@ -61,7 +61,7 @@ class BIFF8
|
|||
0x3D => '993366',
|
||||
0x3E => '333399',
|
||||
0x3F => '333333',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Map color array from BIFF8 built-in color index
|
||||
|
@ -72,8 +72,9 @@ class BIFF8
|
|||
public static function lookup($color)
|
||||
{
|
||||
if (isset(self::$map[$color])) {
|
||||
return array('rgb' => self::$map[$color]);
|
||||
return ['rgb' => self::$map[$color]];
|
||||
}
|
||||
return array('rgb' => '000000');
|
||||
|
||||
return ['rgb' => '000000'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace PhpSpreadsheet\Reader\Excel5\Color;
|
|||
|
||||
class BuiltIn
|
||||
{
|
||||
protected static $map = array(
|
||||
protected static $map = [
|
||||
0x00 => '000000',
|
||||
0x01 => 'FFFFFF',
|
||||
0x02 => 'FF0000',
|
||||
|
@ -15,7 +15,7 @@ class BuiltIn
|
|||
0x07 => '00FFFF',
|
||||
0x40 => '000000', // system window text color
|
||||
0x41 => 'FFFFFF', // system window background color
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Map built-in color to RGB value
|
||||
|
@ -26,8 +26,9 @@ class BuiltIn
|
|||
public static function lookup($color)
|
||||
{
|
||||
if (isset(self::$map[$color])) {
|
||||
return array('rgb' => self::$map[$color]);
|
||||
return ['rgb' => self::$map[$color]];
|
||||
}
|
||||
return array('rgb' => '000000');
|
||||
|
||||
return ['rgb' => '000000'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace PhpSpreadsheet\Reader\Excel5;
|
|||
|
||||
class ErrorCode
|
||||
{
|
||||
protected static $map = array(
|
||||
protected static $map = [
|
||||
0x00 => '#NULL!',
|
||||
0x07 => '#DIV/0!',
|
||||
0x0F => '#VALUE!',
|
||||
|
@ -12,19 +12,20 @@ class ErrorCode
|
|||
0x1D => '#NAME?',
|
||||
0x24 => '#NUM!',
|
||||
0x2A => '#N/A',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Map error code, e.g. '#N/A'
|
||||
*
|
||||
* @param int $code
|
||||
* @return string|boolean
|
||||
* @return string|bool
|
||||
*/
|
||||
public static function lookup($code)
|
||||
{
|
||||
if (isset(self::$map[$code])) {
|
||||
return self::$map[$code];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ class Escher
|
|||
// record is a container, read contents
|
||||
$dggContainer = new \PhpSpreadsheet\Shared\Escher\DggContainer();
|
||||
$this->object->setDggContainer($dggContainer);
|
||||
$reader = new Escher($dggContainer);
|
||||
$reader = new self($dggContainer);
|
||||
$reader->load($recordData);
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ class Escher
|
|||
// record is a container, read contents
|
||||
$bstoreContainer = new \PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer();
|
||||
$this->object->setBstoreContainer($bstoreContainer);
|
||||
$reader = new Escher($bstoreContainer);
|
||||
$reader = new self($bstoreContainer);
|
||||
$reader->load($recordData);
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ class Escher
|
|||
$pos += 16;
|
||||
|
||||
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
|
||||
if (in_array($recInstance, array(0x046B, 0x06E3))) {
|
||||
if (in_array($recInstance, [0x046B, 0x06E3])) {
|
||||
$rgbUid2 = substr($recordData, 16, 16);
|
||||
$pos += 16;
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ class Escher
|
|||
$this->object->addChild($spgrContainer);
|
||||
}
|
||||
|
||||
$reader = new Escher($spgrContainer);
|
||||
$reader = new self($spgrContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
|
@ -505,7 +505,7 @@ class Escher
|
|||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$reader = new Escher($spContainer);
|
||||
$reader = new self($spContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class MD5
|
|||
public function getContext()
|
||||
{
|
||||
$s = '';
|
||||
foreach (array('a', 'b', 'c', 'd') as $i) {
|
||||
foreach (['a', 'b', 'c', 'd'] as $i) {
|
||||
$v = $this->{$i};
|
||||
$s .= chr($v & 0xff);
|
||||
$s .= chr(($v >> 8) & 0xff);
|
||||
|
@ -169,22 +169,22 @@ class MD5
|
|||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
@ -196,7 +196,8 @@ class MD5
|
|||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace PhpSpreadsheet\Reader\Excel5;
|
|||
class RC4
|
||||
{
|
||||
// Context
|
||||
protected $s = array();
|
||||
protected $s = [];
|
||||
protected $i = 0;
|
||||
protected $j = 0;
|
||||
|
||||
|
@ -40,12 +40,12 @@ class RC4
|
|||
{
|
||||
$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->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;
|
||||
$t = $this->s[$this->i];
|
||||
$this->s[$this->i] = $this->s[$this->j];
|
||||
|
@ -64,7 +64,7 @@ class RC4
|
|||
public function RC4($data)
|
||||
{
|
||||
$len = strlen($data);
|
||||
for ($c = 0; $c < $len; $c++) {
|
||||
for ($c = 0; $c < $len; ++$c) {
|
||||
$this->i = ($this->i + 1) % 256;
|
||||
$this->j = ($this->j + $this->s[$this->i]) % 256;
|
||||
$t = $this->s[$this->i];
|
||||
|
@ -75,6 +75,7 @@ class RC4
|
|||
|
||||
$data[$c] = chr(ord($data[$c]) ^ $this->s[$t]);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace PhpSpreadsheet\Reader\Excel5\Style;
|
||||
|
||||
use \PhpSpreadsheet\Style\Border as StyleBorder;
|
||||
use PhpSpreadsheet\Style\Border as StyleBorder;
|
||||
|
||||
class Border
|
||||
{
|
||||
protected static $map = array(
|
||||
protected static $map = [
|
||||
0x00 => StyleBorder::BORDER_NONE,
|
||||
0x01 => StyleBorder::BORDER_THIN,
|
||||
0x02 => StyleBorder::BORDER_MEDIUM,
|
||||
|
@ -21,7 +21,7 @@ class Border
|
|||
0x0B => StyleBorder::BORDER_DASHDOTDOT,
|
||||
0x0C => StyleBorder::BORDER_MEDIUMDASHDOTDOT,
|
||||
0x0D => StyleBorder::BORDER_SLANTDASHDOT,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Map border style
|
||||
|
@ -35,6 +35,7 @@ class Border
|
|||
if (isset(self::$map[$index])) {
|
||||
return self::$map[$index];
|
||||
}
|
||||
|
||||
return StyleBorder::BORDER_NONE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace PhpSpreadsheet\Reader\Excel5\Style;
|
||||
|
||||
use \PhpSpreadsheet\Style\Fill;
|
||||
use PhpSpreadsheet\Style\Fill;
|
||||
|
||||
class FillPattern
|
||||
{
|
||||
protected static $map = array(
|
||||
protected static $map = [
|
||||
0x00 => Fill::FILL_NONE,
|
||||
0x01 => Fill::FILL_SOLID,
|
||||
0x02 => Fill::FILL_PATTERN_MEDIUMGRAY,
|
||||
|
@ -26,7 +26,7 @@ class FillPattern
|
|||
0x10 => Fill::FILL_PATTERN_LIGHTTRELLIS,
|
||||
0x11 => Fill::FILL_PATTERN_GRAY125,
|
||||
0x12 => Fill::FILL_PATTERN_GRAY0625,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Get fill pattern from index
|
||||
|
@ -40,6 +40,7 @@ class FillPattern
|
|||
if (isset(self::$map[$index])) {
|
||||
return self::$map[$index];
|
||||
}
|
||||
|
||||
return Fill::FILL_NONE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,14 +31,14 @@ class Gnumeric extends BaseReader implements IReader
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $styles = array();
|
||||
private $styles = [];
|
||||
|
||||
/**
|
||||
* Shared Expressions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $expressions = array();
|
||||
private $expressions = [];
|
||||
|
||||
private $referenceHelper = null;
|
||||
|
||||
|
@ -55,19 +55,19 @@ class Gnumeric extends BaseReader implements IReader
|
|||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
// Check if gzlib functions are available
|
||||
if (!function_exists('gzread')) {
|
||||
throw new Exception("gzlib library is not enabled");
|
||||
throw new Exception('gzlib library is not enabled');
|
||||
}
|
||||
|
||||
// Read signature data (first 3 bytes)
|
||||
|
@ -92,14 +92,14 @@ class Gnumeric extends BaseReader implements IReader
|
|||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
$xml = new XMLReader();
|
||||
$xml->xml($this->securityScanFile('compress.zlib://' . realpath($pFilename)), null, \PhpSpreadsheet\Settings::getLibXmlLoaderOptions());
|
||||
$xml->setParserProperty(2, true);
|
||||
|
||||
$worksheetNames = array();
|
||||
$worksheetNames = [];
|
||||
while ($xml->read()) {
|
||||
if ($xml->name == 'gnm:SheetName' && $xml->nodeType == XMLReader::ELEMENT) {
|
||||
$xml->read(); // Move onto the value node
|
||||
|
@ -123,23 +123,23 @@ class Gnumeric extends BaseReader implements IReader
|
|||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
$xml = new XMLReader();
|
||||
$xml->xml($this->securityScanFile('compress.zlib://' . realpath($pFilename)), null, \PhpSpreadsheet\Settings::getLibXmlLoaderOptions());
|
||||
$xml->setParserProperty(2, true);
|
||||
|
||||
$worksheetInfo = array();
|
||||
$worksheetInfo = [];
|
||||
while ($xml->read()) {
|
||||
if ($xml->name == 'gnm:Sheet' && $xml->nodeType == XMLReader::ELEMENT) {
|
||||
$tmpInfo = array(
|
||||
$tmpInfo = [
|
||||
'worksheetName' => '',
|
||||
'lastColumnLetter' => 'A',
|
||||
'lastColumnIndex' => 0,
|
||||
'totalRows' => 0,
|
||||
'totalColumns' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
while ($xml->read()) {
|
||||
if ($xml->name == 'gnm:Name' && $xml->nodeType == XMLReader::ELEMENT) {
|
||||
|
@ -173,6 +173,7 @@ class Gnumeric extends BaseReader implements IReader
|
|||
}
|
||||
gzclose($file);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -180,8 +181,8 @@ class Gnumeric extends BaseReader implements IReader
|
|||
* Loads PhpSpreadsheet from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PhpSpreadsheet
|
||||
* @throws Exception
|
||||
* @return PhpSpreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
|
@ -197,14 +198,14 @@ class Gnumeric extends BaseReader implements IReader
|
|||
*
|
||||
* @param string $pFilename
|
||||
* @param \PhpSpreadsheet\Spreadsheet $spreadsheet
|
||||
* @return PhpSpreadsheet
|
||||
* @throws Exception
|
||||
* @return PhpSpreadsheet
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, \PhpSpreadsheet\Spreadsheet $spreadsheet)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
$timezoneObj = new DateTimeZone('Europe/London');
|
||||
|
@ -231,7 +232,7 @@ class Gnumeric extends BaseReader implements IReader
|
|||
$officeDocMetaXML = $officeDocXML->meta;
|
||||
|
||||
foreach ($officeDocMetaXML as $officePropertyData) {
|
||||
$officePropertyDC = array();
|
||||
$officePropertyDC = [];
|
||||
if (isset($namespacesMeta['dc'])) {
|
||||
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
|
||||
}
|
||||
|
@ -258,7 +259,7 @@ class Gnumeric extends BaseReader implements IReader
|
|||
break;
|
||||
}
|
||||
}
|
||||
$officePropertyMeta = array();
|
||||
$officePropertyMeta = [];
|
||||
if (isset($namespacesMeta['meta'])) {
|
||||
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
|
||||
}
|
||||
|
@ -407,11 +408,11 @@ class Gnumeric extends BaseReader implements IReader
|
|||
$type = \PhpSpreadsheet\Cell\DataType::TYPE_FORMULA;
|
||||
if ($ExprID > '') {
|
||||
if (((string) $cell) > '') {
|
||||
$this->expressions[$ExprID] = array(
|
||||
$this->expressions[$ExprID] = [
|
||||
'column' => $cellAttributes->Col,
|
||||
'row' => $cellAttributes->Row,
|
||||
'formula' => (string) $cell
|
||||
);
|
||||
'formula' => (string) $cell,
|
||||
];
|
||||
// echo 'NEW EXPRESSION ', $ExprID,'<br />';
|
||||
} else {
|
||||
$expression = $this->expressions[$ExprID];
|
||||
|
@ -487,7 +488,7 @@ class Gnumeric extends BaseReader implements IReader
|
|||
// We still set the number format mask for date/time values, even if readDataOnly is true
|
||||
if ((!$this->readDataOnly) ||
|
||||
(\PhpSpreadsheet\Shared\Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) {
|
||||
$styleArray = array();
|
||||
$styleArray = [];
|
||||
$styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
|
||||
// If readDataOnly is false, we set all formatting information
|
||||
if (!$this->readDataOnly) {
|
||||
|
@ -530,15 +531,15 @@ class Gnumeric extends BaseReader implements IReader
|
|||
|
||||
$styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false;
|
||||
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false;
|
||||
$styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0;
|
||||
$styleArray['alignment']['indent'] = (intval($styleAttributes['Indent']) > 0) ? $styleAttributes['indent'] : 0;
|
||||
|
||||
$RGB = self::parseGnumericColour($styleAttributes["Fore"]);
|
||||
$RGB = self::parseGnumericColour($styleAttributes['Fore']);
|
||||
$styleArray['font']['color']['rgb'] = $RGB;
|
||||
$RGB = self::parseGnumericColour($styleAttributes["Back"]);
|
||||
$shade = $styleAttributes["Shade"];
|
||||
$RGB = self::parseGnumericColour($styleAttributes['Back']);
|
||||
$shade = $styleAttributes['Shade'];
|
||||
if (($RGB != '000000') || ($shade != '0')) {
|
||||
$styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB;
|
||||
$RGB2 = self::parseGnumericColour($styleAttributes["PatternColor"]);
|
||||
$RGB2 = self::parseGnumericColour($styleAttributes['PatternColor']);
|
||||
$styleArray['fill']['endcolor']['rgb'] = $RGB2;
|
||||
switch ($shade) {
|
||||
case '1':
|
||||
|
@ -742,7 +743,7 @@ class Gnumeric extends BaseReader implements IReader
|
|||
}
|
||||
}
|
||||
|
||||
$worksheetID++;
|
||||
++$worksheetID;
|
||||
}
|
||||
|
||||
// Loop through definedNames (global named ranges)
|
||||
|
@ -769,12 +770,12 @@ class Gnumeric extends BaseReader implements IReader
|
|||
|
||||
private static function parseBorderAttributes($borderAttributes)
|
||||
{
|
||||
$styleArray = array();
|
||||
if (isset($borderAttributes["Color"])) {
|
||||
$styleArray['color']['rgb'] = self::parseGnumericColour($borderAttributes["Color"]);
|
||||
$styleArray = [];
|
||||
if (isset($borderAttributes['Color'])) {
|
||||
$styleArray['color']['rgb'] = self::parseGnumericColour($borderAttributes['Color']);
|
||||
}
|
||||
|
||||
switch ($borderAttributes["Style"]) {
|
||||
switch ($borderAttributes['Style']) {
|
||||
case '0':
|
||||
$styleArray['style'] = \PhpSpreadsheet\Style\Border::BORDER_NONE;
|
||||
break;
|
||||
|
@ -818,6 +819,7 @@ class Gnumeric extends BaseReader implements IReader
|
|||
$styleArray['style'] = \PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT;
|
||||
break;
|
||||
}
|
||||
|
||||
return $styleArray;
|
||||
}
|
||||
|
||||
|
@ -835,6 +837,7 @@ class Gnumeric extends BaseReader implements IReader
|
|||
$gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2);
|
||||
$gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2);
|
||||
$gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2);
|
||||
|
||||
return $gnmR . $gnmG . $gnmB;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ namespace PhpSpreadsheet\Reader;
|
|||
/** PhpSpreadsheet root directory */
|
||||
class HTML extends BaseReader implements IReader
|
||||
{
|
||||
|
||||
/**
|
||||
* Input encoding
|
||||
*
|
||||
|
@ -47,64 +46,64 @@ class HTML extends BaseReader implements IReader
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $formats = array(
|
||||
'h1' => array(
|
||||
'font' => array(
|
||||
protected $formats = [
|
||||
'h1' => [
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
'size' => 24,
|
||||
),
|
||||
), // Bold, 24pt
|
||||
'h2' => array(
|
||||
'font' => array(
|
||||
],
|
||||
], // Bold, 24pt
|
||||
'h2' => [
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
'size' => 18,
|
||||
),
|
||||
), // Bold, 18pt
|
||||
'h3' => array(
|
||||
'font' => array(
|
||||
],
|
||||
], // Bold, 18pt
|
||||
'h3' => [
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
'size' => 13.5,
|
||||
),
|
||||
), // Bold, 13.5pt
|
||||
'h4' => array(
|
||||
'font' => array(
|
||||
],
|
||||
], // Bold, 13.5pt
|
||||
'h4' => [
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
'size' => 12,
|
||||
),
|
||||
), // Bold, 12pt
|
||||
'h5' => array(
|
||||
'font' => array(
|
||||
],
|
||||
], // Bold, 12pt
|
||||
'h5' => [
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
'size' => 10,
|
||||
),
|
||||
), // Bold, 10pt
|
||||
'h6' => array(
|
||||
'font' => array(
|
||||
],
|
||||
], // Bold, 10pt
|
||||
'h6' => [
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
'size' => 7.5,
|
||||
),
|
||||
), // Bold, 7.5pt
|
||||
'a' => array(
|
||||
'font' => array(
|
||||
],
|
||||
], // Bold, 7.5pt
|
||||
'a' => [
|
||||
'font' => [
|
||||
'underline' => true,
|
||||
'color' => array(
|
||||
'color' => [
|
||||
'argb' => \PhpSpreadsheet\Style\Color::COLOR_BLUE,
|
||||
),
|
||||
),
|
||||
), // Blue underlined
|
||||
'hr' => array(
|
||||
'borders' => array(
|
||||
'bottom' => array(
|
||||
],
|
||||
],
|
||||
], // Blue underlined
|
||||
'hr' => [
|
||||
'borders' => [
|
||||
'bottom' => [
|
||||
'style' => \PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||
'color' => array(
|
||||
'color' => [
|
||||
\PhpSpreadsheet\Style\Color::COLOR_BLACK,
|
||||
),
|
||||
),
|
||||
),
|
||||
), // Bottom border
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
], // Bottom border
|
||||
];
|
||||
|
||||
protected $rowspan = array();
|
||||
protected $rowspan = [];
|
||||
|
||||
/**
|
||||
* Create a new HTML Reader instance
|
||||
|
@ -117,7 +116,7 @@ class HTML extends BaseReader implements IReader
|
|||
/**
|
||||
* Validate that the current file is an HTML file
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidFormat()
|
||||
{
|
||||
|
@ -135,8 +134,8 @@ class HTML extends BaseReader implements IReader
|
|||
* Loads PhpSpreadsheet from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PhpSpreadsheet
|
||||
* @throws Exception
|
||||
* @return PhpSpreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
|
@ -170,9 +169,9 @@ class HTML extends BaseReader implements IReader
|
|||
}
|
||||
|
||||
// Data Array used for testing only, should write to PhpSpreadsheet object on completion of tests
|
||||
protected $dataArray = array();
|
||||
protected $dataArray = [];
|
||||
protected $tableLevel = 0;
|
||||
protected $nestedColumn = array('A');
|
||||
protected $nestedColumn = ['A'];
|
||||
|
||||
protected function setTableStartColumn($column)
|
||||
{
|
||||
|
@ -232,7 +231,7 @@ class HTML extends BaseReader implements IReader
|
|||
} elseif ($child instanceof DOMElement) {
|
||||
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
|
||||
|
||||
$attributeArray = array();
|
||||
$attributeArray = [];
|
||||
foreach ($child->attributes as $attribute) {
|
||||
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
|
||||
$attributeArray[$attribute->name] = $attribute->value;
|
||||
|
@ -329,7 +328,7 @@ class HTML extends BaseReader implements IReader
|
|||
} else {
|
||||
if ($cellContent > '') {
|
||||
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||
$row++;
|
||||
++$row;
|
||||
}
|
||||
// echo 'START OF PARAGRAPH: ' , '<br />';
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
|
@ -340,7 +339,7 @@ class HTML extends BaseReader implements IReader
|
|||
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
|
||||
}
|
||||
|
||||
$row++;
|
||||
++$row;
|
||||
$column = 'A';
|
||||
}
|
||||
break;
|
||||
|
@ -414,7 +413,7 @@ class HTML extends BaseReader implements IReader
|
|||
if (isset($attributeArray['rowspan']) && isset($attributeArray['colspan'])) {
|
||||
//create merging rowspan and colspan
|
||||
$columnTo = $column;
|
||||
for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) {
|
||||
for ($i = 0; $i < $attributeArray['colspan'] - 1; ++$i) {
|
||||
++$columnTo;
|
||||
}
|
||||
$range = $column . $row . ':' . $columnTo . ($row + $attributeArray['rowspan'] - 1);
|
||||
|
@ -433,7 +432,7 @@ class HTML extends BaseReader implements IReader
|
|||
} elseif (isset($attributeArray['colspan'])) {
|
||||
//create merging colspan
|
||||
$columnTo = $column;
|
||||
for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) {
|
||||
for ($i = 0; $i < $attributeArray['colspan'] - 1; ++$i) {
|
||||
++$columnTo;
|
||||
}
|
||||
$sheet->mergeCells($column . $row . ':' . $columnTo . $row);
|
||||
|
@ -460,8 +459,8 @@ class HTML extends BaseReader implements IReader
|
|||
*
|
||||
* @param string $pFilename
|
||||
* @param \PhpSpreadsheet\Spreadsheet $spreadsheet
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
* @throws Exception
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, \PhpSpreadsheet\Spreadsheet $spreadsheet)
|
||||
{
|
||||
|
@ -469,7 +468,7 @@ class HTML extends BaseReader implements IReader
|
|||
$this->openFile($pFilename);
|
||||
if (!$this->isValidFormat()) {
|
||||
fclose($this->fileHandle);
|
||||
throw new Exception($pFilename . " is an Invalid HTML file.");
|
||||
throw new Exception($pFilename . ' is an Invalid HTML file.');
|
||||
}
|
||||
// Close after validating
|
||||
fclose($this->fileHandle);
|
||||
|
@ -481,7 +480,7 @@ class HTML extends BaseReader implements IReader
|
|||
$spreadsheet->setActiveSheetIndex($this->sheetIndex);
|
||||
|
||||
// Create a new DOM object
|
||||
$dom = new domDocument;
|
||||
$dom = new domDocument();
|
||||
// Reload the HTML file into the DOM object
|
||||
$loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanFile($pFilename), 'HTML-ENTITIES', 'UTF-8'));
|
||||
if ($loaded === false) {
|
||||
|
@ -535,6 +534,7 @@ class HTML extends BaseReader implements IReader
|
|||
if (preg_match($pattern, $xml)) {
|
||||
throw new Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ interface IReadFilter
|
|||
* @param $column Column address (as a string value like "A", or "IV")
|
||||
* @param $row Row number
|
||||
* @param $worksheetName Optional worksheet name
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '');
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ interface IReader
|
|||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename);
|
||||
|
||||
|
@ -38,8 +38,8 @@ interface IReader
|
|||
* Loads PhpSpreadsheet from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PhpSpreadsheet
|
||||
* @throws Exception
|
||||
* @return PhpSpreadsheet
|
||||
*/
|
||||
public function load($pFilename);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class OOCalc extends BaseReader implements IReader
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $styles = array();
|
||||
private $styles = [];
|
||||
|
||||
/**
|
||||
* Create a new OOCalc Reader instance
|
||||
|
@ -45,14 +45,14 @@ class OOCalc extends BaseReader implements IReader
|
|||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
$zipClass = \PhpSpreadsheet\Settings::getZipClass();
|
||||
|
@ -64,7 +64,7 @@ class OOCalc extends BaseReader implements IReader
|
|||
|
||||
$mimeType = 'UNKNOWN';
|
||||
// Load file
|
||||
$zip = new $zipClass;
|
||||
$zip = new $zipClass();
|
||||
if ($zip->open($pFilename) === true) {
|
||||
// check if it is an OOXML archive
|
||||
$stat = $zip->statName('mimetype');
|
||||
|
@ -91,13 +91,12 @@ class OOCalc extends BaseReader implements IReader
|
|||
|
||||
$zip->close();
|
||||
|
||||
return ($mimeType === 'application/vnd.oasis.opendocument.spreadsheet');
|
||||
return $mimeType === 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads names of the worksheets from a file, without parsing the whole file to a PhpSpreadsheet object
|
||||
*
|
||||
|
@ -108,17 +107,17 @@ class OOCalc extends BaseReader implements IReader
|
|||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
$zipClass = \PhpSpreadsheet\Settings::getZipClass();
|
||||
|
||||
$zip = new $zipClass;
|
||||
$zip = new $zipClass();
|
||||
if (!$zip->open($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! Error opening file.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.');
|
||||
}
|
||||
|
||||
$worksheetNames = array();
|
||||
$worksheetNames = [];
|
||||
|
||||
$xml = new XMLReader();
|
||||
$res = $xml->xml(
|
||||
|
@ -164,16 +163,16 @@ class OOCalc extends BaseReader implements IReader
|
|||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
$worksheetInfo = array();
|
||||
$worksheetInfo = [];
|
||||
|
||||
$zipClass = \PhpSpreadsheet\Settings::getZipClass();
|
||||
|
||||
$zip = new $zipClass;
|
||||
$zip = new $zipClass();
|
||||
if (!$zip->open($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! Error opening file.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.');
|
||||
}
|
||||
|
||||
$xml = new XMLReader();
|
||||
|
@ -200,13 +199,13 @@ class OOCalc extends BaseReader implements IReader
|
|||
if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
|
||||
$worksheetNames[] = $xml->getAttribute('table:name');
|
||||
|
||||
$tmpInfo = array(
|
||||
$tmpInfo = [
|
||||
'worksheetName' => $xml->getAttribute('table:name'),
|
||||
'lastColumnLetter' => 'A',
|
||||
'lastColumnIndex' => 0,
|
||||
'totalRows' => 0,
|
||||
'totalColumns' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
// Loop through each child node of the table:table element reading
|
||||
$currCells = 0;
|
||||
|
@ -223,7 +222,7 @@ class OOCalc extends BaseReader implements IReader
|
|||
do {
|
||||
if ($xml->name == 'table:table-cell' && $xml->nodeType == XMLReader::ELEMENT) {
|
||||
if (!$xml->isEmptyElement) {
|
||||
$currCells++;
|
||||
++$currCells;
|
||||
$xml->next();
|
||||
} else {
|
||||
$xml->read();
|
||||
|
@ -287,8 +286,8 @@ class OOCalc extends BaseReader implements IReader
|
|||
* Loads PhpSpreadsheet from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
* @throws Exception
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
|
@ -305,9 +304,11 @@ class OOCalc extends BaseReader implements IReader
|
|||
foreach ($styleList as $style) {
|
||||
if ($styleAttributeValue == strtolower($style)) {
|
||||
$styleAttributeValue = $style;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -316,14 +317,14 @@ class OOCalc extends BaseReader implements IReader
|
|||
*
|
||||
* @param string $pFilename
|
||||
* @param \PhpSpreadsheet\Spreadsheet $spreadsheet
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
* @throws Exception
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, \PhpSpreadsheet\Spreadsheet $spreadsheet)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
|
||||
}
|
||||
|
||||
$timezoneObj = new DateTimeZone('Europe/London');
|
||||
|
@ -331,14 +332,14 @@ class OOCalc extends BaseReader implements IReader
|
|||
|
||||
$zipClass = \PhpSpreadsheet\Settings::getZipClass();
|
||||
|
||||
$zip = new $zipClass;
|
||||
$zip = new $zipClass();
|
||||
if (!$zip->open($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! Error opening file.");
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.');
|
||||
}
|
||||
|
||||
// echo '<h1>Meta Information</h1>';
|
||||
$xml = simplexml_load_string(
|
||||
$this->securityScan($zip->getFromName("meta.xml")),
|
||||
$this->securityScan($zip->getFromName('meta.xml')),
|
||||
'SimpleXMLElement',
|
||||
\PhpSpreadsheet\Settings::getLibXmlLoaderOptions()
|
||||
);
|
||||
|
@ -350,7 +351,7 @@ class OOCalc extends BaseReader implements IReader
|
|||
$docProps = $spreadsheet->getProperties();
|
||||
$officeProperty = $xml->children($namespacesMeta['office']);
|
||||
foreach ($officeProperty as $officePropertyData) {
|
||||
$officePropertyDC = array();
|
||||
$officePropertyDC = [];
|
||||
if (isset($namespacesMeta['dc'])) {
|
||||
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
|
||||
}
|
||||
|
@ -377,7 +378,7 @@ class OOCalc extends BaseReader implements IReader
|
|||
break;
|
||||
}
|
||||
}
|
||||
$officePropertyMeta = array();
|
||||
$officePropertyMeta = [];
|
||||
if (isset($namespacesMeta['dc'])) {
|
||||
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
|
||||
}
|
||||
|
@ -425,10 +426,9 @@ class OOCalc extends BaseReader implements IReader
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// echo '<h1>Workbook Content</h1>';
|
||||
$xml = simplexml_load_string(
|
||||
$this->securityScan($zip->getFromName("content.xml")),
|
||||
$this->securityScan($zip->getFromName('content.xml')),
|
||||
'SimpleXMLElement',
|
||||
\PhpSpreadsheet\Settings::getLibXmlLoaderOptions()
|
||||
);
|
||||
|
@ -511,7 +511,7 @@ class OOCalc extends BaseReader implements IReader
|
|||
if (isset($cellDataOffice->annotation)) {
|
||||
// echo 'Cell has comment<br />';
|
||||
$annotationText = $cellDataOffice->annotation->children($namespacesContent['text']);
|
||||
$textArray = array();
|
||||
$textArray = [];
|
||||
foreach ($annotationText as $t) {
|
||||
if (isset($t->span)) {
|
||||
foreach ($t->span as $text) {
|
||||
|
@ -529,7 +529,7 @@ class OOCalc extends BaseReader implements IReader
|
|||
|
||||
if (isset($cellDataText->p)) {
|
||||
// Consolidate if there are multiple p records (maybe with spans as well)
|
||||
$dataArray = array();
|
||||
$dataArray = [];
|
||||
// Text can have multiple text:p and within those, multiple text:span.
|
||||
// text:p newlines, but text:span does not.
|
||||
// Also, here we assume there is no text data is span fields are specified, since
|
||||
|
@ -537,7 +537,7 @@ class OOCalc extends BaseReader implements IReader
|
|||
foreach ($cellDataText->p as $pData) {
|
||||
if (isset($pData->span)) {
|
||||
// span sections do not newline, so we just create one large string here
|
||||
$spanSection = "";
|
||||
$spanSection = '';
|
||||
foreach ($pData->span as $spanData) {
|
||||
$spanSection .= $spanData;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class SYLK extends BaseReader implements IReader
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $formats = array();
|
||||
private $formats = [];
|
||||
|
||||
/**
|
||||
* Format Count
|
||||
|
@ -65,7 +65,7 @@ class SYLK extends BaseReader implements IReader
|
|||
/**
|
||||
* Validate that the current file is a SYLK file
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidFormat()
|
||||
{
|
||||
|
@ -95,6 +95,7 @@ class SYLK extends BaseReader implements IReader
|
|||
public function setInputEncoding($pValue = 'ANSI')
|
||||
{
|
||||
$this->inputEncoding = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -120,12 +121,12 @@ class SYLK extends BaseReader implements IReader
|
|||
$this->openFile($pFilename);
|
||||
if (!$this->isValidFormat()) {
|
||||
fclose($this->fileHandle);
|
||||
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
$fileHandle = $this->fileHandle;
|
||||
rewind($fileHandle);
|
||||
|
||||
$worksheetInfo = array();
|
||||
$worksheetInfo = [];
|
||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||
|
@ -133,7 +134,7 @@ class SYLK extends BaseReader implements IReader
|
|||
$worksheetInfo[0]['totalColumns'] = 0;
|
||||
|
||||
// Loop through file
|
||||
$rowData = array();
|
||||
$rowData = [];
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
$rowIndex = 0;
|
||||
|
@ -181,8 +182,8 @@ class SYLK extends BaseReader implements IReader
|
|||
* Loads PhpSpreadsheet from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
* @throws Exception
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
|
@ -198,8 +199,8 @@ class SYLK extends BaseReader implements IReader
|
|||
*
|
||||
* @param string $pFilename
|
||||
* @param \PhpSpreadsheet\Spreadsheet $spreadsheet
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
* @throws Exception
|
||||
* @return \PhpSpreadsheet\Spreadsheet
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, \PhpSpreadsheet\Spreadsheet $spreadsheet)
|
||||
{
|
||||
|
@ -207,7 +208,7 @@ class SYLK extends BaseReader implements IReader
|
|||
$this->openFile($pFilename);
|
||||
if (!$this->isValidFormat()) {
|
||||
fclose($this->fileHandle);
|
||||
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
$fileHandle = $this->fileHandle;
|
||||
rewind($fileHandle);
|
||||
|
@ -218,11 +219,11 @@ class SYLK extends BaseReader implements IReader
|
|||
}
|
||||
$spreadsheet->setActiveSheetIndex($this->sheetIndex);
|
||||
|
||||
$fromFormats = array('\-', '\ ');
|
||||
$toFormats = array('-', ' ');
|
||||
$fromFormats = ['\-', '\ '];
|
||||
$toFormats = ['-', ' '];
|
||||
|
||||
// Loop through file
|
||||
$rowData = array();
|
||||
$rowData = [];
|
||||
$column = $row = '';
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
|
@ -237,7 +238,7 @@ class SYLK extends BaseReader implements IReader
|
|||
$dataType = array_shift($rowData);
|
||||
// Read shared styles
|
||||
if ($dataType == 'P') {
|
||||
$formatArray = array();
|
||||
$formatArray = [];
|
||||
foreach ($rowData as $rowDatum) {
|
||||
switch ($rowDatum{0}) {
|
||||
case 'P':
|
||||
|
@ -354,7 +355,7 @@ class SYLK extends BaseReader implements IReader
|
|||
// Read cell formatting
|
||||
} elseif ($dataType == 'F') {
|
||||
$formatStyle = $columnWidth = $styleSettings = '';
|
||||
$styleData = array();
|
||||
$styleData = [];
|
||||
foreach ($rowData as $rowDatum) {
|
||||
switch ($rowDatum{0}) {
|
||||
case 'C':
|
||||
|
@ -463,6 +464,7 @@ class SYLK extends BaseReader implements IReader
|
|||
public function setSheetIndex($pValue = 0)
|
||||
{
|
||||
$this->sheetIndex = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ class ReferenceHelper
|
|||
public static function getInstance()
|
||||
{
|
||||
if (!isset(self::$instance) || (self::$instance === null)) {
|
||||
self::$instance = new ReferenceHelper();
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
|
@ -67,7 +67,7 @@ class ReferenceHelper
|
|||
*
|
||||
* @param string $a First column to test (e.g. 'AA')
|
||||
* @param string $b Second column to test (e.g. 'Z')
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public static function columnSort($a, $b)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ class ReferenceHelper
|
|||
*
|
||||
* @param string $a First column to test (e.g. 'AA')
|
||||
* @param string $b Second column to test (e.g. 'Z')
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public static function columnReverseSort($a, $b)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ class ReferenceHelper
|
|||
*
|
||||
* @param string $a First cell to test (e.g. 'AA1')
|
||||
* @param string $b Second cell to test (e.g. 'Z1')
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public static function cellSort($a, $b)
|
||||
{
|
||||
|
@ -103,6 +103,7 @@ class ReferenceHelper
|
|||
if ($ar == $br) {
|
||||
return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
|
||||
}
|
||||
|
||||
return ($ar < $br) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
@ -112,7 +113,7 @@ class ReferenceHelper
|
|||
*
|
||||
* @param string $a First cell to test (e.g. 'AA1')
|
||||
* @param string $b Second cell to test (e.g. 'Z1')
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public static function cellReverseSort($a, $b)
|
||||
{
|
||||
|
@ -122,6 +123,7 @@ class ReferenceHelper
|
|||
if ($ar == $br) {
|
||||
return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
|
||||
}
|
||||
|
||||
return ($ar < $br) ? 1 : -1;
|
||||
}
|
||||
|
||||
|
@ -129,11 +131,11 @@ class ReferenceHelper
|
|||
* Test whether a cell address falls within a defined range of cells
|
||||
*
|
||||
* @param string $cellAddress Address of the cell we're testing
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @return boolean
|
||||
* @param int $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @return bool
|
||||
*/
|
||||
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)
|
||||
{
|
||||
|
@ -149,6 +151,7 @@ class ReferenceHelper
|
|||
($cellColumnIndex < $beforeColumnIndex)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -157,17 +160,17 @@ class ReferenceHelper
|
|||
*
|
||||
* @param Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function adjustPageBreaks(Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aBreaks = $pSheet->getBreaks();
|
||||
($pNumCols > 0 || $pNumRows > 0) ?
|
||||
uksort($aBreaks, array('self','cellReverseSort')) :
|
||||
uksort($aBreaks, array('self','cellSort'));
|
||||
uksort($aBreaks, ['self', 'cellReverseSort']) :
|
||||
uksort($aBreaks, ['self', 'cellSort']);
|
||||
|
||||
foreach ($aBreaks as $key => $value) {
|
||||
if (self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {
|
||||
|
@ -191,15 +194,15 @@ class ReferenceHelper
|
|||
*
|
||||
* @param Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aComments = $pSheet->getComments();
|
||||
$aNewComments = array(); // the new array of all comments
|
||||
$aNewComments = []; // the new array of all comments
|
||||
|
||||
foreach ($aComments as $key => &$value) {
|
||||
// Any comments inside a deleted range will be ignored
|
||||
|
@ -218,17 +221,17 @@ class ReferenceHelper
|
|||
*
|
||||
* @param Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aHyperlinkCollection = $pSheet->getHyperlinkCollection();
|
||||
($pNumCols > 0 || $pNumRows > 0) ?
|
||||
uksort($aHyperlinkCollection, array('self','cellReverseSort')) :
|
||||
uksort($aHyperlinkCollection, array('self','cellSort'));
|
||||
uksort($aHyperlinkCollection, ['self', 'cellReverseSort']) :
|
||||
uksort($aHyperlinkCollection, ['self', 'cellSort']);
|
||||
|
||||
foreach ($aHyperlinkCollection as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
|
@ -244,17 +247,17 @@ class ReferenceHelper
|
|||
*
|
||||
* @param Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aDataValidationCollection = $pSheet->getDataValidationCollection();
|
||||
($pNumCols > 0 || $pNumRows > 0) ?
|
||||
uksort($aDataValidationCollection, array('self','cellReverseSort')) :
|
||||
uksort($aDataValidationCollection, array('self','cellSort'));
|
||||
uksort($aDataValidationCollection, ['self', 'cellReverseSort']) :
|
||||
uksort($aDataValidationCollection, ['self', 'cellSort']);
|
||||
|
||||
foreach ($aDataValidationCollection as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
|
@ -270,15 +273,15 @@ class ReferenceHelper
|
|||
*
|
||||
* @param Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aMergeCells = $pSheet->getMergeCells();
|
||||
$aNewMergeCells = array(); // the new array of all merge cells
|
||||
$aNewMergeCells = []; // the new array of all merge cells
|
||||
foreach ($aMergeCells as $key => &$value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
$aNewMergeCells[$newReference] = $newReference;
|
||||
|
@ -291,17 +294,17 @@ class ReferenceHelper
|
|||
*
|
||||
* @param Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aProtectedCells = $pSheet->getProtectedCells();
|
||||
($pNumCols > 0 || $pNumRows > 0) ?
|
||||
uksort($aProtectedCells, array('self','cellReverseSort')) :
|
||||
uksort($aProtectedCells, array('self','cellSort'));
|
||||
uksort($aProtectedCells, ['self', 'cellReverseSort']) :
|
||||
uksort($aProtectedCells, ['self', 'cellSort']);
|
||||
foreach ($aProtectedCells as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
|
@ -316,10 +319,10 @@ class ReferenceHelper
|
|||
*
|
||||
* @param Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
|
@ -341,10 +344,10 @@ class ReferenceHelper
|
|||
*
|
||||
* @param Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param int $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
|
@ -374,8 +377,8 @@ class ReferenceHelper
|
|||
* Insert a new column or row, updating all possible related data
|
||||
*
|
||||
* @param string $pBefore Insert before this cell address (e.g. 'A1')
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param Worksheet $pSheet The worksheet that we're editing
|
||||
* @throws Exception
|
||||
*/
|
||||
|
@ -480,7 +483,7 @@ class ReferenceHelper
|
|||
for ($j = $beforeColumnIndex - 1; $j <= $beforeColumnIndex - 2 + $pNumCols; ++$j) {
|
||||
$pSheet->getCellByColumnAndRow($j, $i)->setXfIndex($xfIndex);
|
||||
if ($conditionalStyles) {
|
||||
$cloned = array();
|
||||
$cloned = [];
|
||||
foreach ($conditionalStyles as $conditionalStyle) {
|
||||
$cloned[] = clone $conditionalStyle;
|
||||
}
|
||||
|
@ -502,7 +505,7 @@ class ReferenceHelper
|
|||
for ($j = $beforeRow; $j <= $beforeRow - 1 + $pNumRows; ++$j) {
|
||||
$pSheet->getCell(Cell::stringFromColumnIndex($i) . $j)->setXfIndex($xfIndex);
|
||||
if ($conditionalStyles) {
|
||||
$cloned = array();
|
||||
$cloned = [];
|
||||
foreach ($conditionalStyles as $conditionalStyle) {
|
||||
$cloned[] = clone $conditionalStyle;
|
||||
}
|
||||
|
@ -635,8 +638,8 @@ class ReferenceHelper
|
|||
* @param int $pNumCols Number of columns to insert
|
||||
* @param int $pNumRows Number of rows to insert
|
||||
* @param string $sheetName Worksheet name/title
|
||||
* @return string Updated formula
|
||||
* @throws Exception
|
||||
* @return string Updated formula
|
||||
*/
|
||||
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '')
|
||||
{
|
||||
|
@ -647,7 +650,7 @@ class ReferenceHelper
|
|||
// Ignore blocks that were enclosed in quotes (alternating entries in the $formulaBlocks array after the explode)
|
||||
if ($i = !$i) {
|
||||
$adjustCount = 0;
|
||||
$newCellTokens = $cellTokens = array();
|
||||
$newCellTokens = $cellTokens = [];
|
||||
// Search for row ranges (e.g. 'Sheet1'!3:5 or 3:5) with or without $ absolutes (e.g. $3:5)
|
||||
$matchCount = preg_match_all('/' . self::REFHELPER_REGEXP_ROWRANGE . '/i', ' ' . $formulaBlock . ' ', $matches, PREG_SET_ORDER);
|
||||
if ($matchCount > 0) {
|
||||
|
@ -775,13 +778,13 @@ class ReferenceHelper
|
|||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to increment
|
||||
* @param int $pNumRows Number of rows to increment
|
||||
* @return string Updated cell range
|
||||
* @throws Exception
|
||||
* @return string Updated cell range
|
||||
*/
|
||||
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
|
||||
{
|
||||
// Is it in another worksheet? Will not have to update anything.
|
||||
if (strpos($pCellRange, "!") !== false) {
|
||||
if (strpos($pCellRange, '!') !== false) {
|
||||
return $pCellRange;
|
||||
// Is it a range or a single cell?
|
||||
} elseif (strpos($pCellRange, ':') === false && strpos($pCellRange, ',') === false) {
|
||||
|
@ -816,7 +819,7 @@ class ReferenceHelper
|
|||
$formula = $cell->getValue();
|
||||
if (strpos($formula, $oldName) !== false) {
|
||||
$formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
|
||||
$formula = str_replace($oldName . "!", $newName . "!", $formula);
|
||||
$formula = str_replace($oldName . '!', $newName . '!', $formula);
|
||||
$cell->setValueExplicit($formula, Cell\DataType::TYPE_FORMULA);
|
||||
}
|
||||
}
|
||||
|
@ -831,8 +834,8 @@ class ReferenceHelper
|
|||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to increment
|
||||
* @param int $pNumRows Number of rows to increment
|
||||
* @return string Updated cell range
|
||||
* @throws Exception
|
||||
* @return string Updated cell range
|
||||
*/
|
||||
private function updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
|
||||
{
|
||||
|
@ -858,7 +861,7 @@ class ReferenceHelper
|
|||
// Recreate range string
|
||||
return Cell::buildRange($range);
|
||||
} else {
|
||||
throw new Exception("Only cell ranges may be passed to this method.");
|
||||
throw new Exception('Only cell ranges may be passed to this method.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -869,8 +872,8 @@ class ReferenceHelper
|
|||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to increment
|
||||
* @param int $pNumRows Number of rows to increment
|
||||
* @return string Updated cell reference
|
||||
* @throws Exception
|
||||
* @return string Updated cell reference
|
||||
*/
|
||||
private function updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
|
||||
{
|
||||
|
@ -898,7 +901,7 @@ class ReferenceHelper
|
|||
// Return new reference
|
||||
return $newColumn . $newRow;
|
||||
} else {
|
||||
throw new Exception("Only single cell references may be passed to this method.");
|
||||
throw new Exception('Only single cell references may be passed to this method.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -909,6 +912,6 @@ class ReferenceHelper
|
|||
*/
|
||||
final public function __clone()
|
||||
{
|
||||
throw new Exception("Cloning a Singleton is not allowed!");
|
||||
throw new Exception('Cloning a Singleton is not allowed!');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@ class RichText implements IComparable
|
|||
public function __construct(Cell $pCell = null)
|
||||
{
|
||||
// Initialise variables
|
||||
$this->richTextElements = array();
|
||||
$this->richTextElements = [];
|
||||
|
||||
// Rich-Text string attached to cell?
|
||||
if ($pCell !== null) {
|
||||
// Add cell text and style
|
||||
if ($pCell->getValue() != "") {
|
||||
if ($pCell->getValue() != '') {
|
||||
$objRun = new RichText\Run($pCell->getValue());
|
||||
$objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
|
||||
$this->addText($objRun);
|
||||
|
@ -68,6 +68,7 @@ class RichText implements IComparable
|
|||
public function addText(RichText\ITextElement $pText = null)
|
||||
{
|
||||
$this->richTextElements[] = $pText;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -75,13 +76,14 @@ class RichText implements IComparable
|
|||
* Create text
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return RichText\TextElement
|
||||
* @throws Exception
|
||||
* @return RichText\TextElement
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
$objText = new RichText\TextElement($pText);
|
||||
$this->addText($objText);
|
||||
|
||||
return $objText;
|
||||
}
|
||||
|
||||
|
@ -89,13 +91,14 @@ class RichText implements IComparable
|
|||
* Create text run
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return RichText\Run
|
||||
* @throws Exception
|
||||
* @return RichText\Run
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
{
|
||||
$objText = new RichText\Run($pText);
|
||||
$this->addText($objText);
|
||||
|
||||
return $objText;
|
||||
}
|
||||
|
||||
|
@ -151,6 +154,7 @@ class RichText implements IComparable
|
|||
} else {
|
||||
throw new Exception("Invalid \PhpSpreadsheet\RichText\ITextElement[] array passed.");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ class Run extends TextElement implements ITextElement
|
|||
public function setFont(\PhpSpreadsheet\Style\Font $pFont = null)
|
||||
{
|
||||
$this->font = $pFont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ class TextElement implements ITextElement
|
|||
public function setText($pText = '')
|
||||
{
|
||||
$this->text = $pText;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,17 +39,15 @@ class Settings
|
|||
const PDF_RENDERER_DOMPDF = 'DomPDF';
|
||||
const PDF_RENDERER_MPDF = 'MPDF';
|
||||
|
||||
|
||||
private static $chartRenderers = array(
|
||||
private static $chartRenderers = [
|
||||
self::CHART_RENDERER_JPGRAPH,
|
||||
);
|
||||
];
|
||||
|
||||
private static $pdfRenderers = array(
|
||||
private static $pdfRenderers = [
|
||||
self::PDF_RENDERER_TCPDF,
|
||||
self::PDF_RENDERER_DOMPDF,
|
||||
self::PDF_RENDERER_MPDF,
|
||||
);
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Name of the class used for Zip file management
|
||||
|
@ -60,7 +58,6 @@ class Settings
|
|||
*/
|
||||
private static $zipClass = self::ZIPARCHIVE;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the external Library used for rendering charts
|
||||
* e.g.
|
||||
|
@ -77,7 +74,6 @@ class Settings
|
|||
*/
|
||||
private static $chartRendererPath;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the external Library used for rendering PDF files
|
||||
* e.g.
|
||||
|
@ -106,19 +102,20 @@ class Settings
|
|||
*
|
||||
* @param string $zipClass The Zip handler class that PhpSpreadsheet should use for Zip file management
|
||||
* e.g. \PhpSpreadsheet\Settings::PCLZip or \PhpSpreadsheet\Settings::ZipArchive
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setZipClass($zipClass)
|
||||
{
|
||||
if (($zipClass === self::PCLZIP) ||
|
||||
($zipClass === self::ZIPARCHIVE)) {
|
||||
self::$zipClass = $zipClass;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the Zip handler Class that PhpSpreadsheet is configured to use (PCLZip or ZipArchive)
|
||||
* or Zip file management
|
||||
|
@ -132,7 +129,6 @@ class Settings
|
|||
return self::$zipClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the method that is currently configured for cell cacheing
|
||||
*
|
||||
|
@ -143,7 +139,6 @@ class Settings
|
|||
return CachedObjectStorageFactory::getCacheStorageMethod();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the class that is currently being used for cell cacheing
|
||||
*
|
||||
|
@ -154,32 +149,29 @@ class Settings
|
|||
return CachedObjectStorageFactory::getCacheStorageClass();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the method that should be used for cell cacheing
|
||||
*
|
||||
* @param string $method Name of the cacheing method
|
||||
* @param array $arguments Optional configuration arguments for the cacheing method
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setCacheStorageMethod($method = CachedObjectStorageFactory::cache_in_memory, $arguments = array())
|
||||
public static function setCacheStorageMethod($method = CachedObjectStorageFactory::cache_in_memory, $arguments = [])
|
||||
{
|
||||
return CachedObjectStorageFactory::initialize($method, $arguments);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the locale code to use for formula translations and any special formatting
|
||||
*
|
||||
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setLocale($locale = 'en_us')
|
||||
{
|
||||
return Calculation::getInstance()->setLocale($locale);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set details of the external library that PhpSpreadsheet should use for rendering charts
|
||||
*
|
||||
|
@ -187,24 +179,24 @@ class Settings
|
|||
* e.g. \PhpSpreadsheet\Settings::CHART_RENDERER_JPGRAPH
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setChartRenderer($libraryName, $libraryBaseDir)
|
||||
{
|
||||
if (!self::setChartRendererName($libraryName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::setChartRendererPath($libraryBaseDir);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Identify to PhpSpreadsheet the external library to use for rendering charts
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. \PhpSpreadsheet\Settings::CHART_RENDERER_JPGRAPH
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setChartRendererName($libraryName)
|
||||
{
|
||||
|
@ -216,12 +208,11 @@ class Settings
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tell PhpSpreadsheet where to find the external library to use for rendering charts
|
||||
*
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setChartRendererPath($libraryBaseDir)
|
||||
{
|
||||
|
@ -233,11 +224,10 @@ class Settings
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the Chart Rendering Library that PhpSpreadsheet is currently configured to use (e.g. jpgraph)
|
||||
*
|
||||
* @return string|NULL Internal reference name of the Chart Rendering Library that PhpSpreadsheet is
|
||||
* @return string|null Internal reference name of the Chart Rendering Library that PhpSpreadsheet is
|
||||
* currently configured to use
|
||||
* e.g. \PhpSpreadsheet\Settings::CHART_RENDERER_JPGRAPH
|
||||
*/
|
||||
|
@ -246,11 +236,10 @@ class Settings
|
|||
return self::$chartRendererName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the directory path to the Chart Rendering Library that PhpSpreadsheet is currently configured to use
|
||||
*
|
||||
* @return string|NULL Directory Path to the Chart Rendering Library that PhpSpreadsheet is
|
||||
* @return string|null Directory Path to the Chart Rendering Library that PhpSpreadsheet is
|
||||
* currently configured to use
|
||||
*/
|
||||
public static function getChartRendererPath()
|
||||
|
@ -258,7 +247,6 @@ class Settings
|
|||
return self::$chartRendererPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set details of the external library that PhpSpreadsheet should use for rendering PDF files
|
||||
*
|
||||
|
@ -268,17 +256,17 @@ class Settings
|
|||
* or \PhpSpreadsheet\Settings::PDF_RENDERER_MPDF
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setPdfRenderer($libraryName, $libraryBaseDir)
|
||||
{
|
||||
if (!self::setPdfRendererName($libraryName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::setPdfRendererPath($libraryBaseDir);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Identify to PhpSpreadsheet the external library to use for rendering PDF files
|
||||
*
|
||||
|
@ -287,7 +275,7 @@ class Settings
|
|||
* \PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF
|
||||
* or \PhpSpreadsheet\Settings::PDF_RENDERER_MPDF
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setPdfRendererName($libraryName)
|
||||
{
|
||||
|
@ -299,12 +287,11 @@ class Settings
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tell PhpSpreadsheet where to find the external library to use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setPdfRendererPath($libraryBaseDir)
|
||||
{
|
||||
|
@ -316,11 +303,10 @@ class Settings
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the PDF Rendering Library that PhpSpreadsheet is currently configured to use (e.g. dompdf)
|
||||
*
|
||||
* @return string|NULL Internal reference name of the PDF Rendering Library that PhpSpreadsheet is
|
||||
* @return string|null Internal reference name of the PDF Rendering Library that PhpSpreadsheet is
|
||||
* currently configured to use
|
||||
* e.g. \PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF,
|
||||
* \PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF
|
||||
|
@ -334,7 +320,7 @@ class Settings
|
|||
/**
|
||||
* Return the directory path to the PDF Rendering Library that PhpSpreadsheet is currently configured to use
|
||||
*
|
||||
* @return string|NULL Directory Path to the PDF Rendering Library that PhpSpreadsheet is
|
||||
* @return string|null Directory Path to the PDF Rendering Library that PhpSpreadsheet is
|
||||
* currently configured to use
|
||||
*/
|
||||
public static function getPdfRendererPath()
|
||||
|
|
|
@ -32,9 +32,9 @@ class CodePage
|
|||
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
|
||||
* and mbstring understands
|
||||
*
|
||||
* @param integer $codePage Microsoft Code Page Indentifier
|
||||
* @return string Code Page Name
|
||||
* @param int $codePage Microsoft Code Page Indentifier
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return string Code Page Name
|
||||
*/
|
||||
public static function numberToName($codePage = 1252)
|
||||
{
|
||||
|
|
|
@ -85,23 +85,25 @@ class Date
|
|||
/**
|
||||
* Set the Excel calendar (Windows 1900 or Mac 1904)
|
||||
*
|
||||
* @param integer $baseDate Excel base date (1900 or 1904)
|
||||
* @return boolean Success or failure
|
||||
* @param int $baseDate Excel base date (1900 or 1904)
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setExcelCalendar($baseDate)
|
||||
{
|
||||
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
|
||||
($baseDate == self::CALENDAR_MAC_1904)) {
|
||||
self::$excelCalendar = $baseDate;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Excel calendar (Windows 1900 or Mac 1904)
|
||||
*
|
||||
* @return integer Excel base date (1900 or 1904)
|
||||
* @return int Excel base date (1900 or 1904)
|
||||
*/
|
||||
public static function getExcelCalendar()
|
||||
{
|
||||
|
@ -112,15 +114,17 @@ class Date
|
|||
* Set the Default timezone to use for dates
|
||||
*
|
||||
* @param string|\DateTimeZone $timezone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions
|
||||
* @return boolean Success or failure
|
||||
* @throws \Exception
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setDefaultTimezone($timeZone)
|
||||
{
|
||||
if ($timeZone = self::validateTimeZone($timeZone)) {
|
||||
self::$defaultTimeZone = $timeZone;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -134,6 +138,7 @@ class Date
|
|||
if (self::$defaultTimeZone === null) {
|
||||
self::$defaultTimeZone = new \DateTimeZone('UTC');
|
||||
}
|
||||
|
||||
return self::$defaultTimeZone;
|
||||
}
|
||||
|
||||
|
@ -141,8 +146,8 @@ class Date
|
|||
* Validate a timezone
|
||||
*
|
||||
* @param string|\DateTimeZone $timezone The timezone to validate, either as a timezone string or object
|
||||
* @return \DateTimeZone The timezone as a timezone object
|
||||
* @throws \Exception
|
||||
* @return \DateTimeZone The timezone as a timezone object
|
||||
*/
|
||||
protected static function validateTimeZone($timeZone)
|
||||
{
|
||||
|
@ -157,12 +162,12 @@ class Date
|
|||
/**
|
||||
* Convert a MS serialized datetime value from Excel to a PHP Date/Time object
|
||||
*
|
||||
* @param integer|float $dateValue MS Excel serialized date/time value
|
||||
* @param int|float $dateValue MS Excel serialized date/time value
|
||||
* @param \DateTimeZone|string|null $timezone The timezone to assume for the Excel timestamp,
|
||||
* if you don't want to treat it as a UTC value
|
||||
* Use the default (UST) unless you absolutely need a conversion
|
||||
* @return \DateTime PHP date/time object
|
||||
* @throws \Exception
|
||||
* @return \DateTime PHP date/time object
|
||||
*/
|
||||
public static function excelToDateTimeObject($excelTimestamp = 0, $timeZone = null)
|
||||
{
|
||||
|
@ -188,6 +193,7 @@ class Date
|
|||
$seconds = round($partDay * 60);
|
||||
|
||||
$interval = '+' . $days . ' days';
|
||||
|
||||
return $baseDate->modify($interval)
|
||||
->setTime($hours, $minutes, $seconds);
|
||||
}
|
||||
|
@ -195,12 +201,12 @@ class Date
|
|||
/**
|
||||
* Convert a MS serialized datetime value from Excel to a unix timestamp
|
||||
*
|
||||
* @param integer|float $dateValue MS Excel serialized date/time value
|
||||
* @param int|float $dateValue MS Excel serialized date/time value
|
||||
* @param \DateTimeZone|string|null $timezone The timezone to assume for the Excel timestamp,
|
||||
* if you don't want to treat it as a UTC value
|
||||
* Use the default (UST) unless you absolutely need a conversion
|
||||
* @return integer Unix timetamp for this date/time
|
||||
* @throws \Exception
|
||||
* @return int Unix timetamp for this date/time
|
||||
*/
|
||||
public static function excelToTimestamp($excelTimestamp = 0, $timeZone = null)
|
||||
{
|
||||
|
@ -212,7 +218,7 @@ class Date
|
|||
* Convert a date from PHP to an MS Excel serialized date/time value
|
||||
*
|
||||
* @param mixed $dateValue PHP serialized date/time or date object
|
||||
* @return float|boolean Excel date/time value
|
||||
* @return float|bool Excel date/time value
|
||||
* or boolean FALSE on failure
|
||||
*/
|
||||
public static function PHPToExcel($dateValue = 0)
|
||||
|
@ -257,19 +263,20 @@ class Date
|
|||
if (!is_numeric($dateValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::DateTimeToExcel(new \DateTime('@' . $dateValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* formattedPHPToExcel
|
||||
*
|
||||
* @param integer $year
|
||||
* @param integer $month
|
||||
* @param integer $day
|
||||
* @param integer $hours
|
||||
* @param integer $minutes
|
||||
* @param integer $seconds
|
||||
* @return integer Excel date/time value
|
||||
* @param int $year
|
||||
* @param int $month
|
||||
* @param int $day
|
||||
* @param int $hours
|
||||
* @param int $minutes
|
||||
* @param int $seconds
|
||||
* @return int Excel date/time value
|
||||
*/
|
||||
public static function formattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0)
|
||||
{
|
||||
|
@ -306,12 +313,11 @@ class Date
|
|||
return (float) $excelDate + $excelTime;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is a given cell a date/time?
|
||||
*
|
||||
* @param \PhpSpreadsheet\Cell $pCell
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isDateTime(\PhpSpreadsheet\Cell $pCell)
|
||||
{
|
||||
|
@ -322,26 +328,24 @@ class Date
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is a given number format a date/time?
|
||||
*
|
||||
* @param \PhpSpreadsheet\Style\NumberFormat $pFormat
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isDateTimeFormat(\PhpSpreadsheet\Style\NumberFormat $pFormat)
|
||||
{
|
||||
return self::isDateTimeFormatCode($pFormat->getFormatCode());
|
||||
}
|
||||
|
||||
|
||||
private static $possibleDateFormatCharacters = 'eymdHs';
|
||||
|
||||
/**
|
||||
* Is a given number format code a date/time?
|
||||
*
|
||||
* @param string $pFormatCode
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isDateTimeFormatCode($pFormatCode = '')
|
||||
{
|
||||
|
@ -399,8 +403,10 @@ class Date
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -408,12 +414,11 @@ class Date
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date/time string to Excel time
|
||||
*
|
||||
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
|
||||
* @return float|FALSE Excel date/time serial value
|
||||
* @return float|false Excel date/time serial value
|
||||
*/
|
||||
public static function stringToExcel($dateValue = '')
|
||||
{
|
||||
|
@ -437,6 +442,7 @@ class Date
|
|||
}
|
||||
$dateValueNew += $timeValue;
|
||||
}
|
||||
|
||||
return $dateValueNew;
|
||||
}
|
||||
|
||||
|
@ -444,7 +450,7 @@ class Date
|
|||
* Converts a month name (either a long or a short name) to a month number
|
||||
*
|
||||
* @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
|
||||
* @return int|string Month number (1 - 12), or the original string argument if it isn't a valid month name
|
||||
*/
|
||||
public static function monthStringToNumber($month)
|
||||
{
|
||||
|
@ -455,6 +461,7 @@ class Date
|
|||
}
|
||||
++$monthIndex;
|
||||
}
|
||||
|
||||
return $month;
|
||||
}
|
||||
|
||||
|
@ -462,7 +469,7 @@ class Date
|
|||
* Strips an ordinal froma numeric value
|
||||
*
|
||||
* @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 int|string The integer value with any ordinal stripped, or the original string argument if it isn't a valid numeric
|
||||
*/
|
||||
public static function dayStringToNumber($day)
|
||||
{
|
||||
|
@ -470,6 +477,7 @@ class Date
|
|||
if (is_numeric($strippedDayValue)) {
|
||||
return (integer) $strippedDayValue;
|
||||
}
|
||||
|
||||
return $day;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,19 +169,19 @@ class Drawing
|
|||
public static function imagecreatefrombmp($p_sFile)
|
||||
{
|
||||
// Load the image into a string
|
||||
$file = fopen($p_sFile, "rb");
|
||||
$file = fopen($p_sFile, 'rb');
|
||||
$read = fread($file, 10);
|
||||
while (!feof($file) && ($read<>"")) {
|
||||
while (!feof($file) && ($read != '')) {
|
||||
$read .= fread($file, 1024);
|
||||
}
|
||||
|
||||
$temp = unpack("H*", $read);
|
||||
$temp = unpack('H*', $read);
|
||||
$hex = $temp[1];
|
||||
$header = substr($hex, 0, 108);
|
||||
|
||||
// Process the header
|
||||
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
|
||||
if (substr($header, 0, 4)=="424d") {
|
||||
if (substr($header, 0, 4) == '424d') {
|
||||
// Cut it in parts of 2 bytes
|
||||
$header_parts = str_split($header, 2);
|
||||
|
||||
|
@ -229,7 +229,7 @@ class Drawing
|
|||
$x = 0;
|
||||
|
||||
// Raise the height-position (bottom-up)
|
||||
$y++;
|
||||
++$y;
|
||||
|
||||
// Reached the image-height? Break the for-loop
|
||||
if ($y > $height) {
|
||||
|
@ -249,7 +249,7 @@ class Drawing
|
|||
imagesetpixel($image, $x, $height - $y, $color);
|
||||
|
||||
// Raise the horizontal position
|
||||
$x++;
|
||||
++$x;
|
||||
}
|
||||
|
||||
// Unset the body / free the memory
|
||||
|
|
|
@ -38,7 +38,7 @@ class SpgrContainer
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $children = array();
|
||||
private $children = [];
|
||||
|
||||
/**
|
||||
* Set parent Shape Group Container
|
||||
|
@ -86,10 +86,10 @@ class SpgrContainer
|
|||
*/
|
||||
public function getAllSpContainers()
|
||||
{
|
||||
$allSpContainers = array();
|
||||
$allSpContainers = [];
|
||||
|
||||
foreach ($this->children as $child) {
|
||||
if ($child instanceof SpgrContainer) {
|
||||
if ($child instanceof self) {
|
||||
$allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers());
|
||||
} else {
|
||||
$allSpContainers[] = $child;
|
||||
|
|
|
@ -36,7 +36,7 @@ class SpContainer
|
|||
/**
|
||||
* Is this a group shape?
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $spgr = false;
|
||||
|
||||
|
@ -57,7 +57,7 @@ class SpContainer
|
|||
/**
|
||||
* Shape index (usually group shape has index 0, and the rest: 1,2,3...)
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $spId;
|
||||
|
||||
|
@ -133,7 +133,7 @@ class SpContainer
|
|||
/**
|
||||
* Set whether this is a group shape
|
||||
*
|
||||
* @param boolean $value
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setSpgr($value = false)
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ class SpContainer
|
|||
/**
|
||||
* Get whether this is a group shape
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getSpgr()
|
||||
{
|
||||
|
@ -232,6 +232,7 @@ class SpContainer
|
|||
if (isset($this->OPT[$property])) {
|
||||
return $this->OPT[$property];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,14 +59,14 @@ class DggContainer
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $OPT = array();
|
||||
private $OPT = [];
|
||||
|
||||
/**
|
||||
* Array of identifier clusters containg information about the maximum shape identifiers
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $IDCLs = array();
|
||||
private $IDCLs = [];
|
||||
|
||||
/**
|
||||
* Get maximum shape index of all shapes in all drawings (plus one)
|
||||
|
@ -170,6 +170,7 @@ class DggContainer
|
|||
if (isset($this->OPT[$property])) {
|
||||
return $this->OPT[$property];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class BstoreContainer
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $BSECollection = array();
|
||||
private $BSECollection = [];
|
||||
|
||||
/**
|
||||
* Add a BLIP Store Entry
|
||||
|
|
|
@ -33,7 +33,7 @@ class Excel5
|
|||
*
|
||||
* @param \PhpSpreadsheet\Worksheet $sheet The sheet
|
||||
* @param string $col The column
|
||||
* @return integer The width in pixels
|
||||
* @return int The width in pixels
|
||||
*/
|
||||
public static function sizeCol($sheet, $col = 'A')
|
||||
{
|
||||
|
@ -74,8 +74,8 @@ class Excel5
|
|||
* use the default value. If the row is hidden we use a value of zero.
|
||||
*
|
||||
* @param \PhpSpreadsheet\Worksheet $sheet The sheet
|
||||
* @param integer $row The row index (1-based)
|
||||
* @return integer The width in pixels
|
||||
* @param int $row The row index (1-based)
|
||||
* @return int The width in pixels
|
||||
*/
|
||||
public static function sizeRow($sheet, $row = 1)
|
||||
{
|
||||
|
@ -117,10 +117,10 @@ class Excel5
|
|||
*
|
||||
* @param \PhpSpreadsheet\Worksheet $sheet
|
||||
* @param string $startColumn
|
||||
* @param integer $startOffsetX Offset within start cell measured in 1/1024 of the cell width
|
||||
* @param int $startOffsetX Offset within start cell measured in 1/1024 of the cell width
|
||||
* @param string $endColumn
|
||||
* @param integer $endOffsetX Offset within end cell measured in 1/1024 of the cell width
|
||||
* @return integer Horizontal measured in pixels
|
||||
* @param int $endOffsetX Offset within end cell measured in 1/1024 of the cell width
|
||||
* @return int Horizontal measured in pixels
|
||||
*/
|
||||
public static function getDistanceX(\PhpSpreadsheet\Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0)
|
||||
{
|
||||
|
@ -147,11 +147,11 @@ class Excel5
|
|||
* The distanceY is found as sum of all the spanning rows minus two offsets
|
||||
*
|
||||
* @param \PhpSpreadsheet\Worksheet $sheet
|
||||
* @param integer $startRow (1-based)
|
||||
* @param integer $startOffsetY Offset within start cell measured in 1/256 of the cell height
|
||||
* @param integer $endRow (1-based)
|
||||
* @param integer $endOffsetY Offset within end cell measured in 1/256 of the cell height
|
||||
* @return integer Vertical distance measured in pixels
|
||||
* @param int $startRow (1-based)
|
||||
* @param int $startOffsetY Offset within start cell measured in 1/256 of the cell height
|
||||
* @param int $endRow (1-based)
|
||||
* @param int $endOffsetY Offset within end cell measured in 1/256 of the cell height
|
||||
* @return int Vertical distance measured in pixels
|
||||
*/
|
||||
public static function getDistanceY(\PhpSpreadsheet\Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0)
|
||||
{
|
||||
|
@ -217,10 +217,10 @@ class Excel5
|
|||
*
|
||||
* @param \PhpSpreadsheet\Worksheet $sheet
|
||||
* @param string $coordinates E.g. 'A1'
|
||||
* @param integer $offsetX Horizontal offset in pixels
|
||||
* @param integer $offsetY Vertical offset in pixels
|
||||
* @param integer $width Width in pixels
|
||||
* @param integer $height Height in pixels
|
||||
* @param int $offsetX Horizontal offset in pixels
|
||||
* @param int $offsetY Vertical offset in pixels
|
||||
* @param int $width Width in pixels
|
||||
* @param int $height Height in pixels
|
||||
* @return array
|
||||
*/
|
||||
public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height)
|
||||
|
@ -283,14 +283,14 @@ class Excel5
|
|||
$startCoordinates = \PhpSpreadsheet\Cell::stringFromColumnIndex($col_start) . ($row_start + 1);
|
||||
$endCoordinates = \PhpSpreadsheet\Cell::stringFromColumnIndex($col_end) . ($row_end + 1);
|
||||
|
||||
$twoAnchor = array(
|
||||
$twoAnchor = [
|
||||
'startCoordinates' => $startCoordinates,
|
||||
'startOffsetX' => $x1,
|
||||
'startOffsetY' => $y1,
|
||||
'endCoordinates' => $endCoordinates,
|
||||
'endOffsetX' => $x2,
|
||||
'endOffsetY' => $y2,
|
||||
);
|
||||
];
|
||||
|
||||
return $twoAnchor;
|
||||
}
|
||||
|
|
|
@ -36,29 +36,26 @@ class File
|
|||
*/
|
||||
protected static $useUploadTempDirectory = false;
|
||||
|
||||
|
||||
/**
|
||||
* Set the flag indicating whether the File Upload Temp directory should be used for temporary files
|
||||
*
|
||||
* @param boolean $useUploadTempDir Use File Upload Temporary directory (true or false)
|
||||
* @param bool $useUploadTempDir Use File Upload Temporary directory (true or false)
|
||||
*/
|
||||
public static function setUseUploadTempDirectory($useUploadTempDir = false)
|
||||
{
|
||||
self::$useUploadTempDirectory = (boolean) $useUploadTempDir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the flag indicating whether the File Upload Temp directory should be used for temporary files
|
||||
*
|
||||
* @return boolean Use File Upload Temporary directory (true or false)
|
||||
* @return bool Use File Upload Temporary directory (true or false)
|
||||
*/
|
||||
public static function getUseUploadTempDirectory()
|
||||
{
|
||||
return self::$useUploadTempDirectory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verify if a file exists
|
||||
*
|
||||
|
@ -80,6 +77,7 @@ class File
|
|||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = ($zip->getFromName($archiveFile) !== false);
|
||||
$zip->close();
|
||||
|
||||
return $returnValue;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -168,6 +166,7 @@ class File
|
|||
$temp = tempnam(__FILE__, '');
|
||||
if (file_exists($temp)) {
|
||||
unlink($temp);
|
||||
|
||||
return realpath(dirname($temp));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ class Font
|
|||
const AUTOSIZE_METHOD_APPROX = 'approx';
|
||||
const AUTOSIZE_METHOD_EXACT = 'exact';
|
||||
|
||||
private static $autoSizeMethods = array(
|
||||
private static $autoSizeMethods = [
|
||||
self::AUTOSIZE_METHOD_APPROX,
|
||||
self::AUTOSIZE_METHOD_EXACT,
|
||||
);
|
||||
];
|
||||
|
||||
/** Character set codes used by BIFF5-8 in Font records */
|
||||
const CHARSET_ANSI_LATIN = 0x00;
|
||||
|
@ -141,51 +141,51 @@ class Font
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $defaultColumnWidths = array(
|
||||
'Arial' => array(
|
||||
1 => array('px' => 24, 'width' => 12.00000000),
|
||||
2 => array('px' => 24, 'width' => 12.00000000),
|
||||
3 => array('px' => 32, 'width' => 10.66406250),
|
||||
4 => array('px' => 32, 'width' => 10.66406250),
|
||||
5 => array('px' => 40, 'width' => 10.00000000),
|
||||
6 => array('px' => 48, 'width' => 9.59765625),
|
||||
7 => array('px' => 48, 'width' => 9.59765625),
|
||||
8 => array('px' => 56, 'width' => 9.33203125),
|
||||
9 => array('px' => 64, 'width' => 9.14062500),
|
||||
10 => array('px' => 64, 'width' => 9.14062500),
|
||||
),
|
||||
'Calibri' => array(
|
||||
1 => array('px' => 24, 'width' => 12.00000000),
|
||||
2 => array('px' => 24, 'width' => 12.00000000),
|
||||
3 => array('px' => 32, 'width' => 10.66406250),
|
||||
4 => array('px' => 32, 'width' => 10.66406250),
|
||||
5 => array('px' => 40, 'width' => 10.00000000),
|
||||
6 => array('px' => 48, 'width' => 9.59765625),
|
||||
7 => array('px' => 48, 'width' => 9.59765625),
|
||||
8 => array('px' => 56, 'width' => 9.33203125),
|
||||
9 => array('px' => 56, 'width' => 9.33203125),
|
||||
10 => array('px' => 64, 'width' => 9.14062500),
|
||||
11 => array('px' => 64, 'width' => 9.14062500),
|
||||
),
|
||||
'Verdana' => array(
|
||||
1 => array('px' => 24, 'width' => 12.00000000),
|
||||
2 => array('px' => 24, 'width' => 12.00000000),
|
||||
3 => array('px' => 32, 'width' => 10.66406250),
|
||||
4 => array('px' => 32, 'width' => 10.66406250),
|
||||
5 => array('px' => 40, 'width' => 10.00000000),
|
||||
6 => array('px' => 48, 'width' => 9.59765625),
|
||||
7 => array('px' => 48, 'width' => 9.59765625),
|
||||
8 => array('px' => 64, 'width' => 9.14062500),
|
||||
9 => array('px' => 72, 'width' => 9.00000000),
|
||||
10 => array('px' => 72, 'width' => 9.00000000),
|
||||
),
|
||||
);
|
||||
public static $defaultColumnWidths = [
|
||||
'Arial' => [
|
||||
1 => ['px' => 24, 'width' => 12.00000000],
|
||||
2 => ['px' => 24, 'width' => 12.00000000],
|
||||
3 => ['px' => 32, 'width' => 10.66406250],
|
||||
4 => ['px' => 32, 'width' => 10.66406250],
|
||||
5 => ['px' => 40, 'width' => 10.00000000],
|
||||
6 => ['px' => 48, 'width' => 9.59765625],
|
||||
7 => ['px' => 48, 'width' => 9.59765625],
|
||||
8 => ['px' => 56, 'width' => 9.33203125],
|
||||
9 => ['px' => 64, 'width' => 9.14062500],
|
||||
10 => ['px' => 64, 'width' => 9.14062500],
|
||||
],
|
||||
'Calibri' => [
|
||||
1 => ['px' => 24, 'width' => 12.00000000],
|
||||
2 => ['px' => 24, 'width' => 12.00000000],
|
||||
3 => ['px' => 32, 'width' => 10.66406250],
|
||||
4 => ['px' => 32, 'width' => 10.66406250],
|
||||
5 => ['px' => 40, 'width' => 10.00000000],
|
||||
6 => ['px' => 48, 'width' => 9.59765625],
|
||||
7 => ['px' => 48, 'width' => 9.59765625],
|
||||
8 => ['px' => 56, 'width' => 9.33203125],
|
||||
9 => ['px' => 56, 'width' => 9.33203125],
|
||||
10 => ['px' => 64, 'width' => 9.14062500],
|
||||
11 => ['px' => 64, 'width' => 9.14062500],
|
||||
],
|
||||
'Verdana' => [
|
||||
1 => ['px' => 24, 'width' => 12.00000000],
|
||||
2 => ['px' => 24, 'width' => 12.00000000],
|
||||
3 => ['px' => 32, 'width' => 10.66406250],
|
||||
4 => ['px' => 32, 'width' => 10.66406250],
|
||||
5 => ['px' => 40, 'width' => 10.00000000],
|
||||
6 => ['px' => 48, 'width' => 9.59765625],
|
||||
7 => ['px' => 48, 'width' => 9.59765625],
|
||||
8 => ['px' => 64, 'width' => 9.14062500],
|
||||
9 => ['px' => 72, 'width' => 9.00000000],
|
||||
10 => ['px' => 72, 'width' => 9.00000000],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Set autoSize method
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return boolean Success or failure
|
||||
* @return bool Success or failure
|
||||
*/
|
||||
public static function setAutoSizeMethod($pValue = self::AUTOSIZE_METHOD_APPROX)
|
||||
{
|
||||
|
@ -238,9 +238,9 @@ class Font
|
|||
*
|
||||
* @param \PhpSpreadsheet\Style\Font $font Font object
|
||||
* @param \PhpSpreadsheet\RichText|string $cellText Text to calculate width
|
||||
* @param integer $rotation Rotation angle
|
||||
* @param \PhpSpreadsheet\Style\Font|NULL $defaultFont Font object
|
||||
* @return integer Column width
|
||||
* @param int $rotation Rotation angle
|
||||
* @param \PhpSpreadsheet\Style\Font|null $defaultFont Font object
|
||||
* @return int Column width
|
||||
*/
|
||||
public static function calculateColumnWidth(\PhpSpreadsheet\Style\Font $font, $cellText = '', $rotation = 0, \PhpSpreadsheet\Style\Font $defaultFont = null)
|
||||
{
|
||||
|
@ -252,10 +252,11 @@ class Font
|
|||
// Special case if there are one or more newline characters ("\n")
|
||||
if (strpos($cellText, "\n") !== false) {
|
||||
$lineTexts = explode("\n", $cellText);
|
||||
$lineWidths = array();
|
||||
$lineWidths = [];
|
||||
foreach ($lineTexts as $lineText) {
|
||||
$lineWidths[] = self::calculateColumnWidth($font, $lineText, $rotation = 0, $defaultFont);
|
||||
}
|
||||
|
||||
return max($lineWidths); // width of longest line in cell
|
||||
}
|
||||
|
||||
|
@ -292,8 +293,8 @@ class Font
|
|||
* @param string $text
|
||||
* @param \PhpSpreadsheet\Style\Font
|
||||
* @param int $rotation
|
||||
* @return int
|
||||
* @throws \PhpSpreadsheet\Exception
|
||||
* @return int
|
||||
*/
|
||||
public static function getTextWidthPixelsExact($text, \PhpSpreadsheet\Style\Font $font, $rotation = 0)
|
||||
{
|
||||
|
@ -399,7 +400,7 @@ class Font
|
|||
*/
|
||||
public static function inchSizeToPixels($sizeInInch = 1)
|
||||
{
|
||||
return ($sizeInInch * 96);
|
||||
return $sizeInInch * 96;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -410,7 +411,7 @@ class Font
|
|||
*/
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1)
|
||||
{
|
||||
return ($sizeInCm * 37.795275591);
|
||||
return $sizeInCm * 37.795275591;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -553,7 +554,7 @@ class Font
|
|||
* For example, for Calibri 11 this is 9.140625 (64 px)
|
||||
*
|
||||
* @param \PhpSpreadsheet\Style\Font $font The workbooks default font
|
||||
* @param boolean $pPixels true = return column width in pixels, false = return in OOXML units
|
||||
* @param bool $pPixels true = return column width in pixels, false = return in OOXML units
|
||||
* @return mixed Column width
|
||||
*/
|
||||
public static function getDefaultColumnWidthByFont(\PhpSpreadsheet\Style\Font $font, $pPixels = false)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace PhpSpreadsheet\Shared\JAMA;
|
||||
|
||||
/**
|
||||
*
|
||||
* Cholesky decomposition class
|
||||
*
|
||||
* For a symmetric, positive definite matrix A, the Cholesky decomposition
|
||||
|
@ -22,21 +21,18 @@ class CholeskyDecomposition
|
|||
/**
|
||||
* Decomposition storage
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $L = array();
|
||||
private $L = [];
|
||||
|
||||
/**
|
||||
* Matrix row and column dimension
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $m;
|
||||
|
||||
/**
|
||||
* Symmetric positive definite flag
|
||||
* @var boolean
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $isspd = true;
|
||||
|
||||
|
@ -82,7 +78,7 @@ class CholeskyDecomposition
|
|||
/**
|
||||
* Is the matrix symmetric and positive definite?
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isSPD()
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue