Upgrade to PHP-CS-Fixer 2.0

This commit is contained in:
Adrien Crivelli 2016-12-22 23:43:37 +09:00
parent 0de994c998
commit 8c66afe39a
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
236 changed files with 8615 additions and 4409 deletions

3
.gitignore vendored
View File

@ -1,9 +1,8 @@
/build/PHPExcel.phar
/tests/codeCoverage /tests/codeCoverage
/analysis /analysis
/vendor/ /vendor/
/composer.lock
/phpunit.xml /phpunit.xml
/.php_cs.cache
## IDE support ## IDE support
*.buildpath *.buildpath

109
.php_cs
View File

@ -1,109 +0,0 @@
<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
->exclude('vendor')
->in('samples')
->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);

140
.php_cs.dist Normal file
View File

@ -0,0 +1,140 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in('samples')
->in('src')
->in('tests');
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setFinder($finder)
->setRules([
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_return' => true,
'braces' => true,
'cast_spaces' => true,
'class_definition' => true,
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'declare_strict_types' => false, // Too early to adopt strict types
'dir_constant' => true,
'elseif' => true,
'encoding' => true,
'ereg_to_preg' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false, // No use for that
'hash_to_slash_comment' => true,
'header_comment' => false, // We don't use common header in all our files
'heredoc_to_nowdoc' => false, // Not sure about this one
'include' => true,
'indentation_type' => true,
'line_ending' => true,
'linebreak_after_opening_tag' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'mb_str_functions' => false, // No, too dangerous to change that
'method_argument_space' => true,
'method_separation' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'useTrait', 'curly_brace_block', 'parenthesis_brace_block', 'square_brace_block'],
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
'not_operator_with_successor_space' => false, // idem
'object_operator_without_whitespace' => true,
'ordered_class_elements' => false, // We prefer to keep some freedom
'ordered_imports' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'php_unit_fqcn_annotation' => true,
'php_unit_strict' => false, // We sometime actually need assertEquals 'phpdoc_align' => false, // Waste of time
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => false, // Waste of time
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => false,
'pre_increment' => true,
'protected_to_private' => true,
'psr0' => true,
'psr4' => true,
'random_api_migration' => false, // This breaks our unit tests
'return_type_declaration' => true,
'self_accessor' => true,
'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
'short_scalar_cast' => true,
'silenced_deprecation_error' => true,
'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'strict_comparison' => false, // No, too dangerous to change that
'strict_param' => false, // No, too dangerous to change that
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
'whitespace_after_comma_in_array' => true,
]);

View File

@ -33,7 +33,7 @@
"squizlabs/php_codesniffer": "2.*", "squizlabs/php_codesniffer": "2.*",
"phpunit/phpunit": "4.6.*", "phpunit/phpunit": "4.6.*",
"mikey179/vfsStream": "1.5.*", "mikey179/vfsStream": "1.5.*",
"friendsofphp/php-cs-fixer": "^1.11" "friendsofphp/php-cs-fixer": "^2.0"
}, },
"suggest": { "suggest": {
"ext-zip": "Required to handle .xlsx .ods or .gnumeric files", "ext-zip": "Required to handle .xlsx .ods or .gnumeric files",

1751
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Autoloader for PhpSpreadsheet classes * Autoloader for PhpSpreadsheet classes.
* *
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet
* *
@ -22,13 +22,14 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Autoloader class Autoloader
{ {
/** /**
* Register the Autoloader with SPL * Register the Autoloader with SPL.
*/ */
public static function register() public static function register()
{ {
@ -41,7 +42,7 @@ class Autoloader
} }
/** /**
* Autoload a class identified by name * Autoload a class identified by name.
* *
* @param string $className Name of the object to load * @param string $className Name of the object to load
*/ */

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* Bootstrap for PhpSpreadsheet classes * Bootstrap for PhpSpreadsheet classes.
* *
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet
* *
@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,20 +20,21 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class APC extends CacheBase implements ICache class APC extends CacheBase implements ICache
{ {
/** /**
* Prefix used to uniquely identify cache data for this worksheet * Prefix used to uniquely identify cache data for this worksheet.
* *
* @var string * @var string
*/ */
private $cachePrefix = null; private $cachePrefix = null;
/** /**
* Cache timeout * Cache timeout.
* *
* @var int * @var int
*/ */
@ -41,7 +42,7 @@ class APC extends CacheBase implements ICache
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -64,11 +65,13 @@ class APC extends CacheBase implements ICache
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -89,7 +92,9 @@ class APC extends CacheBase implements ICache
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell? * Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return bool * @return bool
*/ */
public function isDataSet($pCoord) public function isDataSet($pCoord)
@ -114,10 +119,12 @@ class APC extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -151,7 +158,7 @@ class APC extends CacheBase implements ICache
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
@ -165,9 +172,10 @@ class APC extends CacheBase implements ICache
} }
/** /**
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function deleteCacheData($pCoord) public function deleteCacheData($pCoord)
@ -180,9 +188,10 @@ class APC extends CacheBase implements ICache
} }
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent) public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
@ -210,7 +219,7 @@ class APC extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {
@ -229,7 +238,7 @@ class APC extends CacheBase implements ICache
} }
/** /**
* Initialise this new cell collection * Initialise this new cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments * @param array of mixed $arguments Additional initialisation arguments
@ -248,7 +257,7 @@ class APC extends CacheBase implements ICache
} }
/** /**
* Destroy this cell collection * Destroy this cell collection.
*/ */
public function __destruct() public function __destruct()
{ {
@ -260,7 +269,7 @@ class APC extends CacheBase implements ICache
/** /**
* Identify whether the caching method is currently available * Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build * Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
* *
* @return bool * @return bool
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,34 +20,35 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
abstract class CacheBase abstract class CacheBase
{ {
/** /**
* Parent worksheet * Parent worksheet.
* *
* @var \PhpOffice\PhpSpreadsheet\Worksheet * @var \PhpOffice\PhpSpreadsheet\Worksheet
*/ */
protected $parent; protected $parent;
/** /**
* The currently active Cell * The currently active Cell.
* *
* @var \PhpOffice\PhpSpreadsheet\Cell * @var \PhpOffice\PhpSpreadsheet\Cell
*/ */
protected $currentObject = null; protected $currentObject = null;
/** /**
* Coordinate address of the currently active Cell * Coordinate address of the currently active Cell.
* *
* @var string * @var string
*/ */
protected $currentObjectID = null; protected $currentObjectID = null;
/** /**
* Flag indicating whether the currently active Cell requires saving * Flag indicating whether the currently active Cell requires saving.
* *
* @var bool * @var bool
*/ */
@ -55,14 +56,14 @@ abstract class CacheBase
/** /**
* An array of cells or cell pointers for the worksheet cells held in this cache, * An array of cells or cell pointers for the worksheet cells held in this cache,
* and indexed by their coordinate address within the worksheet * and indexed by their coordinate address within the worksheet.
* *
* @var array of mixed * @var array of mixed
*/ */
protected $cellCache = []; protected $cellCache = [];
/** /**
* Initialise this new cell collection * Initialise this new cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
*/ */
@ -75,7 +76,7 @@ abstract class CacheBase
} }
/** /**
* Return the parent worksheet for this cell collection * Return the parent worksheet for this cell collection.
* *
* @return \PhpOffice\PhpSpreadsheet\Worksheet * @return \PhpOffice\PhpSpreadsheet\Worksheet
*/ */
@ -88,6 +89,7 @@ abstract class CacheBase
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell? * Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
*
* @return bool * @return bool
*/ */
public function isDataSet($pCoord) public function isDataSet($pCoord)
@ -100,10 +102,11 @@ abstract class CacheBase
} }
/** /**
* Move a cell object from one address to another * Move a cell object from one address to another.
* *
* @param string $fromAddress Current address of the cell to move * @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move * @param string $toAddress Destination address of the cell to move
*
* @return bool * @return bool
*/ */
public function moveCell($fromAddress, $toAddress) public function moveCell($fromAddress, $toAddress)
@ -121,10 +124,12 @@ abstract class CacheBase
} }
/** /**
* Add or Update a cell in cache * Add or Update a cell in cache.
* *
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function updateCacheData(\PhpOffice\PhpSpreadsheet\Cell $cell) public function updateCacheData(\PhpOffice\PhpSpreadsheet\Cell $cell)
@ -133,9 +138,10 @@ abstract class CacheBase
} }
/** /**
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function deleteCacheData($pCoord) public function deleteCacheData($pCoord)
@ -153,7 +159,7 @@ abstract class CacheBase
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
@ -163,7 +169,7 @@ abstract class CacheBase
} }
/** /**
* Sort the list of all cell addresses currently held in cache by row and column * Sort the list of all cell addresses currently held in cache by row and column.
* *
* @return string[] * @return string[]
*/ */
@ -180,7 +186,7 @@ abstract class CacheBase
} }
/** /**
* Get highest worksheet column and highest row that have cell records * Get highest worksheet column and highest row that have cell records.
* *
* @return array Highest column name and highest row number * @return array Highest column name and highest row number
*/ */
@ -207,7 +213,7 @@ abstract class CacheBase
} }
/** /**
* Return the cell address of the currently active cell object * Return the cell address of the currently active cell object.
* *
* @return string * @return string
*/ */
@ -217,7 +223,7 @@ abstract class CacheBase
} }
/** /**
* Return the column address of the currently active cell object * Return the column address of the currently active cell object.
* *
* @return string * @return string
*/ */
@ -229,7 +235,7 @@ abstract class CacheBase
} }
/** /**
* Return the row address of the currently active cell object * Return the row address of the currently active cell object.
* *
* @return int * @return int
*/ */
@ -237,14 +243,15 @@ abstract class CacheBase
{ {
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row); sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
return (integer) $row; return (int) $row;
} }
/** /**
* Get highest worksheet column * Get highest worksheet column.
* *
* @param string $row Return the highest column for the specified row, * @param string $row Return the highest column for the specified row,
* or the highest column of any row if no row number is passed * or the highest column of any row if no row number is passed
*
* @return string Highest column name * @return string Highest column name
*/ */
public function getHighestColumn($row = null) public function getHighestColumn($row = null)
@ -268,10 +275,11 @@ abstract class CacheBase
} }
/** /**
* Get highest worksheet row * Get highest worksheet row.
* *
* @param string $column Return the highest row for the specified column, * @param string $column Return the highest row for the specified column,
* or the highest row of any column if no column letter is passed * or the highest row of any column if no column letter is passed
*
* @return int Highest row number * @return int Highest row number
*/ */
public function getHighestRow($column = null) public function getHighestRow($column = null)
@ -295,7 +303,7 @@ abstract class CacheBase
} }
/** /**
* Generate a unique ID for cache referencing * Generate a unique ID for cache referencing.
* *
* @return string Unique Reference * @return string Unique Reference
*/ */
@ -311,7 +319,7 @@ abstract class CacheBase
} }
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*/ */
@ -327,7 +335,7 @@ abstract class CacheBase
} }
/** /**
* Remove a row, deleting all cells in that row * Remove a row, deleting all cells in that row.
* *
* @param string $row Row number to remove * @param string $row Row number to remove
*/ */
@ -342,7 +350,7 @@ abstract class CacheBase
} }
/** /**
* Remove a column, deleting all cells in that column * Remove a column, deleting all cells in that column.
* *
* @param string $column Column ID to remove * @param string $column Column ID to remove
*/ */
@ -358,7 +366,7 @@ abstract class CacheBase
/** /**
* Identify whether the caching method is currently available * Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build * Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
* *
* @return bool * @return bool
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,27 +20,28 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class DiscISAM extends CacheBase implements ICache class DiscISAM extends CacheBase implements ICache
{ {
/** /**
* Name of the file for this cache * Name of the file for this cache.
* *
* @var string * @var string
*/ */
private $fileName = null; private $fileName = null;
/** /**
* File handle for this cache file * File handle for this cache file.
* *
* @var resource * @var resource
*/ */
private $fileHandle = null; private $fileHandle = null;
/** /**
* Directory/Folder where the cache file is located * Directory/Folder where the cache file is located.
* *
* @var string * @var string
*/ */
@ -48,7 +49,7 @@ class DiscISAM extends CacheBase implements ICache
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -69,11 +70,13 @@ class DiscISAM extends CacheBase implements ICache
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -90,10 +93,12 @@ class DiscISAM extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -121,7 +126,7 @@ class DiscISAM extends CacheBase implements ICache
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
@ -135,7 +140,7 @@ class DiscISAM extends CacheBase implements ICache
} }
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*/ */
@ -153,7 +158,7 @@ class DiscISAM extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {
@ -171,7 +176,7 @@ class DiscISAM extends CacheBase implements ICache
} }
/** /**
* Initialise this new cell collection * Initialise this new cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments * @param array of mixed $arguments Additional initialisation arguments
@ -191,7 +196,7 @@ class DiscISAM extends CacheBase implements ICache
} }
/** /**
* Destroy this cell collection * Destroy this cell collection.
*/ */
public function __destruct() public function __destruct()
{ {

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,43 +20,51 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
interface ICache interface ICache
{ {
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell); public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell);
/** /**
* Add or Update a cell in cache * Add or Update a cell in cache.
* *
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function updateCacheData(\PhpOffice\PhpSpreadsheet\Cell $cell); public function updateCacheData(\PhpOffice\PhpSpreadsheet\Cell $cell);
/** /**
* Fetch a cell from cache identified by coordinate address * Fetch a cell from cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to retrieve * @param string $pCoord Coordinate address of the cell to retrieve
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord); public function getCacheData($pCoord);
/** /**
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function deleteCacheData($pCoord); public function deleteCacheData($pCoord);
@ -65,26 +73,27 @@ interface ICache
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell? * Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
*
* @return bool * @return bool
*/ */
public function isDataSet($pCoord); public function isDataSet($pCoord);
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
public function getCellList(); public function getCellList();
/** /**
* Get the list of all cell addresses currently held in cache sorted by column and row * Get the list of all cell addresses currently held in cache sorted by column and row.
* *
* @return string[] * @return string[]
*/ */
public function getSortedCellList(); public function getSortedCellList();
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*/ */
@ -92,7 +101,7 @@ interface ICache
/** /**
* Identify whether the caching method is currently available * Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build * Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
* *
* @return bool * @return bool
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -27,7 +28,7 @@ class Igbinary extends CacheBase implements ICache
{ {
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -40,14 +41,18 @@ class Igbinary extends CacheBase implements ICache
$this->currentCellIsDirty = false; $this->currentCellIsDirty = false;
} }
$this->currentObjectID = $this->currentObject = null; $this->currentObjectID = $this->currentObject = null;
} // function _storeData() }
// function _storeData()
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -64,10 +69,12 @@ class Igbinary extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -91,10 +98,12 @@ class Igbinary extends CacheBase implements ICache
// Return requested entry // Return requested entry
return $this->currentObject; return $this->currentObject;
} // function getCacheData() }
// function getCacheData()
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
@ -108,7 +117,7 @@ class Igbinary extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {
@ -120,11 +129,13 @@ class Igbinary extends CacheBase implements ICache
// detach ourself from the worksheet, so that it can then delete this object successfully // detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null; $this->parent = null;
} // function unsetWorksheetCells() }
// function unsetWorksheetCells()
/** /**
* Identify whether the caching method is currently available * Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build * Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
* *
* @return bool * @return bool
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,27 +20,28 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Memcache extends CacheBase implements ICache class Memcache extends CacheBase implements ICache
{ {
/** /**
* Prefix used to uniquely identify cache data for this worksheet * Prefix used to uniquely identify cache data for this worksheet.
* *
* @var string * @var string
*/ */
private $cachePrefix = null; private $cachePrefix = null;
/** /**
* Cache timeout * Cache timeout.
* *
* @var int * @var int
*/ */
private $cacheTime = 600; private $cacheTime = 600;
/** /**
* Memcache interface * Memcache interface.
* *
* @var resource * @var resource
*/ */
@ -48,7 +49,7 @@ class Memcache extends CacheBase implements ICache
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -70,11 +71,13 @@ class Memcache extends CacheBase implements ICache
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -95,7 +98,9 @@ class Memcache extends CacheBase implements ICache
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell? * Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return bool * @return bool
*/ */
public function isDataSet($pCoord) public function isDataSet($pCoord)
@ -120,10 +125,12 @@ class Memcache extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -157,7 +164,7 @@ class Memcache extends CacheBase implements ICache
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
@ -171,9 +178,10 @@ class Memcache extends CacheBase implements ICache
} }
/** /**
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function deleteCacheData($pCoord) public function deleteCacheData($pCoord)
@ -186,9 +194,10 @@ class Memcache extends CacheBase implements ICache
} }
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent) public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
@ -216,7 +225,7 @@ class Memcache extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {
@ -235,10 +244,11 @@ class Memcache extends CacheBase implements ICache
} }
/** /**
* Initialise this new cell collection * Initialise this new cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
* @param mixed[] $arguments Additional initialisation arguments * @param mixed[] $arguments Additional initialisation arguments
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent, $arguments) public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent, $arguments)
@ -263,10 +273,11 @@ class Memcache extends CacheBase implements ICache
} }
/** /**
* Memcache error handler * Memcache error handler.
* *
* @param string $host Memcache server * @param string $host Memcache server
* @param int $port Memcache port * @param int $port Memcache port
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function failureCallback($host, $port) public function failureCallback($host, $port)
@ -275,7 +286,7 @@ class Memcache extends CacheBase implements ICache
} }
/** /**
* Destroy this cell collection * Destroy this cell collection.
*/ */
public function __destruct() public function __destruct()
{ {
@ -287,7 +298,7 @@ class Memcache extends CacheBase implements ICache
/** /**
* Identify whether the caching method is currently available * Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build * Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
* *
* @return bool * @return bool
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,24 +20,27 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Memory extends CacheBase implements ICache class Memory extends CacheBase implements ICache
{ {
/** /**
* Dummy method callable from CacheBase, but unused by Memory cache * Dummy method callable from CacheBase, but unused by Memory cache.
*/ */
protected function storeData() protected function storeData()
{ {
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -51,10 +54,12 @@ class Memory extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -74,7 +79,7 @@ class Memory extends CacheBase implements ICache
} }
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*/ */
@ -92,7 +97,7 @@ class Memory extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -27,7 +28,7 @@ class MemoryGZip extends CacheBase implements ICache
{ {
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -43,11 +44,13 @@ class MemoryGZip extends CacheBase implements ICache
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -64,10 +67,12 @@ class MemoryGZip extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -94,7 +99,7 @@ class MemoryGZip extends CacheBase implements ICache
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
@ -108,7 +113,7 @@ class MemoryGZip extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -27,7 +28,7 @@ class MemorySerialized extends CacheBase implements ICache
{ {
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -43,11 +44,13 @@ class MemorySerialized extends CacheBase implements ICache
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -64,10 +67,12 @@ class MemorySerialized extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -94,7 +99,7 @@ class MemorySerialized extends CacheBase implements ICache
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
@ -108,7 +113,7 @@ class MemorySerialized extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,20 +20,21 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class PHPTemp extends CacheBase implements ICache class PHPTemp extends CacheBase implements ICache
{ {
/** /**
* Name of the file for this cache * Name of the file for this cache.
* *
* @var string * @var string
*/ */
private $fileHandle = null; private $fileHandle = null;
/** /**
* Memory limit to use before reverting to file cache * Memory limit to use before reverting to file cache.
* *
* @var int * @var int
*/ */
@ -41,7 +42,7 @@ class PHPTemp extends CacheBase implements ICache
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -62,11 +63,13 @@ class PHPTemp extends CacheBase implements ICache
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -83,10 +86,12 @@ class PHPTemp extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -114,7 +119,7 @@ class PHPTemp extends CacheBase implements ICache
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
@ -128,7 +133,7 @@ class PHPTemp extends CacheBase implements ICache
} }
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*/ */
@ -146,7 +151,7 @@ class PHPTemp extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {
@ -164,7 +169,7 @@ class PHPTemp extends CacheBase implements ICache
} }
/** /**
* Initialise this new cell collection * Initialise this new cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
* @param mixed[] $arguments Additional initialisation arguments * @param mixed[] $arguments Additional initialisation arguments
@ -180,7 +185,7 @@ class PHPTemp extends CacheBase implements ICache
} }
/** /**
* Destroy this cell collection * Destroy this cell collection.
*/ */
public function __destruct() public function __destruct()
{ {

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,20 +20,21 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class SQLite extends CacheBase implements ICache class SQLite extends CacheBase implements ICache
{ {
/** /**
* Database table name * Database table name.
* *
* @var string * @var string
*/ */
private $TableName = null; private $TableName = null;
/** /**
* Database handle * Database handle.
* *
* @var resource * @var resource
*/ */
@ -41,7 +42,7 @@ class SQLite extends CacheBase implements ICache
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -59,11 +60,13 @@ class SQLite extends CacheBase implements ICache
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -80,10 +83,12 @@ class SQLite extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -118,7 +123,9 @@ class SQLite extends CacheBase implements ICache
* Is a value set for an indexed cell? * Is a value set for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return bool * @return bool
*/ */
public function isDataSet($pCoord) public function isDataSet($pCoord)
@ -141,9 +148,10 @@ class SQLite extends CacheBase implements ICache
} }
/** /**
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function deleteCacheData($pCoord) public function deleteCacheData($pCoord)
@ -163,11 +171,13 @@ class SQLite extends CacheBase implements ICache
} }
/** /**
* Move a cell object from one address to another * Move a cell object from one address to another.
* *
* @param string $fromAddress Current address of the cell to move * @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move * @param string $toAddress Destination address of the cell to move
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return bool * @return bool
*/ */
public function moveCell($fromAddress, $toAddress) public function moveCell($fromAddress, $toAddress)
@ -192,9 +202,10 @@ class SQLite extends CacheBase implements ICache
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return string[] * @return string[]
*/ */
public function getCellList() public function getCellList()
@ -218,9 +229,10 @@ class SQLite extends CacheBase implements ICache
} }
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent) public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
@ -241,7 +253,7 @@ class SQLite extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {
@ -257,9 +269,10 @@ class SQLite extends CacheBase implements ICache
} }
/** /**
* Initialise this new cell collection * Initialise this new cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent) public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
@ -280,7 +293,7 @@ class SQLite extends CacheBase implements ICache
} }
/** /**
* Destroy this cell collection * Destroy this cell collection.
*/ */
public function __destruct() public function __destruct()
{ {
@ -292,7 +305,7 @@ class SQLite extends CacheBase implements ICache
/** /**
* Identify whether the caching method is currently available * Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build * Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
* *
* @return bool * @return bool
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,48 +20,49 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class SQLite3 extends CacheBase implements ICache class SQLite3 extends CacheBase implements ICache
{ {
/** /**
* Database table name * Database table name.
* *
* @var string * @var string
*/ */
private $TableName = null; private $TableName = null;
/** /**
* Database handle * Database handle.
* *
* @var resource * @var resource
*/ */
private $DBHandle = null; private $DBHandle = null;
/** /**
* Prepared statement for a SQLite3 select query * Prepared statement for a SQLite3 select query.
* *
* @var SQLite3Stmt * @var SQLite3Stmt
*/ */
private $selectQuery; private $selectQuery;
/** /**
* Prepared statement for a SQLite3 insert query * Prepared statement for a SQLite3 insert query.
* *
* @var SQLite3Stmt * @var SQLite3Stmt
*/ */
private $insertQuery; private $insertQuery;
/** /**
* Prepared statement for a SQLite3 update query * Prepared statement for a SQLite3 update query.
* *
* @var SQLite3Stmt * @var SQLite3Stmt
*/ */
private $updateQuery; private $updateQuery;
/** /**
* Prepared statement for a SQLite3 delete query * Prepared statement for a SQLite3 delete query.
* *
* @var SQLite3Stmt * @var SQLite3Stmt
*/ */
@ -69,7 +70,7 @@ class SQLite3 extends CacheBase implements ICache
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -90,11 +91,13 @@ class SQLite3 extends CacheBase implements ICache
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -111,11 +114,13 @@ class SQLite3 extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -151,7 +156,9 @@ class SQLite3 extends CacheBase implements ICache
* Is a value set for an indexed cell? * Is a value set for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return bool * @return bool
*/ */
public function isDataSet($pCoord) public function isDataSet($pCoord)
@ -172,9 +179,10 @@ class SQLite3 extends CacheBase implements ICache
} }
/** /**
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function deleteCacheData($pCoord) public function deleteCacheData($pCoord)
@ -195,11 +203,13 @@ class SQLite3 extends CacheBase implements ICache
} }
/** /**
* Move a cell object from one address to another * Move a cell object from one address to another.
* *
* @param string $fromAddress Current address of the cell to move * @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move * @param string $toAddress Destination address of the cell to move
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return bool * @return bool
*/ */
public function moveCell($fromAddress, $toAddress) public function moveCell($fromAddress, $toAddress)
@ -225,9 +235,10 @@ class SQLite3 extends CacheBase implements ICache
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return string[] * @return string[]
*/ */
public function getCellList() public function getCellList()
@ -251,9 +262,10 @@ class SQLite3 extends CacheBase implements ICache
} }
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent) public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
@ -274,7 +286,7 @@ class SQLite3 extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {
@ -290,9 +302,10 @@ class SQLite3 extends CacheBase implements ICache
} }
/** /**
* Initialise this new cell collection * Initialise this new cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent) public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
@ -318,7 +331,7 @@ class SQLite3 extends CacheBase implements ICache
} }
/** /**
* Destroy this cell collection * Destroy this cell collection.
*/ */
public function __destruct() public function __destruct()
{ {
@ -331,7 +344,7 @@ class SQLite3 extends CacheBase implements ICache
/** /**
* Identify whether the caching method is currently available * Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build * Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
* *
* @return bool * @return bool
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage; namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,20 +20,21 @@ namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Wincache extends CacheBase implements ICache class Wincache extends CacheBase implements ICache
{ {
/** /**
* Prefix used to uniquely identify cache data for this worksheet * Prefix used to uniquely identify cache data for this worksheet.
* *
* @var string * @var string
*/ */
private $cachePrefix = null; private $cachePrefix = null;
/** /**
* Cache timeout * Cache timeout.
* *
* @var int * @var int
*/ */
@ -41,7 +42,7 @@ class Wincache extends CacheBase implements ICache
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object.
* *
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
@ -69,11 +70,13 @@ class Wincache extends CacheBase implements ICache
} }
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell * @return \PhpOffice\PhpSpreadsheet\Cell
*/ */
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell) public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
@ -94,7 +97,9 @@ class Wincache extends CacheBase implements ICache
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell? * Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
* *
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return bool * @return bool
*/ */
public function isDataSet($pCoord) public function isDataSet($pCoord)
@ -119,10 +124,12 @@ class Wincache extends CacheBase implements ICache
} }
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate.
* *
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found * @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) public function getCacheData($pCoord)
@ -158,7 +165,7 @@ class Wincache extends CacheBase implements ICache
} }
/** /**
* Get a list of all cell addresses currently held in cache * Get a list of all cell addresses currently held in cache.
* *
* @return string[] * @return string[]
*/ */
@ -172,9 +179,10 @@ class Wincache extends CacheBase implements ICache
} }
/** /**
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address.
* *
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function deleteCacheData($pCoord) public function deleteCacheData($pCoord)
@ -187,9 +195,10 @@ class Wincache extends CacheBase implements ICache
} }
/** /**
* Clone the cell collection * Clone the cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*/ */
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent) public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
@ -218,7 +227,7 @@ class Wincache extends CacheBase implements ICache
} }
/** /**
* Clear the cell collection and disconnect from our parent * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {
@ -237,7 +246,7 @@ class Wincache extends CacheBase implements ICache
} }
/** /**
* Initialise this new cell collection * Initialise this new cell collection.
* *
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
* @param mixed[] $arguments Additional initialisation arguments * @param mixed[] $arguments Additional initialisation arguments
@ -256,7 +265,7 @@ class Wincache extends CacheBase implements ICache
} }
/** /**
* Destroy this cell collection * Destroy this cell collection.
*/ */
public function __destruct() public function __destruct()
{ {
@ -268,7 +277,7 @@ class Wincache extends CacheBase implements ICache
/** /**
* Identify whether the caching method is currently available * Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build * Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
* *
* @return bool * @return bool
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -38,21 +39,21 @@ class CachedObjectStorageFactory
const CACHE_TO_SQLITE3 = 'SQLite3'; const CACHE_TO_SQLITE3 = 'SQLite3';
/** /**
* Name of the method used for cell cacheing * Name of the method used for cell cacheing.
* *
* @var string * @var string
*/ */
private static $cacheStorageMethod; private static $cacheStorageMethod;
/** /**
* Name of the class used for cell cacheing * Name of the class used for cell cacheing.
* *
* @var string * @var string
*/ */
private static $cacheStorageClass; private static $cacheStorageClass;
/** /**
* List of all possible cache storage methods * List of all possible cache storage methods.
* *
* @var string[] * @var string[]
*/ */
@ -71,7 +72,7 @@ class CachedObjectStorageFactory
]; ];
/** /**
* Default arguments for each cache storage method * Default arguments for each cache storage method.
* *
* @var array of mixed array * @var array of mixed array
*/ */
@ -102,14 +103,14 @@ class CachedObjectStorageFactory
]; ];
/** /**
* Arguments for the active cache storage method * Arguments for the active cache storage method.
* *
* @var mixed[] * @var mixed[]
*/ */
private static $storageMethodParameters = []; private static $storageMethodParameters = [];
/** /**
* Return the current cache storage method * Return the current cache storage method.
* *
* @return string|null * @return string|null
**/ **/
@ -119,7 +120,7 @@ class CachedObjectStorageFactory
} }
/** /**
* Return the current cache storage class * Return the current cache storage class.
* *
* @return string * @return string
**/ **/
@ -129,7 +130,7 @@ class CachedObjectStorageFactory
} }
/** /**
* Return the list of all possible cache storage methods * Return the list of all possible cache storage methods.
* *
* @return string[] * @return string[]
**/ **/
@ -139,7 +140,7 @@ class CachedObjectStorageFactory
} }
/** /**
* Return the list of all available cache storage methods * Return the list of all available cache storage methods.
* *
* @return string[] * @return string[]
**/ **/
@ -157,11 +158,12 @@ class CachedObjectStorageFactory
} }
/** /**
* Identify the cache storage method to use * Identify the cache storage method to use.
* *
* @param string $method Name of the method to use for cell cacheing * @param string $method Name of the method to use for cell cacheing
* @param mixed[] $arguments Additional arguments to pass to the cell caching class * @param mixed[] $arguments Additional arguments to pass to the cell caching class
* when instantiating * when instantiating
*
* @return bool * @return bool
**/ **/
public static function initialize($method = self::CACHE_IN_MEMORY, $arguments = []) public static function initialize($method = self::CACHE_IN_MEMORY, $arguments = [])
@ -191,9 +193,10 @@ class CachedObjectStorageFactory
} }
/** /**
* Initialise the cache storage * Initialise the cache storage.
* *
* @param Worksheet $parent Enable cell caching for this worksheet * @param Worksheet $parent Enable cell caching for this worksheet
*
* @return CachedObjectStorage\ICache * @return CachedObjectStorage\ICache
**/ **/
public static function getInstance(Worksheet $parent) public static function getInstance(Worksheet $parent)
@ -217,7 +220,7 @@ class CachedObjectStorageFactory
} }
/** /**
* Clear the cache storage * Clear the cache storage.
**/ **/
public static function finalize() public static function finalize()
{ {

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CalcEngine; namespace PhpOffice\PhpSpreadsheet\CalcEngine;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,20 +20,21 @@ namespace PhpOffice\PhpSpreadsheet\CalcEngine;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class CyclicReferenceStack class CyclicReferenceStack
{ {
/** /**
* The call stack for calculated cells * The call stack for calculated cells.
* *
* @var mixed[] * @var mixed[]
*/ */
private $stack = []; private $stack = [];
/** /**
* Return the number of entries on the stack * Return the number of entries on the stack.
* *
* @return int * @return int
*/ */
@ -43,7 +44,7 @@ class CyclicReferenceStack
} }
/** /**
* Push a new entry onto the stack * Push a new entry onto the stack.
* *
* @param mixed $value * @param mixed $value
*/ */
@ -53,7 +54,7 @@ class CyclicReferenceStack
} }
/** /**
* Pop the last entry from the stack * Pop the last entry from the stack.
* *
* @return mixed * @return mixed
*/ */
@ -63,7 +64,7 @@ class CyclicReferenceStack
} }
/** /**
* Test to see if a specified entry exists on the stack * Test to see if a specified entry exists on the stack.
* *
* @param mixed $value The value to test * @param mixed $value The value to test
*/ */
@ -73,7 +74,7 @@ class CyclicReferenceStack
} }
/** /**
* Clear the stack * Clear the stack.
*/ */
public function clear() public function clear()
{ {
@ -81,7 +82,7 @@ class CyclicReferenceStack
} }
/** /**
* Return an array of all entries on the stack * Return an array of all entries on the stack.
* *
* @return mixed[] * @return mixed[]
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\CalcEngine; namespace PhpOffice\PhpSpreadsheet\CalcEngine;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\CalcEngine;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -28,7 +29,7 @@ class Logger
/** /**
* Flag to determine whether a debug log should be generated by the calculation engine * Flag to determine whether a debug log should be generated by the calculation engine
* If true, then a debug log will be generated * If true, then a debug log will be generated
* If false, then a debug log will not be generated * If false, then a debug log will not be generated.
* *
* @var bool * @var bool
*/ */
@ -38,28 +39,28 @@ class Logger
* Flag to determine whether a debug log should be echoed by the calculation engine * Flag to determine whether a debug log should be echoed by the calculation engine
* If true, then a debug log will be echoed * If true, then a debug log will be echoed
* If false, then a debug log will not be echoed * If false, then a debug log will not be echoed
* A debug log can only be echoed if it is generated * A debug log can only be echoed if it is generated.
* *
* @var bool * @var bool
*/ */
private $echoDebugLog = false; private $echoDebugLog = false;
/** /**
* The debug log generated by the calculation engine * The debug log generated by the calculation engine.
* *
* @var string[] * @var string[]
*/ */
private $debugLog = []; private $debugLog = [];
/** /**
* The calculation engine cell reference stack * The calculation engine cell reference stack.
* *
* @var CyclicReferenceStack * @var CyclicReferenceStack
*/ */
private $cellStack; private $cellStack;
/** /**
* Instantiate a Calculation engine logger * Instantiate a Calculation engine logger.
* *
* @param CyclicReferenceStack $stack * @param CyclicReferenceStack $stack
*/ */
@ -69,7 +70,7 @@ class Logger
} }
/** /**
* Enable/Disable Calculation engine logging * Enable/Disable Calculation engine logging.
* *
* @param bool $pValue * @param bool $pValue
*/ */
@ -79,7 +80,7 @@ class Logger
} }
/** /**
* Return whether calculation engine logging is enabled or disabled * Return whether calculation engine logging is enabled or disabled.
* *
* @return bool * @return bool
*/ */
@ -89,7 +90,7 @@ class Logger
} }
/** /**
* Enable/Disable echoing of debug log information * Enable/Disable echoing of debug log information.
* *
* @param bool $pValue * @param bool $pValue
*/ */
@ -99,7 +100,7 @@ class Logger
} }
/** /**
* Return whether echoing of debug log information is enabled or disabled * Return whether echoing of debug log information is enabled or disabled.
* *
* @return bool * @return bool
*/ */
@ -109,7 +110,7 @@ class Logger
} }
/** /**
* Write an entry to the calculation engine debug log * Write an entry to the calculation engine debug log.
*/ */
public function writeDebugLog() public function writeDebugLog()
{ {
@ -130,7 +131,7 @@ class Logger
} }
/** /**
* Clear the calculation engine debug log * Clear the calculation engine debug log.
*/ */
public function clearLog() public function clearLog()
{ {
@ -138,7 +139,7 @@ class Logger
} }
/** /**
* Return the calculation engine debug log * Return the calculation engine debug log.
* *
* @return string[] * @return string[]
*/ */

View File

@ -20,7 +20,7 @@ if (!defined('CALCULATION_REGEXP_CELLREF')) {
} }
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -37,13 +37,14 @@ if (!defined('CALCULATION_REGEXP_CELLREF')) {
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Calculation class Calculation
{ {
/** Constants */ /** Constants */
/** Regular Expressions */ /** Regular Expressions */
// Numeric operand // Numeric operand
const CALCULATION_REGEXP_NUMBER = '[-+]?\d*\.?\d+(e[-+]?\d+)?'; const CALCULATION_REGEXP_NUMBER = '[-+]?\d*\.?\d+(e[-+]?\d+)?';
// String operand // String operand
@ -67,35 +68,35 @@ class Calculation
private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE; private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE;
/** /**
* Instance of this class * Instance of this class.
* *
* @var \PhpOffice\PhpSpreadsheet\Calculation * @var \PhpOffice\PhpSpreadsheet\Calculation
*/ */
private static $instance; private static $instance;
/** /**
* Instance of the spreadsheet this Calculation Engine is using * Instance of the spreadsheet this Calculation Engine is using.
* *
* @var PhpSpreadsheet * @var PhpSpreadsheet
*/ */
private $spreadsheet; private $spreadsheet;
/** /**
* List of instances of the calculation engine that we've instantiated for individual spreadsheets * List of instances of the calculation engine that we've instantiated for individual spreadsheets.
* *
* @var \PhpOffice\PhpSpreadsheet\Calculation[] * @var \PhpOffice\PhpSpreadsheet\Calculation[]
*/ */
private static $spreadsheetSets; private static $spreadsheetSets;
/** /**
* Calculation cache * Calculation cache.
* *
* @var array * @var array
*/ */
private $calculationCache = []; private $calculationCache = [];
/** /**
* Calculation cache enabled * Calculation cache enabled.
* *
* @var bool * @var bool
*/ */
@ -103,7 +104,7 @@ class Calculation
/** /**
* List of operators that can be used within formulae * List of operators that can be used within formulae
* The true/false value indicates whether it is a binary operator or a unary operator * The true/false value indicates whether it is a binary operator or a unary operator.
* *
* @var array * @var array
*/ */
@ -115,7 +116,7 @@ class Calculation
]; ];
/** /**
* List of binary operators (those that expect two operands) * List of binary operators (those that expect two operands).
* *
* @var array * @var array
*/ */
@ -127,7 +128,7 @@ class Calculation
]; ];
/** /**
* The debug log generated by the calculation engine * The debug log generated by the calculation engine.
* *
* @var CalcEngine\Logger * @var CalcEngine\Logger
*/ */
@ -136,21 +137,21 @@ class Calculation
/** /**
* Flag to determine how formula errors should be handled * Flag to determine how formula errors should be handled
* If true, then a user error will be triggered * If true, then a user error will be triggered
* If false, then an exception will be thrown * If false, then an exception will be thrown.
* *
* @var bool * @var bool
*/ */
public $suppressFormulaErrors = false; public $suppressFormulaErrors = false;
/** /**
* Error message for any error that was raised/thrown by the calculation engine * Error message for any error that was raised/thrown by the calculation engine.
* *
* @var string * @var string
*/ */
public $formulaError = null; public $formulaError = null;
/** /**
* An array of the nested cell references accessed by the calculation engine, used for the debug log * An array of the nested cell references accessed by the calculation engine, used for the debug log.
* *
* @var array of string * @var array of string
*/ */
@ -161,7 +162,7 @@ class Calculation
/** /**
* Current iteration counter for cyclic formulae * Current iteration counter for cyclic formulae
* If the value is 0 (or less) then cyclic formulae will throw an exception, * If the value is 0 (or less) then cyclic formulae will throw an exception,
* otherwise they will iterate to the limit defined here before returning a result * otherwise they will iterate to the limit defined here before returning a result.
* *
* @var int * @var int
*/ */
@ -170,21 +171,21 @@ class Calculation
private $cyclicFormulaCell = ''; private $cyclicFormulaCell = '';
/** /**
* Number of iterations for cyclic formulae * Number of iterations for cyclic formulae.
* *
* @var int * @var int
*/ */
public $cyclicFormulaCount = 1; public $cyclicFormulaCount = 1;
/** /**
* Epsilon Precision used for comparisons in calculations * Epsilon Precision used for comparisons in calculations.
* *
* @var float * @var float
*/ */
private $delta = 0.1e-12; private $delta = 0.1e-12;
/** /**
* The current locale setting * The current locale setting.
* *
* @var string * @var string
*/ */
@ -192,7 +193,7 @@ class Calculation
/** /**
* List of available locale settings * List of available locale settings
* Note that this is read for the locale subdirectory only when requested * Note that this is read for the locale subdirectory only when requested.
* *
* @var string[] * @var string[]
*/ */
@ -201,7 +202,7 @@ class Calculation
]; ];
/** /**
* Locale-specific argument separator for function arguments * Locale-specific argument separator for function arguments.
* *
* @var string * @var string
*/ */
@ -209,7 +210,7 @@ class Calculation
private static $localeFunctions = []; private static $localeFunctions = [];
/** /**
* Locale-specific translations for Excel constants (True, False and Null) * Locale-specific translations for Excel constants (True, False and Null).
* *
* @var string[] * @var string[]
*/ */
@ -221,7 +222,7 @@ class Calculation
/** /**
* Excel constant string translations to their PHP equivalents * Excel constant string translations to their PHP equivalents
* Constant conversion from text name/value to actual (datatyped) value * Constant conversion from text name/value to actual (datatyped) value.
* *
* @var string[] * @var string[]
*/ */
@ -2045,10 +2046,11 @@ class Calculation
} }
/** /**
* Get an instance of this class * Get an instance of this class.
* *
* @param Spreadsheet $spreadsheet Injected spreadsheet for working with a PhpSpreadsheet Spreadsheet object, * @param Spreadsheet $spreadsheet Injected spreadsheet for working with a PhpSpreadsheet Spreadsheet object,
* or NULL to create a standalone claculation engine * or NULL to create a standalone claculation engine
*
* @return Calculation * @return Calculation
*/ */
public static function getInstance(Spreadsheet $spreadsheet = null) public static function getInstance(Spreadsheet $spreadsheet = null)
@ -2068,7 +2070,7 @@ class Calculation
} }
/** /**
* Unset an instance of this class * Unset an instance of this class.
* *
* @param Spreadsheet $spreadsheet Injected spreadsheet identifying the instance to unset * @param Spreadsheet $spreadsheet Injected spreadsheet identifying the instance to unset
*/ */
@ -2079,7 +2081,7 @@ class Calculation
/** /**
* Flush the calculation cache for any existing instance of this class * Flush the calculation cache for any existing instance of this class
* but only if a \PhpOffice\PhpSpreadsheet\Calculation instance exists * but only if a \PhpOffice\PhpSpreadsheet\Calculation instance exists.
*/ */
public function flushInstance() public function flushInstance()
{ {
@ -2087,7 +2089,7 @@ class Calculation
} }
/** /**
* Get the debuglog for this claculation engine instance * Get the debuglog for this claculation engine instance.
* *
* @return CalcEngine\Logger * @return CalcEngine\Logger
*/ */
@ -2107,7 +2109,7 @@ class Calculation
} }
/** /**
* Return the locale-specific translation of TRUE * Return the locale-specific translation of TRUE.
* *
* @return string locale-specific translation of TRUE * @return string locale-specific translation of TRUE
*/ */
@ -2117,7 +2119,7 @@ class Calculation
} }
/** /**
* Return the locale-specific translation of FALSE * Return the locale-specific translation of FALSE.
* *
* @return string locale-specific translation of FALSE * @return string locale-specific translation of FALSE
*/ */
@ -2127,9 +2129,10 @@ class Calculation
} }
/** /**
* Set the Array Return Type (Array or Value of first element in the array) * Set the Array Return Type (Array or Value of first element in the array).
* *
* @param string $returnType Array return type * @param string $returnType Array return type
*
* @return bool Success or failure * @return bool Success or failure
*/ */
public static function setArrayReturnType($returnType) public static function setArrayReturnType($returnType)
@ -2146,7 +2149,7 @@ class Calculation
} }
/** /**
* Return the Array Return Type (Array or Value of first element in the array) * Return the Array Return Type (Array or Value of first element in the array).
* *
* @return string $returnType Array return type * @return string $returnType Array return type
*/ */
@ -2166,7 +2169,7 @@ class Calculation
} }
/** /**
* Enable/disable calculation cache * Enable/disable calculation cache.
* *
* @param bool $pValue * @param bool $pValue
*/ */
@ -2177,7 +2180,7 @@ class Calculation
} }
/** /**
* Enable calculation cache * Enable calculation cache.
*/ */
public function enableCalculationCache() public function enableCalculationCache()
{ {
@ -2185,7 +2188,7 @@ class Calculation
} }
/** /**
* Disable calculation cache * Disable calculation cache.
*/ */
public function disableCalculationCache() public function disableCalculationCache()
{ {
@ -2193,7 +2196,7 @@ class Calculation
} }
/** /**
* Clear calculation cache * Clear calculation cache.
*/ */
public function clearCalculationCache() public function clearCalculationCache()
{ {
@ -2201,7 +2204,7 @@ class Calculation
} }
/** /**
* Clear calculation cache for a specified worksheet * Clear calculation cache for a specified worksheet.
* *
* @param string $worksheetName * @param string $worksheetName
*/ */
@ -2213,7 +2216,7 @@ class Calculation
} }
/** /**
* Rename calculation cache for a specified worksheet * Rename calculation cache for a specified worksheet.
* *
* @param string $fromWorksheetName * @param string $fromWorksheetName
* @param string $toWorksheetName * @param string $toWorksheetName
@ -2227,7 +2230,7 @@ class Calculation
} }
/** /**
* Get the currently defined locale code * Get the currently defined locale code.
* *
* @return string * @return string
*/ */
@ -2237,9 +2240,10 @@ class Calculation
} }
/** /**
* Set the locale code * Set the locale code.
* *
* @param string $locale The locale to use for formula translation * @param string $locale The locale to use for formula translation
*
* @return bool * @return bool
*/ */
public function setLocale($locale = 'en_us') public function setLocale($locale = 'en_us')
@ -2347,6 +2351,9 @@ class Calculation
/** /**
* @param string $fromSeparator * @param string $fromSeparator
* @param string $toSeparator * @param string $toSeparator
* @param mixed $from
* @param mixed $to
* @param mixed $formula
*/ */
private static function translateFormula($from, $to, $formula, $fromSeparator, $toSeparator) private static function translateFormula($from, $to, $formula, $fromSeparator, $toSeparator)
{ {
@ -2452,9 +2459,10 @@ class Calculation
} }
/** /**
* Wrap string values in quotes * Wrap string values in quotes.
* *
* @param mixed $value * @param mixed $value
*
* @return mixed * @return mixed
*/ */
public static function wrapResult($value) public static function wrapResult($value)
@ -2476,15 +2484,16 @@ class Calculation
} }
/** /**
* Remove quotes used as a wrapper to identify string values * Remove quotes used as a wrapper to identify string values.
* *
* @param mixed $value * @param mixed $value
*
* @return mixed * @return mixed
*/ */
public static function unwrapResult($value) public static function unwrapResult($value)
{ {
if (is_string($value)) { if (is_string($value)) {
if ((isset($value{0})) && ($value{0} == '"') && (substr($value, -1) == '"')) { if ((isset($value[0])) && ($value[0] == '"') && (substr($value, -1) == '"')) {
return substr($value, 1, -1); return substr($value, 1, -1);
} }
// Convert numeric errors to NAN error // Convert numeric errors to NAN error
@ -2497,10 +2506,12 @@ class Calculation
/** /**
* Calculate cell value (using formula from a cell ID) * Calculate cell value (using formula from a cell ID)
* Retained for backward compatibility * Retained for backward compatibility.
* *
* @param Cell $pCell Cell to calculate * @param Cell $pCell Cell to calculate
*
* @throws Calculation\Exception * @throws Calculation\Exception
*
* @return mixed * @return mixed
*/ */
public function calculate(Cell $pCell = null) public function calculate(Cell $pCell = null)
@ -2513,11 +2524,13 @@ class Calculation
} }
/** /**
* Calculate the value of a cell formula * Calculate the value of a cell formula.
* *
* @param Cell $pCell Cell to calculate * @param Cell $pCell Cell to calculate
* @param bool $resetLog Flag indicating whether the debug log should be reset or not * @param bool $resetLog Flag indicating whether the debug log should be reset or not
*
* @throws Calculation\Exception * @throws Calculation\Exception
*
* @return mixed * @return mixed
*/ */
public function calculateCellValue(Cell $pCell = null, $resetLog = true) public function calculateCellValue(Cell $pCell = null, $resetLog = true)
@ -2588,10 +2601,12 @@ class Calculation
} }
/** /**
* Validate and parse a formula string * Validate and parse a formula string.
* *
* @param string $formula Formula to parse * @param string $formula Formula to parse
*
* @throws Calculation\Exception * @throws Calculation\Exception
*
* @return array * @return array
*/ */
public function parseFormula($formula) public function parseFormula($formula)
@ -2599,11 +2614,11 @@ class Calculation
// Basic validation that this is indeed a formula // Basic validation that this is indeed a formula
// We return an empty array if not // We return an empty array if not
$formula = trim($formula); $formula = trim($formula);
if ((!isset($formula{0})) || ($formula{0} != '=')) { if ((!isset($formula[0])) || ($formula[0] != '=')) {
return []; return [];
} }
$formula = ltrim(substr($formula, 1)); $formula = ltrim(substr($formula, 1));
if (!isset($formula{0})) { if (!isset($formula[0])) {
return []; return [];
} }
@ -2612,12 +2627,14 @@ class Calculation
} }
/** /**
* Calculate the value of a formula * Calculate the value of a formula.
* *
* @param string $formula Formula to parse * @param string $formula Formula to parse
* @param string $cellID Address of the cell to calculate * @param string $cellID Address of the cell to calculate
* @param Cell $pCell Cell to calculate * @param Cell $pCell Cell to calculate
*
* @throws Calculation\Exception * @throws Calculation\Exception
*
* @return mixed * @return mixed
*/ */
public function calculateFormula($formula, $cellID = null, Cell $pCell = null) public function calculateFormula($formula, $cellID = null, Cell $pCell = null)
@ -2670,6 +2687,7 @@ class Calculation
/** /**
* @param string $cellReference * @param string $cellReference
* @param mixed $cellValue
*/ */
public function saveValueToCache($cellReference, $cellValue) public function saveValueToCache($cellReference, $cellValue)
{ {
@ -2679,12 +2697,14 @@ class Calculation
} }
/** /**
* Parse a cell formula and calculate its value * Parse a cell formula and calculate its value.
* *
* @param string $formula The formula to parse and calculate * @param string $formula The formula to parse and calculate
* @param string $cellID The ID (e.g. A3) of the cell that we are calculating * @param string $cellID The ID (e.g. A3) of the cell that we are calculating
* @param Cell $pCell Cell to calculate * @param Cell $pCell Cell to calculate
*
* @throws Calculation\Exception * @throws Calculation\Exception
*
* @return mixed * @return mixed
*/ */
public function _calculateFormulaValue($formula, $cellID = null, Cell $pCell = null) public function _calculateFormulaValue($formula, $cellID = null, Cell $pCell = null)
@ -2694,11 +2714,11 @@ class Calculation
// Basic validation that this is indeed a formula // Basic validation that this is indeed a formula
// We simply return the cell value if not // We simply return the cell value if not
$formula = trim($formula); $formula = trim($formula);
if ($formula{0} != '=') { if ($formula[0] != '=') {
return self::wrapResult($formula); return self::wrapResult($formula);
} }
$formula = ltrim(substr($formula, 1)); $formula = ltrim(substr($formula, 1));
if (!isset($formula{0})) { if (!isset($formula[0])) {
return self::wrapResult($formula); return self::wrapResult($formula);
} }
@ -2710,7 +2730,7 @@ class Calculation
return $cellValue; return $cellValue;
} }
if (($wsTitle{0} !== "\x00") && ($this->cyclicReferenceStack->onStack($wsCellReference))) { if (($wsTitle[0] !== "\x00") && ($this->cyclicReferenceStack->onStack($wsCellReference))) {
if ($this->cyclicFormulaCount <= 0) { if ($this->cyclicFormulaCount <= 0) {
$this->cyclicFormulaCell = ''; $this->cyclicFormulaCell = '';
@ -2745,7 +2765,7 @@ class Calculation
} }
/** /**
* Ensure that paired matrix operands are both matrices and of the same size * Ensure that paired matrix operands are both matrices and of the same size.
* *
* @param mixed &$operand1 First matrix operand * @param mixed &$operand1 First matrix operand
* @param mixed &$operand2 Second matrix operand * @param mixed &$operand2 Second matrix operand
@ -2788,9 +2808,10 @@ class Calculation
} }
/** /**
* Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0 * Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0.
* *
* @param mixed &$matrix matrix operand * @param mixed &$matrix matrix operand
*
* @return int[] An array comprising the number of rows, and number of columns * @return int[] An array comprising the number of rows, and number of columns
*/ */
private static function getMatrixDimensions(&$matrix) private static function getMatrixDimensions(&$matrix)
@ -2811,7 +2832,7 @@ class Calculation
} }
/** /**
* Ensure that paired matrix operands are both matrices of the same size * Ensure that paired matrix operands are both matrices of the same size.
* *
* @param mixed &$matrix1 First matrix operand * @param mixed &$matrix1 First matrix operand
* @param mixed &$matrix2 Second matrix operand * @param mixed &$matrix2 Second matrix operand
@ -2854,7 +2875,7 @@ class Calculation
} }
/** /**
* Ensure that paired matrix operands are both matrices of the same size * Ensure that paired matrix operands are both matrices of the same size.
* *
* @param mixed &$matrix1 First matrix operand * @param mixed &$matrix1 First matrix operand
* @param mixed &$matrix2 Second matrix operand * @param mixed &$matrix2 Second matrix operand
@ -2901,9 +2922,10 @@ class Calculation
} }
/** /**
* Format details of an operand for display in the log (based on operand type) * Format details of an operand for display in the log (based on operand type).
* *
* @param mixed $value First matrix operand * @param mixed $value First matrix operand
*
* @return mixed * @return mixed
*/ */
private function showValue($value) private function showValue($value)
@ -2938,9 +2960,10 @@ class Calculation
} }
/** /**
* Format type and details of an operand for display in the log (based on operand type) * Format type and details of an operand for display in the log (based on operand type).
* *
* @param mixed $value First matrix operand * @param mixed $value First matrix operand
*
* @return string|null * @return string|null
*/ */
private function showTypeDetails($value) private function showTypeDetails($value)
@ -2964,11 +2987,10 @@ class Calculation
} else { } else {
if ($value == '') { if ($value == '') {
return 'an empty string'; return 'an empty string';
} elseif ($value{0} == '#') { } elseif ($value[0] == '#') {
return 'a ' . $value . ' error'; return 'a ' . $value . ' error';
} else {
$typeString = 'a string';
} }
$typeString = 'a string';
} }
return $typeString . ' with a value of ' . $this->showValue($value); return $typeString . ' with a value of ' . $this->showValue($value);
@ -3011,15 +3033,15 @@ class Calculation
if ($openCount < $closeCount) { if ($openCount < $closeCount) {
if ($openCount > 0) { if ($openCount > 0) {
return $this->raiseFormulaError("Formula Error: Mismatched matrix braces '}'"); return $this->raiseFormulaError("Formula Error: Mismatched matrix braces '}'");
} else {
return $this->raiseFormulaError("Formula Error: Unexpected '}' encountered");
} }
return $this->raiseFormulaError("Formula Error: Unexpected '}' encountered");
} elseif ($openCount > $closeCount) { } elseif ($openCount > $closeCount) {
if ($closeCount > 0) { if ($closeCount > 0) {
return $this->raiseFormulaError("Formula Error: Mismatched matrix braces '{'"); return $this->raiseFormulaError("Formula Error: Mismatched matrix braces '{'");
} else {
return $this->raiseFormulaError("Formula Error: Unexpected '{' encountered");
} }
return $this->raiseFormulaError("Formula Error: Unexpected '{' encountered");
} }
} }
@ -3093,9 +3115,9 @@ class Calculation
// The guts of the lexical parser // The guts of the lexical parser
// Loop through the formula extracting each operator and operand in turn // Loop through the formula extracting each operator and operand in turn
while (true) { while (true) {
$opCharacter = $formula{$index}; // Get the first character of the value at the current index position $opCharacter = $formula[$index]; // Get the first character of the value at the current index position
if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula{$index + 1}]))) { if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula[$index + 1]]))) {
$opCharacter .= $formula{++$index}; $opCharacter .= $formula[++$index];
} }
// Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand // Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand
@ -3126,9 +3148,8 @@ class Calculation
while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
if ($o2 === null) { if ($o2 === null) {
return $this->raiseFormulaError('Formula Error: Unexpected closing brace ")"'); return $this->raiseFormulaError('Formula Error: Unexpected closing brace ")"');
} else {
$output[] = $o2;
} }
$output[] = $o2;
} }
$d = $stack->last(2); $d = $stack->last(2);
if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function?
@ -3192,9 +3213,8 @@ class Calculation
while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
if ($o2 === null) { if ($o2 === null) {
return $this->raiseFormulaError('Formula Error: Unexpected ,'); return $this->raiseFormulaError('Formula Error: Unexpected ,');
} else {
$output[] = $o2; // pop the argument expression stuff and push onto the output
} }
$output[] = $o2; // pop the argument expression stuff and push onto the output
} }
// If we've a comma when we're expecting an operand, then what we actually have is a null operand; // If we've a comma when we're expecting an operand, then what we actually have is a null operand;
// so push a null onto the stack // so push a null onto the stack
@ -3278,7 +3298,7 @@ class Calculation
if ($rangeWS2 != '') { if ($rangeWS2 != '') {
$rangeWS2 .= '!'; $rangeWS2 .= '!';
} }
if ((is_integer($startRowColRef)) && (ctype_digit($val)) && if ((is_int($startRowColRef)) && (ctype_digit($val)) &&
($startRowColRef <= 1048576) && ($val <= 1048576)) { ($startRowColRef <= 1048576) && ($val <= 1048576)) {
// Row range // Row range
$endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007 $endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
@ -3301,7 +3321,7 @@ class Calculation
if ((strpos($val, '.') !== false) || (stripos($val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) { if ((strpos($val, '.') !== false) || (stripos($val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
$val = (float) $val; $val = (float) $val;
} else { } else {
$val = (integer) $val; $val = (int) $val;
} }
} elseif (isset(self::$excelConstants[trim(strtoupper($val))])) { } elseif (isset(self::$excelConstants[trim(strtoupper($val))])) {
$excelConstant = trim(strtoupper($val)); $excelConstant = trim(strtoupper($val));
@ -3337,16 +3357,15 @@ class Calculation
// Only valid for the % unary operator // Only valid for the % unary operator
if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) { if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) {
return $this->raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands"); return $this->raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands");
} else { }
break; break;
} }
}
// Ignore white space // Ignore white space
while (($formula{$index} == "\n") || ($formula{$index} == "\r")) { while (($formula[$index] == "\n") || ($formula[$index] == "\r")) {
++$index; ++$index;
} }
if ($formula{$index} == ' ') { if ($formula[$index] == ' ') {
while ($formula{$index} == ' ') { while ($formula[$index] == ' ') {
++$index; ++$index;
} }
// If we're expecting an operator, but only have a space between the previous and next operands (and both are // If we're expecting an operator, but only have a space between the previous and next operands (and both are
@ -3395,6 +3414,7 @@ class Calculation
/** /**
* @param string $cellID * @param string $cellID
* @param mixed $tokens
*/ */
private function processTokenStack($tokens, $cellID = null, Cell $pCell = null) private function processTokenStack($tokens, $cellID = null, Cell $pCell = null)
{ {
@ -3734,7 +3754,7 @@ class Calculation
$excelConstant = strtoupper($token); $excelConstant = strtoupper($token);
$stack->push('Constant Value', self::$excelConstants[$excelConstant]); $stack->push('Constant Value', self::$excelConstants[$excelConstant]);
$this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->showTypeDetails(self::$excelConstants[$excelConstant])); $this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->showTypeDetails(self::$excelConstants[$excelConstant]));
} elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) { } elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token[0] == '"') || ($token[0] == '#')) {
$stack->push('Value', $token); $stack->push('Value', $token);
// if the token is a named range, push the named range name onto the stack // if the token is a named range, push the named range name onto the stack
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $token, $matches)) { } elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $token, $matches)) {
@ -3775,13 +3795,13 @@ class Calculation
if (is_string($operand)) { if (is_string($operand)) {
// We only need special validations for the operand if it is a string // We only need special validations for the operand if it is a string
// Start by stripping off the quotation marks we use to identify true excel string values internally // Start by stripping off the quotation marks we use to identify true excel string values internally
if ($operand > '' && $operand{0} == '"') { if ($operand > '' && $operand[0] == '"') {
$operand = self::unwrapResult($operand); $operand = self::unwrapResult($operand);
} }
// If the string is a numeric value, we treat it as a numeric, so no further testing // If the string is a numeric value, we treat it as a numeric, so no further testing
if (!is_numeric($operand)) { if (!is_numeric($operand)) {
// If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations // If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations
if ($operand > '' && $operand{0} == '#') { if ($operand > '' && $operand[0] == '#') {
$stack->push('Value', $operand); $stack->push('Value', $operand);
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($operand)); $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($operand));
@ -3839,10 +3859,10 @@ class Calculation
} }
// Simple validate the two operands if they are string values // Simple validate the two operands if they are string values
if (is_string($operand1) && $operand1 > '' && $operand1{0} == '"') { if (is_string($operand1) && $operand1 > '' && $operand1[0] == '"') {
$operand1 = self::unwrapResult($operand1); $operand1 = self::unwrapResult($operand1);
} }
if (is_string($operand2) && $operand2 > '' && $operand2{0} == '"') { if (is_string($operand2) && $operand2 > '' && $operand2[0] == '"') {
$operand2 = self::unwrapResult($operand2); $operand2 = self::unwrapResult($operand2);
} }
@ -3923,9 +3943,11 @@ class Calculation
} }
/** /**
* Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters * Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters.
*
* @param string $str1 First string value for the comparison * @param string $str1 First string value for the comparison
* @param string $str2 Second string value for the comparison * @param string $str2 Second string value for the comparison
*
* @return int * @return int
*/ */
private function strcmpLowercaseFirst($str1, $str2) private function strcmpLowercaseFirst($str1, $str2)
@ -3938,6 +3960,10 @@ class Calculation
/** /**
* @param string $matrixFunction * @param string $matrixFunction
* @param mixed $cellID
* @param mixed $operand1
* @param mixed $operand2
* @param mixed $operation
*/ */
private function executeNumericBinaryOperation($cellID, $operand1, $operand2, $operation, $matrixFunction, &$stack) private function executeNumericBinaryOperation($cellID, $operand1, $operand2, $operation, $matrixFunction, &$stack)
{ {
@ -3994,9 +4020,9 @@ class Calculation
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails('#DIV/0!')); $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails('#DIV/0!'));
return false; return false;
} else {
$result = $operand1 / $operand2;
} }
$result = $operand1 / $operand2;
break; break;
// Power // Power
case '^': case '^':
@ -4026,12 +4052,14 @@ class Calculation
} }
/** /**
* Extract range values * Extract range values.
* *
* @param string &$pRange String based range representation * @param string &$pRange String based range representation
* @param Worksheet $pSheet Worksheet * @param Worksheet $pSheet Worksheet
* @param bool $resetLog Flag indicating whether calculation log should be reset or not * @param bool $resetLog Flag indicating whether calculation log should be reset or not
*
* @throws Calculation\Exception * @throws Calculation\Exception
*
* @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned.
*/ */
public function extractCellRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true) public function extractCellRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true)
@ -4077,12 +4105,14 @@ class Calculation
} }
/** /**
* Extract range values * Extract range values.
* *
* @param string &$pRange String based range representation * @param string &$pRange String based range representation
* @param Worksheet $pSheet Worksheet * @param Worksheet $pSheet Worksheet
* @param bool $resetLog Flag indicating whether calculation log should be reset or not * @param bool $resetLog Flag indicating whether calculation log should be reset or not
*
* @throws Calculation\Exception * @throws Calculation\Exception
*
* @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned.
*/ */
public function extractNamedRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true) public function extractNamedRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true)
@ -4146,6 +4176,7 @@ class Calculation
* Is a specific function implemented? * Is a specific function implemented?
* *
* @param string $pFunction Function Name * @param string $pFunction Function Name
*
* @return bool * @return bool
*/ */
public function isImplemented($pFunction = '') public function isImplemented($pFunction = '')
@ -4153,13 +4184,13 @@ class Calculation
$pFunction = strtoupper($pFunction); $pFunction = strtoupper($pFunction);
if (isset(self::$phpSpreadsheetFunctions[$pFunction])) { if (isset(self::$phpSpreadsheetFunctions[$pFunction])) {
return self::$phpSpreadsheetFunctions[$pFunction]['functionCall'] !== '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Functions::DUMMY'; return self::$phpSpreadsheetFunctions[$pFunction]['functionCall'] !== '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Functions::DUMMY';
} else {
return false;
} }
return false;
} }
/** /**
* Get a list of all implemented functions as an array of function objects * Get a list of all implemented functions as an array of function objects.
* *
* @return array of Calculation\Category * @return array of Calculation\Category
*/ */
@ -4169,7 +4200,7 @@ class Calculation
} }
/** /**
* Get a list of implemented Excel function names * Get a list of implemented Excel function names.
* *
* @return array * @return array
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,13 +20,14 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Database class Database
{ {
/** /**
* fieldExtract * fieldExtract.
* *
* Extracts the column ID to use for the data field. * Extracts the column ID to use for the data field.
* *
@ -39,6 +40,7 @@ class Database
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on. * the first column, 2 for the second column, and so on.
*
* @return string|null * @return string|null
*/ */
private static function fieldExtract($database, $field) private static function fieldExtract($database, $field)
@ -57,7 +59,7 @@ class Database
} }
/** /**
* filter * filter.
* *
* Parses the selection criteria, extracts the database rows that match those criteria, and * Parses the selection criteria, extracts the database rows that match those criteria, and
* returns that subset of rows. * returns that subset of rows.
@ -71,6 +73,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return array of mixed * @return array of mixed
*/ */
private static function filter($database, $criteria) private static function filter($database, $criteria)
@ -142,7 +145,7 @@ class Database
} }
/** /**
* DAVERAGE * DAVERAGE.
* *
* Averages the values in a column of a list or database that match conditions you specify. * Averages the values in a column of a list or database that match conditions you specify.
* *
@ -150,6 +153,7 @@ class Database
* DAVERAGE(database,field,criteria) * DAVERAGE(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -164,6 +168,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return float * @return float
*/ */
public static function DAVERAGE($database, $field, $criteria) public static function DAVERAGE($database, $field, $criteria)
@ -180,7 +185,7 @@ class Database
} }
/** /**
* DCOUNT * DCOUNT.
* *
* Counts the cells that contain numbers in a column of a list or database that match conditions * Counts the cells that contain numbers in a column of a list or database that match conditions
* that you specify. * that you specify.
@ -192,6 +197,7 @@ class Database
* DAVERAGE(database,field,criteria) * DAVERAGE(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -206,6 +212,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return int * @return int
* *
* @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the * @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the
@ -225,7 +232,7 @@ class Database
} }
/** /**
* DCOUNTA * DCOUNTA.
* *
* Counts the nonblank cells in a column of a list or database that match conditions that you specify. * Counts the nonblank cells in a column of a list or database that match conditions that you specify.
* *
@ -233,6 +240,7 @@ class Database
* DCOUNTA(database,[field],criteria) * DCOUNTA(database,[field],criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -247,6 +255,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return int * @return int
* *
* @TODO The field argument is optional. If field is omitted, DCOUNTA counts all records in the * @TODO The field argument is optional. If field is omitted, DCOUNTA counts all records in the
@ -274,7 +283,7 @@ class Database
} }
/** /**
* DGET * DGET.
* *
* Extracts a single value from a column of a list or database that matches conditions that you * Extracts a single value from a column of a list or database that matches conditions that you
* specify. * specify.
@ -283,6 +292,7 @@ class Database
* DGET(database,field,criteria) * DGET(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -297,6 +307,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return mixed * @return mixed
*/ */
public static function DGET($database, $field, $criteria) public static function DGET($database, $field, $criteria)
@ -316,7 +327,7 @@ class Database
} }
/** /**
* DMAX * DMAX.
* *
* Returns the largest number in a column of a list or database that matches conditions you that * Returns the largest number in a column of a list or database that matches conditions you that
* specify. * specify.
@ -325,6 +336,7 @@ class Database
* DMAX(database,field,criteria) * DMAX(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -339,6 +351,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return float * @return float
*/ */
public static function DMAX($database, $field, $criteria) public static function DMAX($database, $field, $criteria)
@ -355,7 +368,7 @@ class Database
} }
/** /**
* DMIN * DMIN.
* *
* Returns the smallest number in a column of a list or database that matches conditions you that * Returns the smallest number in a column of a list or database that matches conditions you that
* specify. * specify.
@ -364,6 +377,7 @@ class Database
* DMIN(database,field,criteria) * DMIN(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -378,6 +392,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return float * @return float
*/ */
public static function DMIN($database, $field, $criteria) public static function DMIN($database, $field, $criteria)
@ -394,7 +409,7 @@ class Database
} }
/** /**
* DPRODUCT * DPRODUCT.
* *
* Multiplies the values in a column of a list or database that match conditions that you specify. * Multiplies the values in a column of a list or database that match conditions that you specify.
* *
@ -402,6 +417,7 @@ class Database
* DPRODUCT(database,field,criteria) * DPRODUCT(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -416,6 +432,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return float * @return float
*/ */
public static function DPRODUCT($database, $field, $criteria) public static function DPRODUCT($database, $field, $criteria)
@ -432,7 +449,7 @@ class Database
} }
/** /**
* DSTDEV * DSTDEV.
* *
* Estimates the standard deviation of a population based on a sample by using the numbers in a * Estimates the standard deviation of a population based on a sample by using the numbers in a
* column of a list or database that match conditions that you specify. * column of a list or database that match conditions that you specify.
@ -441,6 +458,7 @@ class Database
* DSTDEV(database,field,criteria) * DSTDEV(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -455,6 +473,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return float * @return float
*/ */
public static function DSTDEV($database, $field, $criteria) public static function DSTDEV($database, $field, $criteria)
@ -471,7 +490,7 @@ class Database
} }
/** /**
* DSTDEVP * DSTDEVP.
* *
* Calculates the standard deviation of a population based on the entire population by using the * Calculates the standard deviation of a population based on the entire population by using the
* numbers in a column of a list or database that match conditions that you specify. * numbers in a column of a list or database that match conditions that you specify.
@ -480,6 +499,7 @@ class Database
* DSTDEVP(database,field,criteria) * DSTDEVP(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -494,6 +514,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return float * @return float
*/ */
public static function DSTDEVP($database, $field, $criteria) public static function DSTDEVP($database, $field, $criteria)
@ -510,7 +531,7 @@ class Database
} }
/** /**
* DSUM * DSUM.
* *
* Adds the numbers in a column of a list or database that match conditions that you specify. * Adds the numbers in a column of a list or database that match conditions that you specify.
* *
@ -518,6 +539,7 @@ class Database
* DSUM(database,field,criteria) * DSUM(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -532,6 +554,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return float * @return float
*/ */
public static function DSUM($database, $field, $criteria) public static function DSUM($database, $field, $criteria)
@ -548,7 +571,7 @@ class Database
} }
/** /**
* DVAR * DVAR.
* *
* Estimates the variance of a population based on a sample by using the numbers in a column * Estimates the variance of a population based on a sample by using the numbers in a column
* of a list or database that match conditions that you specify. * of a list or database that match conditions that you specify.
@ -557,6 +580,7 @@ class Database
* DVAR(database,field,criteria) * DVAR(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -571,6 +595,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return float * @return float
*/ */
public static function DVAR($database, $field, $criteria) public static function DVAR($database, $field, $criteria)
@ -587,7 +612,7 @@ class Database
} }
/** /**
* DVARP * DVARP.
* *
* Calculates the variance of a population based on the entire population by using the numbers * Calculates the variance of a population based on the entire population by using the numbers
* in a column of a list or database that match conditions that you specify. * in a column of a list or database that match conditions that you specify.
@ -596,6 +621,7 @@ class Database
* DVARP(database,field,criteria) * DVARP(database,field,criteria)
* *
* @category Database Functions * @category Database Functions
*
* @param mixed[] $database The range of cells that makes up the list or database. * @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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
@ -610,6 +636,7 @@ class Database
* includes at least one column label and at least one cell below * includes at least one column label and at least one cell below
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
*
* @return float * @return float
*/ */
public static function DVARP($database, $field, $criteria) public static function DVARP($database, $field, $criteria)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,15 +20,17 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class DateTime class DateTime
{ {
/** /**
* Identify if a year is a leap year or not * Identify if a year is a leap year or not.
* *
* @param int $year The year to test * @param int $year The year to test
*
* @return bool TRUE if the year is a leap year, otherwise FALSE * @return bool TRUE if the year is a leap year, otherwise FALSE
*/ */
public static function isLeapYear($year) public static function isLeapYear($year)
@ -37,7 +39,7 @@ class DateTime
} }
/** /**
* Return the number of days between two dates based on a 360 day calendar * Return the number of days between two dates based on a 360 day calendar.
* *
* @param int $startDay Day of month of the start date * @param int $startDay Day of month of the start date
* @param int $startMonth Month of the start date * @param int $startMonth Month of the start date
@ -46,6 +48,7 @@ class DateTime
* @param int $endMonth Month of the start date * @param int $endMonth Month of the start date
* @param int $endYear Year 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 * @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 * @return int Number of days between the start date and the end date
*/ */
private static function dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) private static function dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS)
@ -73,9 +76,10 @@ class DateTime
} }
/** /**
* getDateValue * getDateValue.
* *
* @param string $dateValue * @param string $dateValue
*
* @return mixed Excel date/time serial value, or string if error * @return mixed Excel date/time serial value, or string if error
*/ */
public static function getDateValue($dateValue) public static function getDateValue($dateValue)
@ -99,9 +103,10 @@ class DateTime
} }
/** /**
* getTimeValue * getTimeValue.
* *
* @param string $timeValue * @param string $timeValue
*
* @return mixed Excel date/time serial value, or string if error * @return mixed Excel date/time serial value, or string if error
*/ */
private static function getTimeValue($timeValue) private static function getTimeValue($timeValue)
@ -142,7 +147,7 @@ class DateTime
} }
/** /**
* DATETIMENOW * DATETIMENOW.
* *
* Returns the current date and time. * Returns the current date and time.
* The NOW function is useful when you need to display the current date and time on a worksheet or * The NOW function is useful when you need to display the current date and time on a worksheet or
@ -156,6 +161,7 @@ class DateTime
* NOW() * NOW()
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * @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 * depending on the value of the ReturnDateType flag
*/ */
@ -169,7 +175,7 @@ class DateTime
$retValue = (float) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(time()); $retValue = (float) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(time());
break; break;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
$retValue = (integer) time(); $retValue = (int) time();
break; break;
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
$retValue = new \DateTime(); $retValue = new \DateTime();
@ -181,7 +187,7 @@ class DateTime
} }
/** /**
* DATENOW * DATENOW.
* *
* Returns the current date. * Returns the current date.
* The NOW function is useful when you need to display the current date and time on a worksheet or * The NOW function is useful when you need to display the current date and time on a worksheet or
@ -195,6 +201,7 @@ class DateTime
* TODAY() * TODAY()
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * @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 * depending on the value of the ReturnDateType flag
*/ */
@ -209,7 +216,7 @@ class DateTime
$retValue = (float) $excelDateTime; $retValue = (float) $excelDateTime;
break; break;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
$retValue = (integer) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateTime); $retValue = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateTime);
break; break;
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
$retValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDateTime); $retValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDateTime);
@ -221,7 +228,7 @@ class DateTime
} }
/** /**
* DATE * DATE.
* *
* The DATE function returns a value that represents a particular date. * The DATE function returns a value that represents a particular date.
* *
@ -236,6 +243,7 @@ class DateTime
* as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language.
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @param int $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 * Excel interprets the year argument according to the configured
* date system: 1900 or 1904. * date system: 1900 or 1904.
@ -266,6 +274,7 @@ class DateTime
* days, plus one, from the first day of the month specified. For * days, plus one, from the first day of the month specified. For
* example, DATE(2008,1,-15) returns the serial number representing * example, DATE(2008,1,-15) returns the serial number representing
* December 16, 2007. * December 16, 2007.
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * @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 * depending on the value of the ReturnDateType flag
*/ */
@ -291,9 +300,9 @@ class DateTime
(!is_numeric($day))) { (!is_numeric($day))) {
return Functions::VALUE(); return Functions::VALUE();
} }
$year = (integer) $year; $year = (int) $year;
$month = (integer) $month; $month = (int) $month;
$day = (integer) $day; $day = (int) $day;
$baseYear = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar(); $baseYear = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar();
// Validate parameters // Validate parameters
@ -330,14 +339,14 @@ class DateTime
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) $excelDateValue; return (float) $excelDateValue;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
return (integer) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateValue); return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateValue);
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
return \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDateValue); return \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDateValue);
} }
} }
/** /**
* TIME * TIME.
* *
* The TIME function returns a value that represents a particular time. * The TIME function returns a value that represents a particular time.
* *
@ -348,6 +357,7 @@ class DateTime
* TIME(hour,minute,second) * TIME(hour,minute,second)
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @param int $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 * 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) = * will be treated as the hour value. For example, TIME(27,0,0) =
@ -359,6 +369,7 @@ class DateTime
* Any value greater than 59 will be converted to hours, minutes, * Any value greater than 59 will be converted to hours, minutes,
* and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148 * and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148
* or 12:33:20 AM * or 12:33:20 AM
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * @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 * depending on the value of the ReturnDateType flag
*/ */
@ -381,9 +392,9 @@ class DateTime
if ((!is_numeric($hour)) || (!is_numeric($minute)) || (!is_numeric($second))) { if ((!is_numeric($hour)) || (!is_numeric($minute)) || (!is_numeric($second))) {
return Functions::VALUE(); return Functions::VALUE();
} }
$hour = (integer) $hour; $hour = (int) $hour;
$minute = (integer) $minute; $minute = (int) $minute;
$second = (integer) $second; $second = (int) $second;
if ($second < 0) { if ($second < 0) {
$minute += floor($second / 60); $minute += floor($second / 60);
@ -423,7 +434,7 @@ class DateTime
return (float) \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second); return (float) \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
return (integer) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600 return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
$dayAdjust = 0; $dayAdjust = 0;
if ($hour < 0) { if ($hour < 0) {
@ -446,7 +457,7 @@ class DateTime
} }
/** /**
* DATEVALUE * DATEVALUE.
* *
* Returns a value that represents a particular date. * Returns a value that represents a particular date.
* Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp * Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp
@ -459,6 +470,7 @@ class DateTime
* DATEVALUE(dateValue) * DATEVALUE(dateValue)
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @param string $dateValue Text that represents a date in a Microsoft Excel date format. * @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 * For example, "1/30/2008" or "30-Jan-2008" are text strings within
* quotation marks that represent dates. Using the default date * quotation marks that represent dates. Using the default date
@ -467,6 +479,7 @@ class DateTime
* system in Excel for the Macintosh, date_text must represent a date * system in Excel for the Macintosh, date_text must represent a date
* from January 1, 1904, to December 31, 9999. DATEVALUE returns the * from January 1, 1904, to December 31, 9999. DATEVALUE returns the
* #VALUE! error value if date_text is out of this range. * #VALUE! error value if date_text is out of this range.
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * @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 * depending on the value of the ReturnDateType flag
*/ */
@ -485,14 +498,13 @@ class DateTime
if ((is_numeric($t)) && ($t > 31)) { if ((is_numeric($t)) && ($t > 31)) {
if ($yearFound) { if ($yearFound) {
return Functions::VALUE(); return Functions::VALUE();
} else { }
if ($t < 100) { if ($t < 100) {
$t += 1900; $t += 1900;
} }
$yearFound = true; $yearFound = true;
} }
} }
}
if ((count($t1) == 1) && (strpos($t, ':') != false)) { if ((count($t1) == 1) && (strpos($t, ':') != false)) {
// We've been fed a time value without any date // We've been fed a time value without any date
return 0.0; return 0.0;
@ -571,7 +583,7 @@ class DateTime
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) $excelDateValue; return (float) $excelDateValue;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
return (integer) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateValue); return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateValue);
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
return new \DateTime($PHPDateArray['year'] . '-' . $PHPDateArray['month'] . '-' . $PHPDateArray['day'] . ' 00:00:00'); return new \DateTime($PHPDateArray['year'] . '-' . $PHPDateArray['month'] . '-' . $PHPDateArray['day'] . ' 00:00:00');
} }
@ -581,7 +593,7 @@ class DateTime
} }
/** /**
* TIMEVALUE * TIMEVALUE.
* *
* Returns a value that represents a particular time. * Returns a value that represents a particular time.
* Use TIMEVALUE to convert a time represented by a text string to an Excel or PHP date/time stamp * Use TIMEVALUE to convert a time represented by a text string to an Excel or PHP date/time stamp
@ -594,10 +606,12 @@ class DateTime
* TIMEVALUE(timeValue) * TIMEVALUE(timeValue)
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @param string $timeValue A text string that represents a time in any one of the Microsoft * @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 * Excel time formats; for example, "6:45 PM" and "18:45" text strings
* within quotation marks that represent time. * within quotation marks that represent time.
* Date information in time_text is ignored. * Date information in time_text is ignored.
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * @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 * depending on the value of the ReturnDateType flag
*/ */
@ -631,7 +645,7 @@ class DateTime
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) $excelDateValue; return (float) $excelDateValue;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
return (integer) $phpDateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateValue + 25569) - 3600; return (int) $phpDateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateValue + 25569) - 3600;
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
return new \DateTime('1900-01-01 ' . $PHPDateArray['hour'] . ':' . $PHPDateArray['minute'] . ':' . $PHPDateArray['second']); return new \DateTime('1900-01-01 ' . $PHPDateArray['hour'] . ':' . $PHPDateArray['minute'] . ':' . $PHPDateArray['second']);
} }
@ -641,13 +655,14 @@ class DateTime
} }
/** /**
* DATEDIF * DATEDIF.
* *
* @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object * @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object
* or a standard date string * or a standard date string
* @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object
* or a standard date string * or a standard date string
* @param string $unit * @param string $unit
*
* @return int Interval between the dates * @return int Interval between the dates
*/ */
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D')
@ -684,17 +699,17 @@ class DateTime
$retVal = Functions::NAN(); $retVal = Functions::NAN();
switch ($unit) { switch ($unit) {
case 'D': case 'D':
$retVal = intval($difference); $retVal = (int) $difference;
break; break;
case 'M': case 'M':
$retVal = intval($endMonths - $startMonths) + (intval($endYears - $startYears) * 12); $retVal = (int) ($endMonths - $startMonths) + ((int) ($endYears - $startYears) * 12);
// We're only interested in full months // We're only interested in full months
if ($endDays < $startDays) { if ($endDays < $startDays) {
--$retVal; --$retVal;
} }
break; break;
case 'Y': case 'Y':
$retVal = intval($endYears - $startYears); $retVal = (int) ($endYears - $startYears);
// We're only interested in full months // We're only interested in full months
if ($endMonths < $startMonths) { if ($endMonths < $startMonths) {
--$retVal; --$retVal;
@ -716,7 +731,7 @@ class DateTime
} }
break; break;
case 'YM': case 'YM':
$retVal = intval($endMonths - $startMonths); $retVal = (int) ($endMonths - $startMonths);
if ($retVal < 0) { if ($retVal < 0) {
$retVal += 12; $retVal += 12;
} }
@ -726,7 +741,7 @@ class DateTime
} }
break; break;
case 'YD': case 'YD':
$retVal = intval($difference); $retVal = (int) $difference;
if ($endYears > $startYears) { if ($endYears > $startYears) {
$isLeapStartYear = $PHPStartDateObject->format('L'); $isLeapStartYear = $PHPStartDateObject->format('L');
$wasLeapEndYear = $PHPEndDateObject->format('L'); $wasLeapEndYear = $PHPEndDateObject->format('L');
@ -757,7 +772,7 @@ class DateTime
} }
/** /**
* DAYS360 * DAYS360.
* *
* Returns the number of days between two dates based on a 360-day year (twelve 30-day months), * Returns the number of days between two dates based on a 360-day year (twelve 30-day months),
* which is used in some accounting calculations. Use this function to help compute payments if * which is used in some accounting calculations. Use this function to help compute payments if
@ -767,6 +782,7 @@ class DateTime
* DAYS360(startDate,endDate[,method]) * DAYS360(startDate,endDate[,method])
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string * PHP DateTime object, or a standard date string
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
@ -782,6 +798,7 @@ class DateTime
* TRUE: European method. Starting dates and ending dates that * TRUE: European method. Starting dates and ending dates that
* occur on the 31st of a month become equal to the 30th of the * occur on the 31st of a month become equal to the 30th of the
* same month. * same month.
*
* @return int 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) public static function DAYS360($startDate = 0, $endDate = 0, $method = false)
@ -815,7 +832,7 @@ class DateTime
} }
/** /**
* YEARFRAC * YEARFRAC.
* *
* Calculates the fraction of the year represented by the number of whole days between two dates * Calculates the fraction of the year represented by the number of whole days between two dates
* (the start_date and the end_date). * (the start_date and the end_date).
@ -826,6 +843,7 @@ class DateTime
* YEARFRAC(startDate,endDate[,method]) * YEARFRAC(startDate,endDate[,method])
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string * PHP DateTime object, or a standard date string
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
@ -836,6 +854,7 @@ class DateTime
* 2 Actual/360 * 2 Actual/360
* 3 Actual/365 * 3 Actual/365
* 4 European 30/360 * 4 European 30/360
*
* @return float fraction of the year * @return float fraction of the year
*/ */
public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0)
@ -913,7 +932,7 @@ class DateTime
} }
/** /**
* NETWORKDAYS * NETWORKDAYS.
* *
* Returns the number of whole working days between start_date and end_date. Working days * Returns the number of whole working days between start_date and end_date. Working days
* exclude weekends and any dates identified in holidays. * exclude weekends and any dates identified in holidays.
@ -924,10 +943,12 @@ class DateTime
* NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]]) * NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]])
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string * PHP DateTime object, or a standard date string
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string * PHP DateTime object, or a standard date string
*
* @return int Interval between the dates * @return int Interval between the dates
*/ */
public static function NETWORKDAYS($startDate, $endDate) public static function NETWORKDAYS($startDate, $endDate)
@ -993,7 +1014,7 @@ class DateTime
} }
/** /**
* WORKDAY * WORKDAY.
* *
* Returns the date that is the indicated number of working days before or after a date (the * Returns the date that is the indicated number of working days before or after a date (the
* starting date). Working days exclude weekends and any dates identified as holidays. * starting date). Working days exclude weekends and any dates identified as holidays.
@ -1004,11 +1025,13 @@ class DateTime
* WORKDAY(startDate,endDays[,holidays[,holiday[,...]]]) * WORKDAY(startDate,endDays[,holidays[,holiday[,...]]])
* *
* @category Date/Time Functions * @category Date/Time Functions
*
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string * PHP DateTime object, or a standard date string
* @param int $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 * startDate. A positive value for days yields a future date; a
* negative value yields a past date. * negative value yields a past date.
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * @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 * depending on the value of the ReturnDateType flag
*/ */
@ -1043,7 +1066,7 @@ class DateTime
} }
// Add endDays // Add endDays
$endDate = (float) $startDate + (intval($endDays / 5) * 7) + ($endDays % 5); $endDate = (float) $startDate + ((int) ($endDays / 5) * 7) + ($endDays % 5);
// Adjust the calculated end date if it falls over a weekend // Adjust the calculated end date if it falls over a weekend
$endDoW = self::WEEKDAY($endDate, 3); $endDoW = self::WEEKDAY($endDate, 3);
@ -1097,14 +1120,14 @@ class DateTime
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) $endDate; return (float) $endDate;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
return (integer) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($endDate); return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($endDate);
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
return \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($endDate); return \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($endDate);
} }
} }
/** /**
* DAYOFMONTH * DAYOFMONTH.
* *
* Returns the day of the month, for a specified date. The day is given as an integer * Returns the day of the month, for a specified date. The day is given as an integer
* ranging from 1 to 31. * ranging from 1 to 31.
@ -1114,6 +1137,7 @@ class DateTime
* *
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string * PHP DateTime object, or a standard date string
*
* @return int Day of the month * @return int Day of the month
*/ */
public static function DAYOFMONTH($dateValue = 1) public static function DAYOFMONTH($dateValue = 1)
@ -1137,7 +1161,7 @@ class DateTime
} }
/** /**
* WEEKDAY * WEEKDAY.
* *
* Returns the day of the week for a specified date. The day is given as an integer * Returns the day of the week for a specified date. The day is given as an integer
* ranging from 0 to 7 (dependent on the requested style). * ranging from 0 to 7 (dependent on the requested style).
@ -1151,6 +1175,7 @@ class DateTime
* 1 or omitted Numbers 1 (Sunday) through 7 (Saturday). * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday).
* 2 Numbers 1 (Monday) through 7 (Sunday). * 2 Numbers 1 (Monday) through 7 (Sunday).
* 3 Numbers 0 (Monday) through 6 (Sunday). * 3 Numbers 0 (Monday) through 6 (Sunday).
*
* @return int Day of the week value * @return int Day of the week value
*/ */
public static function WEEKDAY($dateValue = 1, $style = 1) public static function WEEKDAY($dateValue = 1, $style = 1)
@ -1209,7 +1234,7 @@ class DateTime
} }
/** /**
* WEEKNUM * WEEKNUM.
* *
* Returns the week of the year for a specified date. * Returns the week of the year for a specified date.
* The WEEKNUM function considers the week containing January 1 to be the first week of the year. * The WEEKNUM function considers the week containing January 1 to be the first week of the year.
@ -1226,6 +1251,7 @@ class DateTime
* @param int $method Week begins on Sunday or Monday * @param int $method Week begins on Sunday or Monday
* 1 or omitted Week begins on Sunday. * 1 or omitted Week begins on Sunday.
* 2 Week begins on Monday. * 2 Week begins on Monday.
*
* @return int Week Number * @return int Week Number
*/ */
public static function WEEKNUM($dateValue = 1, $method = 1) public static function WEEKNUM($dateValue = 1, $method = 1)
@ -1265,7 +1291,7 @@ class DateTime
} }
/** /**
* MONTHOFYEAR * MONTHOFYEAR.
* *
* Returns the month of a date represented by a serial number. * Returns the month of a date represented by a serial number.
* The month is given as an integer, ranging from 1 (January) to 12 (December). * The month is given as an integer, ranging from 1 (January) to 12 (December).
@ -1275,6 +1301,7 @@ class DateTime
* *
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string * PHP DateTime object, or a standard date string
*
* @return int Month of the year * @return int Month of the year
*/ */
public static function MONTHOFYEAR($dateValue = 1) public static function MONTHOFYEAR($dateValue = 1)
@ -1297,7 +1324,7 @@ class DateTime
} }
/** /**
* YEAR * YEAR.
* *
* Returns the year corresponding to a date. * Returns the year corresponding to a date.
* The year is returned as an integer in the range 1900-9999. * The year is returned as an integer in the range 1900-9999.
@ -1307,6 +1334,7 @@ class DateTime
* *
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string * PHP DateTime object, or a standard date string
*
* @return int Year * @return int Year
*/ */
public static function YEAR($dateValue = 1) public static function YEAR($dateValue = 1)
@ -1328,7 +1356,7 @@ class DateTime
} }
/** /**
* HOUROFDAY * HOUROFDAY.
* *
* Returns the hour of a time value. * Returns the hour of a time value.
* The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.). * The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).
@ -1338,6 +1366,7 @@ class DateTime
* *
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string * PHP DateTime object, or a standard time string
*
* @return int Hour * @return int Hour
*/ */
public static function HOUROFDAY($timeValue = 0) public static function HOUROFDAY($timeValue = 0)
@ -1368,7 +1397,7 @@ class DateTime
} }
/** /**
* MINUTE * MINUTE.
* *
* Returns the minutes of a time value. * Returns the minutes of a time value.
* The minute is given as an integer, ranging from 0 to 59. * The minute is given as an integer, ranging from 0 to 59.
@ -1378,6 +1407,7 @@ class DateTime
* *
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string * PHP DateTime object, or a standard time string
*
* @return int Minute * @return int Minute
*/ */
public static function MINUTE($timeValue = 0) public static function MINUTE($timeValue = 0)
@ -1408,7 +1438,7 @@ class DateTime
} }
/** /**
* SECOND * SECOND.
* *
* Returns the seconds of a time value. * Returns the seconds of a time value.
* The second is given as an integer in the range 0 (zero) to 59. * The second is given as an integer in the range 0 (zero) to 59.
@ -1418,6 +1448,7 @@ class DateTime
* *
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string * PHP DateTime object, or a standard time string
*
* @return int Second * @return int Second
*/ */
public static function SECOND($timeValue = 0) public static function SECOND($timeValue = 0)
@ -1448,7 +1479,7 @@ class DateTime
} }
/** /**
* EDATE * EDATE.
* *
* Returns the serial number that represents the date that is the indicated number of months * Returns the serial number that represents the date that is the indicated number of months
* before or after a specified date (the start_date). * before or after a specified date (the start_date).
@ -1463,6 +1494,7 @@ class DateTime
* @param int $adjustmentMonths The number of months before or after start_date. * @param int $adjustmentMonths The number of months before or after start_date.
* A positive value for months yields a future date; * A positive value for months yields a future date;
* a negative value yields a past date. * a negative value yields a past date.
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * @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 * depending on the value of the ReturnDateType flag
*/ */
@ -1487,14 +1519,14 @@ class DateTime
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject); return (float) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject);
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
return (integer) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject)); return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject));
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
return $PHPDateObject; return $PHPDateObject;
} }
} }
/** /**
* EOMONTH * EOMONTH.
* *
* Returns the date value for the last day of the month that is the indicated number of months * Returns the date value for the last day of the month that is the indicated number of months
* before or after start_date. * before or after start_date.
@ -1508,6 +1540,7 @@ class DateTime
* @param int $adjustmentMonths The number of months before or after start_date. * @param int $adjustmentMonths The number of months before or after start_date.
* A positive value for months yields a future date; * A positive value for months yields a future date;
* a negative value yields a past date. * a negative value yields a past date.
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * @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 * depending on the value of the ReturnDateType flag
*/ */
@ -1535,7 +1568,7 @@ class DateTime
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject); return (float) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject);
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
return (integer) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject)); return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject));
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
return $PHPDateObject; return $PHPDateObject;
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,13 +20,14 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Exception extends \PhpOffice\PhpSpreadsheet\Exception class Exception extends \PhpOffice\PhpSpreadsheet\Exception
{ {
/** /**
* Error handler callback * Error handler callback.
* *
* @param mixed $code * @param mixed $code
* @param mixed $string * @param mixed $string

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,13 +20,14 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class ExceptionHandler class ExceptionHandler
{ {
/** /**
* Register errorhandler * Register errorhandler.
*/ */
public function __construct() public function __construct()
{ {
@ -34,7 +35,7 @@ class ExceptionHandler
} }
/** /**
* Unregister errorhandler * Unregister errorhandler.
*/ */
public function __destruct() public function __destruct()
{ {

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -66,23 +67,24 @@ class FormulaParser
const OPERATORS_POSTFIX = '%'; const OPERATORS_POSTFIX = '%';
/** /**
* Formula * Formula.
* *
* @var string * @var string
*/ */
private $formula; private $formula;
/** /**
* Tokens * Tokens.
* *
* @var FormulaToken[] * @var FormulaToken[]
*/ */
private $tokens = []; private $tokens = [];
/** /**
* Create a new FormulaParser * Create a new FormulaParser.
* *
* @param string $pFormula Formula to parse * @param string $pFormula Formula to parse
*
* @throws Exception * @throws Exception
*/ */
public function __construct($pFormula = '') public function __construct($pFormula = '')
@ -99,7 +101,7 @@ class FormulaParser
} }
/** /**
* Get Formula * Get Formula.
* *
* @return string * @return string
*/ */
@ -109,23 +111,24 @@ class FormulaParser
} }
/** /**
* Get Token * Get Token.
* *
* @param int $pId Token id * @param int $pId Token id
*
* @throws Exception * @throws Exception
*
* @return string * @return string
*/ */
public function getToken($pId = 0) public function getToken($pId = 0)
{ {
if (isset($this->tokens[$pId])) { if (isset($this->tokens[$pId])) {
return $this->tokens[$pId]; return $this->tokens[$pId];
} else {
throw new Exception("Token with id $pId does not exist.");
} }
throw new Exception("Token with id $pId does not exist.");
} }
/** /**
* Get Token count * Get Token count.
* *
* @return int * @return int
*/ */
@ -135,7 +138,7 @@ class FormulaParser
} }
/** /**
* Get Tokens * Get Tokens.
* *
* @return FormulaToken[] * @return FormulaToken[]
*/ */
@ -145,7 +148,7 @@ class FormulaParser
} }
/** /**
* Parse to tokens * Parse to tokens.
*/ */
private function parseToTokens() private function parseToTokens()
{ {
@ -154,7 +157,7 @@ class FormulaParser
// Check if the formula has a valid starting = // Check if the formula has a valid starting =
$formulaLength = strlen($this->formula); $formulaLength = strlen($this->formula);
if ($formulaLength < 2 || $this->formula{0} != '=') { if ($formulaLength < 2 || $this->formula[0] != '=') {
return; return;
} }
@ -176,8 +179,8 @@ class FormulaParser
// embeds are doubled // embeds are doubled
// end marks token // end marks token
if ($inString) { if ($inString) {
if ($this->formula{$index} == self::QUOTE_DOUBLE) { if ($this->formula[$index] == self::QUOTE_DOUBLE) {
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == self::QUOTE_DOUBLE)) { if ((($index + 2) <= $formulaLength) && ($this->formula[$index + 1] == self::QUOTE_DOUBLE)) {
$value .= self::QUOTE_DOUBLE; $value .= self::QUOTE_DOUBLE;
++$index; ++$index;
} else { } else {
@ -186,7 +189,7 @@ class FormulaParser
$value = ''; $value = '';
} }
} else { } else {
$value .= $this->formula{$index}; $value .= $this->formula[$index];
} }
++$index; ++$index;
continue; continue;
@ -196,15 +199,15 @@ class FormulaParser
// embeds are double // embeds are double
// end does not mark a token // end does not mark a token
if ($inPath) { if ($inPath) {
if ($this->formula{$index} == self::QUOTE_SINGLE) { if ($this->formula[$index] == self::QUOTE_SINGLE) {
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == self::QUOTE_SINGLE)) { if ((($index + 2) <= $formulaLength) && ($this->formula[$index + 1] == self::QUOTE_SINGLE)) {
$value .= self::QUOTE_SINGLE; $value .= self::QUOTE_SINGLE;
++$index; ++$index;
} else { } else {
$inPath = false; $inPath = false;
} }
} else { } else {
$value .= $this->formula{$index}; $value .= $this->formula[$index];
} }
++$index; ++$index;
continue; continue;
@ -214,10 +217,10 @@ class FormulaParser
// no embeds (changed to "()" by Excel) // no embeds (changed to "()" by Excel)
// end does not mark a token // end does not mark a token
if ($inRange) { if ($inRange) {
if ($this->formula{$index} == self::BRACKET_CLOSE) { if ($this->formula[$index] == self::BRACKET_CLOSE) {
$inRange = false; $inRange = false;
} }
$value .= $this->formula{$index}; $value .= $this->formula[$index];
++$index; ++$index;
continue; continue;
} }
@ -225,7 +228,7 @@ class FormulaParser
// error values // error values
// end marks a token, determined from absolute list of values // end marks a token, determined from absolute list of values
if ($inError) { if ($inError) {
$value .= $this->formula{$index}; $value .= $this->formula[$index];
++$index; ++$index;
if (in_array($value, $ERRORS)) { if (in_array($value, $ERRORS)) {
$inError = false; $inError = false;
@ -236,10 +239,10 @@ class FormulaParser
} }
// scientific notation check // scientific notation check
if (strpos(self::OPERATORS_SN, $this->formula{$index}) !== false) { if (strpos(self::OPERATORS_SN, $this->formula[$index]) !== false) {
if (strlen($value) > 1) { if (strlen($value) > 1) {
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula{$index}) != 0) { if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula[$index]) != 0) {
$value .= $this->formula{$index}; $value .= $this->formula[$index];
++$index; ++$index;
continue; continue;
} }
@ -249,7 +252,7 @@ class FormulaParser
// independent character evaluation (order not important) // independent character evaluation (order not important)
// establish state-dependent character evaluations // establish state-dependent character evaluations
if ($this->formula{$index} == self::QUOTE_DOUBLE) { if ($this->formula[$index] == self::QUOTE_DOUBLE) {
if (strlen($value > 0)) { if (strlen($value > 0)) {
// unexpected // unexpected
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
@ -260,7 +263,7 @@ class FormulaParser
continue; continue;
} }
if ($this->formula{$index} == self::QUOTE_SINGLE) { if ($this->formula[$index] == self::QUOTE_SINGLE) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
// unexpected // unexpected
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
@ -271,14 +274,14 @@ class FormulaParser
continue; continue;
} }
if ($this->formula{$index} == self::BRACKET_OPEN) { if ($this->formula[$index] == self::BRACKET_OPEN) {
$inRange = true; $inRange = true;
$value .= self::BRACKET_OPEN; $value .= self::BRACKET_OPEN;
++$index; ++$index;
continue; continue;
} }
if ($this->formula{$index} == self::ERROR_START) { if ($this->formula[$index] == self::ERROR_START) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
// unexpected // unexpected
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
@ -291,7 +294,7 @@ class FormulaParser
} }
// mark start and end of arrays and array rows // mark start and end of arrays and array rows
if ($this->formula{$index} == self::BRACE_OPEN) { if ($this->formula[$index] == self::BRACE_OPEN) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
// unexpected // unexpected
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
@ -310,7 +313,7 @@ class FormulaParser
continue; continue;
} }
if ($this->formula{$index} == self::SEMICOLON) { if ($this->formula[$index] == self::SEMICOLON) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
$value = ''; $value = '';
@ -332,7 +335,7 @@ class FormulaParser
continue; continue;
} }
if ($this->formula{$index} == self::BRACE_CLOSE) { if ($this->formula[$index] == self::BRACE_CLOSE) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
$value = ''; $value = '';
@ -353,14 +356,14 @@ class FormulaParser
} }
// trim white-space // trim white-space
if ($this->formula{$index} == self::WHITESPACE) { if ($this->formula[$index] == self::WHITESPACE) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND); $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; ++$index;
while (($this->formula{$index} == self::WHITESPACE) && ($index < $formulaLength)) { while (($this->formula[$index] == self::WHITESPACE) && ($index < $formulaLength)) {
++$index; ++$index;
} }
continue; continue;
@ -380,29 +383,29 @@ class FormulaParser
} }
// standard infix operators // standard infix operators
if (strpos(self::OPERATORS_INFIX, $this->formula{$index}) !== false) { if (strpos(self::OPERATORS_INFIX, $this->formula[$index]) !== false) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
$value = ''; $value = '';
} }
$tokens1[] = new FormulaToken($this->formula{$index}, FormulaToken::TOKEN_TYPE_OPERATORINFIX); $tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORINFIX);
++$index; ++$index;
continue; continue;
} }
// standard postfix operators (only one) // standard postfix operators (only one)
if (strpos(self::OPERATORS_POSTFIX, $this->formula{$index}) !== false) { if (strpos(self::OPERATORS_POSTFIX, $this->formula[$index]) !== false) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
$value = ''; $value = '';
} }
$tokens1[] = new FormulaToken($this->formula{$index}, FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX); $tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
++$index; ++$index;
continue; continue;
} }
// start subexpression or function // start subexpression or function
if ($this->formula{$index} == self::PAREN_OPEN) { if ($this->formula[$index] == self::PAREN_OPEN) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tmp = new FormulaToken($value, FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START); $tmp = new FormulaToken($value, FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp; $tokens1[] = $tmp;
@ -418,7 +421,7 @@ class FormulaParser
} }
// function, subexpression, or array parameters, or operand unions // function, subexpression, or array parameters, or operand unions
if ($this->formula{$index} == self::COMMA) { if ($this->formula[$index] == self::COMMA) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
$value = ''; $value = '';
@ -439,7 +442,7 @@ class FormulaParser
} }
// stop subexpression // stop subexpression
if ($this->formula{$index} == self::PAREN_CLOSE) { if ($this->formula[$index] == self::PAREN_CLOSE) {
if (strlen($value) > 0) { if (strlen($value) > 0) {
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
$value = ''; $value = '';
@ -455,7 +458,7 @@ class FormulaParser
} }
// token accumulation // token accumulation
$value .= $this->formula{$index}; $value .= $this->formula[$index];
++$index; ++$index;
} }

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -75,28 +76,28 @@ class FormulaToken
const TOKEN_SUBTYPE_UNION = 'Union'; const TOKEN_SUBTYPE_UNION = 'Union';
/** /**
* Value * Value.
* *
* @var string * @var string
*/ */
private $value; private $value;
/** /**
* Token Type (represented by TOKEN_TYPE_*) * Token Type (represented by TOKEN_TYPE_*).
* *
* @var string * @var string
*/ */
private $tokenType; private $tokenType;
/** /**
* Token SubType (represented by TOKEN_SUBTYPE_*) * Token SubType (represented by TOKEN_SUBTYPE_*).
* *
* @var string * @var string
*/ */
private $tokenSubType; private $tokenSubType;
/** /**
* Create a new FormulaToken * Create a new FormulaToken.
* *
* @param string $pValue * @param string $pValue
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*) * @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
@ -111,7 +112,7 @@ class FormulaToken
} }
/** /**
* Get Value * Get Value.
* *
* @return string * @return string
*/ */
@ -121,7 +122,7 @@ class FormulaToken
} }
/** /**
* Set Value * Set Value.
* *
* @param string $value * @param string $value
*/ */
@ -131,7 +132,7 @@ class FormulaToken
} }
/** /**
* Get Token Type (represented by TOKEN_TYPE_*) * Get Token Type (represented by TOKEN_TYPE_*).
* *
* @return string * @return string
*/ */
@ -141,7 +142,7 @@ class FormulaToken
} }
/** /**
* Set Token Type * Set Token Type.
* *
* @param string $value * @param string $value
*/ */
@ -151,7 +152,7 @@ class FormulaToken
} }
/** /**
* Get Token SubType (represented by TOKEN_SUBTYPE_*) * Get Token SubType (represented by TOKEN_SUBTYPE_*).
* *
* @return string * @return string
*/ */
@ -161,7 +162,7 @@ class FormulaToken
} }
/** /**
* Set Token SubType * Set Token SubType.
* *
* @param string $value * @param string $value
*/ */

View File

@ -15,7 +15,7 @@ define('MAX_ITERATIONS', 256);
define('PRECISION', 8.88E-016); define('PRECISION', 8.88E-016);
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -32,6 +32,7 @@ define('PRECISION', 8.88E-016);
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -47,21 +48,21 @@ class Functions
const RETURNDATE_EXCEL = 'E'; const RETURNDATE_EXCEL = 'E';
/** /**
* Compatibility mode to use for error checking and responses * Compatibility mode to use for error checking and responses.
* *
* @var string * @var string
*/ */
protected static $compatibilityMode = self::COMPATIBILITY_EXCEL; protected static $compatibilityMode = self::COMPATIBILITY_EXCEL;
/** /**
* Data Type to use when returning date values * Data Type to use when returning date values.
* *
* @var string * @var string
*/ */
protected static $returnDateType = self::RETURNDATE_EXCEL; protected static $returnDateType = self::RETURNDATE_EXCEL;
/** /**
* List of error codes * List of error codes.
* *
* @var array * @var array
*/ */
@ -77,14 +78,16 @@ class Functions
]; ];
/** /**
* Set the Compatibility Mode * Set the Compatibility Mode.
* *
* @category Function Configuration * @category Function Configuration
*
* @param string $compatibilityMode Compatibility Mode * @param string $compatibilityMode Compatibility Mode
* Permitted values are: * Permitted values are:
* Functions::COMPATIBILITY_EXCEL 'Excel' * Functions::COMPATIBILITY_EXCEL 'Excel'
* Functions::COMPATIBILITY_GNUMERIC 'Gnumeric' * Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
* Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc' * Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
*
* @return bool (Success or Failure) * @return bool (Success or Failure)
*/ */
public static function setCompatibilityMode($compatibilityMode) public static function setCompatibilityMode($compatibilityMode)
@ -102,9 +105,10 @@ class Functions
} }
/** /**
* Return the current Compatibility Mode * Return the current Compatibility Mode.
* *
* @category Function Configuration * @category Function Configuration
*
* @return string Compatibility Mode * @return string Compatibility Mode
* Possible Return values are: * Possible Return values are:
* Functions::COMPATIBILITY_EXCEL 'Excel' * Functions::COMPATIBILITY_EXCEL 'Excel'
@ -117,14 +121,16 @@ class Functions
} }
/** /**
* Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object) * Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object).
* *
* @category Function Configuration * @category Function Configuration
*
* @param string $returnDateType Return Date Format * @param string $returnDateType Return Date Format
* Permitted values are: * Permitted values are:
* Functions::RETURNDATE_PHP_NUMERIC 'P' * Functions::RETURNDATE_PHP_NUMERIC 'P'
* Functions::RETURNDATE_PHP_OBJECT 'O' * Functions::RETURNDATE_PHP_OBJECT 'O'
* Functions::RETURNDATE_EXCEL 'E' * Functions::RETURNDATE_EXCEL 'E'
*
* @return bool Success or failure * @return bool Success or failure
*/ */
public static function setReturnDateType($returnDateType) public static function setReturnDateType($returnDateType)
@ -142,9 +148,10 @@ class Functions
} }
/** /**
* Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object) * Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object).
* *
* @category Function Configuration * @category Function Configuration
*
* @return string Return Date Format * @return string Return Date Format
* Possible Return values are: * Possible Return values are:
* Functions::RETURNDATE_PHP_NUMERIC 'P' * Functions::RETURNDATE_PHP_NUMERIC 'P'
@ -157,9 +164,10 @@ class Functions
} }
/** /**
* DUMMY * DUMMY.
* *
* @category Error Returns * @category Error Returns
*
* @return string #Not Yet Implemented * @return string #Not Yet Implemented
*/ */
public static function DUMMY() public static function DUMMY()
@ -168,9 +176,10 @@ class Functions
} }
/** /**
* DIV0 * DIV0.
* *
* @category Error Returns * @category Error Returns
*
* @return string #Not Yet Implemented * @return string #Not Yet Implemented
*/ */
public static function DIV0() public static function DIV0()
@ -179,7 +188,7 @@ class Functions
} }
/** /**
* NA * NA.
* *
* Excel Function: * Excel Function:
* =NA() * =NA()
@ -188,6 +197,7 @@ class Functions
* #N/A is the error value that means "no value is available." * #N/A is the error value that means "no value is available."
* *
* @category Logical Functions * @category Logical Functions
*
* @return string #N/A! * @return string #N/A!
*/ */
public static function NA() public static function NA()
@ -196,11 +206,12 @@ class Functions
} }
/** /**
* NaN * NaN.
* *
* Returns the error value #NUM! * Returns the error value #NUM!
* *
* @category Error Returns * @category Error Returns
*
* @return string #NUM! * @return string #NUM!
*/ */
public static function NAN() public static function NAN()
@ -209,11 +220,12 @@ class Functions
} }
/** /**
* NAME * NAME.
* *
* Returns the error value #NAME? * Returns the error value #NAME?
* *
* @category Error Returns * @category Error Returns
*
* @return string #NAME? * @return string #NAME?
*/ */
public static function NAME() public static function NAME()
@ -222,11 +234,12 @@ class Functions
} }
/** /**
* REF * REF.
* *
* Returns the error value #REF! * Returns the error value #REF!
* *
* @category Error Returns * @category Error Returns
*
* @return string #REF! * @return string #REF!
*/ */
public static function REF() public static function REF()
@ -235,11 +248,12 @@ class Functions
} }
/** /**
* NULL * NULL.
* *
* Returns the error value #NULL! * Returns the error value #NULL!
* *
* @category Error Returns * @category Error Returns
*
* @return string #NULL! * @return string #NULL!
*/ */
public static function null() public static function null()
@ -248,11 +262,12 @@ class Functions
} }
/** /**
* VALUE * VALUE.
* *
* Returns the error value #VALUE! * Returns the error value #VALUE!
* *
* @category Error Returns * @category Error Returns
*
* @return string #VALUE! * @return string #VALUE!
*/ */
public static function VALUE() public static function VALUE()
@ -278,16 +293,16 @@ class Functions
public static function ifCondition($condition) public static function ifCondition($condition)
{ {
$condition = self::flattenSingleValue($condition); $condition = self::flattenSingleValue($condition);
if (!isset($condition{0})) { if (!isset($condition[0])) {
$condition = '=""'; $condition = '=""';
} }
if (!in_array($condition{0}, ['>', '<', '='])) { if (!in_array($condition[0], ['>', '<', '='])) {
if (!is_numeric($condition)) { if (!is_numeric($condition)) {
$condition = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($condition)); $condition = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($condition));
} }
return '=' . $condition; return '=' . $condition;
} else { }
preg_match('/([<>=]+)(.*)/', $condition, $matches); preg_match('/([<>=]+)(.*)/', $condition, $matches);
list(, $operator, $operand) = $matches; list(, $operator, $operand) = $matches;
@ -298,12 +313,12 @@ class Functions
return $operator . $operand; return $operator . $operand;
} }
}
/** /**
* ERROR_TYPE * ERROR_TYPE.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function errorType($value = '') public static function errorType($value = '')
@ -322,9 +337,10 @@ class Functions
} }
/** /**
* IS_BLANK * IS_BLANK.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function isBlank($value = null) public static function isBlank($value = null)
@ -337,9 +353,10 @@ class Functions
} }
/** /**
* IS_ERR * IS_ERR.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function isErr($value = '') public static function isErr($value = '')
@ -350,9 +367,10 @@ class Functions
} }
/** /**
* IS_ERROR * IS_ERROR.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function isError($value = '') public static function isError($value = '')
@ -367,9 +385,10 @@ class Functions
} }
/** /**
* IS_NA * IS_NA.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function isNa($value = '') public static function isNa($value = '')
@ -380,9 +399,10 @@ class Functions
} }
/** /**
* IS_EVEN * IS_EVEN.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return string|bool * @return string|bool
*/ */
public static function isEven($value = null) public static function isEven($value = null)
@ -399,9 +419,10 @@ class Functions
} }
/** /**
* IS_ODD * IS_ODD.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return string|bool * @return string|bool
*/ */
public static function isOdd($value = null) public static function isOdd($value = null)
@ -418,9 +439,10 @@ class Functions
} }
/** /**
* IS_NUMBER * IS_NUMBER.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function isNumber($value = null) public static function isNumber($value = null)
@ -435,9 +457,10 @@ class Functions
} }
/** /**
* IS_LOGICAL * IS_LOGICAL.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function isLogical($value = null) public static function isLogical($value = null)
@ -448,9 +471,10 @@ class Functions
} }
/** /**
* IS_TEXT * IS_TEXT.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function isText($value = null) public static function isText($value = null)
@ -461,9 +485,10 @@ class Functions
} }
/** /**
* IS_NONTEXT * IS_NONTEXT.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function isNonText($value = null) public static function isNonText($value = null)
@ -472,11 +497,13 @@ class Functions
} }
/** /**
* N * N.
* *
* Returns a value converted to a number * Returns a value converted to a number
* *
* @param value The value you want converted * @param value The value you want converted
* @param null|mixed $value
*
* @return number N converts values listed in the following table * @return number N converts values listed in the following table
* If value is or refers to N returns * If value is or refers to N returns
* A number That number * A number That number
@ -498,10 +525,10 @@ class Functions
case 'integer': case 'integer':
return $value; return $value;
case 'boolean': case 'boolean':
return (integer) $value; return (int) $value;
case 'string': case 'string':
// Errors // Errors
if ((strlen($value) > 0) && ($value{0} == '#')) { if ((strlen($value) > 0) && ($value[0] == '#')) {
return $value; return $value;
} }
break; break;
@ -511,11 +538,13 @@ class Functions
} }
/** /**
* TYPE * TYPE.
* *
* Returns a number that identifies the type of a value * Returns a number that identifies the type of a value
* *
* @param value The value you want tested * @param value The value you want tested
* @param null|mixed $value
*
* @return number N converts values listed in the following table * @return number N converts values listed in the following table
* If value is or refers to N returns * If value is or refers to N returns
* A number 1 * A number 1
@ -551,7 +580,7 @@ class Functions
return 64; return 64;
} elseif (is_string($value)) { } elseif (is_string($value)) {
// Errors // Errors
if ((strlen($value) > 0) && ($value{0} == '#')) { if ((strlen($value) > 0) && ($value[0] == '#')) {
return 16; return 16;
} }
@ -562,9 +591,10 @@ class Functions
} }
/** /**
* Convert a multi-dimensional array to a simple 1-dimensional array * Convert a multi-dimensional array to a simple 1-dimensional array.
* *
* @param array $array Array to be flattened * @param array $array Array to be flattened
*
* @return array Flattened array * @return array Flattened array
*/ */
public static function flattenArray($array) public static function flattenArray($array)
@ -594,9 +624,10 @@ class Functions
} }
/** /**
* Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing * Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing.
* *
* @param array $array Array to be flattened * @param array $array Array to be flattened
*
* @return array Flattened array * @return array Flattened array
*/ */
public static function flattenArrayIndexed($array) public static function flattenArrayIndexed($array)
@ -626,9 +657,10 @@ class Functions
} }
/** /**
* Convert an array to a single scalar value by extracting the first element * Convert an array to a single scalar value by extracting the first element.
* *
* @param mixed $value Array or scalar value * @param mixed $value Array or scalar value
*
* @return mixed * @return mixed
*/ */
public static function flattenSingleValue($value = '') public static function flattenSingleValue($value = '')

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,13 +20,14 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Logical class Logical
{ {
/** /**
* TRUE * TRUE.
* *
* Returns the boolean TRUE. * Returns the boolean TRUE.
* *
@ -34,6 +35,7 @@ class Logical
* =TRUE() * =TRUE()
* *
* @category Logical Functions * @category Logical Functions
*
* @return bool True * @return bool True
*/ */
public static function true() public static function true()
@ -42,7 +44,7 @@ class Logical
} }
/** /**
* FALSE * FALSE.
* *
* Returns the boolean FALSE. * Returns the boolean FALSE.
* *
@ -50,6 +52,7 @@ class Logical
* =FALSE() * =FALSE()
* *
* @category Logical Functions * @category Logical Functions
*
* @return bool False * @return bool False
*/ */
public static function false() public static function false()
@ -58,7 +61,7 @@ class Logical
} }
/** /**
* LOGICAL_AND * LOGICAL_AND.
* *
* Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE. * Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
* *
@ -74,8 +77,10 @@ class Logical
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value * the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
* *
* @category Logical Functions * @category Logical Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
* @return string|bool The logical AND of the arguments. *
* @return string|bool the logical AND of the arguments
*/ */
public static function logicalAnd() public static function logicalAnd()
{ {
@ -113,7 +118,7 @@ class Logical
} }
/** /**
* LOGICAL_OR * LOGICAL_OR.
* *
* Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE. * Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
* *
@ -129,8 +134,10 @@ class Logical
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value * the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
* *
* @category Logical Functions * @category Logical Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
* @return string|bool The logical OR of the arguments. *
* @return string|bool the logical OR of the arguments
*/ */
public static function logicalOr() public static function logicalOr()
{ {
@ -168,7 +175,7 @@ class Logical
} }
/** /**
* NOT * NOT.
* *
* Returns the boolean inverse of the argument. * Returns the boolean inverse of the argument.
* *
@ -183,8 +190,10 @@ class Logical
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value * the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
* *
* @category Logical Functions * @category Logical Functions
*
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE * @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
* @return bool|string The boolean inverse of the argument. *
* @return bool|string the boolean inverse of the argument
*/ */
public static function NOT($logical = false) public static function NOT($logical = false)
{ {
@ -195,16 +204,16 @@ class Logical
return false; return false;
} elseif (($logical == 'FALSE') || ($logical == \PhpOffice\PhpSpreadsheet\Calculation::getFALSE())) { } elseif (($logical == 'FALSE') || ($logical == \PhpOffice\PhpSpreadsheet\Calculation::getFALSE())) {
return true; return true;
} else {
return Functions::VALUE();
} }
return Functions::VALUE();
} }
return !$logical; return !$logical;
} }
/** /**
* STATEMENT_IF * STATEMENT_IF.
* *
* Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE. * Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
* *
@ -229,14 +238,16 @@ class Logical
* ReturnIfFalse can be another formula. * ReturnIfFalse can be another formula.
* *
* @category Logical Functions * @category Logical Functions
*
* @param mixed $condition Condition to evaluate * @param mixed $condition Condition to evaluate
* @param mixed $returnIfTrue Value to return when condition is true * @param mixed $returnIfTrue Value to return when condition is true
* @param mixed $returnIfFalse Optional value to return when condition is false * @param mixed $returnIfFalse Optional value to return when condition is false
*
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition * @return mixed The value of returnIfTrue or returnIfFalse determined by condition
*/ */
public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false) public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
{ {
$condition = (is_null($condition)) ? true : (boolean) Functions::flattenSingleValue($condition); $condition = (is_null($condition)) ? true : (bool) Functions::flattenSingleValue($condition);
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : Functions::flattenSingleValue($returnIfTrue); $returnIfTrue = (is_null($returnIfTrue)) ? 0 : Functions::flattenSingleValue($returnIfTrue);
$returnIfFalse = (is_null($returnIfFalse)) ? false : Functions::flattenSingleValue($returnIfFalse); $returnIfFalse = (is_null($returnIfFalse)) ? false : Functions::flattenSingleValue($returnIfFalse);
@ -244,14 +255,16 @@ class Logical
} }
/** /**
* IFERROR * IFERROR.
* *
* Excel Function: * Excel Function:
* =IFERROR(testValue,errorpart) * =IFERROR(testValue,errorpart)
* *
* @category Logical Functions * @category Logical Functions
*
* @param mixed $testValue Value to check, is also the value returned when no error * @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 * @param mixed $errorpart Value to return when testValue is an error condition
*
* @return mixed The value of errorpart or testValue determined by error condition * @return mixed The value of errorpart or testValue determined by error condition
*/ */
public static function IFERROR($testValue = '', $errorpart = '') public static function IFERROR($testValue = '', $errorpart = '')

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,13 +20,14 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class LookupRef class LookupRef
{ {
/** /**
* CELL_ADDRESS * CELL_ADDRESS.
* *
* Creates a cell address as text, given specified row and column numbers. * Creates a cell address as text, given specified row and column numbers.
* *
@ -44,6 +45,12 @@ class LookupRef
* TRUE or omitted CELL_ADDRESS returns an A1-style reference * TRUE or omitted CELL_ADDRESS returns an A1-style reference
* FALSE CELL_ADDRESS returns an R1C1-style reference * FALSE CELL_ADDRESS returns an R1C1-style reference
* @param sheetText Optional Name of worksheet to use * @param sheetText Optional Name of worksheet to use
* @param mixed $row
* @param mixed $column
* @param mixed $relativity
* @param mixed $referenceStyle
* @param mixed $sheetText
*
* @return string * @return string
*/ */
public static function cellAddress($row, $column, $relativity = 1, $referenceStyle = true, $sheetText = '') public static function cellAddress($row, $column, $relativity = 1, $referenceStyle = true, $sheetText = '')
@ -74,7 +81,7 @@ class LookupRef
} }
return $sheetText . $columnRelative . $column . $rowRelative . $row; return $sheetText . $columnRelative . $column . $rowRelative . $row;
} else { }
if (($relativity == 2) || ($relativity == 4)) { if (($relativity == 2) || ($relativity == 4)) {
$column = '[' . $column . ']'; $column = '[' . $column . ']';
} }
@ -84,10 +91,9 @@ class LookupRef
return $sheetText . 'R' . $row . 'C' . $column; return $sheetText . 'R' . $row . 'C' . $column;
} }
}
/** /**
* COLUMN * COLUMN.
* *
* Returns the column number of the given cell reference * Returns the column number of the given cell reference
* If the cell reference is a range of cells, COLUMN returns the column numbers of each column in the reference as a horizontal array. * If the cell reference is a range of cells, COLUMN returns the column numbers of each column in the reference as a horizontal array.
@ -98,6 +104,8 @@ class LookupRef
* =COLUMN([cellAddress]) * =COLUMN([cellAddress])
* *
* @param cellAddress A reference to a range of cells for which you want the column numbers * @param cellAddress A reference to a range of cells for which you want the column numbers
* @param null|mixed $cellAddress
*
* @return int or array of integer * @return int or array of integer
*/ */
public static function COLUMN($cellAddress = null) public static function COLUMN($cellAddress = null)
@ -110,7 +118,7 @@ class LookupRef
foreach ($cellAddress as $columnKey => $value) { foreach ($cellAddress as $columnKey => $value) {
$columnKey = preg_replace('/[^a-z]/i', '', $columnKey); $columnKey = preg_replace('/[^a-z]/i', '', $columnKey);
return (integer) \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnKey); return (int) \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnKey);
} }
} else { } else {
if (strpos($cellAddress, '!') !== false) { if (strpos($cellAddress, '!') !== false) {
@ -122,20 +130,19 @@ class LookupRef
$endAddress = preg_replace('/[^a-z]/i', '', $endAddress); $endAddress = preg_replace('/[^a-z]/i', '', $endAddress);
$returnValue = []; $returnValue = [];
do { do {
$returnValue[] = (integer) \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($startAddress); $returnValue[] = (int) \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($startAddress);
} while ($startAddress++ != $endAddress); } while ($startAddress++ != $endAddress);
return $returnValue; return $returnValue;
} else { }
$cellAddress = preg_replace('/[^a-z]/i', '', $cellAddress); $cellAddress = preg_replace('/[^a-z]/i', '', $cellAddress);
return (integer) \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($cellAddress); return (int) \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($cellAddress);
}
} }
} }
/** /**
* COLUMNS * COLUMNS.
* *
* Returns the number of columns in an array or reference. * Returns the number of columns in an array or reference.
* *
@ -143,6 +150,8 @@ class LookupRef
* =COLUMNS(cellAddress) * =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 * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
* @param null|mixed $cellAddress
*
* @return int The number of columns in cellAddress * @return int The number of columns in cellAddress
*/ */
public static function COLUMNS($cellAddress = null) public static function COLUMNS($cellAddress = null)
@ -159,13 +168,13 @@ class LookupRef
if ($isMatrix) { if ($isMatrix) {
return $rows; return $rows;
} else {
return $columns;
} }
return $columns;
} }
/** /**
* ROW * ROW.
* *
* Returns the row number of the given cell reference * Returns the row number of the given cell reference
* If the cell reference is a range of cells, ROW returns the row numbers of each row in the reference as a vertical array. * If the cell reference is a range of cells, ROW returns the row numbers of each row in the reference as a vertical array.
@ -176,6 +185,8 @@ class LookupRef
* =ROW([cellAddress]) * =ROW([cellAddress])
* *
* @param cellAddress A reference to a range of cells for which you want the row numbers * @param cellAddress A reference to a range of cells for which you want the row numbers
* @param null|mixed $cellAddress
*
* @return int or array of integer * @return int or array of integer
*/ */
public static function ROW($cellAddress = null) public static function ROW($cellAddress = null)
@ -187,7 +198,7 @@ class LookupRef
if (is_array($cellAddress)) { if (is_array($cellAddress)) {
foreach ($cellAddress as $columnKey => $rowValue) { foreach ($cellAddress as $columnKey => $rowValue) {
foreach ($rowValue as $rowKey => $cellValue) { foreach ($rowValue as $rowKey => $cellValue) {
return (integer) preg_replace('/[^0-9]/i', '', $rowKey); return (int) preg_replace('/[^0-9]/i', '', $rowKey);
} }
} }
} else { } else {
@ -200,20 +211,19 @@ class LookupRef
$endAddress = preg_replace('/[^0-9]/', '', $endAddress); $endAddress = preg_replace('/[^0-9]/', '', $endAddress);
$returnValue = []; $returnValue = [];
do { do {
$returnValue[][] = (integer) $startAddress; $returnValue[][] = (int) $startAddress;
} while ($startAddress++ != $endAddress); } while ($startAddress++ != $endAddress);
return $returnValue; return $returnValue;
} else { }
list($cellAddress) = explode(':', $cellAddress); list($cellAddress) = explode(':', $cellAddress);
return (integer) preg_replace('/[^0-9]/', '', $cellAddress); return (int) preg_replace('/[^0-9]/', '', $cellAddress);
}
} }
} }
/** /**
* ROWS * ROWS.
* *
* Returns the number of rows in an array or reference. * Returns the number of rows in an array or reference.
* *
@ -221,6 +231,8 @@ class LookupRef
* =ROWS(cellAddress) * =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 * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
* @param null|mixed $cellAddress
*
* @return int The number of rows in cellAddress * @return int The number of rows in cellAddress
*/ */
public static function ROWS($cellAddress = null) public static function ROWS($cellAddress = null)
@ -237,21 +249,23 @@ class LookupRef
if ($isMatrix) { if ($isMatrix) {
return $columns; return $columns;
} else {
return $rows;
} }
return $rows;
} }
/** /**
* HYPERLINK * HYPERLINK.
* *
* Excel Function: * Excel Function:
* =HYPERLINK(linkURL,displayName) * =HYPERLINK(linkURL,displayName)
* *
* @category Logical Functions * @category Logical Functions
*
* @param string $linkURL Value to check, is also the value returned when no error * @param string $linkURL Value to check, is also the value returned when no error
* @param string $displayName Value to return when testValue is an error condition * @param string $displayName Value to return when testValue is an error condition
* @param \PhpOffice\PhpSpreadsheet\Cell $pCell The cell to set the hyperlink in * @param \PhpOffice\PhpSpreadsheet\Cell $pCell The cell to set the hyperlink in
*
* @return mixed The value of $displayName (or $linkURL if $displayName was blank) * @return mixed The value of $displayName (or $linkURL if $displayName was blank)
*/ */
public static function HYPERLINK($linkURL = '', $displayName = null, \PhpOffice\PhpSpreadsheet\Cell $pCell = null) public static function HYPERLINK($linkURL = '', $displayName = null, \PhpOffice\PhpSpreadsheet\Cell $pCell = null)
@ -277,7 +291,7 @@ class LookupRef
} }
/** /**
* INDIRECT * INDIRECT.
* *
* Returns the reference specified by a text string. * Returns the reference specified by a text string.
* References are immediately evaluated to display their contents. * References are immediately evaluated to display their contents.
@ -289,6 +303,7 @@ class LookupRef
* *
* @param cellAddress $cellAddress The cell address of the current cell (containing this formula) * @param cellAddress $cellAddress The cell address of the current cell (containing this formula)
* @param \PhpOffice\PhpSpreadsheet\Cell $pCell The current cell (containing this formula) * @param \PhpOffice\PhpSpreadsheet\Cell $pCell The current cell (containing this formula)
*
* @return mixed The cells referenced by cellAddress * @return mixed The cells referenced by cellAddress
* *
* @todo Support for the optional a1 parameter introduced in Excel 2010 * @todo Support for the optional a1 parameter introduced in Excel 2010
@ -335,7 +350,7 @@ class LookupRef
} }
/** /**
* OFFSET * OFFSET.
* *
* Returns a reference to a range that is a specified number of rows and columns from a cell or range of cells. * Returns a reference to a range that is a specified number of rows and columns from a cell or range of cells.
* The reference that is returned can be a single cell or a range of cells. You can specify the number of rows and * The reference that is returned can be a single cell or a range of cells. You can specify the number of rows and
@ -357,6 +372,12 @@ class LookupRef
* starting reference). * starting reference).
* @param height The height, in number of rows, that you want the returned reference to be. Height must be a positive number. * @param height The height, in number of rows, that you want the returned reference to be. Height must be a positive number.
* @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number. * @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number.
* @param null|mixed $cellAddress
* @param mixed $rows
* @param mixed $columns
* @param null|mixed $height
* @param null|mixed $width
*
* @return string A reference to a cell or range of cells * @return string A reference to a cell or range of cells
*/ */
public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null) public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null)
@ -429,7 +450,7 @@ class LookupRef
} }
/** /**
* CHOOSE * CHOOSE.
* *
* Uses lookup_value to return a value from the list of value arguments. * Uses lookup_value to return a value from the list of value arguments.
* Use CHOOSE to select one of up to 254 values based on the lookup_value. * Use CHOOSE to select one of up to 254 values based on the lookup_value.
@ -444,6 +465,7 @@ class LookupRef
* Between 1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on * Between 1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on
* index_num. The arguments can be numbers, cell references, defined names, formulas, functions, or * index_num. The arguments can be numbers, cell references, defined names, formulas, functions, or
* text. * text.
*
* @return mixed The selected value * @return mixed The selected value
*/ */
public static function CHOOSE() public static function CHOOSE()
@ -467,13 +489,13 @@ class LookupRef
if (is_array($chooseArgs[$chosenEntry])) { if (is_array($chooseArgs[$chosenEntry])) {
return Functions::flattenArray($chooseArgs[$chosenEntry]); return Functions::flattenArray($chooseArgs[$chosenEntry]);
} else {
return $chooseArgs[$chosenEntry];
} }
return $chooseArgs[$chosenEntry];
} }
/** /**
* MATCH * MATCH.
* *
* The MATCH function searches for a specified item in a range of cells * The MATCH function searches for a specified item in a range of cells
* *
@ -483,6 +505,10 @@ class LookupRef
* @param lookup_value The value that you want to match in lookup_array * @param lookup_value The value that you want to match in lookup_array
* @param lookup_array The range of cells being searched * @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. * @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.
* @param mixed $lookup_value
* @param mixed $lookup_array
* @param mixed $match_type
*
* @return int 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) public static function MATCH($lookup_value, $lookup_array, $match_type = 1)
@ -547,29 +573,27 @@ class LookupRef
if ($i < 1) { if ($i < 1) {
// 1st cell was already smaller than the lookup_value // 1st cell was already smaller than the lookup_value
break; break;
} else { }
// the previous cell was the match // the previous cell was the match
return $keySet[$i - 1] + 1; return $keySet[$i - 1] + 1;
}
} elseif (($match_type == 1) && ($lookupArrayValue >= $lookup_value)) { } elseif (($match_type == 1) && ($lookupArrayValue >= $lookup_value)) {
$i = array_search($i, $keySet); $i = array_search($i, $keySet);
// if match_type is 1 <=> find the largest value that is less than or equal to lookup_value // if match_type is 1 <=> find the largest value that is less than or equal to lookup_value
if ($i < 1) { if ($i < 1) {
// 1st cell was already bigger than the lookup_value // 1st cell was already bigger than the lookup_value
break; break;
} else { }
// the previous cell was the match // the previous cell was the match
return $keySet[$i - 1] + 1; return $keySet[$i - 1] + 1;
} }
} }
}
// unsuccessful in finding a match, return #N/A error value // unsuccessful in finding a match, return #N/A error value
return Functions::NA(); return Functions::NA();
} }
/** /**
* INDEX * INDEX.
* *
* Uses an index to choose a value from a reference or array * Uses an index to choose a value from a reference or array
* *
@ -579,6 +603,10 @@ class LookupRef
* @param range_array A range of cells or an array constant * @param range_array A range of cells or an array constant
* @param row_num The row in array from which to return a value. If row_num is omitted, column_num is required. * @param row_num The row in array from which to return a value. If row_num is omitted, column_num is required.
* @param column_num The column in array from which to return a value. If column_num is omitted, row_num is required. * @param column_num The column in array from which to return a value. If column_num is omitted, row_num is required.
* @param mixed $arrayValues
* @param mixed $rowNum
* @param mixed $columnNum
*
* @return mixed the value of a specified cell or array of cells * @return mixed the value of a specified cell or array of cells
*/ */
public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0) public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0)
@ -628,12 +656,13 @@ class LookupRef
} }
/** /**
* TRANSPOSE * TRANSPOSE.
* *
* @param array $matrixData A matrix of values * @param array $matrixData A matrix of values
*
* @return array * @return array
* *
* Unlike the Excel TRANSPOSE function, which will only work on a single row or column, this function will transpose a full matrix. * Unlike the Excel TRANSPOSE function, which will only work on a single row or column, this function will transpose a full matrix
*/ */
public static function TRANSPOSE($matrixData) public static function TRANSPOSE($matrixData)
{ {
@ -669,10 +698,16 @@ class LookupRef
/** /**
* VLOOKUP * 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. * 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.
*
* @param lookup_value The value that you want to match in lookup_array * @param lookup_value The value that you want to match in lookup_array
* @param lookup_array The range of cells being searched * @param lookup_array The range of cells being searched
* @param index_number The column number in table_array from which the matching value must be returned. The first column is 1. * @param index_number The column number in table_array from which the matching value must be returned. The first column is 1.
* @param not_exact_match Determines if you are looking for an exact match based on lookup_value. * @param not_exact_match determines if you are looking for an exact match based on lookup_value
* @param mixed $lookup_value
* @param mixed $lookup_array
* @param mixed $index_number
* @param mixed $not_exact_match
*
* @return mixed The value of the found cell * @return mixed The value of the found cell
*/ */
public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true) public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true)
@ -689,17 +724,15 @@ class LookupRef
// index_number must be less than or equal to the number of columns in lookup_array // index_number must be less than or equal to the number of columns in lookup_array
if ((!is_array($lookup_array)) || (empty($lookup_array))) { if ((!is_array($lookup_array)) || (empty($lookup_array))) {
return Functions::REF(); return Functions::REF();
} else { }
$f = array_keys($lookup_array); $f = array_keys($lookup_array);
$firstRow = array_pop($f); $firstRow = array_pop($f);
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
return Functions::REF(); return Functions::REF();
} else { }
$columnKeys = array_keys($lookup_array[$firstRow]); $columnKeys = array_keys($lookup_array[$firstRow]);
$returnColumn = $columnKeys[--$index_number]; $returnColumn = $columnKeys[--$index_number];
$firstColumn = array_shift($columnKeys); $firstColumn = array_shift($columnKeys);
}
}
if (!$not_exact_match) { if (!$not_exact_match) {
uasort($lookup_array, ['self', 'vlookupSort']); uasort($lookup_array, ['self', 'vlookupSort']);
@ -723,11 +756,10 @@ class LookupRef
if ((!$not_exact_match) && ($rowValue != $lookup_value)) { if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
// if an exact match is required, we have what we need to return an appropriate response // if an exact match is required, we have what we need to return an appropriate response
return Functions::NA(); return Functions::NA();
} else { }
// otherwise return the appropriate value // otherwise return the appropriate value
return $lookup_array[$rowNumber][$returnColumn]; return $lookup_array[$rowNumber][$returnColumn];
} }
}
return Functions::NA(); return Functions::NA();
} }
@ -735,10 +767,16 @@ class LookupRef
/** /**
* HLOOKUP * 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. * 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.
*
* @param lookup_value The value that you want to match in lookup_array * @param lookup_value The value that you want to match in lookup_array
* @param lookup_array The range of cells being searched * @param lookup_array The range of cells being searched
* @param index_number The row number in table_array from which the matching value must be returned. The first row is 1. * @param index_number The row number in table_array from which the matching value must be returned. The first row is 1.
* @param not_exact_match Determines if you are looking for an exact match based on lookup_value. * @param not_exact_match determines if you are looking for an exact match based on lookup_value
* @param mixed $lookup_value
* @param mixed $lookup_array
* @param mixed $index_number
* @param mixed $not_exact_match
*
* @return mixed The value of the found cell * @return mixed The value of the found cell
*/ */
public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true) public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true)
@ -755,18 +793,16 @@ class LookupRef
// index_number must be less than or equal to the number of columns in lookup_array // index_number must be less than or equal to the number of columns in lookup_array
if ((!is_array($lookup_array)) || (empty($lookup_array))) { if ((!is_array($lookup_array)) || (empty($lookup_array))) {
return Functions::REF(); return Functions::REF();
} else { }
$f = array_keys($lookup_array); $f = array_keys($lookup_array);
$firstRow = array_pop($f); $firstRow = array_pop($f);
if ((!is_array($lookup_array[$firstRow])) || ($index_number - 1 > count($lookup_array[$firstRow]))) { if ((!is_array($lookup_array[$firstRow])) || ($index_number - 1 > count($lookup_array[$firstRow]))) {
return Functions::REF(); return Functions::REF();
} else { }
$columnKeys = array_keys($lookup_array[$firstRow]); $columnKeys = array_keys($lookup_array[$firstRow]);
$firstkey = $f[0] - 1; $firstkey = $f[0] - 1;
$returnColumn = $firstkey + $index_number; $returnColumn = $firstkey + $index_number;
$firstColumn = array_shift($f); $firstColumn = array_shift($f);
}
}
if (!$not_exact_match) { if (!$not_exact_match) {
$firstRowH = asort($lookup_array[$firstColumn]); $firstRowH = asort($lookup_array[$firstColumn]);
@ -785,11 +821,10 @@ class LookupRef
if ((!$not_exact_match) && ($rowValue != $lookup_value)) { if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
// if an exact match is required, we have what we need to return an appropriate response // if an exact match is required, we have what we need to return an appropriate response
return Functions::NA(); return Functions::NA();
} else { }
// otherwise return the appropriate value // otherwise return the appropriate value
return $lookup_array[$returnColumn][$rowNumber]; return $lookup_array[$returnColumn][$rowNumber];
} }
}
return Functions::NA(); return Functions::NA();
} }
@ -797,9 +832,14 @@ class LookupRef
/** /**
* LOOKUP * LOOKUP
* The LOOKUP function searches for value either from a one-row or one-column range or from an array. * The LOOKUP function searches for value either from a one-row or one-column range or from an array.
*
* @param lookup_value The value that you want to match in lookup_array * @param lookup_value The value that you want to match in lookup_array
* @param lookup_vector The range of cells being searched * @param lookup_vector The range of cells being searched
* @param result_vector The column from which the matching value must be returned * @param result_vector The column from which the matching value must be returned
* @param mixed $lookup_value
* @param mixed $lookup_vector
* @param null|mixed $result_vector
*
* @return mixed The value of the found cell * @return mixed The value of the found cell
*/ */
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null) public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -46,9 +47,9 @@ class MathTrig
rsort($factorArray); rsort($factorArray);
return $factorArray; return $factorArray;
} else {
return [(integer) $value];
} }
return [(int) $value];
} }
private static function romanCut($num, $n) private static function romanCut($num, $n)
@ -57,7 +58,7 @@ class MathTrig
} }
/** /**
* ATAN2 * ATAN2.
* *
* This function calculates the arc tangent of the two variables x and y. It is similar to * This function calculates the arc tangent of the two variables x and y. It is similar to
* calculating the arc tangent of y ÷ x, except that the signs of both arguments are used * calculating the arc tangent of y ÷ x, except that the signs of both arguments are used
@ -73,9 +74,11 @@ class MathTrig
* ATAN2(xCoordinate,yCoordinate) * ATAN2(xCoordinate,yCoordinate)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
* @param float $xCoordinate The x-coordinate of the point. *
* @param float $yCoordinate The y-coordinate of the point. * @param float $xCoordinate the x-coordinate of the point
* @return float The inverse tangent of the specified x- and y-coordinates. * @param float $yCoordinate the y-coordinate of the point
*
* @return float the inverse tangent of the specified x- and y-coordinates
*/ */
public static function ATAN2($xCoordinate = null, $yCoordinate = null) public static function ATAN2($xCoordinate = null, $yCoordinate = null)
{ {
@ -101,7 +104,7 @@ class MathTrig
} }
/** /**
* CEILING * CEILING.
* *
* Returns number rounded up, away from zero, to the nearest multiple of significance. * Returns number rounded up, away from zero, to the nearest multiple of significance.
* For example, if you want to avoid using pennies in your prices and your product is * For example, if you want to avoid using pennies in your prices and your product is
@ -112,8 +115,10 @@ class MathTrig
* CEILING(number[,significance]) * CEILING(number[,significance])
* *
* @category Mathematical and Trigonometric Functions * @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. * @param float $number the number you want to round
* @param float $significance the multiple to which you want to round
*
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function CEILING($number, $significance = null) public static function CEILING($number, $significance = null)
@ -131,16 +136,16 @@ class MathTrig
return 0.0; return 0.0;
} elseif (self::SIGN($number) == self::SIGN($significance)) { } elseif (self::SIGN($number) == self::SIGN($significance)) {
return ceil($number / $significance) * $significance; return ceil($number / $significance) * $significance;
} else {
return Functions::NAN();
} }
return Functions::NAN();
} }
return Functions::VALUE(); return Functions::VALUE();
} }
/** /**
* COMBIN * COMBIN.
* *
* Returns the number of combinations for a given number of items. Use COMBIN to * Returns the number of combinations for a given number of items. Use COMBIN to
* determine the total possible number of groups for a given number of items. * determine the total possible number of groups for a given number of items.
@ -149,8 +154,10 @@ class MathTrig
* COMBIN(numObjs,numInSet) * COMBIN(numObjs,numInSet)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param int $numObjs Number of different objects * @param int $numObjs Number of different objects
* @param int $numInSet Number of objects in each combination * @param int $numInSet Number of objects in each combination
*
* @return int Number of combinations * @return int Number of combinations
*/ */
public static function COMBIN($numObjs, $numInSet) public static function COMBIN($numObjs, $numInSet)
@ -172,7 +179,7 @@ class MathTrig
} }
/** /**
* EVEN * EVEN.
* *
* Returns number rounded up to the nearest even integer. * Returns number rounded up to the nearest even integer.
* You can use this function for processing items that come in twos. For example, * You can use this function for processing items that come in twos. For example,
@ -184,7 +191,9 @@ class MathTrig
* EVEN(number) * EVEN(number)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param float $number Number to round * @param float $number Number to round
*
* @return int Rounded Number * @return int Rounded Number
*/ */
public static function EVEN($number) public static function EVEN($number)
@ -207,7 +216,7 @@ class MathTrig
} }
/** /**
* FACT * FACT.
* *
* Returns the factorial of a number. * Returns the factorial of a number.
* The factorial of a number is equal to 1*2*3*...* number. * The factorial of a number is equal to 1*2*3*...* number.
@ -216,7 +225,9 @@ class MathTrig
* FACT(factVal) * FACT(factVal)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param float $factVal Factorial Value * @param float $factVal Factorial Value
*
* @return int Factorial * @return int Factorial
*/ */
public static function FACT($factVal) public static function FACT($factVal)
@ -246,7 +257,7 @@ class MathTrig
} }
/** /**
* FACTDOUBLE * FACTDOUBLE.
* *
* Returns the double factorial of a number. * Returns the double factorial of a number.
* *
@ -254,7 +265,9 @@ class MathTrig
* FACTDOUBLE(factVal) * FACTDOUBLE(factVal)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param float $factVal Factorial Value * @param float $factVal Factorial Value
*
* @return int Double Factorial * @return int Double Factorial
*/ */
public static function FACTDOUBLE($factVal) public static function FACTDOUBLE($factVal)
@ -279,7 +292,7 @@ class MathTrig
} }
/** /**
* FLOOR * FLOOR.
* *
* Rounds number down, toward zero, to the nearest multiple of significance. * Rounds number down, toward zero, to the nearest multiple of significance.
* *
@ -287,8 +300,10 @@ class MathTrig
* FLOOR(number[,significance]) * FLOOR(number[,significance])
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param float $number Number to round * @param float $number Number to round
* @param float $significance Significance * @param float $significance Significance
*
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function FLOOR($number, $significance = null) public static function FLOOR($number, $significance = null)
@ -308,16 +323,16 @@ class MathTrig
return 0.0; return 0.0;
} elseif (self::SIGN($number) == self::SIGN($significance)) { } elseif (self::SIGN($number) == self::SIGN($significance)) {
return floor($number / $significance) * $significance; return floor($number / $significance) * $significance;
} else {
return Functions::NAN();
} }
return Functions::NAN();
} }
return Functions::VALUE(); return Functions::VALUE();
} }
/** /**
* GCD * GCD.
* *
* Returns the greatest common divisor of a series of numbers. * Returns the greatest common divisor of a series of numbers.
* The greatest common divisor is the largest integer that divides both * The greatest common divisor is the largest integer that divides both
@ -327,7 +342,9 @@ class MathTrig
* GCD(number1[,number2[, ...]]) * GCD(number1[,number2[, ...]])
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
*
* @return int Greatest Common Divisor * @return int Greatest Common Divisor
*/ */
public static function GCD() public static function GCD()
@ -377,7 +394,7 @@ class MathTrig
} }
return $returnValue; return $returnValue;
} else { }
$keys = array_keys($mergedArray); $keys = array_keys($mergedArray);
$key = $keys[0]; $key = $keys[0];
$value = $mergedArray[$key]; $value = $mergedArray[$key];
@ -391,10 +408,9 @@ class MathTrig
return pow($key, $value); return pow($key, $value);
} }
}
/** /**
* INT * INT.
* *
* Casts a floating point value to an integer * Casts a floating point value to an integer
* *
@ -402,7 +418,9 @@ class MathTrig
* INT(number) * INT(number)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param float $number Number to cast to an integer * @param float $number Number to cast to an integer
*
* @return int Integer value * @return int Integer value
*/ */
public static function INT($number) public static function INT($number)
@ -422,7 +440,7 @@ class MathTrig
} }
/** /**
* LCM * LCM.
* *
* Returns the lowest common multiplier of a series of numbers * Returns the lowest common multiplier of a series of numbers
* The least common multiple is the smallest positive integer that is a multiple * The least common multiple is the smallest positive integer that is a multiple
@ -433,7 +451,9 @@ class MathTrig
* LCM(number1[,number2[, ...]]) * LCM(number1[,number2[, ...]])
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
*
* @return int Lowest Common Multiplier * @return int Lowest Common Multiplier
*/ */
public static function LCM() public static function LCM()
@ -467,14 +487,14 @@ class MathTrig
} }
} }
foreach ($allPoweredFactors as $allPoweredFactor) { foreach ($allPoweredFactors as $allPoweredFactor) {
$returnValue *= (integer) $allPoweredFactor; $returnValue *= (int) $allPoweredFactor;
} }
return $returnValue; return $returnValue;
} }
/** /**
* LOG_BASE * LOG_BASE.
* *
* Returns the logarithm of a number to a specified base. The default base is 10. * Returns the logarithm of a number to a specified base. The default base is 10.
* *
@ -482,8 +502,10 @@ class MathTrig
* LOG(number[,base]) * LOG(number[,base])
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param float $number The positive real number for which you want the logarithm * @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. * @param float $base The base of the logarithm. If base is omitted, it is assumed to be 10.
*
* @return float * @return float
*/ */
public static function logBase($number = null, $base = 10) public static function logBase($number = null, $base = 10)
@ -502,7 +524,7 @@ class MathTrig
} }
/** /**
* MDETERM * MDETERM.
* *
* Returns the matrix determinant of an array. * Returns the matrix determinant of an array.
* *
@ -510,7 +532,9 @@ class MathTrig
* MDETERM(array) * MDETERM(array)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param array $matrixValues A matrix of values * @param array $matrixValues A matrix of values
*
* @return float * @return float
*/ */
public static function MDETERM($matrixValues) public static function MDETERM($matrixValues)
@ -552,7 +576,7 @@ class MathTrig
} }
/** /**
* MINVERSE * MINVERSE.
* *
* Returns the inverse matrix for the matrix stored in an array. * Returns the inverse matrix for the matrix stored in an array.
* *
@ -560,7 +584,9 @@ class MathTrig
* MINVERSE(array) * MINVERSE(array)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param array $matrixValues A matrix of values * @param array $matrixValues A matrix of values
*
* @return array * @return array
*/ */
public static function MINVERSE($matrixValues) public static function MINVERSE($matrixValues)
@ -604,10 +630,11 @@ class MathTrig
} }
/** /**
* MMULT * MMULT.
* *
* @param array $matrixData1 A matrix of values * @param array $matrixData1 A matrix of values
* @param array $matrixData2 A matrix of values * @param array $matrixData2 A matrix of values
*
* @return array * @return array
*/ */
public static function MMULT($matrixData1, $matrixData2) public static function MMULT($matrixData1, $matrixData2)
@ -665,10 +692,11 @@ class MathTrig
} }
/** /**
* MOD * MOD.
* *
* @param int $a Dividend * @param int $a Dividend
* @param int $b Divisor * @param int $b Divisor
*
* @return int Remainder * @return int Remainder
*/ */
public static function MOD($a = 1, $b = 1) public static function MOD($a = 1, $b = 1)
@ -688,12 +716,13 @@ class MathTrig
} }
/** /**
* MROUND * MROUND.
* *
* Rounds a number to the nearest multiple of a specified value * Rounds a number to the nearest multiple of a specified value
* *
* @param float $number Number to round * @param float $number Number to round
* @param int $multiple Multiple to which you want to round $number * @param int $multiple Multiple to which you want to round $number
*
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function MROUND($number, $multiple) public static function MROUND($number, $multiple)
@ -718,11 +747,12 @@ class MathTrig
} }
/** /**
* MULTINOMIAL * MULTINOMIAL.
* *
* Returns the ratio of the factorial of a sum of values to the product of factorials. * Returns the ratio of the factorial of a sum of values to the product of factorials.
* *
* @param array of mixed Data Series * @param array of mixed Data Series
*
* @return float * @return float
*/ */
public static function MULTINOMIAL() public static function MULTINOMIAL()
@ -754,11 +784,12 @@ class MathTrig
} }
/** /**
* ODD * ODD.
* *
* Returns number rounded up to the nearest odd integer. * Returns number rounded up to the nearest odd integer.
* *
* @param float $number Number to round * @param float $number Number to round
*
* @return int Rounded Number * @return int Rounded Number
*/ */
public static function ODD($number) public static function ODD($number)
@ -787,12 +818,13 @@ class MathTrig
} }
/** /**
* POWER * POWER.
* *
* Computes x raised to the power y. * Computes x raised to the power y.
* *
* @param float $x * @param float $x
* @param float $y * @param float $y
*
* @return float * @return float
*/ */
public static function POWER($x = 0, $y = 2) public static function POWER($x = 0, $y = 2)
@ -814,7 +846,7 @@ class MathTrig
} }
/** /**
* PRODUCT * PRODUCT.
* *
* PRODUCT returns the product of all the values and cells referenced in the argument list. * PRODUCT returns the product of all the values and cells referenced in the argument list.
* *
@ -822,7 +854,9 @@ class MathTrig
* PRODUCT(value1[,value2[, ...]]) * PRODUCT(value1[,value2[, ...]])
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
*
* @return float * @return float
*/ */
public static function PRODUCT() public static function PRODUCT()
@ -851,7 +885,7 @@ class MathTrig
} }
/** /**
* QUOTIENT * QUOTIENT.
* *
* QUOTIENT function returns the integer portion of a division. Numerator is the divided number * QUOTIENT function returns the integer portion of a division. Numerator is the divided number
* and denominator is the divisor. * and denominator is the divisor.
@ -860,7 +894,9 @@ class MathTrig
* QUOTIENT(value1[,value2[, ...]]) * QUOTIENT(value1[,value2[, ...]])
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
*
* @return float * @return float
*/ */
public static function QUOTIENT() public static function QUOTIENT()
@ -885,14 +921,15 @@ class MathTrig
} }
// Return // Return
return intval($returnValue); return (int) $returnValue;
} }
/** /**
* RAND * RAND.
* *
* @param int $min Minimal value * @param int $min Minimal value
* @param int $max Maximal value * @param int $max Maximal value
*
* @return int Random number * @return int Random number
*/ */
public static function RAND($min = 0, $max = 0) public static function RAND($min = 0, $max = 0)
@ -902,19 +939,19 @@ class MathTrig
if ($min == 0 && $max == 0) { if ($min == 0 && $max == 0) {
return (mt_rand(0, 10000000)) / 10000000; return (mt_rand(0, 10000000)) / 10000000;
} else {
return mt_rand($min, $max);
} }
return mt_rand($min, $max);
} }
public static function ROMAN($aValue, $style = 0) public static function ROMAN($aValue, $style = 0)
{ {
$aValue = Functions::flattenSingleValue($aValue); $aValue = Functions::flattenSingleValue($aValue);
$style = (is_null($style)) ? 0 : (integer) Functions::flattenSingleValue($style); $style = (is_null($style)) ? 0 : (int) Functions::flattenSingleValue($style);
if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) { if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) {
return Functions::VALUE(); return Functions::VALUE();
} }
$aValue = (integer) $aValue; $aValue = (int) $aValue;
if ($aValue == 0) { if ($aValue == 0) {
return ''; return '';
} }
@ -940,12 +977,13 @@ class MathTrig
} }
/** /**
* ROUNDUP * ROUNDUP.
* *
* Rounds a number up to a specified number of decimal places * Rounds a number up to a specified number of decimal places
* *
* @param float $number Number to round * @param float $number Number to round
* @param int $digits Number of digits to which you want to round $number * @param int $digits Number of digits to which you want to round $number
*
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function ROUNDUP($number, $digits) public static function ROUNDUP($number, $digits)
@ -957,21 +995,22 @@ class MathTrig
$significance = pow(10, (int) $digits); $significance = pow(10, (int) $digits);
if ($number < 0.0) { if ($number < 0.0) {
return floor($number * $significance) / $significance; return floor($number * $significance) / $significance;
} else {
return ceil($number * $significance) / $significance;
} }
return ceil($number * $significance) / $significance;
} }
return Functions::VALUE(); return Functions::VALUE();
} }
/** /**
* ROUNDDOWN * ROUNDDOWN.
* *
* Rounds a number down to a specified number of decimal places * Rounds a number down to a specified number of decimal places
* *
* @param float $number Number to round * @param float $number Number to round
* @param int $digits Number of digits to which you want to round $number * @param int $digits Number of digits to which you want to round $number
*
* @return float Rounded Number * @return float Rounded Number
*/ */
public static function ROUNDDOWN($number, $digits) public static function ROUNDDOWN($number, $digits)
@ -983,16 +1022,16 @@ class MathTrig
$significance = pow(10, (int) $digits); $significance = pow(10, (int) $digits);
if ($number < 0.0) { if ($number < 0.0) {
return ceil($number * $significance) / $significance; return ceil($number * $significance) / $significance;
} else {
return floor($number * $significance) / $significance;
} }
return floor($number * $significance) / $significance;
} }
return Functions::VALUE(); return Functions::VALUE();
} }
/** /**
* SERIESSUM * SERIESSUM.
* *
* Returns the sum of a power series * Returns the sum of a power series
* *
@ -1000,6 +1039,7 @@ class MathTrig
* @param float $n Initial power to which you want to raise $x * @param float $n Initial power to which you want to raise $x
* @param float $m Step by which to increase $n for each term in the series * @param float $m Step by which to increase $n for each term in the series
* @param array of mixed Data Series * @param array of mixed Data Series
*
* @return float * @return float
*/ */
public static function SERIESSUM() public static function SERIESSUM()
@ -1032,12 +1072,13 @@ class MathTrig
} }
/** /**
* SIGN * SIGN.
* *
* Determines the sign of a number. Returns 1 if the number is positive, zero (0) * Determines the sign of a number. Returns 1 if the number is positive, zero (0)
* if the number is 0, and -1 if the number is negative. * if the number is 0, and -1 if the number is negative.
* *
* @param float $number Number to round * @param float $number Number to round
*
* @return int sign value * @return int sign value
*/ */
public static function SIGN($number) public static function SIGN($number)
@ -1059,11 +1100,12 @@ class MathTrig
} }
/** /**
* SQRTPI * SQRTPI.
* *
* Returns the square root of (number * pi). * Returns the square root of (number * pi).
* *
* @param float $number Number * @param float $number Number
*
* @return float Square Root of Number * Pi * @return float Square Root of Number * Pi
*/ */
public static function SQRTPI($number) public static function SQRTPI($number)
@ -1082,13 +1124,14 @@ class MathTrig
} }
/** /**
* SUBTOTAL * SUBTOTAL.
* *
* Returns a subtotal in a list or database. * Returns a subtotal in a list or database.
* *
* @param int the number 1 to 11 that specifies which function to * @param int the number 1 to 11 that specifies which function to
* use in calculating subtotals within a list. * use in calculating subtotals within a list
* @param array of mixed Data Series * @param array of mixed Data Series
*
* @return float * @return float
*/ */
public static function SUBTOTAL() public static function SUBTOTAL()
@ -1129,7 +1172,7 @@ class MathTrig
} }
/** /**
* SUM * SUM.
* *
* SUM computes the sum of all the values and cells referenced in the argument list. * SUM computes the sum of all the values and cells referenced in the argument list.
* *
@ -1137,7 +1180,9 @@ class MathTrig
* SUM(value1[,value2[, ...]]) * SUM(value1[,value2[, ...]])
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
*
* @return float * @return float
*/ */
public static function SUM() public static function SUM()
@ -1156,7 +1201,7 @@ class MathTrig
} }
/** /**
* SUMIF * SUMIF.
* *
* Counts the number of cells that contain numbers within the list of arguments * Counts the number of cells that contain numbers within the list of arguments
* *
@ -1164,8 +1209,12 @@ class MathTrig
* SUMIF(value1[,value2[, ...]],condition) * SUMIF(value1[,value2[, ...]],condition)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
* @param string $condition The criteria that defines which cells will be summed. * @param string $condition the criteria that defines which cells will be summed
* @param mixed $aArgs
* @param mixed $sumArgs
*
* @return float * @return float
*/ */
public static function SUMIF($aArgs, $condition, $sumArgs = []) public static function SUMIF($aArgs, $condition, $sumArgs = [])
@ -1196,7 +1245,7 @@ class MathTrig
} }
/** /**
* SUMIFS * SUMIFS.
* *
* Counts the number of cells that contain numbers within the list of arguments * Counts the number of cells that contain numbers within the list of arguments
* *
@ -1204,8 +1253,10 @@ class MathTrig
* SUMIFS(value1[,value2[, ...]],condition) * SUMIFS(value1[,value2[, ...]],condition)
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
* @param string $condition The criteria that defines which cells will be summed. * @param string $condition the criteria that defines which cells will be summed
*
* @return float * @return float
*/ */
public static function SUMIFS() public static function SUMIFS()
@ -1244,13 +1295,15 @@ class MathTrig
} }
/** /**
* SUMPRODUCT * SUMPRODUCT.
* *
* Excel Function: * Excel Function:
* SUMPRODUCT(value1[,value2[, ...]]) * SUMPRODUCT(value1[,value2[, ...]])
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
*
* @return float * @return float
*/ */
public static function SUMPRODUCT() public static function SUMPRODUCT()
@ -1285,7 +1338,7 @@ class MathTrig
} }
/** /**
* SUMSQ * SUMSQ.
* *
* SUMSQ returns the sum of the squares of the arguments * SUMSQ returns the sum of the squares of the arguments
* *
@ -1293,7 +1346,9 @@ class MathTrig
* SUMSQ(value1[,value2[, ...]]) * SUMSQ(value1[,value2[, ...]])
* *
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
*
* @param mixed $arg,... Data values * @param mixed $arg,... Data values
*
* @return float * @return float
*/ */
public static function SUMSQ() public static function SUMSQ()
@ -1312,10 +1367,11 @@ class MathTrig
} }
/** /**
* SUMX2MY2 * SUMX2MY2.
* *
* @param mixed[] $matrixData1 Matrix #1 * @param mixed[] $matrixData1 Matrix #1
* @param mixed[] $matrixData2 Matrix #2 * @param mixed[] $matrixData2 Matrix #2
*
* @return float * @return float
*/ */
public static function SUMX2MY2($matrixData1, $matrixData2) public static function SUMX2MY2($matrixData1, $matrixData2)
@ -1336,10 +1392,11 @@ class MathTrig
} }
/** /**
* SUMX2PY2 * SUMX2PY2.
* *
* @param mixed[] $matrixData1 Matrix #1 * @param mixed[] $matrixData1 Matrix #1
* @param mixed[] $matrixData2 Matrix #2 * @param mixed[] $matrixData2 Matrix #2
*
* @return float * @return float
*/ */
public static function SUMX2PY2($matrixData1, $matrixData2) public static function SUMX2PY2($matrixData1, $matrixData2)
@ -1360,10 +1417,11 @@ class MathTrig
} }
/** /**
* SUMXMY2 * SUMXMY2.
* *
* @param mixed[] $matrixData1 Matrix #1 * @param mixed[] $matrixData1 Matrix #1
* @param mixed[] $matrixData2 Matrix #2 * @param mixed[] $matrixData2 Matrix #2
*
* @return float * @return float
*/ */
public static function SUMXMY2($matrixData1, $matrixData2) public static function SUMXMY2($matrixData1, $matrixData2)
@ -1384,12 +1442,13 @@ class MathTrig
} }
/** /**
* TRUNC * TRUNC.
* *
* Truncates value to the number of fractional digits by number_digits. * Truncates value to the number of fractional digits by number_digits.
* *
* @param float $value * @param float $value
* @param int $digits * @param int $digits
*
* @return float Truncated value * @return float Truncated value
*/ */
public static function TRUNC($value = 0, $digits = 0) public static function TRUNC($value = 0, $digits = 0)
@ -1406,10 +1465,10 @@ class MathTrig
// Truncate // Truncate
$adjust = pow(10, $digits); $adjust = pow(10, $digits);
if (($digits > 0) && (rtrim(intval((abs($value) - abs(intval($value))) * $adjust), '0') < $adjust / 10)) { if (($digits > 0) && (rtrim((int) ((abs($value) - abs((int) $value)) * $adjust), '0') < $adjust / 10)) {
return $value; return $value;
} }
return (intval($value * $adjust)) / $adjust; return ((int) ($value * $adjust)) / $adjust;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -33,9 +34,10 @@ class TextData
} }
/** /**
* CHARACTER * CHARACTER.
* *
* @param string $character Value * @param string $character Value
*
* @return string * @return string
*/ */
public static function CHARACTER($character) public static function CHARACTER($character)
@ -50,13 +52,14 @@ class TextData
return iconv('UCS-4LE', 'UTF-8', pack('V', $character)); return iconv('UCS-4LE', 'UTF-8', pack('V', $character));
} }
return mb_convert_encoding('&#' . intval($character) . ';', 'UTF-8', 'HTML-ENTITIES'); return mb_convert_encoding('&#' . (int) $character . ';', 'UTF-8', 'HTML-ENTITIES');
} }
/** /**
* TRIMNONPRINTABLE * TRIMNONPRINTABLE.
* *
* @param mixed $stringValue Value to check * @param mixed $stringValue Value to check
*
* @return string * @return string
*/ */
public static function TRIMNONPRINTABLE($stringValue = '') public static function TRIMNONPRINTABLE($stringValue = '')
@ -79,9 +82,10 @@ class TextData
} }
/** /**
* TRIMSPACES * TRIMSPACES.
* *
* @param mixed $stringValue Value to check * @param mixed $stringValue Value to check
*
* @return string * @return string
*/ */
public static function TRIMSPACES($stringValue = '') public static function TRIMSPACES($stringValue = '')
@ -99,9 +103,10 @@ class TextData
} }
/** /**
* ASCIICODE * ASCIICODE.
* *
* @param string $characters Value * @param string $characters Value
*
* @return int * @return int
*/ */
public static function ASCIICODE($characters) public static function ASCIICODE($characters)
@ -125,17 +130,16 @@ class TextData
} }
return self::unicodeToOrd($character); return self::unicodeToOrd($character);
} else { }
if (strlen($characters) > 0) { if (strlen($characters) > 0) {
$character = substr($characters, 0, 1); $character = substr($characters, 0, 1);
} }
return ord($character); return ord($character);
} }
}
/** /**
* CONCATENATE * CONCATENATE.
* *
* @return string * @return string
*/ */
@ -160,7 +164,7 @@ class TextData
} }
/** /**
* DOLLAR * DOLLAR.
* *
* This function converts a number to text using currency format, with the decimals rounded to the specified place. * This function converts a number to text using currency format, with the decimals rounded to the specified place.
* The format used is $#,##0.00_);($#,##0.00).. * The format used is $#,##0.00_);($#,##0.00)..
@ -169,6 +173,7 @@ class TextData
* @param int $decimals The number of digits to display to the right of the decimal point. * @param int $decimals The number of digits to display to the right of the decimal point.
* If decimals is negative, number is rounded to the left of the decimal point. * If decimals is negative, number is rounded to the left of the decimal point.
* If you omit decimals, it is assumed to be 2 * If you omit decimals, it is assumed to be 2
*
* @return string * @return string
*/ */
public static function DOLLAR($value = 0, $decimals = 2) public static function DOLLAR($value = 0, $decimals = 2)
@ -197,11 +202,12 @@ class TextData
} }
/** /**
* SEARCHSENSITIVE * SEARCHSENSITIVE.
* *
* @param string $needle The string to look for * @param string $needle The string to look for
* @param string $haystack The string in which to look * @param string $haystack The string in which to look
* @param int $offset Offset within $haystack * @param int $offset Offset within $haystack
*
* @return string * @return string
*/ */
public static function SEARCHSENSITIVE($needle, $haystack, $offset = 1) public static function SEARCHSENSITIVE($needle, $haystack, $offset = 1)
@ -234,11 +240,12 @@ class TextData
} }
/** /**
* SEARCHINSENSITIVE * SEARCHINSENSITIVE.
* *
* @param string $needle The string to look for * @param string $needle The string to look for
* @param string $haystack The string in which to look * @param string $haystack The string in which to look
* @param int $offset Offset within $haystack * @param int $offset Offset within $haystack
*
* @return string * @return string
*/ */
public static function SEARCHINSENSITIVE($needle, $haystack, $offset = 1) public static function SEARCHINSENSITIVE($needle, $haystack, $offset = 1)
@ -271,11 +278,12 @@ class TextData
} }
/** /**
* FIXEDFORMAT * FIXEDFORMAT.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
* @param int $decimals * @param int $decimals
* @param bool $no_commas * @param bool $no_commas
*
* @return string * @return string
*/ */
public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = false) public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = false)
@ -302,10 +310,11 @@ class TextData
} }
/** /**
* LEFT * LEFT.
* *
* @param string $value Value * @param string $value Value
* @param int $chars Number of characters * @param int $chars Number of characters
*
* @return string * @return string
*/ */
public static function LEFT($value = '', $chars = 1) public static function LEFT($value = '', $chars = 1)
@ -323,17 +332,18 @@ class TextData
if (function_exists('mb_substr')) { if (function_exists('mb_substr')) {
return mb_substr($value, 0, $chars, 'UTF-8'); return mb_substr($value, 0, $chars, 'UTF-8');
} else {
return substr($value, 0, $chars);
} }
return substr($value, 0, $chars);
} }
/** /**
* MID * MID.
* *
* @param string $value Value * @param string $value Value
* @param int $start Start character * @param int $start Start character
* @param int $chars Number of characters * @param int $chars Number of characters
*
* @return string * @return string
*/ */
public static function MID($value = '', $start = 1, $chars = null) public static function MID($value = '', $start = 1, $chars = null)
@ -355,16 +365,17 @@ class TextData
} }
if (function_exists('mb_substr')) { if (function_exists('mb_substr')) {
return mb_substr($value, --$start, $chars, 'UTF-8'); return mb_substr($value, --$start, $chars, 'UTF-8');
} else {
return substr($value, --$start, $chars);
} }
return substr($value, --$start, $chars);
} }
/** /**
* RIGHT * RIGHT.
* *
* @param string $value Value * @param string $value Value
* @param int $chars Number of characters * @param int $chars Number of characters
*
* @return string * @return string
*/ */
public static function RIGHT($value = '', $chars = 1) public static function RIGHT($value = '', $chars = 1)
@ -382,15 +393,16 @@ class TextData
if ((function_exists('mb_substr')) && (function_exists('mb_strlen'))) { if ((function_exists('mb_substr')) && (function_exists('mb_strlen'))) {
return mb_substr($value, mb_strlen($value, 'UTF-8') - $chars, $chars, 'UTF-8'); return mb_substr($value, mb_strlen($value, 'UTF-8') - $chars, $chars, 'UTF-8');
} else {
return substr($value, strlen($value) - $chars);
} }
return substr($value, strlen($value) - $chars);
} }
/** /**
* STRINGLENGTH * STRINGLENGTH.
* *
* @param string $value Value * @param string $value Value
*
* @return int * @return int
*/ */
public static function STRINGLENGTH($value = '') public static function STRINGLENGTH($value = '')
@ -403,17 +415,18 @@ class TextData
if (function_exists('mb_strlen')) { if (function_exists('mb_strlen')) {
return mb_strlen($value, 'UTF-8'); return mb_strlen($value, 'UTF-8');
} else {
return strlen($value);
} }
return strlen($value);
} }
/** /**
* LOWERCASE * LOWERCASE.
* *
* Converts a string value to upper case. * Converts a string value to upper case.
* *
* @param string $mixedCaseString * @param string $mixedCaseString
*
* @return string * @return string
*/ */
public static function LOWERCASE($mixedCaseString) public static function LOWERCASE($mixedCaseString)
@ -428,11 +441,12 @@ class TextData
} }
/** /**
* UPPERCASE * UPPERCASE.
* *
* Converts a string value to upper case. * Converts a string value to upper case.
* *
* @param string $mixedCaseString * @param string $mixedCaseString
*
* @return string * @return string
*/ */
public static function UPPERCASE($mixedCaseString) public static function UPPERCASE($mixedCaseString)
@ -447,11 +461,12 @@ class TextData
} }
/** /**
* PROPERCASE * PROPERCASE.
* *
* Converts a string value to upper case. * Converts a string value to upper case.
* *
* @param string $mixedCaseString * @param string $mixedCaseString
*
* @return string * @return string
*/ */
public static function PROPERCASE($mixedCaseString) public static function PROPERCASE($mixedCaseString)
@ -466,12 +481,13 @@ class TextData
} }
/** /**
* REPLACE * REPLACE.
* *
* @param string $oldText String to modify * @param string $oldText String to modify
* @param int $start Start character * @param int $start Start character
* @param int $chars Number of characters * @param int $chars Number of characters
* @param string $newText String to replace in defined position * @param string $newText String to replace in defined position
*
* @return string * @return string
*/ */
public static function REPLACE($oldText, $start, $chars, $newText) public static function REPLACE($oldText, $start, $chars, $newText)
@ -488,12 +504,13 @@ class TextData
} }
/** /**
* SUBSTITUTE * SUBSTITUTE.
* *
* @param string $text Value * @param string $text Value
* @param string $fromText From Value * @param string $fromText From Value
* @param string $toText To Value * @param string $toText To Value
* @param int $instance Instance Number * @param int $instance Instance Number
*
* @return string * @return string
*/ */
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0)
@ -506,10 +523,10 @@ class TextData
if ($instance == 0) { if ($instance == 0) {
if (function_exists('mb_str_replace')) { if (function_exists('mb_str_replace')) {
return mb_str_replace($fromText, $toText, $text); return mb_str_replace($fromText, $toText, $text);
} else { }
return str_replace($fromText, $toText, $text); return str_replace($fromText, $toText, $text);
} }
} else {
$pos = -1; $pos = -1;
while ($instance > 0) { while ($instance > 0) {
if (function_exists('mb_strpos')) { if (function_exists('mb_strpos')) {
@ -525,19 +542,19 @@ class TextData
if ($pos !== false) { if ($pos !== false) {
if (function_exists('mb_strlen')) { if (function_exists('mb_strlen')) {
return self::REPLACE($text, ++$pos, mb_strlen($fromText, 'UTF-8'), $toText); return self::REPLACE($text, ++$pos, mb_strlen($fromText, 'UTF-8'), $toText);
} else { }
return self::REPLACE($text, ++$pos, strlen($fromText), $toText); return self::REPLACE($text, ++$pos, strlen($fromText), $toText);
} }
}
}
return $text; return $text;
} }
/** /**
* RETURNSTRING * RETURNSTRING.
* *
* @param mixed $testValue Value to check * @param mixed $testValue Value to check
*
* @return string|null * @return string|null
*/ */
public static function RETURNSTRING($testValue = '') public static function RETURNSTRING($testValue = '')
@ -552,10 +569,11 @@ class TextData
} }
/** /**
* TEXTFORMAT * TEXTFORMAT.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
* @param string $format Format mask to use * @param string $format Format mask to use
*
* @return string * @return string
*/ */
public static function TEXTFORMAT($value, $format) public static function TEXTFORMAT($value, $format)
@ -571,9 +589,10 @@ class TextData
} }
/** /**
* VALUE * VALUE.
* *
* @param mixed $value Value to check * @param mixed $value Value to check
*
* @return bool * @return bool
*/ */
public static function VALUE($value = '') public static function VALUE($value = '')

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\Token; namespace PhpOffice\PhpSpreadsheet\Calculation\Token;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,27 +20,28 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Token;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Stack class Stack
{ {
/** /**
* The parser stack for formulae * The parser stack for formulae.
* *
* @var mixed[] * @var mixed[]
*/ */
private $stack = []; private $stack = [];
/** /**
* Count of entries in the parser stack * Count of entries in the parser stack.
* *
* @var int * @var int
*/ */
private $count = 0; private $count = 0;
/** /**
* Return the number of entries on the stack * Return the number of entries on the stack.
* *
* @return int * @return int
*/ */
@ -50,7 +51,7 @@ class Stack
} }
/** /**
* Push a new entry onto the stack * Push a new entry onto the stack.
* *
* @param mixed $type * @param mixed $type
* @param mixed $value * @param mixed $value
@ -72,7 +73,7 @@ class Stack
} }
/** /**
* Pop the last entry from the stack * Pop the last entry from the stack.
* *
* @return mixed * @return mixed
*/ */
@ -86,9 +87,10 @@ class Stack
} }
/** /**
* Return an entry from the stack without removing it * Return an entry from the stack without removing it.
* *
* @param int $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 * @return mixed
*/ */
public function last($n = 1) public function last($n = 1)
@ -101,7 +103,7 @@ class Stack
} }
/** /**
* Clear the stack * Clear the stack.
*/ */
public function clear() public function clear()
{ {

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,27 +20,28 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Cell class Cell
{ {
/** /**
* Default range variable constant * Default range variable constant.
* *
* @var string * @var string
*/ */
const DEFAULT_RANGE = 'A1:A1'; const DEFAULT_RANGE = 'A1:A1';
/** /**
* Value binder to use * Value binder to use.
* *
* @var Cell\IValueBinder * @var Cell\IValueBinder
*/ */
private static $valueBinder; private static $valueBinder;
/** /**
* Value of the cell * Value of the cell.
* *
* @var mixed * @var mixed
*/ */
@ -59,33 +60,33 @@ class Cell
private $calculatedValue; private $calculatedValue;
/** /**
* Type of the cell data * Type of the cell data.
* *
* @var string * @var string
*/ */
private $dataType; private $dataType;
/** /**
* Parent worksheet * Parent worksheet.
* *
* @var CachedObjectStorage\CacheBase * @var CachedObjectStorage\CacheBase
*/ */
private $parent; private $parent;
/** /**
* Index to cellXf * Index to cellXf.
* *
* @var int * @var int
*/ */
private $xfIndex = 0; private $xfIndex = 0;
/** /**
* Attributes of the formula * Attributes of the formula.
*/ */
private $formulaAttributes; private $formulaAttributes;
/** /**
* Send notification to the cache controller * Send notification to the cache controller.
**/ **/
public function notifyCacheController() public function notifyCacheController()
{ {
@ -105,11 +106,12 @@ class Cell
} }
/** /**
* Create a new Cell * Create a new Cell.
* *
* @param mixed $pValue * @param mixed $pValue
* @param string $pDataType * @param string $pDataType
* @param Worksheet $pSheet * @param Worksheet $pSheet
*
* @throws Exception * @throws Exception
*/ */
public function __construct($pValue = null, $pDataType = null, Worksheet $pSheet = null) public function __construct($pValue = null, $pDataType = null, Worksheet $pSheet = null)
@ -132,7 +134,7 @@ class Cell
} }
/** /**
* Get cell coordinate column * Get cell coordinate column.
* *
* @return string * @return string
*/ */
@ -142,7 +144,7 @@ class Cell
} }
/** /**
* Get cell coordinate row * Get cell coordinate row.
* *
* @return int * @return int
*/ */
@ -152,7 +154,7 @@ class Cell
} }
/** /**
* Get cell coordinate * Get cell coordinate.
* *
* @return string * @return string
*/ */
@ -162,7 +164,7 @@ class Cell
} }
/** /**
* Get cell value * Get cell value.
* *
* @return mixed * @return mixed
*/ */
@ -172,7 +174,7 @@ class Cell
} }
/** /**
* Get cell value with formatting * Get cell value with formatting.
* *
* @return string * @return string
*/ */
@ -186,12 +188,14 @@ class Cell
} }
/** /**
* Set cell value * Set cell value.
* *
* Sets the value for a cell, automatically determining the datatype using the value binder * Sets the value for a cell, automatically determining the datatype using the value binder
* *
* @param mixed $pValue Value * @param mixed $pValue Value
*
* @throws Exception * @throws Exception
*
* @return Cell * @return Cell
*/ */
public function setValue($pValue = null) public function setValue($pValue = null)
@ -204,11 +208,13 @@ class Cell
} }
/** /**
* Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder) * Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder).
* *
* @param mixed $pValue Value * @param mixed $pValue Value
* @param string $pDataType Explicit data type * @param string $pDataType Explicit data type
*
* @throws Exception * @throws Exception
*
* @return Cell * @return Cell
*/ */
public function setValueExplicit($pValue = null, $pDataType = Cell\DataType::TYPE_STRING) public function setValueExplicit($pValue = null, $pDataType = Cell\DataType::TYPE_STRING)
@ -251,12 +257,14 @@ class Cell
} }
/** /**
* Get calculated cell value * Get calculated cell value.
* *
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling * @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
* *
* @param bool $resetLog Whether the calculation engine logger should be reset or not * @param bool $resetLog Whether the calculation engine logger should be reset or not
*
* @throws Exception * @throws Exception
*
* @return mixed * @return mixed
*/ */
public function getCalculatedValue($resetLog = true) public function getCalculatedValue($resetLog = true)
@ -295,9 +303,10 @@ class Cell
} }
/** /**
* Set old calculated value (cached) * Set old calculated value (cached).
* *
* @param mixed $pValue Value * @param mixed $pValue Value
*
* @return Cell * @return Cell
*/ */
public function setCalculatedValue($pValue = null) public function setCalculatedValue($pValue = null)
@ -325,7 +334,7 @@ class Cell
} }
/** /**
* Get cell data type * Get cell data type.
* *
* @return string * @return string
*/ */
@ -335,9 +344,10 @@ class Cell
} }
/** /**
* Set cell data type * Set cell data type.
* *
* @param string $pDataType * @param string $pDataType
*
* @return Cell * @return Cell
*/ */
public function setDataType($pDataType = Cell\DataType::TYPE_STRING) public function setDataType($pDataType = Cell\DataType::TYPE_STRING)
@ -351,7 +361,7 @@ class Cell
} }
/** /**
* Identify if the cell contains a formula * Identify if the cell contains a formula.
* *
* @return bool * @return bool
*/ */
@ -364,6 +374,7 @@ class Cell
* Does this cell contain Data validation rules? * Does this cell contain Data validation rules?
* *
* @throws Exception * @throws Exception
*
* @return bool * @return bool
*/ */
public function hasDataValidation() public function hasDataValidation()
@ -376,9 +387,10 @@ class Cell
} }
/** /**
* Get Data validation rules * Get Data validation rules.
* *
* @throws Exception * @throws Exception
*
* @return Cell\DataValidation * @return Cell\DataValidation
*/ */
public function getDataValidation() public function getDataValidation()
@ -391,10 +403,12 @@ class Cell
} }
/** /**
* Set Data validation rules * Set Data validation rules.
* *
* @param Cell\DataValidation $pDataValidation * @param Cell\DataValidation $pDataValidation
*
* @throws Exception * @throws Exception
*
* @return Cell * @return Cell
*/ */
public function setDataValidation(Cell\DataValidation $pDataValidation = null) public function setDataValidation(Cell\DataValidation $pDataValidation = null)
@ -412,6 +426,7 @@ class Cell
* Does this cell contain a Hyperlink? * Does this cell contain a Hyperlink?
* *
* @throws Exception * @throws Exception
*
* @return bool * @return bool
*/ */
public function hasHyperlink() public function hasHyperlink()
@ -424,9 +439,10 @@ class Cell
} }
/** /**
* Get Hyperlink * Get Hyperlink.
* *
* @throws Exception * @throws Exception
*
* @return Cell\Hyperlink * @return Cell\Hyperlink
*/ */
public function getHyperlink() public function getHyperlink()
@ -439,10 +455,12 @@ class Cell
} }
/** /**
* Set Hyperlink * Set Hyperlink.
* *
* @param Cell\Hyperlink $pHyperlink * @param Cell\Hyperlink $pHyperlink
*
* @throws Exception * @throws Exception
*
* @return Cell * @return Cell
*/ */
public function setHyperlink(Cell\Hyperlink $pHyperlink = null) public function setHyperlink(Cell\Hyperlink $pHyperlink = null)
@ -457,7 +475,7 @@ class Cell
} }
/** /**
* Get parent worksheet * Get parent worksheet.
* *
* @return CachedObjectStorage\CacheBase * @return CachedObjectStorage\CacheBase
*/ */
@ -467,7 +485,7 @@ class Cell
} }
/** /**
* Get parent worksheet * Get parent worksheet.
* *
* @return Worksheet * @return Worksheet
*/ */
@ -477,17 +495,17 @@ class Cell
} }
/** /**
* Is this cell in a merge range * Is this cell in a merge range.
* *
* @return bool * @return bool
*/ */
public function isInMergeRange() public function isInMergeRange()
{ {
return (boolean) $this->getMergeRange(); return (bool) $this->getMergeRange();
} }
/** /**
* Is this cell the master (top left cell) in a merge range (that holds the actual data value) * Is this cell the master (top left cell) in a merge range (that holds the actual data value).
* *
* @return bool * @return bool
*/ */
@ -505,7 +523,7 @@ class Cell
} }
/** /**
* If this cell is in a merge range, then return the range * If this cell is in a merge range, then return the range.
* *
* @return string * @return string
*/ */
@ -521,7 +539,7 @@ class Cell
} }
/** /**
* Get cell style * Get cell style.
* *
* @return Style * @return Style
*/ */
@ -531,9 +549,10 @@ class Cell
} }
/** /**
* Re-bind parent * Re-bind parent.
* *
* @param Worksheet $parent * @param Worksheet $parent
*
* @return Cell * @return Cell
*/ */
public function rebindParent(Worksheet $parent) public function rebindParent(Worksheet $parent)
@ -547,6 +566,7 @@ class Cell
* Is cell in a specific range? * Is cell in a specific range?
* *
* @param string $pRange Cell range (e.g. A1:A1) * @param string $pRange Cell range (e.g. A1:A1)
*
* @return bool * @return bool
*/ */
public function isInRange($pRange = 'A1:A1') public function isInRange($pRange = 'A1:A1')
@ -563,10 +583,12 @@ class Cell
} }
/** /**
* Coordinate from string * Coordinate from string.
* *
* @param string $pCoordinateString * @param string $pCoordinateString
*
* @throws Exception * @throws Exception
*
* @return string[] Array containing column and row (indexes 0 and 1) * @return string[] Array containing column and row (indexes 0 and 1)
*/ */
public static function coordinateFromString($pCoordinateString = 'A1') public static function coordinateFromString($pCoordinateString = 'A1')
@ -583,11 +605,13 @@ class Cell
} }
/** /**
* Make string row, column or cell coordinate absolute * Make string row, column or cell coordinate absolute.
* *
* @param string $pCoordinateString e.g. 'A' or '1' or 'A1' * @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
* Note that this value can be a row or column reference as well as a cell reference * Note that this value can be a row or column reference as well as a cell reference
*
* @throws Exception * @throws Exception
*
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1' * @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
*/ */
public static function absoluteReference($pCoordinateString = 'A1') public static function absoluteReference($pCoordinateString = 'A1')
@ -617,10 +641,12 @@ class Cell
} }
/** /**
* Make string coordinate absolute * Make string coordinate absolute.
* *
* @param string $pCoordinateString e.g. 'A1' * @param string $pCoordinateString e.g. 'A1'
*
* @throws Exception * @throws Exception
*
* @return string Absolute coordinate e.g. '$A$1' * @return string Absolute coordinate e.g. '$A$1'
*/ */
public static function absoluteCoordinate($pCoordinateString = 'A1') public static function absoluteCoordinate($pCoordinateString = 'A1')
@ -648,9 +674,10 @@ class Cell
} }
/** /**
* Split range into coordinate strings * Split range into coordinate strings.
* *
* @param string $pRange e.g. 'B4:D9' or 'B4:D9,H2:O11' or 'B4' * @param string $pRange e.g. 'B4:D9' or 'B4:D9,H2:O11' or 'B4'
*
* @return array Array containg one or more arrays containing one or two coordinate strings * @return array Array containg one or more arrays containing one or two coordinate strings
* e.g. array('B4','D9') or array(array('B4','D9'),array('H2','O11')) * e.g. array('B4','D9') or array(array('B4','D9'),array('H2','O11'))
* or array('B4') * or array('B4')
@ -672,10 +699,12 @@ class Cell
} }
/** /**
* Build range from coordinate strings * Build range from coordinate strings.
* *
* @param array $pRange Array containg one or more arrays containing one or two coordinate strings * @param array $pRange Array containg one or more arrays containing one or two coordinate strings
*
* @throws Exception * @throws Exception
*
* @return string String representation of $pRange * @return string String representation of $pRange
*/ */
public static function buildRange($pRange) public static function buildRange($pRange)
@ -697,9 +726,10 @@ class Cell
} }
/** /**
* Calculate range boundaries * Calculate range boundaries.
* *
* @param string $pRange Cell range (e.g. A1:A1) * @param string $pRange Cell range (e.g. A1:A1)
*
* @return array Range coordinates array(Start Cell, End Cell) * @return array Range coordinates array(Start Cell, End Cell)
* where Start Cell and End Cell are arrays (Column Number, Row Number) * where Start Cell and End Cell are arrays (Column Number, Row Number)
*/ */
@ -732,9 +762,10 @@ class Cell
} }
/** /**
* Calculate range dimension * Calculate range dimension.
* *
* @param string $pRange Cell range (e.g. A1:A1) * @param string $pRange Cell range (e.g. A1:A1)
*
* @return array Range dimension (width, height) * @return array Range dimension (width, height)
*/ */
public static function rangeDimension($pRange = 'A1:A1') public static function rangeDimension($pRange = 'A1:A1')
@ -746,9 +777,10 @@ class Cell
} }
/** /**
* Calculate range boundaries * Calculate range boundaries.
* *
* @param string $pRange Cell range (e.g. A1:A1) * @param string $pRange Cell range (e.g. A1:A1)
*
* @return array Range coordinates array(Start Cell, End Cell) * @return array Range coordinates array(Start Cell, End Cell)
* where Start Cell and End Cell are arrays (Column ID, Row Number) * where Start Cell and End Cell are arrays (Column ID, Row Number)
*/ */
@ -773,9 +805,10 @@ class Cell
} }
/** /**
* Column index from string * Column index from string.
* *
* @param string $pString * @param string $pString
*
* @return int Column index (base 1 !!!) * @return int Column index (base 1 !!!)
*/ */
public static function columnIndexFromString($pString = 'A') public static function columnIndexFromString($pString = 'A')
@ -800,28 +833,29 @@ class Cell
// We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString // We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString
// for improved performance // for improved performance
if (isset($pString{0})) { if (isset($pString[0])) {
if (!isset($pString{1})) { if (!isset($pString[1])) {
$_indexCache[$pString] = $_columnLookup[$pString]; $_indexCache[$pString] = $_columnLookup[$pString];
return $_indexCache[$pString]; return $_indexCache[$pString];
} elseif (!isset($pString{2})) { } elseif (!isset($pString[2])) {
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}]; $_indexCache[$pString] = $_columnLookup[$pString[0]] * 26 + $_columnLookup[$pString[1]];
return $_indexCache[$pString]; return $_indexCache[$pString];
} elseif (!isset($pString{3})) { } elseif (!isset($pString[3])) {
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}]; $_indexCache[$pString] = $_columnLookup[$pString[0]] * 676 + $_columnLookup[$pString[1]] * 26 + $_columnLookup[$pString[2]];
return $_indexCache[$pString]; 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'));
} }
/** /**
* String from columnindex * String from columnindex.
* *
* @param int $pColumnIndex Column index (base 0 !!!) * @param int $pColumnIndex Column index (base 0 !!!)
*
* @return string * @return string
*/ */
public static function stringFromColumnIndex($pColumnIndex = 0) public static function stringFromColumnIndex($pColumnIndex = 0)
@ -849,9 +883,10 @@ class Cell
} }
/** /**
* Extract all cell references in range * Extract all cell references in range.
* *
* @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25) * @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25)
*
* @return array Array containing single cell references * @return array Array containing single cell references
*/ */
public static function extractAllCellReferencesInRange($pRange = 'A1') public static function extractAllCellReferencesInRange($pRange = 'A1')
@ -912,10 +947,11 @@ class Cell
} }
/** /**
* Compare 2 cells * Compare 2 cells.
* *
* @param Cell $a Cell a * @param Cell $a Cell a
* @param Cell $b Cell b * @param Cell $b Cell b
*
* @return int Result of comparison (always -1 or 1, never zero!) * @return int Result of comparison (always -1 or 1, never zero!)
*/ */
public static function compareCells(Cell $a, Cell $b) public static function compareCells(Cell $a, Cell $b)
@ -926,13 +962,13 @@ class Cell
return 1; return 1;
} elseif (self::columnIndexFromString($a->getColumn()) < self::columnIndexFromString($b->getColumn())) { } elseif (self::columnIndexFromString($a->getColumn()) < self::columnIndexFromString($b->getColumn())) {
return -1; return -1;
} else {
return 1;
} }
return 1;
} }
/** /**
* Get value binder to use * Get value binder to use.
* *
* @return Cell\IValueBinder * @return Cell\IValueBinder
*/ */
@ -946,9 +982,10 @@ class Cell
} }
/** /**
* Set value binder to use * Set value binder to use.
* *
* @param Cell\IValueBinder $binder * @param Cell\IValueBinder $binder
*
* @throws Exception * @throws Exception
*/ */
public static function setValueBinder(Cell\IValueBinder $binder = null) public static function setValueBinder(Cell\IValueBinder $binder = null)
@ -976,7 +1013,7 @@ class Cell
} }
/** /**
* Get index to cellXf * Get index to cellXf.
* *
* @return int * @return int
*/ */
@ -986,9 +1023,10 @@ class Cell
} }
/** /**
* Set index to cellXf * Set index to cellXf.
* *
* @param int $pValue * @param int $pValue
*
* @return Cell * @return Cell
*/ */
public function setXfIndex($pValue = 0) public function setXfIndex($pValue = 0)
@ -1000,6 +1038,8 @@ class Cell
/** /**
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling * @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
*
* @param mixed $pAttributes
*/ */
public function setFormulaAttributes($pAttributes) public function setFormulaAttributes($pAttributes)
{ {
@ -1017,7 +1057,7 @@ class Cell
} }
/** /**
* Convert to string * Convert to string.
* *
* @return string * @return string
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Cell; namespace PhpOffice\PhpSpreadsheet\Cell;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,16 +20,18 @@ namespace PhpOffice\PhpSpreadsheet\Cell;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
{ {
/** /**
* Bind value to a cell * Bind value to a cell.
* *
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to bind value to * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
*
* @return bool * @return bool
*/ */
public function bindValue(\PhpOffice\PhpSpreadsheet\Cell $cell, $value = null) public function bindValue(\PhpOffice\PhpSpreadsheet\Cell $cell, $value = null)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Cell; namespace PhpOffice\PhpSpreadsheet\Cell;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Cell;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -36,7 +37,7 @@ class DataType
const TYPE_ERROR = 'e'; const TYPE_ERROR = 'e';
/** /**
* List of error codes * List of error codes.
* *
* @var array * @var array
*/ */
@ -51,7 +52,7 @@ class DataType
]; ];
/** /**
* Get list of error codes * Get list of error codes.
* *
* @return array * @return array
*/ */
@ -61,9 +62,11 @@ class DataType
} }
/** /**
* Check a string that it satisfies Excel requirements * Check a string that it satisfies Excel requirements.
* *
* @param mixed Value to sanitize to an Excel string * @param mixed Value to sanitize to an Excel string
* @param null|mixed $pValue
*
* @return mixed Sanitized value * @return mixed Sanitized value
*/ */
public static function checkString($pValue = null) public static function checkString($pValue = null)
@ -83,9 +86,11 @@ class DataType
} }
/** /**
* Check a value that it is a valid error code * Check a value that it is a valid error code.
* *
* @param mixed Value to sanitize to an Excel error code * @param mixed Value to sanitize to an Excel error code
* @param null|mixed $pValue
*
* @return string Sanitized value * @return string Sanitized value
*/ */
public static function checkErrorCode($pValue = null) public static function checkErrorCode($pValue = null)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Cell; namespace PhpOffice\PhpSpreadsheet\Cell;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Cell;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -51,105 +52,105 @@ class DataValidation
const OPERATOR_NOTEQUAL = 'notEqual'; const OPERATOR_NOTEQUAL = 'notEqual';
/** /**
* Formula 1 * Formula 1.
* *
* @var string * @var string
*/ */
private $formula1 = ''; private $formula1 = '';
/** /**
* Formula 2 * Formula 2.
* *
* @var string * @var string
*/ */
private $formula2 = ''; private $formula2 = '';
/** /**
* Type * Type.
* *
* @var string * @var string
*/ */
private $type = self::TYPE_NONE; private $type = self::TYPE_NONE;
/** /**
* Error style * Error style.
* *
* @var string * @var string
*/ */
private $errorStyle = self::STYLE_STOP; private $errorStyle = self::STYLE_STOP;
/** /**
* Operator * Operator.
* *
* @var string * @var string
*/ */
private $operator = ''; private $operator = '';
/** /**
* Allow Blank * Allow Blank.
* *
* @var bool * @var bool
*/ */
private $allowBlank = false; private $allowBlank = false;
/** /**
* Show DropDown * Show DropDown.
* *
* @var bool * @var bool
*/ */
private $showDropDown = false; private $showDropDown = false;
/** /**
* Show InputMessage * Show InputMessage.
* *
* @var bool * @var bool
*/ */
private $showInputMessage = false; private $showInputMessage = false;
/** /**
* Show ErrorMessage * Show ErrorMessage.
* *
* @var bool * @var bool
*/ */
private $showErrorMessage = false; private $showErrorMessage = false;
/** /**
* Error title * Error title.
* *
* @var string * @var string
*/ */
private $errorTitle = ''; private $errorTitle = '';
/** /**
* Error * Error.
* *
* @var string * @var string
*/ */
private $error = ''; private $error = '';
/** /**
* Prompt title * Prompt title.
* *
* @var string * @var string
*/ */
private $promptTitle = ''; private $promptTitle = '';
/** /**
* Prompt * Prompt.
* *
* @var string * @var string
*/ */
private $prompt = ''; private $prompt = '';
/** /**
* Create a new DataValidation * Create a new DataValidation.
*/ */
public function __construct() public function __construct()
{ {
} }
/** /**
* Get Formula 1 * Get Formula 1.
* *
* @return string * @return string
*/ */
@ -159,9 +160,10 @@ class DataValidation
} }
/** /**
* Set Formula 1 * Set Formula 1.
* *
* @param string $value * @param string $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setFormula1($value = '') public function setFormula1($value = '')
@ -172,7 +174,7 @@ class DataValidation
} }
/** /**
* Get Formula 2 * Get Formula 2.
* *
* @return string * @return string
*/ */
@ -182,9 +184,10 @@ class DataValidation
} }
/** /**
* Set Formula 2 * Set Formula 2.
* *
* @param string $value * @param string $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setFormula2($value = '') public function setFormula2($value = '')
@ -195,7 +198,7 @@ class DataValidation
} }
/** /**
* Get Type * Get Type.
* *
* @return string * @return string
*/ */
@ -205,9 +208,10 @@ class DataValidation
} }
/** /**
* Set Type * Set Type.
* *
* @param string $value * @param string $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setType($value = self::TYPE_NONE) public function setType($value = self::TYPE_NONE)
@ -218,7 +222,7 @@ class DataValidation
} }
/** /**
* Get Error style * Get Error style.
* *
* @return string * @return string
*/ */
@ -228,9 +232,10 @@ class DataValidation
} }
/** /**
* Set Error style * Set Error style.
* *
* @param string $value * @param string $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setErrorStyle($value = self::STYLE_STOP) public function setErrorStyle($value = self::STYLE_STOP)
@ -241,7 +246,7 @@ class DataValidation
} }
/** /**
* Get Operator * Get Operator.
* *
* @return string * @return string
*/ */
@ -251,9 +256,10 @@ class DataValidation
} }
/** /**
* Set Operator * Set Operator.
* *
* @param string $value * @param string $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setOperator($value = '') public function setOperator($value = '')
@ -264,7 +270,7 @@ class DataValidation
} }
/** /**
* Get Allow Blank * Get Allow Blank.
* *
* @return bool * @return bool
*/ */
@ -274,9 +280,10 @@ class DataValidation
} }
/** /**
* Set Allow Blank * Set Allow Blank.
* *
* @param bool $value * @param bool $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setAllowBlank($value = false) public function setAllowBlank($value = false)
@ -287,7 +294,7 @@ class DataValidation
} }
/** /**
* Get Show DropDown * Get Show DropDown.
* *
* @return bool * @return bool
*/ */
@ -297,9 +304,10 @@ class DataValidation
} }
/** /**
* Set Show DropDown * Set Show DropDown.
* *
* @param bool $value * @param bool $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setShowDropDown($value = false) public function setShowDropDown($value = false)
@ -310,7 +318,7 @@ class DataValidation
} }
/** /**
* Get Show InputMessage * Get Show InputMessage.
* *
* @return bool * @return bool
*/ */
@ -320,9 +328,10 @@ class DataValidation
} }
/** /**
* Set Show InputMessage * Set Show InputMessage.
* *
* @param bool $value * @param bool $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setShowInputMessage($value = false) public function setShowInputMessage($value = false)
@ -333,7 +342,7 @@ class DataValidation
} }
/** /**
* Get Show ErrorMessage * Get Show ErrorMessage.
* *
* @return bool * @return bool
*/ */
@ -343,9 +352,10 @@ class DataValidation
} }
/** /**
* Set Show ErrorMessage * Set Show ErrorMessage.
* *
* @param bool $value * @param bool $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setShowErrorMessage($value = false) public function setShowErrorMessage($value = false)
@ -356,7 +366,7 @@ class DataValidation
} }
/** /**
* Get Error title * Get Error title.
* *
* @return string * @return string
*/ */
@ -366,9 +376,10 @@ class DataValidation
} }
/** /**
* Set Error title * Set Error title.
* *
* @param string $value * @param string $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setErrorTitle($value = '') public function setErrorTitle($value = '')
@ -379,7 +390,7 @@ class DataValidation
} }
/** /**
* Get Error * Get Error.
* *
* @return string * @return string
*/ */
@ -389,9 +400,10 @@ class DataValidation
} }
/** /**
* Set Error * Set Error.
* *
* @param string $value * @param string $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setError($value = '') public function setError($value = '')
@ -402,7 +414,7 @@ class DataValidation
} }
/** /**
* Get Prompt title * Get Prompt title.
* *
* @return string * @return string
*/ */
@ -412,9 +424,10 @@ class DataValidation
} }
/** /**
* Set Prompt title * Set Prompt title.
* *
* @param string $value * @param string $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setPromptTitle($value = '') public function setPromptTitle($value = '')
@ -425,7 +438,7 @@ class DataValidation
} }
/** /**
* Get Prompt * Get Prompt.
* *
* @return string * @return string
*/ */
@ -435,9 +448,10 @@ class DataValidation
} }
/** /**
* Set Prompt * Set Prompt.
* *
* @param string $value * @param string $value
*
* @return DataValidation * @return DataValidation
*/ */
public function setPrompt($value = '') public function setPrompt($value = '')
@ -448,7 +462,7 @@ class DataValidation
} }
/** /**
* Get hash code * Get hash code.
* *
* @return string Hash code * @return string Hash code
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Cell; namespace PhpOffice\PhpSpreadsheet\Cell;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,16 +20,18 @@ namespace PhpOffice\PhpSpreadsheet\Cell;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class DefaultValueBinder implements IValueBinder class DefaultValueBinder implements IValueBinder
{ {
/** /**
* Bind value to a cell * Bind value to a cell.
* *
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to bind value to * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
*
* @return bool * @return bool
*/ */
public function bindValue(\PhpOffice\PhpSpreadsheet\Cell $cell, $value = null) public function bindValue(\PhpOffice\PhpSpreadsheet\Cell $cell, $value = null)
@ -54,9 +56,10 @@ class DefaultValueBinder implements IValueBinder
} }
/** /**
* DataType for value * DataType for value.
* *
* @param mixed $pValue * @param mixed $pValue
*
* @return string * @return string
*/ */
public static function dataTypeForValue($pValue = null) public static function dataTypeForValue($pValue = null)
@ -68,7 +71,7 @@ class DefaultValueBinder implements IValueBinder
return DataType::TYPE_STRING; return DataType::TYPE_STRING;
} elseif ($pValue instanceof \PhpOffice\PhpSpreadsheet\RichText) { } elseif ($pValue instanceof \PhpOffice\PhpSpreadsheet\RichText) {
return DataType::TYPE_INLINE; return DataType::TYPE_INLINE;
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) { } elseif ($pValue[0] === '=' && strlen($pValue) > 1) {
return DataType::TYPE_FORMULA; return DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) { } elseif (is_bool($pValue)) {
return DataType::TYPE_BOOL; return DataType::TYPE_BOOL;
@ -76,7 +79,7 @@ class DefaultValueBinder implements IValueBinder
return DataType::TYPE_NUMERIC; return DataType::TYPE_NUMERIC;
} elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) { } elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) {
$tValue = ltrim($pValue, '+-'); $tValue = ltrim($pValue, '+-');
if (is_string($pValue) && $tValue{0} === '0' && strlen($tValue) > 1 && $tValue{1} !== '.') { if (is_string($pValue) && $tValue[0] === '0' && strlen($tValue) > 1 && $tValue[1] !== '.') {
return DataType::TYPE_STRING; return DataType::TYPE_STRING;
} elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) { } elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
return DataType::TYPE_STRING; return DataType::TYPE_STRING;

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Cell; namespace PhpOffice\PhpSpreadsheet\Cell;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,27 +20,28 @@ namespace PhpOffice\PhpSpreadsheet\Cell;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Hyperlink class Hyperlink
{ {
/** /**
* URL to link the cell to * URL to link the cell to.
* *
* @var string * @var string
*/ */
private $url; private $url;
/** /**
* Tooltip to display on the hyperlink * Tooltip to display on the hyperlink.
* *
* @var string * @var string
*/ */
private $tooltip; private $tooltip;
/** /**
* Create a new Hyperlink * Create a new Hyperlink.
* *
* @param string $pUrl Url to link the cell to * @param string $pUrl Url to link the cell to
* @param string $pTooltip Tooltip to display on the hyperlink * @param string $pTooltip Tooltip to display on the hyperlink
@ -53,7 +54,7 @@ class Hyperlink
} }
/** /**
* Get URL * Get URL.
* *
* @return string * @return string
*/ */
@ -63,9 +64,10 @@ class Hyperlink
} }
/** /**
* Set URL * Set URL.
* *
* @param string $value * @param string $value
*
* @return Hyperlink * @return Hyperlink
*/ */
public function setUrl($value = '') public function setUrl($value = '')
@ -76,7 +78,7 @@ class Hyperlink
} }
/** /**
* Get tooltip * Get tooltip.
* *
* @return string * @return string
*/ */
@ -86,9 +88,10 @@ class Hyperlink
} }
/** /**
* Set tooltip * Set tooltip.
* *
* @param string $value * @param string $value
*
* @return Hyperlink * @return Hyperlink
*/ */
public function setTooltip($value = '') public function setTooltip($value = '')
@ -99,7 +102,7 @@ class Hyperlink
} }
/** /**
* Is this hyperlink internal? (to another worksheet) * Is this hyperlink internal? (to another worksheet).
* *
* @return bool * @return bool
*/ */
@ -109,7 +112,7 @@ class Hyperlink
} }
/** /**
* Get hash code * Get hash code.
* *
* @return string Hash code * @return string Hash code
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Cell; namespace PhpOffice\PhpSpreadsheet\Cell;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,16 +20,18 @@ namespace PhpOffice\PhpSpreadsheet\Cell;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
interface IValueBinder interface IValueBinder
{ {
/** /**
* Bind value to a cell * Bind value to a cell.
* *
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to bind value to * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
*
* @return bool * @return bool
*/ */
public function bindValue(\PhpOffice\PhpSpreadsheet\Cell $cell, $value = null); public function bindValue(\PhpOffice\PhpSpreadsheet\Cell $cell, $value = null);

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,146 +20,151 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Chart class Chart
{ {
/** /**
* Chart Name * Chart Name.
* *
* @var string * @var string
*/ */
private $name = ''; private $name = '';
/** /**
* Worksheet * Worksheet.
* *
* @var Worksheet * @var Worksheet
*/ */
private $worksheet; private $worksheet;
/** /**
* Chart Title * Chart Title.
* *
* @var Chart\Title * @var Chart\Title
*/ */
private $title; private $title;
/** /**
* Chart Legend * Chart Legend.
* *
* @var Chart\Legend * @var Chart\Legend
*/ */
private $legend; private $legend;
/** /**
* X-Axis Label * X-Axis Label.
* *
* @var Chart\Title * @var Chart\Title
*/ */
private $xAxisLabel; private $xAxisLabel;
/** /**
* Y-Axis Label * Y-Axis Label.
* *
* @var Chart\Title * @var Chart\Title
*/ */
private $yAxisLabel; private $yAxisLabel;
/** /**
* Chart Plot Area * Chart Plot Area.
* *
* @var Chart\PlotArea * @var Chart\PlotArea
*/ */
private $plotArea; private $plotArea;
/** /**
* Plot Visible Only * Plot Visible Only.
* *
* @var bool * @var bool
*/ */
private $plotVisibleOnly = true; private $plotVisibleOnly = true;
/** /**
* Display Blanks as * Display Blanks as.
* *
* @var string * @var string
*/ */
private $displayBlanksAs = '0'; private $displayBlanksAs = '0';
/** /**
* Chart Asix Y as * Chart Asix Y as.
* *
* @var Chart\Axis * @var Chart\Axis
*/ */
private $yAxis; private $yAxis;
/** /**
* Chart Asix X as * Chart Asix X as.
* *
* @var Chart\Axis * @var Chart\Axis
*/ */
private $xAxis; private $xAxis;
/** /**
* Chart Major Gridlines as * Chart Major Gridlines as.
* *
* @var Chart\GridLines * @var Chart\GridLines
*/ */
private $majorGridlines; private $majorGridlines;
/** /**
* Chart Minor Gridlines as * Chart Minor Gridlines as.
* *
* @var Chart\GridLines * @var Chart\GridLines
*/ */
private $minorGridlines; private $minorGridlines;
/** /**
* Top-Left Cell Position * Top-Left Cell Position.
* *
* @var string * @var string
*/ */
private $topLeftCellRef = 'A1'; private $topLeftCellRef = 'A1';
/** /**
* Top-Left X-Offset * Top-Left X-Offset.
* *
* @var int * @var int
*/ */
private $topLeftXOffset = 0; private $topLeftXOffset = 0;
/** /**
* Top-Left Y-Offset * Top-Left Y-Offset.
* *
* @var int * @var int
*/ */
private $topLeftYOffset = 0; private $topLeftYOffset = 0;
/** /**
* Bottom-Right Cell Position * Bottom-Right Cell Position.
* *
* @var string * @var string
*/ */
private $bottomRightCellRef = 'A1'; private $bottomRightCellRef = 'A1';
/** /**
* Bottom-Right X-Offset * Bottom-Right X-Offset.
* *
* @var int * @var int
*/ */
private $bottomRightXOffset = 10; private $bottomRightXOffset = 10;
/** /**
* Bottom-Right Y-Offset * Bottom-Right Y-Offset.
* *
* @var int * @var int
*/ */
private $bottomRightYOffset = 10; private $bottomRightYOffset = 10;
/** /**
* Create a new Chart * Create a new Chart.
*
* @param mixed $name
* @param mixed $plotVisibleOnly
* @param mixed $displayBlanksAs
*/ */
public function __construct($name, Chart\Title $title = null, Chart\Legend $legend = null, Chart\PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', Chart\Title $xAxisLabel = null, Chart\Title $yAxisLabel = null, Chart\Axis $xAxis = null, Chart\Axis $yAxis = null, Chart\GridLines $majorGridlines = null, Chart\GridLines $minorGridlines = null) public function __construct($name, Chart\Title $title = null, Chart\Legend $legend = null, Chart\PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', Chart\Title $xAxisLabel = null, Chart\Title $yAxisLabel = null, Chart\Axis $xAxis = null, Chart\Axis $yAxis = null, Chart\GridLines $majorGridlines = null, Chart\GridLines $minorGridlines = null)
{ {
@ -178,7 +183,7 @@ class Chart
} }
/** /**
* Get Name * Get Name.
* *
* @return string * @return string
*/ */
@ -188,7 +193,7 @@ class Chart
} }
/** /**
* Get Worksheet * Get Worksheet.
* *
* @return Worksheet * @return Worksheet
*/ */
@ -198,10 +203,12 @@ class Chart
} }
/** /**
* Set Worksheet * Set Worksheet.
* *
* @param Worksheet $pValue * @param Worksheet $pValue
*
* @throws Chart\Exception * @throws Chart\Exception
*
* @return Chart * @return Chart
*/ */
public function setWorksheet(Worksheet $pValue = null) public function setWorksheet(Worksheet $pValue = null)
@ -212,7 +219,7 @@ class Chart
} }
/** /**
* Get Title * Get Title.
* *
* @return Chart\Title * @return Chart\Title
*/ */
@ -222,9 +229,10 @@ class Chart
} }
/** /**
* Set Title * Set Title.
* *
* @param Chart\Title $title * @param Chart\Title $title
*
* @return Chart * @return Chart
*/ */
public function setTitle(Chart\Title $title) public function setTitle(Chart\Title $title)
@ -235,7 +243,7 @@ class Chart
} }
/** /**
* Get Legend * Get Legend.
* *
* @return Chart\Legend * @return Chart\Legend
*/ */
@ -245,9 +253,10 @@ class Chart
} }
/** /**
* Set Legend * Set Legend.
* *
* @param Chart\Legend $legend * @param Chart\Legend $legend
*
* @return Chart * @return Chart
*/ */
public function setLegend(Chart\Legend $legend) public function setLegend(Chart\Legend $legend)
@ -258,7 +267,7 @@ class Chart
} }
/** /**
* Get X-Axis Label * Get X-Axis Label.
* *
* @return Chart\Title * @return Chart\Title
*/ */
@ -268,9 +277,10 @@ class Chart
} }
/** /**
* Set X-Axis Label * Set X-Axis Label.
* *
* @param Chart\Title $label * @param Chart\Title $label
*
* @return Chart * @return Chart
*/ */
public function setXAxisLabel(Chart\Title $label) public function setXAxisLabel(Chart\Title $label)
@ -281,7 +291,7 @@ class Chart
} }
/** /**
* Get Y-Axis Label * Get Y-Axis Label.
* *
* @return Chart\Title * @return Chart\Title
*/ */
@ -291,9 +301,10 @@ class Chart
} }
/** /**
* Set Y-Axis Label * Set Y-Axis Label.
* *
* @param Chart\Title $label * @param Chart\Title $label
*
* @return Chart * @return Chart
*/ */
public function setYAxisLabel(Chart\Title $label) public function setYAxisLabel(Chart\Title $label)
@ -304,7 +315,7 @@ class Chart
} }
/** /**
* Get Plot Area * Get Plot Area.
* *
* @return Chart\PlotArea * @return Chart\PlotArea
*/ */
@ -314,7 +325,7 @@ class Chart
} }
/** /**
* Get Plot Visible Only * Get Plot Visible Only.
* *
* @return bool * @return bool
*/ */
@ -324,9 +335,10 @@ class Chart
} }
/** /**
* Set Plot Visible Only * Set Plot Visible Only.
* *
* @param bool $plotVisibleOnly * @param bool $plotVisibleOnly
*
* @return Chart * @return Chart
*/ */
public function setPlotVisibleOnly($plotVisibleOnly = true) public function setPlotVisibleOnly($plotVisibleOnly = true)
@ -337,7 +349,7 @@ class Chart
} }
/** /**
* Get Display Blanks as * Get Display Blanks as.
* *
* @return string * @return string
*/ */
@ -347,9 +359,10 @@ class Chart
} }
/** /**
* Set Display Blanks as * Set Display Blanks as.
* *
* @param string $displayBlanksAs * @param string $displayBlanksAs
*
* @return Chart * @return Chart
*/ */
public function setDisplayBlanksAs($displayBlanksAs = '0') public function setDisplayBlanksAs($displayBlanksAs = '0')
@ -358,7 +371,7 @@ class Chart
} }
/** /**
* Get yAxis * Get yAxis.
* *
* @return Chart\Axis * @return Chart\Axis
*/ */
@ -372,7 +385,7 @@ class Chart
} }
/** /**
* Get xAxis * Get xAxis.
* *
* @return Chart\Axis * @return Chart\Axis
*/ */
@ -386,7 +399,7 @@ class Chart
} }
/** /**
* Get Major Gridlines * Get Major Gridlines.
* *
* @return Chart\GridLines * @return Chart\GridLines
*/ */
@ -400,7 +413,7 @@ class Chart
} }
/** /**
* Get Minor Gridlines * Get Minor Gridlines.
* *
* @return Chart\GridLines * @return Chart\GridLines
*/ */
@ -414,11 +427,12 @@ class Chart
} }
/** /**
* Set the Top Left position for the chart * Set the Top Left position for the chart.
* *
* @param string $cell * @param string $cell
* @param int $xOffset * @param int $xOffset
* @param int $yOffset * @param int $yOffset
*
* @return Chart * @return Chart
*/ */
public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null) public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null)
@ -435,7 +449,7 @@ class Chart
} }
/** /**
* Get the top left position of the chart * Get the top left position of the chart.
* *
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell * @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
*/ */
@ -449,7 +463,7 @@ class Chart
} }
/** /**
* Get the cell address where the top left of the chart is fixed * Get the cell address where the top left of the chart is fixed.
* *
* @return string * @return string
*/ */
@ -459,9 +473,10 @@ class Chart
} }
/** /**
* Set the Top Left cell position for the chart * Set the Top Left cell position for the chart.
* *
* @param string $cell * @param string $cell
*
* @return Chart * @return Chart
*/ */
public function setTopLeftCell($cell) public function setTopLeftCell($cell)
@ -472,10 +487,11 @@ class Chart
} }
/** /**
* Set the offset position within the Top Left cell for the chart * Set the offset position within the Top Left cell for the chart.
* *
* @param int $xOffset * @param int $xOffset
* @param int $yOffset * @param int $yOffset
*
* @return Chart * @return Chart
*/ */
public function setTopLeftOffset($xOffset = null, $yOffset = null) public function setTopLeftOffset($xOffset = null, $yOffset = null)
@ -491,7 +507,7 @@ class Chart
} }
/** /**
* Get the offset position within the Top Left cell for the chart * Get the offset position within the Top Left cell for the chart.
* *
* @return int[] * @return int[]
*/ */
@ -528,11 +544,12 @@ class Chart
} }
/** /**
* Set the Bottom Right position of the chart * Set the Bottom Right position of the chart.
* *
* @param string $cell * @param string $cell
* @param int $xOffset * @param int $xOffset
* @param int $yOffset * @param int $yOffset
*
* @return Chart * @return Chart
*/ */
public function setBottomRightPosition($cell, $xOffset = null, $yOffset = null) public function setBottomRightPosition($cell, $xOffset = null, $yOffset = null)
@ -549,7 +566,7 @@ class Chart
} }
/** /**
* Get the bottom right position of the chart * Get the bottom right position of the chart.
* *
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell * @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
*/ */
@ -570,7 +587,7 @@ class Chart
} }
/** /**
* Get the cell address where the bottom right of the chart is fixed * Get the cell address where the bottom right of the chart is fixed.
* *
* @return string * @return string
*/ */
@ -580,10 +597,11 @@ class Chart
} }
/** /**
* Set the offset position within the Bottom Right cell for the chart * Set the offset position within the Bottom Right cell for the chart.
* *
* @param int $xOffset * @param int $xOffset
* @param int $yOffset * @param int $yOffset
*
* @return Chart * @return Chart
*/ */
public function setBottomRightOffset($xOffset = null, $yOffset = null) public function setBottomRightOffset($xOffset = null, $yOffset = null)
@ -599,7 +617,7 @@ class Chart
} }
/** /**
* Get the offset position within the Bottom Right cell for the chart * Get the offset position within the Bottom Right cell for the chart.
* *
* @return int[] * @return int[]
*/ */

View File

@ -6,12 +6,12 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Created by PhpStorm. * Created by PhpStorm.
* User: Wiktor Trzonkowski * User: Wiktor Trzonkowski
* Date: 6/17/14 * Date: 6/17/14
* Time: 12:11 PM * Time: 12:11 PM.
*/ */
class Axis extends Properties class Axis extends Properties
{ {
/** /**
* Axis Number * Axis Number.
* *
* @var array of mixed * @var array of mixed
*/ */
@ -21,7 +21,7 @@ class Axis extends Properties
]; ];
/** /**
* Axis Options * Axis Options.
* *
* @var array of mixed * @var array of mixed
*/ */
@ -39,7 +39,7 @@ class Axis extends Properties
]; ];
/** /**
* Fill Properties * Fill Properties.
* *
* @var array of mixed * @var array of mixed
*/ */
@ -50,7 +50,7 @@ class Axis extends Properties
]; ];
/** /**
* Line Properties * Line Properties.
* *
* @var array of mixed * @var array of mixed
*/ */
@ -61,7 +61,7 @@ class Axis extends Properties
]; ];
/** /**
* Line Style Properties * Line Style Properties.
* *
* @var array of mixed * @var array of mixed
*/ */
@ -84,7 +84,7 @@ class Axis extends Properties
]; ];
/** /**
* Shadow Properties * Shadow Properties.
* *
* @var array of mixed * @var array of mixed
*/ */
@ -109,7 +109,7 @@ class Axis extends Properties
]; ];
/** /**
* Glow Properties * Glow Properties.
* *
* @var array of mixed * @var array of mixed
*/ */
@ -123,7 +123,7 @@ class Axis extends Properties
]; ];
/** /**
* Soft Edge Properties * Soft Edge Properties.
* *
* @var array of mixed * @var array of mixed
*/ */
@ -132,7 +132,9 @@ class Axis extends Properties
]; ];
/** /**
* Get Series Data Type * Get Series Data Type.
*
* @param mixed $format_code
* *
* @return string * @return string
*/ */
@ -143,7 +145,7 @@ class Axis extends Properties
} }
/** /**
* Get Axis Number Format Data Type * Get Axis Number Format Data Type.
* *
* @return string * @return string
*/ */
@ -153,7 +155,7 @@ class Axis extends Properties
} }
/** /**
* Get Axis Number Source Linked * Get Axis Number Source Linked.
* *
* @return string * @return string
*/ */
@ -163,7 +165,7 @@ class Axis extends Properties
} }
/** /**
* Set Axis Options Properties * Set Axis Options Properties.
* *
* @param string $axis_labels * @param string $axis_labels
* @param string $horizontal_crosses_value * @param string $horizontal_crosses_value
@ -192,7 +194,7 @@ class Axis extends Properties
} }
/** /**
* Get Axis Options Property * Get Axis Options Property.
* *
* @param string $property * @param string $property
* *
@ -204,7 +206,7 @@ class Axis extends Properties
} }
/** /**
* Set Axis Orientation Property * Set Axis Orientation Property.
* *
* @param string $orientation * @param string $orientation
*/ */
@ -214,7 +216,7 @@ class Axis extends Properties
} }
/** /**
* Set Fill Property * Set Fill Property.
* *
* @param string $color * @param string $color
* @param int $alpha * @param int $alpha
@ -226,7 +228,7 @@ class Axis extends Properties
} }
/** /**
* Set Line Property * Set Line Property.
* *
* @param string $color * @param string $color
* @param int $alpha * @param int $alpha
@ -238,7 +240,7 @@ class Axis extends Properties
} }
/** /**
* Get Fill Property * Get Fill Property.
* *
* @param string $property * @param string $property
* *
@ -250,7 +252,7 @@ class Axis extends Properties
} }
/** /**
* Get Line Property * Get Line Property.
* *
* @param string $property * @param string $property
* *
@ -262,7 +264,7 @@ class Axis extends Properties
} }
/** /**
* Set Line Style Properties * Set Line Style Properties.
* *
* @param float $line_width * @param float $line_width
* @param string $compound_type * @param string $compound_type
@ -288,7 +290,7 @@ class Axis extends Properties
} }
/** /**
* Get Line Style Property * Get Line Style Property.
* *
* @param array|string $elements * @param array|string $elements
* *
@ -300,7 +302,7 @@ class Axis extends Properties
} }
/** /**
* Get Line Style Arrow Excel Width * Get Line Style Arrow Excel Width.
* *
* @param string $arrow * @param string $arrow
* *
@ -312,7 +314,7 @@ class Axis extends Properties
} }
/** /**
* Get Line Style Arrow Excel Length * Get Line Style Arrow Excel Length.
* *
* @param string $arrow * @param string $arrow
* *
@ -324,7 +326,7 @@ class Axis extends Properties
} }
/** /**
* Set Shadow Properties * Set Shadow Properties.
* *
* @param int $sh_presets * @param int $sh_presets
* @param string $sh_color_value * @param string $sh_color_value
@ -348,7 +350,7 @@ class Axis extends Properties
} }
/** /**
* Set Shadow Color * Set Shadow Color.
* *
* @param int $shadow_presets * @param int $shadow_presets
* *
@ -363,7 +365,7 @@ class Axis extends Properties
} }
/** /**
* Set Shadow Properties from Maped Values * Set Shadow Properties from Maped Values.
* *
* @param array $properties_map * @param array $properties_map
* @param * $reference * @param * $reference
@ -394,7 +396,7 @@ class Axis extends Properties
} }
/** /**
* Set Shadow Color * Set Shadow Color.
* *
* @param string $color * @param string $color
* @param int $alpha * @param int $alpha
@ -410,7 +412,7 @@ class Axis extends Properties
} }
/** /**
* Set Shadow Blur * Set Shadow Blur.
* *
* @param float $blur * @param float $blur
* *
@ -426,7 +428,7 @@ class Axis extends Properties
} }
/** /**
* Set Shadow Angle * Set Shadow Angle.
* *
* @param int $angle * @param int $angle
* *
@ -442,7 +444,7 @@ class Axis extends Properties
} }
/** /**
* Set Shadow Distance * Set Shadow Distance.
* *
* @param float $distance * @param float $distance
* *
@ -458,7 +460,9 @@ class Axis extends Properties
} }
/** /**
* Get Shadow Property * Get Shadow Property.
*
* @param mixed $elements
*/ */
public function getShadowProperty($elements) public function getShadowProperty($elements)
{ {
@ -466,7 +470,7 @@ class Axis extends Properties
} }
/** /**
* Set Glow Properties * Set Glow Properties.
* *
* @param float $size * @param float $size
* @param string $color_value * @param string $color_value
@ -484,7 +488,7 @@ class Axis extends Properties
} }
/** /**
* Get Glow Property * Get Glow Property.
* *
* @param array|string $property * @param array|string $property
* *
@ -496,7 +500,7 @@ class Axis extends Properties
} }
/** /**
* Set Glow Color * Set Glow Color.
* *
* @param float $size * @param float $size
* *
@ -512,7 +516,7 @@ class Axis extends Properties
} }
/** /**
* Set Glow Color * Set Glow Color.
* *
* @param string $color * @param string $color
* @param int $alpha * @param int $alpha
@ -528,7 +532,7 @@ class Axis extends Properties
} }
/** /**
* Set Soft Edges Size * Set Soft Edges Size.
* *
* @param float $size * @param float $size
*/ */
@ -540,7 +544,7 @@ class Axis extends Properties
} }
/** /**
* Get Soft Edges Size * Get Soft Edges Size.
* *
* @return string * @return string
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Chart; namespace PhpOffice\PhpSpreadsheet\Chart;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -60,70 +61,80 @@ class DataSeries
const STYLE_FILLED = 'filled'; const STYLE_FILLED = 'filled';
/** /**
* Series Plot Type * Series Plot Type.
* *
* @var string * @var string
*/ */
private $plotType; private $plotType;
/** /**
* Plot Grouping Type * Plot Grouping Type.
* *
* @var string * @var string
*/ */
private $plotGrouping; private $plotGrouping;
/** /**
* Plot Direction * Plot Direction.
* *
* @var string * @var string
*/ */
private $plotDirection; private $plotDirection;
/** /**
* Plot Style * Plot Style.
* *
* @var string * @var string
*/ */
private $plotStyle; private $plotStyle;
/** /**
* Order of plots in Series * Order of plots in Series.
* *
* @var array of integer * @var array of integer
*/ */
private $plotOrder = []; private $plotOrder = [];
/** /**
* Plot Label * Plot Label.
* *
* @var array of DataSeriesValues * @var array of DataSeriesValues
*/ */
private $plotLabel = []; private $plotLabel = [];
/** /**
* Plot Category * Plot Category.
* *
* @var array of DataSeriesValues * @var array of DataSeriesValues
*/ */
private $plotCategory = []; private $plotCategory = [];
/** /**
* Smooth Line * Smooth Line.
* *
* @var bool * @var bool
*/ */
private $smoothLine; private $smoothLine;
/** /**
* Plot Values * Plot Values.
* *
* @var array of DataSeriesValues * @var array of DataSeriesValues
*/ */
private $plotValues = []; private $plotValues = [];
/** /**
* Create a new DataSeries * Create a new DataSeries.
*
* @param null|mixed $plotType
* @param null|mixed $plotGrouping
* @param mixed $plotOrder
* @param mixed $plotLabel
* @param mixed $plotCategory
* @param mixed $plotValues
* @param null|mixed $plotDirection
* @param null|mixed $smoothLine
* @param null|mixed $plotStyle
*/ */
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = [], $plotLabel = [], $plotCategory = [], $plotValues = [], $plotDirection = null, $smoothLine = null, $plotStyle = null) public function __construct($plotType = null, $plotGrouping = null, $plotOrder = [], $plotLabel = [], $plotCategory = [], $plotValues = [], $plotDirection = null, $smoothLine = null, $plotStyle = null)
{ {
@ -151,7 +162,7 @@ class DataSeries
} }
/** /**
* Get Plot Type * Get Plot Type.
* *
* @return string * @return string
*/ */
@ -161,9 +172,10 @@ class DataSeries
} }
/** /**
* Set Plot Type * Set Plot Type.
* *
* @param string $plotType * @param string $plotType
*
* @return DataSeries * @return DataSeries
*/ */
public function setPlotType($plotType = '') public function setPlotType($plotType = '')
@ -174,7 +186,7 @@ class DataSeries
} }
/** /**
* Get Plot Grouping Type * Get Plot Grouping Type.
* *
* @return string * @return string
*/ */
@ -184,9 +196,10 @@ class DataSeries
} }
/** /**
* Set Plot Grouping Type * Set Plot Grouping Type.
* *
* @param string $groupingType * @param string $groupingType
*
* @return DataSeries * @return DataSeries
*/ */
public function setPlotGrouping($groupingType = null) public function setPlotGrouping($groupingType = null)
@ -197,7 +210,7 @@ class DataSeries
} }
/** /**
* Get Plot Direction * Get Plot Direction.
* *
* @return string * @return string
*/ */
@ -207,9 +220,10 @@ class DataSeries
} }
/** /**
* Set Plot Direction * Set Plot Direction.
* *
* @param string $plotDirection * @param string $plotDirection
*
* @return DataSeries * @return DataSeries
*/ */
public function setPlotDirection($plotDirection = null) public function setPlotDirection($plotDirection = null)
@ -220,7 +234,7 @@ class DataSeries
} }
/** /**
* Get Plot Order * Get Plot Order.
* *
* @return string * @return string
*/ */
@ -230,7 +244,7 @@ class DataSeries
} }
/** /**
* Get Plot Labels * Get Plot Labels.
* *
* @return array of DataSeriesValues * @return array of DataSeriesValues
*/ */
@ -240,7 +254,9 @@ class DataSeries
} }
/** /**
* Get Plot Label by Index * Get Plot Label by Index.
*
* @param mixed $index
* *
* @return DataSeriesValues * @return DataSeriesValues
*/ */
@ -257,7 +273,7 @@ class DataSeries
} }
/** /**
* Get Plot Categories * Get Plot Categories.
* *
* @return array of DataSeriesValues * @return array of DataSeriesValues
*/ */
@ -267,7 +283,9 @@ class DataSeries
} }
/** /**
* Get Plot Category by Index * Get Plot Category by Index.
*
* @param mixed $index
* *
* @return DataSeriesValues * @return DataSeriesValues
*/ */
@ -284,7 +302,7 @@ class DataSeries
} }
/** /**
* Get Plot Style * Get Plot Style.
* *
* @return string * @return string
*/ */
@ -294,9 +312,10 @@ class DataSeries
} }
/** /**
* Set Plot Style * Set Plot Style.
* *
* @param string $plotStyle * @param string $plotStyle
*
* @return DataSeries * @return DataSeries
*/ */
public function setPlotStyle($plotStyle = null) public function setPlotStyle($plotStyle = null)
@ -307,7 +326,7 @@ class DataSeries
} }
/** /**
* Get Plot Values * Get Plot Values.
* *
* @return array of DataSeriesValues * @return array of DataSeriesValues
*/ */
@ -317,7 +336,9 @@ class DataSeries
} }
/** /**
* Get Plot Values by Index * Get Plot Values by Index.
*
* @param mixed $index
* *
* @return DataSeriesValues * @return DataSeriesValues
*/ */
@ -334,7 +355,7 @@ class DataSeries
} }
/** /**
* Get Number of Plot Series * Get Number of Plot Series.
* *
* @return int * @return int
*/ */
@ -344,7 +365,7 @@ class DataSeries
} }
/** /**
* Get Smooth Line * Get Smooth Line.
* *
* @return bool * @return bool
*/ */
@ -354,9 +375,10 @@ class DataSeries
} }
/** /**
* Set Smooth Line * Set Smooth Line.
* *
* @param bool $smoothLine * @param bool $smoothLine
*
* @return DataSeries * @return DataSeries
*/ */
public function setSmoothLine($smoothLine = true) public function setSmoothLine($smoothLine = true)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Chart; namespace PhpOffice\PhpSpreadsheet\Chart;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -34,50 +35,56 @@ class DataSeriesValues
]; ];
/** /**
* Series Data Type * Series Data Type.
* *
* @var string * @var string
*/ */
private $dataType; private $dataType;
/** /**
* Series Data Source * Series Data Source.
* *
* @var string * @var string
*/ */
private $dataSource; private $dataSource;
/** /**
* Format Code * Format Code.
* *
* @var string * @var string
*/ */
private $formatCode; private $formatCode;
/** /**
* Series Point Marker * Series Point Marker.
* *
* @var string * @var string
*/ */
private $pointMarker; private $pointMarker;
/** /**
* Point Count (The number of datapoints in the dataseries) * Point Count (The number of datapoints in the dataseries).
* *
* @var int * @var int
*/ */
private $pointCount = 0; private $pointCount = 0;
/** /**
* Data Values * Data Values.
* *
* @var array of mixed * @var array of mixed
*/ */
private $dataValues = []; private $dataValues = [];
/** /**
* Create a new DataSeriesValues object * Create a new DataSeriesValues object.
*
* @param string $dataSource * @param string $dataSource
* @param mixed $dataType
* @param null|mixed $formatCode
* @param mixed $pointCount
* @param mixed $dataValues
* @param null|mixed $marker
*/ */
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = [], $marker = null) public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = [], $marker = null)
{ {
@ -90,7 +97,7 @@ class DataSeriesValues
} }
/** /**
* Get Series Data Type * Get Series Data Type.
* *
* @return string * @return string
*/ */
@ -100,7 +107,7 @@ class DataSeriesValues
} }
/** /**
* Set Series Data Type * Set Series Data Type.
* *
* @param string $dataType Datatype of this data series * @param string $dataType Datatype of this data series
* Typical values are: * Typical values are:
@ -108,7 +115,9 @@ class DataSeriesValues
* Normally used for axis point values * Normally used for axis point values
* \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_NUMBER * \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_NUMBER
* Normally used for chart data values * Normally used for chart data values
*
* @throws Exception * @throws Exception
*
* @return DataSeriesValues * @return DataSeriesValues
*/ */
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER)
@ -122,7 +131,7 @@ class DataSeriesValues
} }
/** /**
* Get Series Data Source (formula) * Get Series Data Source (formula).
* *
* @return string * @return string
*/ */
@ -132,9 +141,11 @@ class DataSeriesValues
} }
/** /**
* Set Series Data Source (formula) * Set Series Data Source (formula).
* *
* @param string $dataSource * @param string $dataSource
* @param mixed $refreshDataValues
*
* @return DataSeriesValues * @return DataSeriesValues
*/ */
public function setDataSource($dataSource = null, $refreshDataValues = true) public function setDataSource($dataSource = null, $refreshDataValues = true)
@ -149,7 +160,7 @@ class DataSeriesValues
} }
/** /**
* Get Point Marker * Get Point Marker.
* *
* @return string * @return string
*/ */
@ -159,9 +170,10 @@ class DataSeriesValues
} }
/** /**
* Set Point Marker * Set Point Marker.
* *
* @param string $marker * @param string $marker
*
* @return DataSeriesValues * @return DataSeriesValues
*/ */
public function setPointMarker($marker = null) public function setPointMarker($marker = null)
@ -172,7 +184,7 @@ class DataSeriesValues
} }
/** /**
* Get Series Format Code * Get Series Format Code.
* *
* @return string * @return string
*/ */
@ -182,9 +194,10 @@ class DataSeriesValues
} }
/** /**
* Set Series Format Code * Set Series Format Code.
* *
* @param string $formatCode * @param string $formatCode
*
* @return DataSeriesValues * @return DataSeriesValues
*/ */
public function setFormatCode($formatCode = null) public function setFormatCode($formatCode = null)
@ -195,7 +208,7 @@ class DataSeriesValues
} }
/** /**
* Get Series Point Count * Get Series Point Count.
* *
* @return int * @return int
*/ */
@ -205,7 +218,7 @@ class DataSeriesValues
} }
/** /**
* Identify if the Data Series is a multi-level or a simple series * Identify if the Data Series is a multi-level or a simple series.
* *
* @return bool|null * @return bool|null
*/ */
@ -219,7 +232,7 @@ class DataSeriesValues
} }
/** /**
* Return the level count of a multi-level Data Series * Return the level count of a multi-level Data Series.
* *
* @return int * @return int
*/ */
@ -234,7 +247,7 @@ class DataSeriesValues
} }
/** /**
* Get Series Data Values * Get Series Data Values.
* *
* @return array of mixed * @return array of mixed
*/ */
@ -244,7 +257,7 @@ class DataSeriesValues
} }
/** /**
* Get the first Series Data value * Get the first Series Data value.
* *
* @return mixed * @return mixed
*/ */
@ -261,12 +274,13 @@ class DataSeriesValues
} }
/** /**
* Set Series Data Values * Set Series Data Values.
* *
* @param array $dataValues * @param array $dataValues
* @param bool $refreshDataSource * @param bool $refreshDataSource
* TRUE - refresh the value of dataSource based on the values of $dataValues * TRUE - refresh the value of dataSource based on the values of $dataValues
* FALSE - don't change the value of dataSource * FALSE - don't change the value of dataSource
*
* @return DataSeriesValues * @return DataSeriesValues
*/ */
public function setDataValues($dataValues = [], $refreshDataSource = true) public function setDataValues($dataValues = [], $refreshDataSource = true)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Chart; namespace PhpOffice\PhpSpreadsheet\Chart;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,13 +20,14 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Exception extends \PhpOffice\PhpSpreadsheet\Exception class Exception extends \PhpOffice\PhpSpreadsheet\Exception
{ {
/** /**
* Error handler callback * Error handler callback.
* *
* @param mixed $code * @param mixed $code
* @param mixed $string * @param mixed $string

View File

@ -6,7 +6,7 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Created by PhpStorm. * Created by PhpStorm.
* User: Wiktor Trzonkowski * User: Wiktor Trzonkowski
* Date: 7/2/14 * Date: 7/2/14
* Time: 2:36 PM * Time: 2:36 PM.
*/ */
class GridLines extends Properties class GridLines extends Properties
{ {
@ -16,7 +16,7 @@ class GridLines extends Properties
* Line Properties @var array of mixed * Line Properties @var array of mixed
* Shadow Properties @var array of mixed * Shadow Properties @var array of mixed
* Glow Properties @var array of mixed * Glow Properties @var array of mixed
* Soft Properties @var array of mixed * Soft Properties @var array of mixed.
*/ */
private $objectState = false; private $objectState = false;
@ -79,7 +79,7 @@ class GridLines extends Properties
]; ];
/** /**
* Get Object State * Get Object State.
* *
* @return bool * @return bool
*/ */
@ -89,7 +89,7 @@ class GridLines extends Properties
} }
/** /**
* Change Object State to True * Change Object State to True.
* *
* @return GridLines * @return GridLines
*/ */
@ -101,7 +101,7 @@ class GridLines extends Properties
} }
/** /**
* Set Line Color Properties * Set Line Color Properties.
* *
* @param string $value * @param string $value
* @param int $alpha * @param int $alpha
@ -118,7 +118,7 @@ class GridLines extends Properties
} }
/** /**
* Set Line Color Properties * Set Line Color Properties.
* *
* @param float $line_width * @param float $line_width
* @param string $compound_type * @param string $compound_type
@ -163,7 +163,7 @@ class GridLines extends Properties
} }
/** /**
* Get Line Color Property * Get Line Color Property.
* *
* @param string $parameter * @param string $parameter
* *
@ -175,7 +175,7 @@ class GridLines extends Properties
} }
/** /**
* Get Line Style Property * Get Line Style Property.
* *
* @param array|string $elements * @param array|string $elements
* *
@ -187,7 +187,7 @@ class GridLines extends Properties
} }
/** /**
* Set Glow Properties * Set Glow Properties.
* *
* @param float $size * @param float $size
* @param string $color_value * @param string $color_value
@ -203,7 +203,7 @@ class GridLines extends Properties
} }
/** /**
* Get Glow Color Property * Get Glow Color Property.
* *
* @param string $property * @param string $property
* *
@ -215,7 +215,7 @@ class GridLines extends Properties
} }
/** /**
* Get Glow Size * Get Glow Size.
* *
* @return string * @return string
*/ */
@ -225,7 +225,7 @@ class GridLines extends Properties
} }
/** /**
* Set Glow Size * Set Glow Size.
* *
* @param float $size * @param float $size
* *
@ -239,7 +239,7 @@ class GridLines extends Properties
} }
/** /**
* Set Glow Color * Set Glow Color.
* *
* @param string $color * @param string $color
* @param int $alpha * @param int $alpha
@ -263,7 +263,7 @@ class GridLines extends Properties
} }
/** /**
* Get Line Style Arrow Parameters * Get Line Style Arrow Parameters.
* *
* @param string $arrow_selector * @param string $arrow_selector
* @param string $property_selector * @param string $property_selector
@ -276,7 +276,7 @@ class GridLines extends Properties
} }
/** /**
* Set Shadow Properties * Set Shadow Properties.
* *
* @param int $sh_presets * @param int $sh_presets
* @param string $sh_color_value * @param string $sh_color_value
@ -301,7 +301,7 @@ class GridLines extends Properties
} }
/** /**
* Set Shadow Presets Properties * Set Shadow Presets Properties.
* *
* @param int $shadow_presets * @param int $shadow_presets
* *
@ -316,7 +316,7 @@ class GridLines extends Properties
} }
/** /**
* Set Shadow Properties Values * Set Shadow Properties Values.
* *
* @param array $properties_map * @param array $properties_map
* @param * $reference * @param * $reference
@ -347,11 +347,12 @@ class GridLines extends Properties
} }
/** /**
* Set Shadow Color * Set Shadow Color.
* *
* @param string $color * @param string $color
* @param int $alpha * @param int $alpha
* @param string $type * @param string $type
*
* @return GridLines * @return GridLines
*/ */
private function setShadowColor($color, $alpha, $type) private function setShadowColor($color, $alpha, $type)
@ -370,7 +371,7 @@ class GridLines extends Properties
} }
/** /**
* Set Shadow Blur * Set Shadow Blur.
* *
* @param float $blur * @param float $blur
* *
@ -386,9 +387,10 @@ class GridLines extends Properties
} }
/** /**
* Set Shadow Angle * Set Shadow Angle.
* *
* @param int $angle * @param int $angle
*
* @return GridLines * @return GridLines
*/ */
private function setShadowAngle($angle) private function setShadowAngle($angle)
@ -401,9 +403,10 @@ class GridLines extends Properties
} }
/** /**
* Set Shadow Distance * Set Shadow Distance.
* *
* @param float $distance * @param float $distance
*
* @return GridLines * @return GridLines
*/ */
private function setShadowDistance($distance) private function setShadowDistance($distance)
@ -416,10 +419,11 @@ class GridLines extends Properties
} }
/** /**
* Get Shadow Property * Get Shadow Property.
* *
* @param string $elements * @param string $elements
* @param array $elements * @param array $elements
*
* @return string * @return string
*/ */
public function getShadowProperty($elements) public function getShadowProperty($elements)
@ -428,7 +432,7 @@ class GridLines extends Properties
} }
/** /**
* Set Soft Edges Size * Set Soft Edges Size.
* *
* @param float $size * @param float $size
*/ */
@ -441,7 +445,7 @@ class GridLines extends Properties
} }
/** /**
* Get Soft Edges Size * Get Soft Edges Size.
* *
* @return string * @return string
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Chart; namespace PhpOffice\PhpSpreadsheet\Chart;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,55 +20,56 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Layout class Layout
{ {
/** /**
* layoutTarget * layoutTarget.
* *
* @var string * @var string
*/ */
private $layoutTarget; private $layoutTarget;
/** /**
* X Mode * X Mode.
* *
* @var string * @var string
*/ */
private $xMode; private $xMode;
/** /**
* Y Mode * Y Mode.
* *
* @var string * @var string
*/ */
private $yMode; private $yMode;
/** /**
* X-Position * X-Position.
* *
* @var float * @var float
*/ */
private $xPos; private $xPos;
/** /**
* Y-Position * Y-Position.
* *
* @var float * @var float
*/ */
private $yPos; private $yPos;
/** /**
* width * width.
* *
* @var float * @var float
*/ */
private $width; private $width;
/** /**
* height * height.
* *
* @var float * @var float
*/ */
@ -76,7 +77,7 @@ class Layout
/** /**
* show legend key * show legend key
* Specifies that legend keys should be shown in data labels * Specifies that legend keys should be shown in data labels.
* *
* @var bool * @var bool
*/ */
@ -115,7 +116,7 @@ class Layout
private $showPercent; private $showPercent;
/** /**
* show bubble size * show bubble size.
* *
* @var bool * @var bool
*/ */
@ -130,7 +131,9 @@ class Layout
private $showLeaderLines; private $showLeaderLines;
/** /**
* Create a new Layout * Create a new Layout.
*
* @param mixed $layout
*/ */
public function __construct($layout = []) public function __construct($layout = [])
{ {
@ -158,7 +161,7 @@ class Layout
} }
/** /**
* Get Layout Target * Get Layout Target.
* *
* @return string * @return string
*/ */
@ -168,10 +171,11 @@ class Layout
} }
/** /**
* Set Layout Target * Set Layout Target.
* *
* @param Layout Target $value * @param Layout Target $value
* @param string $value * @param string $value
*
* @return Layout * @return Layout
*/ */
public function setLayoutTarget($value) public function setLayoutTarget($value)
@ -182,7 +186,7 @@ class Layout
} }
/** /**
* Get X-Mode * Get X-Mode.
* *
* @return string * @return string
*/ */
@ -192,9 +196,10 @@ class Layout
} }
/** /**
* Set X-Mode * Set X-Mode.
* *
* @param X-Mode $value * @param X-Mode $value
*
* @return Layout * @return Layout
*/ */
public function setXMode($value) public function setXMode($value)
@ -205,7 +210,7 @@ class Layout
} }
/** /**
* Get Y-Mode * Get Y-Mode.
* *
* @return string * @return string
*/ */
@ -215,9 +220,10 @@ class Layout
} }
/** /**
* Set Y-Mode * Set Y-Mode.
* *
* @param Y-Mode $value * @param Y-Mode $value
*
* @return Layout * @return Layout
*/ */
public function setYMode($value) public function setYMode($value)
@ -228,7 +234,7 @@ class Layout
} }
/** /**
* Get X-Position * Get X-Position.
* *
* @return number * @return number
*/ */
@ -238,9 +244,10 @@ class Layout
} }
/** /**
* Set X-Position * Set X-Position.
* *
* @param X-Position $value * @param X-Position $value
*
* @return Layout * @return Layout
*/ */
public function setXPosition($value) public function setXPosition($value)
@ -251,7 +258,7 @@ class Layout
} }
/** /**
* Get Y-Position * Get Y-Position.
* *
* @return number * @return number
*/ */
@ -261,9 +268,10 @@ class Layout
} }
/** /**
* Set Y-Position * Set Y-Position.
* *
* @param Y-Position $value * @param Y-Position $value
*
* @return Layout * @return Layout
*/ */
public function setYPosition($value) public function setYPosition($value)
@ -274,7 +282,7 @@ class Layout
} }
/** /**
* Get Width * Get Width.
* *
* @return number * @return number
*/ */
@ -284,9 +292,10 @@ class Layout
} }
/** /**
* Set Width * Set Width.
* *
* @param Width $value * @param Width $value
*
* @return Layout * @return Layout
*/ */
public function setWidth($value) public function setWidth($value)
@ -297,7 +306,7 @@ class Layout
} }
/** /**
* Get Height * Get Height.
* *
* @return number * @return number
*/ */
@ -307,9 +316,10 @@ class Layout
} }
/** /**
* Set Height * Set Height.
* *
* @param Height $value * @param Height $value
*
* @return Layout * @return Layout
*/ */
public function setHeight($value) public function setHeight($value)
@ -320,7 +330,7 @@ class Layout
} }
/** /**
* Get show legend key * Get show legend key.
* *
* @return bool * @return bool
*/ */
@ -334,6 +344,7 @@ class Layout
* Specifies that legend keys should be shown in data labels. * Specifies that legend keys should be shown in data labels.
* *
* @param bool $value Show legend key * @param bool $value Show legend key
*
* @return Layout * @return Layout
*/ */
public function setShowLegendKey($value) public function setShowLegendKey($value)
@ -344,7 +355,7 @@ class Layout
} }
/** /**
* Get show value * Get show value.
* *
* @return bool * @return bool
*/ */
@ -358,6 +369,7 @@ class Layout
* Specifies that the value should be shown in data labels. * Specifies that the value should be shown in data labels.
* *
* @param bool $value Show val * @param bool $value Show val
*
* @return Layout * @return Layout
*/ */
public function setShowVal($value) public function setShowVal($value)
@ -368,7 +380,7 @@ class Layout
} }
/** /**
* Get show category name * Get show category name.
* *
* @return bool * @return bool
*/ */
@ -382,6 +394,7 @@ class Layout
* Specifies that the category name should be shown in data labels. * Specifies that the category name should be shown in data labels.
* *
* @param bool $value Show cat name * @param bool $value Show cat name
*
* @return Layout * @return Layout
*/ */
public function setShowCatName($value) public function setShowCatName($value)
@ -392,7 +405,7 @@ class Layout
} }
/** /**
* Get show data series name * Get show data series name.
* *
* @return bool * @return bool
*/ */
@ -406,6 +419,7 @@ class Layout
* Specifies that the series name should be shown in data labels. * Specifies that the series name should be shown in data labels.
* *
* @param bool $value Show series name * @param bool $value Show series name
*
* @return Layout * @return Layout
*/ */
public function setShowSerName($value) public function setShowSerName($value)
@ -416,7 +430,7 @@ class Layout
} }
/** /**
* Get show percentage * Get show percentage.
* *
* @return bool * @return bool
*/ */
@ -430,6 +444,7 @@ class Layout
* Specifies that the percentage should be shown in data labels. * Specifies that the percentage should be shown in data labels.
* *
* @param bool $value Show percentage * @param bool $value Show percentage
*
* @return Layout * @return Layout
*/ */
public function setShowPercent($value) public function setShowPercent($value)
@ -440,7 +455,7 @@ class Layout
} }
/** /**
* Get show bubble size * Get show bubble size.
* *
* @return bool * @return bool
*/ */
@ -454,6 +469,7 @@ class Layout
* Specifies that the bubble size should be shown in data labels. * Specifies that the bubble size should be shown in data labels.
* *
* @param bool $value Show bubble size * @param bool $value Show bubble size
*
* @return Layout * @return Layout
*/ */
public function setShowBubbleSize($value) public function setShowBubbleSize($value)
@ -464,7 +480,7 @@ class Layout
} }
/** /**
* Get show leader lines * Get show leader lines.
* *
* @return bool * @return bool
*/ */
@ -478,6 +494,7 @@ class Layout
* Specifies that leader lines should be shown in data labels. * Specifies that leader lines should be shown in data labels.
* *
* @param bool $value Show leader lines * @param bool $value Show leader lines
*
* @return Layout * @return Layout
*/ */
public function setShowLeaderLines($value) public function setShowLeaderLines($value)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Chart; namespace PhpOffice\PhpSpreadsheet\Chart;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -49,7 +50,7 @@ class Legend
]; ];
/** /**
* Legend position * Legend position.
* *
* @var string * @var string
*/ */
@ -63,14 +64,17 @@ class Legend
private $overlay = true; private $overlay = true;
/** /**
* Legend Layout * Legend Layout.
* *
* @var Layout * @var Layout
*/ */
private $layout = null; private $layout = null;
/** /**
* Create a new Legend * Create a new Legend.
*
* @param mixed $position
* @param mixed $overlay
*/ */
public function __construct($position = self::POSITION_RIGHT, Layout $layout = null, $overlay = false) public function __construct($position = self::POSITION_RIGHT, Layout $layout = null, $overlay = false)
{ {
@ -80,7 +84,7 @@ class Legend
} }
/** /**
* Get legend position as an excel string value * Get legend position as an excel string value.
* *
* @return string * @return string
*/ */
@ -90,7 +94,7 @@ class Legend
} }
/** /**
* Get legend position using an excel string value * Get legend position using an excel string value.
* *
* @param string $position * @param string $position
*/ */
@ -106,7 +110,7 @@ class Legend
} }
/** /**
* Get legend position as an Excel internal numeric value * Get legend position as an Excel internal numeric value.
* *
* @return number * @return number
*/ */
@ -116,7 +120,7 @@ class Legend
} }
/** /**
* Set legend position using an Excel internal numeric value * Set legend position using an Excel internal numeric value.
* *
* @param number $positionXL * @param number $positionXL
*/ */
@ -145,6 +149,7 @@ class Legend
* Set allow overlay of other elements? * Set allow overlay of other elements?
* *
* @param bool $overlay * @param bool $overlay
*
* @return bool * @return bool
*/ */
public function setOverlay($overlay = false) public function setOverlay($overlay = false)
@ -159,7 +164,7 @@ class Legend
} }
/** /**
* Get Layout * Get Layout.
* *
* @return Layout * @return Layout
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Chart; namespace PhpOffice\PhpSpreadsheet\Chart;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,27 +20,30 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class PlotArea class PlotArea
{ {
/** /**
* PlotArea Layout * PlotArea Layout.
* *
* @var Layout * @var Layout
*/ */
private $layout = null; private $layout = null;
/** /**
* Plot Series * Plot Series.
* *
* @var array of DataSeries * @var array of DataSeries
*/ */
private $plotSeries = []; private $plotSeries = [];
/** /**
* Create a new PlotArea * Create a new PlotArea.
*
* @param mixed $plotSeries
*/ */
public function __construct(Layout $layout = null, $plotSeries = []) public function __construct(Layout $layout = null, $plotSeries = [])
{ {
@ -49,7 +52,7 @@ class PlotArea
} }
/** /**
* Get Layout * Get Layout.
* *
* @return Layout * @return Layout
*/ */
@ -59,7 +62,7 @@ class PlotArea
} }
/** /**
* Get Number of Plot Groups * Get Number of Plot Groups.
* *
* @return array of DataSeries * @return array of DataSeries
*/ */
@ -69,7 +72,7 @@ class PlotArea
} }
/** /**
* Get Number of Plot Series * Get Number of Plot Series.
* *
* @return int * @return int
*/ */
@ -84,7 +87,7 @@ class PlotArea
} }
/** /**
* Get Plot Series * Get Plot Series.
* *
* @return array of DataSeries * @return array of DataSeries
*/ */
@ -94,7 +97,9 @@ class PlotArea
} }
/** /**
* Get Plot Series by Index * Get Plot Series by Index.
*
* @param mixed $index
* *
* @return DataSeries * @return DataSeries
*/ */
@ -104,9 +109,11 @@ class PlotArea
} }
/** /**
* Set Plot Series * Set Plot Series.
* *
* @param DataSeries[] * @param DataSeries[]
* @param mixed $plotSeries
*
* @return PlotArea * @return PlotArea
*/ */
public function setPlotSeries($plotSeries = []) public function setPlotSeries($plotSeries = [])

View File

@ -6,114 +6,109 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Created by PhpStorm. * Created by PhpStorm.
* User: nhw2h8s * User: nhw2h8s
* Date: 7/2/14 * Date: 7/2/14
* Time: 5:45 PM * Time: 5:45 PM.
*/ */
abstract class Properties abstract class Properties
{ {
const const
EXCEL_COLOR_TYPE_STANDARD = 'prstClr', EXCEL_COLOR_TYPE_STANDARD = 'prstClr';
EXCEL_COLOR_TYPE_SCHEME = 'schemeClr', const EXCEL_COLOR_TYPE_SCHEME = 'schemeClr';
EXCEL_COLOR_TYPE_ARGB = 'srgbClr'; const EXCEL_COLOR_TYPE_ARGB = 'srgbClr';
const const
AXIS_LABELS_LOW = 'low', AXIS_LABELS_LOW = 'low';
AXIS_LABELS_HIGH = 'high', const AXIS_LABELS_HIGH = 'high';
AXIS_LABELS_NEXT_TO = 'nextTo', const AXIS_LABELS_NEXT_TO = 'nextTo';
AXIS_LABELS_NONE = 'none'; const AXIS_LABELS_NONE = 'none';
const const
TICK_MARK_NONE = 'none', TICK_MARK_NONE = 'none';
TICK_MARK_INSIDE = 'in', const TICK_MARK_INSIDE = 'in';
TICK_MARK_OUTSIDE = 'out', const TICK_MARK_OUTSIDE = 'out';
TICK_MARK_CROSS = 'cross'; const TICK_MARK_CROSS = 'cross';
const const
HORIZONTAL_CROSSES_AUTOZERO = 'autoZero', HORIZONTAL_CROSSES_AUTOZERO = 'autoZero';
HORIZONTAL_CROSSES_MAXIMUM = 'max'; const HORIZONTAL_CROSSES_MAXIMUM = 'max';
const const
FORMAT_CODE_GENERAL = 'General', FORMAT_CODE_GENERAL = 'General';
FORMAT_CODE_NUMBER = '#,##0.00', const FORMAT_CODE_NUMBER = '#,##0.00';
FORMAT_CODE_CURRENCY = '$#,##0.00', const FORMAT_CODE_CURRENCY = '$#,##0.00';
FORMAT_CODE_ACCOUNTING = '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)', const FORMAT_CODE_ACCOUNTING = '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)';
FORMAT_CODE_DATE = 'm/d/yyyy', const FORMAT_CODE_DATE = 'm/d/yyyy';
FORMAT_CODE_TIME = '[$-F400]h:mm:ss AM/PM', const FORMAT_CODE_TIME = '[$-F400]h:mm:ss AM/PM';
FORMAT_CODE_PERCENTAGE = '0.00%', const FORMAT_CODE_PERCENTAGE = '0.00%';
FORMAT_CODE_FRACTION = '# ?/?', const FORMAT_CODE_FRACTION = '# ?/?';
FORMAT_CODE_SCIENTIFIC = '0.00E+00', const FORMAT_CODE_SCIENTIFIC = '0.00E+00';
FORMAT_CODE_TEXT = '@', const FORMAT_CODE_TEXT = '@';
FORMAT_CODE_SPECIAL = '00000'; const FORMAT_CODE_SPECIAL = '00000';
const const
ORIENTATION_NORMAL = 'minMax', ORIENTATION_NORMAL = 'minMax';
ORIENTATION_REVERSED = 'maxMin'; const ORIENTATION_REVERSED = 'maxMin';
const const
LINE_STYLE_COMPOUND_SIMPLE = 'sng', LINE_STYLE_COMPOUND_SIMPLE = 'sng';
LINE_STYLE_COMPOUND_DOUBLE = 'dbl', const LINE_STYLE_COMPOUND_DOUBLE = 'dbl';
LINE_STYLE_COMPOUND_THICKTHIN = 'thickThin', const LINE_STYLE_COMPOUND_THICKTHIN = 'thickThin';
LINE_STYLE_COMPOUND_THINTHICK = 'thinThick', const LINE_STYLE_COMPOUND_THINTHICK = 'thinThick';
LINE_STYLE_COMPOUND_TRIPLE = 'tri', const LINE_STYLE_COMPOUND_TRIPLE = 'tri';
const LINE_STYLE_DASH_SOLID = 'solid';
LINE_STYLE_DASH_SOLID = 'solid', const LINE_STYLE_DASH_ROUND_DOT = 'sysDot';
LINE_STYLE_DASH_ROUND_DOT = 'sysDot', const LINE_STYLE_DASH_SQUERE_DOT = 'sysDash';
LINE_STYLE_DASH_SQUERE_DOT = 'sysDash', const LINE_STYPE_DASH_DASH = 'dash';
LINE_STYPE_DASH_DASH = 'dash', const LINE_STYLE_DASH_DASH_DOT = 'dashDot';
LINE_STYLE_DASH_DASH_DOT = 'dashDot', const LINE_STYLE_DASH_LONG_DASH = 'lgDash';
LINE_STYLE_DASH_LONG_DASH = 'lgDash', const LINE_STYLE_DASH_LONG_DASH_DOT = 'lgDashDot';
LINE_STYLE_DASH_LONG_DASH_DOT = 'lgDashDot', const LINE_STYLE_DASH_LONG_DASH_DOT_DOT = 'lgDashDotDot';
LINE_STYLE_DASH_LONG_DASH_DOT_DOT = 'lgDashDotDot', const LINE_STYLE_CAP_SQUARE = 'sq';
const LINE_STYLE_CAP_ROUND = 'rnd';
LINE_STYLE_CAP_SQUARE = 'sq', const LINE_STYLE_CAP_FLAT = 'flat';
LINE_STYLE_CAP_ROUND = 'rnd', const LINE_STYLE_JOIN_ROUND = 'bevel';
LINE_STYLE_CAP_FLAT = 'flat', const LINE_STYLE_JOIN_MITER = 'miter';
const LINE_STYLE_JOIN_BEVEL = 'bevel';
LINE_STYLE_JOIN_ROUND = 'bevel', const LINE_STYLE_ARROW_TYPE_NOARROW = null;
LINE_STYLE_JOIN_MITER = 'miter', const LINE_STYLE_ARROW_TYPE_ARROW = 'triangle';
LINE_STYLE_JOIN_BEVEL = 'bevel', const LINE_STYLE_ARROW_TYPE_OPEN = 'arrow';
const LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth';
LINE_STYLE_ARROW_TYPE_NOARROW = null, const LINE_STYLE_ARROW_TYPE_DIAMOND = 'diamond';
LINE_STYLE_ARROW_TYPE_ARROW = 'triangle', const LINE_STYLE_ARROW_TYPE_OVAL = 'oval';
LINE_STYLE_ARROW_TYPE_OPEN = 'arrow', const LINE_STYLE_ARROW_SIZE_1 = 1;
LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth', const LINE_STYLE_ARROW_SIZE_2 = 2;
LINE_STYLE_ARROW_TYPE_DIAMOND = 'diamond', const LINE_STYLE_ARROW_SIZE_3 = 3;
LINE_STYLE_ARROW_TYPE_OVAL = 'oval', const LINE_STYLE_ARROW_SIZE_4 = 4;
const LINE_STYLE_ARROW_SIZE_5 = 5;
LINE_STYLE_ARROW_SIZE_1 = 1, const LINE_STYLE_ARROW_SIZE_6 = 6;
LINE_STYLE_ARROW_SIZE_2 = 2, const LINE_STYLE_ARROW_SIZE_7 = 7;
LINE_STYLE_ARROW_SIZE_3 = 3, const LINE_STYLE_ARROW_SIZE_8 = 8;
LINE_STYLE_ARROW_SIZE_4 = 4, const LINE_STYLE_ARROW_SIZE_9 = 9;
LINE_STYLE_ARROW_SIZE_5 = 5,
LINE_STYLE_ARROW_SIZE_6 = 6,
LINE_STYLE_ARROW_SIZE_7 = 7,
LINE_STYLE_ARROW_SIZE_8 = 8,
LINE_STYLE_ARROW_SIZE_9 = 9;
const const
SHADOW_PRESETS_NOSHADOW = null, SHADOW_PRESETS_NOSHADOW = null;
SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1, const SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1;
SHADOW_PRESETS_OUTER_BOTTOM = 2, const SHADOW_PRESETS_OUTER_BOTTOM = 2;
SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3, const SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3;
SHADOW_PRESETS_OUTER_RIGHT = 4, const SHADOW_PRESETS_OUTER_RIGHT = 4;
SHADOW_PRESETS_OUTER_CENTER = 5, const SHADOW_PRESETS_OUTER_CENTER = 5;
SHADOW_PRESETS_OUTER_LEFT = 6, const SHADOW_PRESETS_OUTER_LEFT = 6;
SHADOW_PRESETS_OUTER_TOP_RIGHT = 7, const SHADOW_PRESETS_OUTER_TOP_RIGHT = 7;
SHADOW_PRESETS_OUTER_TOP = 8, const SHADOW_PRESETS_OUTER_TOP = 8;
SHADOW_PRESETS_OUTER_TOP_LEFT = 9, const SHADOW_PRESETS_OUTER_TOP_LEFT = 9;
SHADOW_PRESETS_INNER_BOTTTOM_RIGHT = 10, const SHADOW_PRESETS_INNER_BOTTTOM_RIGHT = 10;
SHADOW_PRESETS_INNER_BOTTOM = 11, const SHADOW_PRESETS_INNER_BOTTOM = 11;
SHADOW_PRESETS_INNER_BOTTOM_LEFT = 12, const SHADOW_PRESETS_INNER_BOTTOM_LEFT = 12;
SHADOW_PRESETS_INNER_RIGHT = 13, const SHADOW_PRESETS_INNER_RIGHT = 13;
SHADOW_PRESETS_INNER_CENTER = 14, const SHADOW_PRESETS_INNER_CENTER = 14;
SHADOW_PRESETS_INNER_LEFT = 15, const SHADOW_PRESETS_INNER_LEFT = 15;
SHADOW_PRESETS_INNER_TOP_RIGHT = 16, const SHADOW_PRESETS_INNER_TOP_RIGHT = 16;
SHADOW_PRESETS_INNER_TOP = 17, const SHADOW_PRESETS_INNER_TOP = 17;
SHADOW_PRESETS_INNER_TOP_LEFT = 18, const SHADOW_PRESETS_INNER_TOP_LEFT = 18;
SHADOW_PRESETS_PERSPECTIVE_BELOW = 19, const SHADOW_PRESETS_PERSPECTIVE_BELOW = 19;
SHADOW_PRESETS_PERSPECTIVE_UPPER_RIGHT = 20, const SHADOW_PRESETS_PERSPECTIVE_UPPER_RIGHT = 20;
SHADOW_PRESETS_PERSPECTIVE_UPPER_LEFT = 21, const SHADOW_PRESETS_PERSPECTIVE_UPPER_LEFT = 21;
SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22, const SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22;
SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23; const SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23;
/** /**
* @param float $width * @param float $width
@ -359,14 +354,12 @@ abstract class Properties
$reference = &$properties; $reference = &$properties;
if (!is_array($elements)) { if (!is_array($elements)) {
return $reference[$elements]; return $reference[$elements];
} else { }
foreach ($elements as $keys) { foreach ($elements as $keys) {
$reference = &$reference[$keys]; $reference = &$reference[$keys];
} }
return $reference; return $reference;
}
return $this; return $this;
} }
} }

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Chart\Renderer; namespace PhpOffice\PhpSpreadsheet\Chart\Renderer;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Chart\Renderer;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -845,7 +846,7 @@ class JpGraph
} }
/** /**
* Create a new jpgraph * Create a new jpgraph.
*/ */
public function __construct(\PhpOffice\PhpSpreadsheet\Chart $chart) public function __construct(\PhpOffice\PhpSpreadsheet\Chart $chart)
{ {

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Chart; namespace PhpOffice\PhpSpreadsheet\Chart;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,27 +20,30 @@ namespace PhpOffice\PhpSpreadsheet\Chart;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Title class Title
{ {
/** /**
* Title Caption * Title Caption.
* *
* @var string * @var string
*/ */
private $caption = null; private $caption = null;
/** /**
* Title Layout * Title Layout.
* *
* @var Layout * @var Layout
*/ */
private $layout = null; private $layout = null;
/** /**
* Create a new Title * Create a new Title.
*
* @param null|mixed $caption
*/ */
public function __construct($caption = null, Layout $layout = null) public function __construct($caption = null, Layout $layout = null)
{ {
@ -49,7 +52,7 @@ class Title
} }
/** /**
* Get caption * Get caption.
* *
* @return string * @return string
*/ */
@ -59,9 +62,10 @@ class Title
} }
/** /**
* Set caption * Set caption.
* *
* @param string $caption * @param string $caption
*
* @return Title * @return Title
*/ */
public function setCaption($caption = null) public function setCaption($caption = null)
@ -72,7 +76,7 @@ class Title
} }
/** /**
* Get Layout * Get Layout.
* *
* @return Layout * @return Layout
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,76 +20,77 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Comment implements IComparable class Comment implements IComparable
{ {
/** /**
* Author * Author.
* *
* @var string * @var string
*/ */
private $author; private $author;
/** /**
* Rich text comment * Rich text comment.
* *
* @var RichText * @var RichText
*/ */
private $text; private $text;
/** /**
* Comment width (CSS style, i.e. XXpx or YYpt) * Comment width (CSS style, i.e. XXpx or YYpt).
* *
* @var string * @var string
*/ */
private $width = '96pt'; private $width = '96pt';
/** /**
* Left margin (CSS style, i.e. XXpx or YYpt) * Left margin (CSS style, i.e. XXpx or YYpt).
* *
* @var string * @var string
*/ */
private $marginLeft = '59.25pt'; private $marginLeft = '59.25pt';
/** /**
* Top margin (CSS style, i.e. XXpx or YYpt) * Top margin (CSS style, i.e. XXpx or YYpt).
* *
* @var string * @var string
*/ */
private $marginTop = '1.5pt'; private $marginTop = '1.5pt';
/** /**
* Visible * Visible.
* *
* @var bool * @var bool
*/ */
private $visible = false; private $visible = false;
/** /**
* Comment height (CSS style, i.e. XXpx or YYpt) * Comment height (CSS style, i.e. XXpx or YYpt).
* *
* @var string * @var string
*/ */
private $height = '55.5pt'; private $height = '55.5pt';
/** /**
* Comment fill color * Comment fill color.
* *
* @var Style\Color * @var Style\Color
*/ */
private $fillColor; private $fillColor;
/** /**
* Alignment * Alignment.
* *
* @var string * @var string
*/ */
private $alignment; private $alignment;
/** /**
* Create a new Comment * Create a new Comment.
* *
* @throws Exception * @throws Exception
*/ */
@ -103,7 +104,7 @@ class Comment implements IComparable
} }
/** /**
* Get Author * Get Author.
* *
* @return string * @return string
*/ */
@ -113,9 +114,10 @@ class Comment implements IComparable
} }
/** /**
* Set Author * Set Author.
* *
* @param string $pValue * @param string $pValue
*
* @return Comment * @return Comment
*/ */
public function setAuthor($pValue = '') public function setAuthor($pValue = '')
@ -126,7 +128,7 @@ class Comment implements IComparable
} }
/** /**
* Get Rich text comment * Get Rich text comment.
* *
* @return RichText * @return RichText
*/ */
@ -136,9 +138,10 @@ class Comment implements IComparable
} }
/** /**
* Set Rich text comment * Set Rich text comment.
* *
* @param RichText $pValue * @param RichText $pValue
*
* @return Comment * @return Comment
*/ */
public function setText(RichText $pValue) public function setText(RichText $pValue)
@ -149,7 +152,7 @@ class Comment implements IComparable
} }
/** /**
* Get comment width (CSS style, i.e. XXpx or YYpt) * Get comment width (CSS style, i.e. XXpx or YYpt).
* *
* @return string * @return string
*/ */
@ -159,9 +162,10 @@ class Comment implements IComparable
} }
/** /**
* Set comment width (CSS style, i.e. XXpx or YYpt) * Set comment width (CSS style, i.e. XXpx or YYpt).
* *
* @param string $value * @param string $value
*
* @return Comment * @return Comment
*/ */
public function setWidth($value = '96pt') public function setWidth($value = '96pt')
@ -172,7 +176,7 @@ class Comment implements IComparable
} }
/** /**
* Get comment height (CSS style, i.e. XXpx or YYpt) * Get comment height (CSS style, i.e. XXpx or YYpt).
* *
* @return string * @return string
*/ */
@ -182,9 +186,10 @@ class Comment implements IComparable
} }
/** /**
* Set comment height (CSS style, i.e. XXpx or YYpt) * Set comment height (CSS style, i.e. XXpx or YYpt).
* *
* @param string $value * @param string $value
*
* @return Comment * @return Comment
*/ */
public function setHeight($value = '55.5pt') public function setHeight($value = '55.5pt')
@ -195,7 +200,7 @@ class Comment implements IComparable
} }
/** /**
* Get left margin (CSS style, i.e. XXpx or YYpt) * Get left margin (CSS style, i.e. XXpx or YYpt).
* *
* @return string * @return string
*/ */
@ -205,9 +210,10 @@ class Comment implements IComparable
} }
/** /**
* Set left margin (CSS style, i.e. XXpx or YYpt) * Set left margin (CSS style, i.e. XXpx or YYpt).
* *
* @param string $value * @param string $value
*
* @return Comment * @return Comment
*/ */
public function setMarginLeft($value = '59.25pt') public function setMarginLeft($value = '59.25pt')
@ -218,7 +224,7 @@ class Comment implements IComparable
} }
/** /**
* Get top margin (CSS style, i.e. XXpx or YYpt) * Get top margin (CSS style, i.e. XXpx or YYpt).
* *
* @return string * @return string
*/ */
@ -228,9 +234,10 @@ class Comment implements IComparable
} }
/** /**
* Set top margin (CSS style, i.e. XXpx or YYpt) * Set top margin (CSS style, i.e. XXpx or YYpt).
* *
* @param string $value * @param string $value
*
* @return Comment * @return Comment
*/ */
public function setMarginTop($value = '1.5pt') public function setMarginTop($value = '1.5pt')
@ -251,9 +258,10 @@ class Comment implements IComparable
} }
/** /**
* Set comment default visibility * Set comment default visibility.
* *
* @param bool $value * @param bool $value
*
* @return Comment * @return Comment
*/ */
public function setVisible($value = false) public function setVisible($value = false)
@ -264,7 +272,7 @@ class Comment implements IComparable
} }
/** /**
* Get fill color * Get fill color.
* *
* @return Style\Color * @return Style\Color
*/ */
@ -274,9 +282,10 @@ class Comment implements IComparable
} }
/** /**
* Set Alignment * Set Alignment.
* *
* @param string $pValue * @param string $pValue
*
* @return Comment * @return Comment
*/ */
public function setAlignment($pValue = Style\Alignment::HORIZONTAL_GENERAL) public function setAlignment($pValue = Style\Alignment::HORIZONTAL_GENERAL)
@ -287,7 +296,7 @@ class Comment implements IComparable
} }
/** /**
* Get Alignment * Get Alignment.
* *
* @return string * @return string
*/ */
@ -297,7 +306,7 @@ class Comment implements IComparable
} }
/** /**
* Get hash code * Get hash code.
* *
* @return string Hash code * @return string Hash code
*/ */
@ -333,7 +342,7 @@ class Comment implements IComparable
} }
/** /**
* Convert to string * Convert to string.
* *
* @return string * @return string
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Document; namespace PhpOffice\PhpSpreadsheet\Document;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Document;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -34,91 +35,91 @@ class Properties
const PROPERTY_TYPE_UNKNOWN = 'u'; const PROPERTY_TYPE_UNKNOWN = 'u';
/** /**
* Creator * Creator.
* *
* @var string * @var string
*/ */
private $creator = 'Unknown Creator'; private $creator = 'Unknown Creator';
/** /**
* LastModifiedBy * LastModifiedBy.
* *
* @var string * @var string
*/ */
private $lastModifiedBy; private $lastModifiedBy;
/** /**
* Created * Created.
* *
* @var int * @var int
*/ */
private $created; private $created;
/** /**
* Modified * Modified.
* *
* @var int * @var int
*/ */
private $modified; private $modified;
/** /**
* Title * Title.
* *
* @var string * @var string
*/ */
private $title = 'Untitled Spreadsheet'; private $title = 'Untitled Spreadsheet';
/** /**
* Description * Description.
* *
* @var string * @var string
*/ */
private $description = ''; private $description = '';
/** /**
* Subject * Subject.
* *
* @var string * @var string
*/ */
private $subject = ''; private $subject = '';
/** /**
* Keywords * Keywords.
* *
* @var string * @var string
*/ */
private $keywords = ''; private $keywords = '';
/** /**
* Category * Category.
* *
* @var string * @var string
*/ */
private $category = ''; private $category = '';
/** /**
* Manager * Manager.
* *
* @var string * @var string
*/ */
private $manager = ''; private $manager = '';
/** /**
* Company * Company.
* *
* @var string * @var string
*/ */
private $company = 'Microsoft Corporation'; private $company = 'Microsoft Corporation';
/** /**
* Custom Properties * Custom Properties.
* *
* @var string * @var string
*/ */
private $customProperties = []; private $customProperties = [];
/** /**
* Create a new Document Properties instance * Create a new Document Properties instance.
*/ */
public function __construct() public function __construct()
{ {
@ -129,7 +130,7 @@ class Properties
} }
/** /**
* Get Creator * Get Creator.
* *
* @return string * @return string
*/ */
@ -139,9 +140,10 @@ class Properties
} }
/** /**
* Set Creator * Set Creator.
* *
* @param string $pValue * @param string $pValue
*
* @return Properties * @return Properties
*/ */
public function setCreator($pValue = '') public function setCreator($pValue = '')
@ -152,7 +154,7 @@ class Properties
} }
/** /**
* Get Last Modified By * Get Last Modified By.
* *
* @return string * @return string
*/ */
@ -162,9 +164,10 @@ class Properties
} }
/** /**
* Set Last Modified By * Set Last Modified By.
* *
* @param string $pValue * @param string $pValue
*
* @return Properties * @return Properties
*/ */
public function setLastModifiedBy($pValue = '') public function setLastModifiedBy($pValue = '')
@ -175,7 +178,7 @@ class Properties
} }
/** /**
* Get Created * Get Created.
* *
* @return int * @return int
*/ */
@ -185,9 +188,10 @@ class Properties
} }
/** /**
* Set Created * Set Created.
* *
* @param datetime $pValue * @param datetime $pValue
*
* @return Properties * @return Properties
*/ */
public function setCreated($pValue = null) public function setCreated($pValue = null)
@ -196,7 +200,7 @@ class Properties
$pValue = time(); $pValue = time();
} elseif (is_string($pValue)) { } elseif (is_string($pValue)) {
if (is_numeric($pValue)) { if (is_numeric($pValue)) {
$pValue = intval($pValue); $pValue = (int) $pValue;
} else { } else {
$pValue = strtotime($pValue); $pValue = strtotime($pValue);
} }
@ -208,7 +212,7 @@ class Properties
} }
/** /**
* Get Modified * Get Modified.
* *
* @return int * @return int
*/ */
@ -218,9 +222,10 @@ class Properties
} }
/** /**
* Set Modified * Set Modified.
* *
* @param datetime $pValue * @param datetime $pValue
*
* @return Properties * @return Properties
*/ */
public function setModified($pValue = null) public function setModified($pValue = null)
@ -229,7 +234,7 @@ class Properties
$pValue = time(); $pValue = time();
} elseif (is_string($pValue)) { } elseif (is_string($pValue)) {
if (is_numeric($pValue)) { if (is_numeric($pValue)) {
$pValue = intval($pValue); $pValue = (int) $pValue;
} else { } else {
$pValue = strtotime($pValue); $pValue = strtotime($pValue);
} }
@ -241,7 +246,7 @@ class Properties
} }
/** /**
* Get Title * Get Title.
* *
* @return string * @return string
*/ */
@ -251,9 +256,10 @@ class Properties
} }
/** /**
* Set Title * Set Title.
* *
* @param string $pValue * @param string $pValue
*
* @return Properties * @return Properties
*/ */
public function setTitle($pValue = '') public function setTitle($pValue = '')
@ -264,7 +270,7 @@ class Properties
} }
/** /**
* Get Description * Get Description.
* *
* @return string * @return string
*/ */
@ -274,9 +280,10 @@ class Properties
} }
/** /**
* Set Description * Set Description.
* *
* @param string $pValue * @param string $pValue
*
* @return Properties * @return Properties
*/ */
public function setDescription($pValue = '') public function setDescription($pValue = '')
@ -287,7 +294,7 @@ class Properties
} }
/** /**
* Get Subject * Get Subject.
* *
* @return string * @return string
*/ */
@ -297,9 +304,10 @@ class Properties
} }
/** /**
* Set Subject * Set Subject.
* *
* @param string $pValue * @param string $pValue
*
* @return Properties * @return Properties
*/ */
public function setSubject($pValue = '') public function setSubject($pValue = '')
@ -310,7 +318,7 @@ class Properties
} }
/** /**
* Get Keywords * Get Keywords.
* *
* @return string * @return string
*/ */
@ -320,9 +328,10 @@ class Properties
} }
/** /**
* Set Keywords * Set Keywords.
* *
* @param string $pValue * @param string $pValue
*
* @return Properties * @return Properties
*/ */
public function setKeywords($pValue = '') public function setKeywords($pValue = '')
@ -333,7 +342,7 @@ class Properties
} }
/** /**
* Get Category * Get Category.
* *
* @return string * @return string
*/ */
@ -343,9 +352,10 @@ class Properties
} }
/** /**
* Set Category * Set Category.
* *
* @param string $pValue * @param string $pValue
*
* @return Properties * @return Properties
*/ */
public function setCategory($pValue = '') public function setCategory($pValue = '')
@ -356,7 +366,7 @@ class Properties
} }
/** /**
* Get Company * Get Company.
* *
* @return string * @return string
*/ */
@ -366,9 +376,10 @@ class Properties
} }
/** /**
* Set Company * Set Company.
* *
* @param string $pValue * @param string $pValue
*
* @return Properties * @return Properties
*/ */
public function setCompany($pValue = '') public function setCompany($pValue = '')
@ -379,7 +390,7 @@ class Properties
} }
/** /**
* Get Manager * Get Manager.
* *
* @return string * @return string
*/ */
@ -389,9 +400,10 @@ class Properties
} }
/** /**
* Set Manager * Set Manager.
* *
* @param string $pValue * @param string $pValue
*
* @return Properties * @return Properties
*/ */
public function setManager($pValue = '') public function setManager($pValue = '')
@ -402,7 +414,7 @@ class Properties
} }
/** /**
* Get a List of Custom Property Names * Get a List of Custom Property Names.
* *
* @return array of string * @return array of string
*/ */
@ -412,9 +424,10 @@ class Properties
} }
/** /**
* Check if a Custom Property is defined * Check if a Custom Property is defined.
* *
* @param string $propertyName * @param string $propertyName
*
* @return bool * @return bool
*/ */
public function isCustomPropertySet($propertyName) public function isCustomPropertySet($propertyName)
@ -423,9 +436,10 @@ class Properties
} }
/** /**
* Get a Custom Property Value * Get a Custom Property Value.
* *
* @param string $propertyName * @param string $propertyName
*
* @return string * @return string
*/ */
public function getCustomPropertyValue($propertyName) public function getCustomPropertyValue($propertyName)
@ -436,9 +450,10 @@ class Properties
} }
/** /**
* Get a Custom Property Type * Get a Custom Property Type.
* *
* @param string $propertyName * @param string $propertyName
*
* @return string * @return string
*/ */
public function getCustomPropertyType($propertyName) public function getCustomPropertyType($propertyName)
@ -449,7 +464,7 @@ class Properties
} }
/** /**
* Set a Custom Property * Set a Custom Property.
* *
* @param string $propertyName * @param string $propertyName
* @param mixed $propertyValue * @param mixed $propertyValue
@ -459,6 +474,7 @@ class Properties
* 's' : String * 's' : String
* 'd' : Date/Time * 'd' : Date/Time
* 'b' : Boolean * 'b' : Boolean
*
* @return Properties * @return Properties
*/ */
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Document; namespace PhpOffice\PhpSpreadsheet\Document;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,48 +20,49 @@ namespace PhpOffice\PhpSpreadsheet\Document;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Security class Security
{ {
/** /**
* LockRevision * LockRevision.
* *
* @var bool * @var bool
*/ */
private $lockRevision = false; private $lockRevision = false;
/** /**
* LockStructure * LockStructure.
* *
* @var bool * @var bool
*/ */
private $lockStructure = false; private $lockStructure = false;
/** /**
* LockWindows * LockWindows.
* *
* @var bool * @var bool
*/ */
private $lockWindows = false; private $lockWindows = false;
/** /**
* RevisionsPassword * RevisionsPassword.
* *
* @var string * @var string
*/ */
private $revisionsPassword = ''; private $revisionsPassword = '';
/** /**
* WorkbookPassword * WorkbookPassword.
* *
* @var string * @var string
*/ */
private $workbookPassword = ''; private $workbookPassword = '';
/** /**
* Create a new Document Security instance * Create a new Document Security instance.
*/ */
public function __construct() public function __construct()
{ {
@ -80,7 +81,7 @@ class Security
} }
/** /**
* Get LockRevision * Get LockRevision.
* *
* @return bool * @return bool
*/ */
@ -90,9 +91,10 @@ class Security
} }
/** /**
* Set LockRevision * Set LockRevision.
* *
* @param bool $pValue * @param bool $pValue
*
* @return Security * @return Security
*/ */
public function setLockRevision($pValue = false) public function setLockRevision($pValue = false)
@ -103,7 +105,7 @@ class Security
} }
/** /**
* Get LockStructure * Get LockStructure.
* *
* @return bool * @return bool
*/ */
@ -113,9 +115,10 @@ class Security
} }
/** /**
* Set LockStructure * Set LockStructure.
* *
* @param bool $pValue * @param bool $pValue
*
* @return Security * @return Security
*/ */
public function setLockStructure($pValue = false) public function setLockStructure($pValue = false)
@ -126,7 +129,7 @@ class Security
} }
/** /**
* Get LockWindows * Get LockWindows.
* *
* @return bool * @return bool
*/ */
@ -136,9 +139,10 @@ class Security
} }
/** /**
* Set LockWindows * Set LockWindows.
* *
* @param bool $pValue * @param bool $pValue
*
* @return Security * @return Security
*/ */
public function setLockWindows($pValue = false) public function setLockWindows($pValue = false)
@ -149,7 +153,7 @@ class Security
} }
/** /**
* Get RevisionsPassword (hashed) * Get RevisionsPassword (hashed).
* *
* @return string * @return string
*/ */
@ -159,10 +163,11 @@ class Security
} }
/** /**
* Set RevisionsPassword * Set RevisionsPassword.
* *
* @param string $pValue * @param string $pValue
* @param bool $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 * @return Security
*/ */
public function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) public function setRevisionsPassword($pValue = '', $pAlreadyHashed = false)
@ -176,7 +181,7 @@ class Security
} }
/** /**
* Get WorkbookPassword (hashed) * Get WorkbookPassword (hashed).
* *
* @return string * @return string
*/ */
@ -186,10 +191,11 @@ class Security
} }
/** /**
* Set WorkbookPassword * Set WorkbookPassword.
* *
* @param string $pValue * @param string $pValue
* @param bool $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 * @return Security
*/ */
public function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) public function setWorkbookPassword($pValue = '', $pAlreadyHashed = false)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,13 +20,14 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Exception extends \Exception class Exception extends \Exception
{ {
/** /**
* Error handler callback * Error handler callback.
* *
* @param mixed $code * @param mixed $code
* @param mixed $string * @param mixed $string

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,29 +20,31 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class HashTable class HashTable
{ {
/** /**
* HashTable elements * HashTable elements.
* *
* @var mixed[] * @var mixed[]
*/ */
protected $items = []; protected $items = [];
/** /**
* HashTable key map * HashTable key map.
* *
* @var mixed[] * @var mixed[]
*/ */
protected $keyMap = []; protected $keyMap = [];
/** /**
* Create a new \PhpOffice\PhpSpreadsheet\HashTable * Create a new \PhpOffice\PhpSpreadsheet\HashTable.
* *
* @param IComparable[] $pSource Optional source array to create HashTable from * @param IComparable[] $pSource Optional source array to create HashTable from
*
* @throws Exception * @throws Exception
*/ */
public function __construct($pSource = null) public function __construct($pSource = null)
@ -54,9 +56,10 @@ class HashTable
} }
/** /**
* Add HashTable items from source * Add HashTable items from source.
* *
* @param IComparable[] $pSource Source array to create HashTable from * @param IComparable[] $pSource Source array to create HashTable from
*
* @throws Exception * @throws Exception
*/ */
public function addFromSource($pSource = null) public function addFromSource($pSource = null)
@ -74,9 +77,10 @@ class HashTable
} }
/** /**
* Add HashTable item * Add HashTable item.
* *
* @param IComparable $pSource Item to add * @param IComparable $pSource Item to add
*
* @throws Exception * @throws Exception
*/ */
public function add(IComparable $pSource = null) public function add(IComparable $pSource = null)
@ -89,9 +93,10 @@ class HashTable
} }
/** /**
* Remove HashTable item * Remove HashTable item.
* *
* @param IComparable $pSource Item to remove * @param IComparable $pSource Item to remove
*
* @throws Exception * @throws Exception
*/ */
public function remove(IComparable $pSource = null) public function remove(IComparable $pSource = null)
@ -115,7 +120,7 @@ class HashTable
} }
/** /**
* Clear HashTable * Clear HashTable.
*/ */
public function clear() public function clear()
{ {
@ -124,7 +129,7 @@ class HashTable
} }
/** /**
* Count * Count.
* *
* @return int * @return int
*/ */
@ -134,9 +139,10 @@ class HashTable
} }
/** /**
* Get index for hash code * Get index for hash code.
* *
* @param string $pHashCode * @param string $pHashCode
*
* @return int Index * @return int Index
*/ */
public function getIndexForHashCode($pHashCode = '') public function getIndexForHashCode($pHashCode = '')
@ -145,9 +151,10 @@ class HashTable
} }
/** /**
* Get by index * Get by index.
* *
* @param int $pIndex * @param int $pIndex
*
* @return IComparable * @return IComparable
*/ */
public function getByIndex($pIndex = 0) public function getByIndex($pIndex = 0)
@ -160,9 +167,10 @@ class HashTable
} }
/** /**
* Get by hashcode * Get by hashcode.
* *
* @param string $pHashCode * @param string $pHashCode
*
* @return IComparable * @return IComparable
*/ */
public function getByHashCode($pHashCode = '') public function getByHashCode($pHashCode = '')
@ -175,7 +183,7 @@ class HashTable
} }
/** /**
* HashTable to array * HashTable to array.
* *
* @return IComparable[] * @return IComparable[]
*/ */

View File

@ -8,7 +8,7 @@ use DOMNode;
use DOMText; use DOMText;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -25,6 +25,7 @@ use DOMText;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */

View File

@ -5,7 +5,8 @@ namespace PhpOffice\PhpSpreadsheet\Helper;
class Migrator class Migrator
{ {
/** /**
* Return the ordered mapping from old PHPExcel class names to new PhpSpreadsheet one * Return the ordered mapping from old PHPExcel class names to new PhpSpreadsheet one.
*
* @return string[] * @return string[]
*/ */
public function getMapping() public function getMapping()
@ -231,7 +232,8 @@ class Migrator
} }
/** /**
* Search in all files in given directory * Search in all files in given directory.
*
* @param string $path * @param string $path
*/ */
private function recursiveReplace($path) private function recursiveReplace($path)

View File

@ -8,7 +8,8 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
class Sample class Sample
{ {
/** /**
* Returns wether we run on CLI or browser * Returns wether we run on CLI or browser.
*
* @return bool * @return bool
*/ */
public function isCli() public function isCli()
@ -17,7 +18,8 @@ class Sample
} }
/** /**
* Return the filename currently being executed * Return the filename currently being executed.
*
* @return string * @return string
*/ */
public function getScriptFilename() public function getScriptFilename()
@ -26,7 +28,8 @@ class Sample
} }
/** /**
* Wether we are executing the index page * Wether we are executing the index page.
*
* @return bool * @return bool
*/ */
public function isIndex() public function isIndex()
@ -35,7 +38,8 @@ class Sample
} }
/** /**
* Return the page title * Return the page title.
*
* @return string * @return string
*/ */
public function getPageTitle() public function getPageTitle()
@ -44,7 +48,8 @@ class Sample
} }
/** /**
* Return the page heading * Return the page heading.
*
* @return string * @return string
*/ */
public function getPageHeading() public function getPageHeading()
@ -53,7 +58,8 @@ class Sample
} }
/** /**
* Returns an array of all known samples * Returns an array of all known samples.
*
* @return string[] [$name => $path] * @return string[] [$name => $path]
*/ */
public function getSamples() public function getSamples()
@ -72,7 +78,7 @@ class Sample
} }
/** /**
* Write documents * Write documents.
* *
* @param Spreadsheet $spreadsheet * @param Spreadsheet $spreadsheet
* @param string $filename * @param string $filename
@ -100,7 +106,8 @@ class Sample
} }
/** /**
* Returns the temporary directory and make sure it exists * Returns the temporary directory and make sure it exists.
*
* @return string * @return string
*/ */
private function getTemporaryFolder() private function getTemporaryFolder()
@ -114,9 +121,11 @@ class Sample
} }
/** /**
* Returns the filename that should be used for sample output * Returns the filename that should be used for sample output.
*
* @param string $filename * @param string $filename
* @param string $extension * @param string $extension
*
* @return string * @return string
*/ */
public function getFilename($filename, $extension = 'xlsx') public function getFilename($filename, $extension = 'xlsx')
@ -125,8 +134,10 @@ class Sample
} }
/** /**
* Return a random temporary file name * Return a random temporary file name.
*
* @param string $extension * @param string $extension
*
* @return string * @return string
*/ */
public function getTemporaryFilename($extension = 'xlsx') public function getTemporaryFilename($extension = 'xlsx')
@ -143,7 +154,7 @@ class Sample
} }
/** /**
* Log ending notes * Log ending notes.
*/ */
public function logEndingNotes() public function logEndingNotes()
{ {
@ -152,7 +163,8 @@ class Sample
} }
/** /**
* Log a line about the write operation * Log a line about the write operation.
*
* @param \PhpOffice\PhpSpreadsheet\Writer\IWriter $writer * @param \PhpOffice\PhpSpreadsheet\Writer\IWriter $writer
* @param string $path * @param string $path
* @param float $callStartTime * @param float $callStartTime
@ -169,7 +181,8 @@ class Sample
} }
/** /**
* Log a line about the read operation * Log a line about the read operation.
*
* @param string $format * @param string $format
* @param string $path * @param string $path
* @param float $callStartTime * @param float $callStartTime

View File

@ -18,13 +18,14 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
interface IComparable interface IComparable
{ {
/** /**
* Get hash code * Get hash code.
* *
* @return string Hash code * @return string Hash code
*/ */

View File

@ -5,7 +5,7 @@ namespace PhpOffice\PhpSpreadsheet;
use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Shared\File;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -22,13 +22,14 @@ use PhpOffice\PhpSpreadsheet\Shared\File;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class IOFactory class IOFactory
{ {
/** /**
* Search locations * Search locations.
* *
* @var array * @var array
* @static * @static
@ -39,7 +40,7 @@ class IOFactory
]; ];
/** /**
* Autoresolve classes * Autoresolve classes.
* *
* @var array * @var array
* @static * @static
@ -56,16 +57,17 @@ class IOFactory
]; ];
/** /**
* Private constructor for IOFactory * Private constructor for IOFactory.
*/ */
private function __construct() private function __construct()
{ {
} }
/** /**
* Get search locations * Get search locations.
* *
* @static * @static
*
* @return array * @return array
*/ */
public static function getSearchLocations() public static function getSearchLocations()
@ -74,10 +76,12 @@ class IOFactory
} }
/** /**
* Set search locations * Set search locations.
* *
* @static * @static
*
* @param array $value * @param array $value
*
* @throws Reader\Exception * @throws Reader\Exception
*/ */
public static function setSearchLocations($value) public static function setSearchLocations($value)
@ -90,9 +94,10 @@ class IOFactory
} }
/** /**
* Add search location * Add search location.
* *
* @static * @static
*
* @param string $type Example: IWriter * @param string $type Example: IWriter
* @param string $location Example: PhpSpreadsheet/Writer/{0}.php * @param string $location Example: PhpSpreadsheet/Writer/{0}.php
* @param string $classname Example: Writer\{0} * @param string $classname Example: Writer\{0}
@ -103,12 +108,15 @@ class IOFactory
} }
/** /**
* Create Writer\IWriter * Create Writer\IWriter.
* *
* @static * @static
*
* @param Spreadsheet $spreadsheet * @param Spreadsheet $spreadsheet
* @param string $writerType Example: Xlsx * @param string $writerType Example: Xlsx
*
* @throws Writer\Exception * @throws Writer\Exception
*
* @return Writer\IWriter * @return Writer\IWriter
*/ */
public static function createWriter(Spreadsheet $spreadsheet, $writerType = '') public static function createWriter(Spreadsheet $spreadsheet, $writerType = '')
@ -133,11 +141,14 @@ class IOFactory
} }
/** /**
* Create Reader\IReader * Create Reader\IReader.
* *
* @static * @static
*
* @param string $readerType Example: Xlsx * @param string $readerType Example: Xlsx
*
* @throws Reader\Exception * @throws Reader\Exception
*
* @return Reader\IReader * @return Reader\IReader
*/ */
public static function createReader($readerType = '') public static function createReader($readerType = '')
@ -162,11 +173,14 @@ class IOFactory
} }
/** /**
* Loads Spreadsheet from file using automatic Reader\IReader resolution * Loads Spreadsheet from file using automatic Reader\IReader resolution.
* *
* @static * @static
*
* @param string $pFilename The name of the spreadsheet file * @param string $pFilename The name of the spreadsheet file
*
* @throws Reader\Exception * @throws Reader\Exception
*
* @return Spreadsheet * @return Spreadsheet
*/ */
public static function load($pFilename) public static function load($pFilename)
@ -177,11 +191,14 @@ class IOFactory
} }
/** /**
* Identify file type using automatic Reader\IReader resolution * Identify file type using automatic Reader\IReader resolution.
* *
* @static * @static
*
* @param string $pFilename The name of the spreadsheet file to identify * @param string $pFilename The name of the spreadsheet file to identify
*
* @throws Reader\Exception * @throws Reader\Exception
*
* @return string * @return string
*/ */
public static function identify($pFilename) public static function identify($pFilename)
@ -195,11 +212,14 @@ class IOFactory
} }
/** /**
* Create Reader\IReader for file using automatic Reader\IReader resolution * Create Reader\IReader for file using automatic Reader\IReader resolution.
* *
* @static * @static
*
* @param string $pFilename The name of the spreadsheet file * @param string $pFilename The name of the spreadsheet file
*
* @throws Reader\Exception * @throws Reader\Exception
*
* @return Reader\IReader * @return Reader\IReader
*/ */
public static function createReaderForFile($pFilename) public static function createReaderForFile($pFilename)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,54 +20,56 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class NamedRange class NamedRange
{ {
/** /**
* Range name * Range name.
* *
* @var string * @var string
*/ */
private $name; private $name;
/** /**
* Worksheet on which the named range can be resolved * Worksheet on which the named range can be resolved.
* *
* @var Worksheet * @var Worksheet
*/ */
private $worksheet; private $worksheet;
/** /**
* Range of the referenced cells * Range of the referenced cells.
* *
* @var string * @var string
*/ */
private $range; private $range;
/** /**
* Is the named range local? (i.e. can only be used on $this->worksheet) * Is the named range local? (i.e. can only be used on $this->worksheet).
* *
* @var bool * @var bool
*/ */
private $localOnly; private $localOnly;
/** /**
* Scope * Scope.
* *
* @var Worksheet * @var Worksheet
*/ */
private $scope; private $scope;
/** /**
* Create a new NamedRange * Create a new NamedRange.
* *
* @param string $pName * @param string $pName
* @param Worksheet $pWorksheet * @param Worksheet $pWorksheet
* @param string $pRange * @param string $pRange
* @param bool $pLocalOnly * @param bool $pLocalOnly
* @param Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope. * @param Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
*
* @throws Exception * @throws Exception
*/ */
public function __construct($pName, Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null) public function __construct($pName, Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
@ -86,7 +88,7 @@ class NamedRange
} }
/** /**
* Get name * Get name.
* *
* @return string * @return string
*/ */
@ -96,9 +98,10 @@ class NamedRange
} }
/** /**
* Set name * Set name.
* *
* @param string $value * @param string $value
*
* @return NamedRange * @return NamedRange
*/ */
public function setName($value = null) public function setName($value = null)
@ -126,7 +129,7 @@ class NamedRange
} }
/** /**
* Get worksheet * Get worksheet.
* *
* @return Worksheet * @return Worksheet
*/ */
@ -136,9 +139,10 @@ class NamedRange
} }
/** /**
* Set worksheet * Set worksheet.
* *
* @param Worksheet $value * @param Worksheet $value
*
* @return NamedRange * @return NamedRange
*/ */
public function setWorksheet(Worksheet $value = null) public function setWorksheet(Worksheet $value = null)
@ -151,7 +155,7 @@ class NamedRange
} }
/** /**
* Get range * Get range.
* *
* @return string * @return string
*/ */
@ -161,9 +165,10 @@ class NamedRange
} }
/** /**
* Set range * Set range.
* *
* @param string $value * @param string $value
*
* @return NamedRange * @return NamedRange
*/ */
public function setRange($value = null) public function setRange($value = null)
@ -176,7 +181,7 @@ class NamedRange
} }
/** /**
* Get localOnly * Get localOnly.
* *
* @return bool * @return bool
*/ */
@ -186,9 +191,10 @@ class NamedRange
} }
/** /**
* Set localOnly * Set localOnly.
* *
* @param bool $value * @param bool $value
*
* @return NamedRange * @return NamedRange
*/ */
public function setLocalOnly($value = false) public function setLocalOnly($value = false)
@ -200,7 +206,7 @@ class NamedRange
} }
/** /**
* Get scope * Get scope.
* *
* @return Worksheet|null * @return Worksheet|null
*/ */
@ -210,9 +216,10 @@ class NamedRange
} }
/** /**
* Set scope * Set scope.
* *
* @param Worksheet|null $value * @param Worksheet|null $value
*
* @return NamedRange * @return NamedRange
*/ */
public function setScope(Worksheet $value = null) public function setScope(Worksheet $value = null)
@ -224,10 +231,11 @@ class NamedRange
} }
/** /**
* Resolve a named range to a regular cell range * Resolve a named range to a regular cell range.
* *
* @param string $pNamedRange Named range * @param string $pNamedRange Named range
* @param Worksheet|null $pSheet Scope. Use null for global scope * @param Worksheet|null $pSheet Scope. Use null for global scope
*
* @return NamedRange * @return NamedRange
*/ */
public static function resolveRange($pNamedRange, Worksheet $pSheet = null) public static function resolveRange($pNamedRange, Worksheet $pSheet = null)

View File

@ -5,7 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Shared\File;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -22,6 +22,7 @@ use PhpOffice\PhpSpreadsheet\Shared\File;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -30,7 +31,7 @@ abstract class BaseReader implements IReader
/** /**
* Read data only? * Read data only?
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information; * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
* or whether it should read both data and formatting * or whether it should read both data and formatting.
* *
* @var bool * @var bool
*/ */
@ -39,7 +40,7 @@ abstract class BaseReader implements IReader
/** /**
* Read empty cells? * Read empty cells?
* Identifies whether the Reader should read data values for cells all cells, or should ignore cells containing * Identifies whether the Reader should read data values for cells all cells, or should ignore cells containing
* null value or empty string * null value or empty string.
* *
* @var bool * @var bool
*/ */
@ -47,7 +48,7 @@ abstract class BaseReader implements IReader
/** /**
* Read charts that are defined in the workbook? * Read charts that are defined in the workbook?
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook; * Identifies whether the Reader should read the definitions for any charts that exist in the workbook;.
* *
* @var bool * @var bool
*/ */
@ -62,7 +63,7 @@ abstract class BaseReader implements IReader
protected $loadSheetsOnly; protected $loadSheetsOnly;
/** /**
* IReadFilter instance * IReadFilter instance.
* *
* @var IReadFilter * @var IReadFilter
*/ */
@ -93,7 +94,7 @@ abstract class BaseReader implements IReader
*/ */
public function setReadDataOnly($pValue = false) public function setReadDataOnly($pValue = false)
{ {
$this->readDataOnly = (boolean) $pValue; $this->readDataOnly = (bool) $pValue;
return $this; return $this;
} }
@ -121,7 +122,7 @@ abstract class BaseReader implements IReader
*/ */
public function setReadEmptyCells($pValue = true) public function setReadEmptyCells($pValue = true)
{ {
$this->readEmptyCells = (boolean) $pValue; $this->readEmptyCells = (bool) $pValue;
return $this; return $this;
} }
@ -151,7 +152,7 @@ abstract class BaseReader implements IReader
*/ */
public function setIncludeCharts($pValue = false) public function setIncludeCharts($pValue = false)
{ {
$this->includeCharts = (boolean) $pValue; $this->includeCharts = (bool) $pValue;
return $this; return $this;
} }
@ -169,7 +170,7 @@ abstract class BaseReader implements IReader
} }
/** /**
* Set which sheets to load * Set which sheets to load.
* *
* @param mixed $value * @param mixed $value
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
@ -202,7 +203,7 @@ abstract class BaseReader implements IReader
} }
/** /**
* Read filter * Read filter.
* *
* @return IReadFilter * @return IReadFilter
*/ */
@ -212,9 +213,10 @@ abstract class BaseReader implements IReader
} }
/** /**
* Set read filter * Set read filter.
* *
* @param IReadFilter $pValue * @param IReadFilter $pValue
*
* @return IReader * @return IReader
*/ */
public function setReadFilter(IReadFilter $pValue) public function setReadFilter(IReadFilter $pValue)
@ -225,10 +227,12 @@ abstract class BaseReader implements IReader
} }
/** /**
* Open file for reading * Open file for reading.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return resource * @return resource
*/ */
protected function openFile($pFilename) protected function openFile($pFilename)
@ -243,9 +247,10 @@ abstract class BaseReader implements IReader
} }
/** /**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks * Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks.
* *
* @param string $xml * @param string $xml
*
* @throws Exception * @throws Exception
*/ */
public function securityScan($xml) public function securityScan($xml)
@ -259,9 +264,10 @@ abstract class BaseReader implements IReader
} }
/** /**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks * Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks.
* *
* @param string $filestream * @param string $filestream
*
* @throws Exception * @throws Exception
*/ */
public function securityScanFile($filestream) public function securityScanFile($filestream)

View File

@ -5,7 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -22,55 +22,56 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class CSV extends BaseReader implements IReader class CSV extends BaseReader implements IReader
{ {
/** /**
* Input encoding * Input encoding.
* *
* @var string * @var string
*/ */
private $inputEncoding = 'UTF-8'; private $inputEncoding = 'UTF-8';
/** /**
* Delimiter * Delimiter.
* *
* @var string * @var string
*/ */
private $delimiter = ','; private $delimiter = ',';
/** /**
* Enclosure * Enclosure.
* *
* @var string * @var string
*/ */
private $enclosure = '"'; private $enclosure = '"';
/** /**
* Sheet index to read * Sheet index to read.
* *
* @var int * @var int
*/ */
private $sheetIndex = 0; private $sheetIndex = 0;
/** /**
* Load rows contiguously * Load rows contiguously.
* *
* @var bool * @var bool
*/ */
private $contiguous = false; private $contiguous = false;
/** /**
* Row counter for loading rows contiguously * Row counter for loading rows contiguously.
* *
* @var int * @var int
*/ */
private $contiguousRow = -1; private $contiguousRow = -1;
/** /**
* Create a new CSV Reader instance * Create a new CSV Reader instance.
*/ */
public function __construct() public function __construct()
{ {
@ -78,7 +79,7 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Set input encoding * Set input encoding.
* *
* @param string $pValue Input encoding * @param string $pValue Input encoding
*/ */
@ -90,7 +91,7 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Get input encoding * Get input encoding.
* *
* @return string * @return string
*/ */
@ -100,7 +101,7 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Move filepointer past any BOM marker * Move filepointer past any BOM marker.
*/ */
protected function skipBOM() protected function skipBOM()
{ {
@ -133,7 +134,7 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Identify any separator that is explicitly set in the file * Identify any separator that is explicitly set in the file.
*/ */
protected function checkSeparator() protected function checkSeparator()
{ {
@ -152,9 +153,10 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
@ -195,10 +197,12 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Loads Spreadsheet from file * Loads Spreadsheet from file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet * @return \PhpOffice\PhpSpreadsheet\Spreadsheet
*/ */
public function load($pFilename) public function load($pFilename)
@ -211,11 +215,13 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance * Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param Spreadsheet $spreadsheet * @param Spreadsheet $spreadsheet
*
* @throws Exception * @throws Exception
*
* @return Spreadsheet * @return Spreadsheet
*/ */
public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
@ -286,7 +292,7 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Get delimiter * Get delimiter.
* *
* @return string * @return string
*/ */
@ -296,9 +302,10 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Set delimiter * Set delimiter.
* *
* @param string $pValue Delimiter, defaults to , * @param string $pValue Delimiter, defaults to ,
*
* @return CSV * @return CSV
*/ */
public function setDelimiter($pValue = ',') public function setDelimiter($pValue = ',')
@ -309,7 +316,7 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Get enclosure * Get enclosure.
* *
* @return string * @return string
*/ */
@ -319,9 +326,10 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Set enclosure * Set enclosure.
* *
* @param string $pValue Enclosure, defaults to " * @param string $pValue Enclosure, defaults to "
*
* @return CSV * @return CSV
*/ */
public function setEnclosure($pValue = '"') public function setEnclosure($pValue = '"')
@ -335,7 +343,7 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Get sheet index * Get sheet index.
* *
* @return int * @return int
*/ */
@ -345,9 +353,10 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Set sheet index * Set sheet index.
* *
* @param int $pValue Sheet index * @param int $pValue Sheet index
*
* @return CSV * @return CSV
*/ */
public function setSheetIndex($pValue = 0) public function setSheetIndex($pValue = 0)
@ -358,7 +367,7 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Set Contiguous * Set Contiguous.
* *
* @param bool $contiguous * @param bool $contiguous
*/ */
@ -373,7 +382,7 @@ class CSV extends BaseReader implements IReader
} }
/** /**
* Get Contiguous * Get Contiguous.
* *
* @return bool * @return bool
*/ */
@ -386,7 +395,9 @@ class CSV extends BaseReader implements IReader
* Can the current IReader read the file? * Can the current IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return bool * @return bool
*/ */
public function canRead($pFilename) public function canRead($pFilename)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader; namespace PhpOffice\PhpSpreadsheet\Reader;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -31,6 +32,7 @@ class DefaultReadFilter implements IReadFilter
* @param $column Column address (as a string value like "A", or "IV") * @param $column Column address (as a string value like "A", or "IV")
* @param $row Row number * @param $row Row number
* @param $worksheetName Optional worksheet name * @param $worksheetName Optional worksheet name
*
* @return bool * @return bool
*/ */
public function readCell($column, $row, $worksheetName = '') public function readCell($column, $row, $worksheetName = '')

View File

@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Shared\File;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -23,27 +23,28 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Excel2003XML extends BaseReader implements IReader class Excel2003XML extends BaseReader implements IReader
{ {
/** /**
* Formats * Formats.
* *
* @var array * @var array
*/ */
protected $styles = []; protected $styles = [];
/** /**
* Character set used in the file * Character set used in the file.
* *
* @var string * @var string
*/ */
protected $charSet = 'UTF-8'; protected $charSet = 'UTF-8';
/** /**
* Create a new Excel2003XML Reader instance * Create a new Excel2003XML Reader instance.
*/ */
public function __construct() public function __construct()
{ {
@ -54,12 +55,13 @@ class Excel2003XML extends BaseReader implements IReader
* Can the current IReader read the file? * Can the current IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return bool * @return bool
*/ */
public function canRead($pFilename) public function canRead($pFilename)
{ {
// Office xmlns:o="urn:schemas-microsoft-com:office:office" // Office xmlns:o="urn:schemas-microsoft-com:office:office"
// Excel xmlns:x="urn:schemas-microsoft-com:office:excel" // Excel xmlns:x="urn:schemas-microsoft-com:office:excel"
// XML Spreadsheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" // XML Spreadsheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
@ -102,9 +104,10 @@ class Excel2003XML extends BaseReader implements IReader
} }
/** /**
* Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object * Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetNames($pFilename) public function listWorksheetNames($pFilename)
@ -133,9 +136,10 @@ class Excel2003XML extends BaseReader implements IReader
} }
/** /**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
@ -204,10 +208,12 @@ class Excel2003XML extends BaseReader implements IReader
} }
/** /**
* Loads Spreadsheet from file * Loads Spreadsheet from file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet * @return \PhpOffice\PhpSpreadsheet\Spreadsheet
*/ */
public function load($pFilename) public function load($pFilename)
@ -235,8 +241,11 @@ class Excel2003XML extends BaseReader implements IReader
} }
/** /**
* pixel units to excel width units(units of 1/256th of a character width) * pixel units to excel width units(units of 1/256th of a character width).
*
* @param pxs * @param pxs
* @param mixed $pxs
*
* @return * @return
*/ */
protected static function pixel2WidthUnits($pxs) protected static function pixel2WidthUnits($pxs)
@ -250,8 +259,11 @@ class Excel2003XML extends BaseReader implements IReader
} }
/** /**
* excel width units(units of 1/256th of a character width) to pixel units * excel width units(units of 1/256th of a character width) to pixel units.
*
* @param widthUnits * @param widthUnits
* @param mixed $widthUnits
*
* @return * @return
*/ */
protected static function widthUnits2Pixel($widthUnits) protected static function widthUnits2Pixel($widthUnits)
@ -269,11 +281,13 @@ class Excel2003XML extends BaseReader implements IReader
} }
/** /**
* Loads from file into Spreadsheet instance * Loads from file into Spreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet
*
* @throws Exception * @throws Exception
*
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet * @return \PhpOffice\PhpSpreadsheet\Spreadsheet
*/ */
public function loadIntoExisting($pFilename, \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) public function loadIntoExisting($pFilename, \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet)
@ -376,11 +390,11 @@ class Excel2003XML extends BaseReader implements IReader
break; break;
case 'integer': case 'integer':
$propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_INTEGER; $propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_INTEGER;
$propertyValue = intval($propertyValue); $propertyValue = (int) $propertyValue;
break; break;
case 'float': case 'float':
$propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_FLOAT; $propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_FLOAT;
$propertyValue = floatval($propertyValue); $propertyValue = (float) $propertyValue;
break; break;
case 'dateTime.tz': case 'dateTime.tz':
$propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE; $propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE;
@ -549,7 +563,7 @@ class Excel2003XML extends BaseReader implements IReader
$rowHasData = false; $rowHasData = false;
$row_ss = $rowData->attributes($namespaces['ss']); $row_ss = $rowData->attributes($namespaces['ss']);
if (isset($row_ss['Index'])) { if (isset($row_ss['Index'])) {
$rowID = (integer) $row_ss['Index']; $rowID = (int) $row_ss['Index'];
} }
$columnID = 'A'; $columnID = 'A';
@ -615,7 +629,7 @@ class Excel2003XML extends BaseReader implements IReader
$type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC; $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC;
$cellValue = (float) $cellValue; $cellValue = (float) $cellValue;
if (floor($cellValue) == $cellValue) { if (floor($cellValue) == $cellValue) {
$cellValue = (integer) $cellValue; $cellValue = (int) $cellValue;
} }
break; break;
case 'Boolean': case 'Boolean':
@ -666,7 +680,7 @@ class Excel2003XML extends BaseReader implements IReader
$rowReference = $rowID; $rowReference = $rowID;
} }
// Bracketed R references are relative to the current row // Bracketed R references are relative to the current row
if ($rowReference{0} == '[') { if ($rowReference[0] == '[') {
$rowReference = $rowID + trim($rowReference, '[]'); $rowReference = $rowID + trim($rowReference, '[]');
} }
$columnReference = $cellReference[4][0]; $columnReference = $cellReference[4][0];
@ -675,7 +689,7 @@ class Excel2003XML extends BaseReader implements IReader
$columnReference = $columnNumber; $columnReference = $columnNumber;
} }
// Bracketed C references are relative to the current column // Bracketed C references are relative to the current column
if ($columnReference{0} == '[') { if ($columnReference[0] == '[') {
$columnReference = $columnNumber + trim($columnReference, '[]'); $columnReference = $columnNumber + trim($columnReference, '[]');
} }
$A1CellReference = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnReference - 1) . $rowReference; $A1CellReference = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnReference - 1) . $rowReference;

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader; namespace PhpOffice\PhpSpreadsheet\Reader;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,13 +20,14 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Exception extends \PhpOffice\PhpSpreadsheet\Exception class Exception extends \PhpOffice\PhpSpreadsheet\Exception
{ {
/** /**
* Error handler callback * Error handler callback.
* *
* @param mixed $code * @param mixed $code
* @param mixed $string * @param mixed $string

View File

@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\Shared\File;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -24,20 +24,21 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Gnumeric extends BaseReader implements IReader class Gnumeric extends BaseReader implements IReader
{ {
/** /**
* Formats * Formats.
* *
* @var array * @var array
*/ */
private $styles = []; private $styles = [];
/** /**
* Shared Expressions * Shared Expressions.
* *
* @var array * @var array
*/ */
@ -46,7 +47,7 @@ class Gnumeric extends BaseReader implements IReader
private $referenceHelper = null; private $referenceHelper = null;
/** /**
* Create a new Gnumeric * Create a new Gnumeric.
*/ */
public function __construct() public function __construct()
{ {
@ -58,7 +59,9 @@ class Gnumeric extends BaseReader implements IReader
* Can the current IReader read the file? * Can the current IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return bool * @return bool
*/ */
public function canRead($pFilename) public function canRead($pFilename)
@ -83,9 +86,10 @@ class Gnumeric extends BaseReader implements IReader
} }
/** /**
* Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object * Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetNames($pFilename) public function listWorksheetNames($pFilename)
@ -111,9 +115,10 @@ class Gnumeric extends BaseReader implements IReader
} }
/** /**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
@ -175,10 +180,12 @@ class Gnumeric extends BaseReader implements IReader
} }
/** /**
* Loads Spreadsheet from file * Loads Spreadsheet from file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return Spreadsheet * @return Spreadsheet
*/ */
public function load($pFilename) public function load($pFilename)
@ -191,11 +198,13 @@ class Gnumeric extends BaseReader implements IReader
} }
/** /**
* Loads from file into Spreadsheet instance * Loads from file into Spreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param Spreadsheet $spreadsheet * @param Spreadsheet $spreadsheet
*
* @throws Exception * @throws Exception
*
* @return Spreadsheet * @return Spreadsheet
*/ */
public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
@ -339,7 +348,7 @@ class Gnumeric extends BaseReader implements IReader
$marginSize = 72 / 100; // Default $marginSize = 72 / 100; // Default
switch ($marginAttributes['PrefUnit']) { switch ($marginAttributes['PrefUnit']) {
case 'mm': case 'mm':
$marginSize = intval($marginAttributes['Points']) / 100; $marginSize = (int) ($marginAttributes['Points']) / 100;
break; break;
} }
switch ($key) { switch ($key) {
@ -419,7 +428,7 @@ class Gnumeric extends BaseReader implements IReader
$cell = ($cell == 'TRUE') ? true : false; $cell = ($cell == 'TRUE') ? true : false;
break; break;
case '30': // Integer case '30': // Integer
$cell = intval($cell); $cell = (int) $cell;
// Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case // Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case
case '40': // Float case '40': // Float
$type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC; $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC;
@ -507,7 +516,7 @@ class Gnumeric extends BaseReader implements IReader
$styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false; $styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false;
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false; $styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false;
$styleArray['alignment']['indent'] = (intval($styleAttributes['Indent']) > 0) ? $styleAttributes['indent'] : 0; $styleArray['alignment']['indent'] = ((int) ($styleAttributes['Indent']) > 0) ? $styleAttributes['indent'] : 0;
$RGB = self::parseGnumericColour($styleAttributes['Fore']); $RGB = self::parseGnumericColour($styleAttributes['Fore']);
$styleArray['font']['color']['rgb'] = $RGB; $styleArray['font']['color']['rgb'] = $RGB;
@ -583,7 +592,7 @@ class Gnumeric extends BaseReader implements IReader
$fontAttributes = $styleRegion->Style->Font->attributes(); $fontAttributes = $styleRegion->Style->Font->attributes();
$styleArray['font']['name'] = (string) $styleRegion->Style->Font; $styleArray['font']['name'] = (string) $styleRegion->Style->Font;
$styleArray['font']['size'] = intval($fontAttributes['Unit']); $styleArray['font']['size'] = (int) ($fontAttributes['Unit']);
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false; $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false;
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false; $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false;
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false; $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false;

View File

@ -9,7 +9,7 @@ use DOMText;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -26,6 +26,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -33,26 +34,26 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
class HTML extends BaseReader implements IReader class HTML extends BaseReader implements IReader
{ {
/** /**
* Sample size to read to determine if it's HTML or not * Sample size to read to determine if it's HTML or not.
*/ */
const TEST_SAMPLE_SIZE = 2048; const TEST_SAMPLE_SIZE = 2048;
/** /**
* Input encoding * Input encoding.
* *
* @var string * @var string
*/ */
protected $inputEncoding = 'ANSI'; protected $inputEncoding = 'ANSI';
/** /**
* Sheet index to read * Sheet index to read.
* *
* @var int * @var int
*/ */
protected $sheetIndex = 0; protected $sheetIndex = 0;
/** /**
* Formats * Formats.
* *
* @var array * @var array
*/ */
@ -116,7 +117,7 @@ class HTML extends BaseReader implements IReader
protected $rowspan = []; protected $rowspan = [];
/** /**
* Create a new HTML Reader instance * Create a new HTML Reader instance.
*/ */
public function __construct() public function __construct()
{ {
@ -124,10 +125,12 @@ class HTML extends BaseReader implements IReader
} }
/** /**
* Validate that the current file is an HTML file * Validate that the current file is an HTML file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return bool * @return bool
*/ */
public function canRead($pFilename) public function canRead($pFilename)
@ -185,10 +188,12 @@ class HTML extends BaseReader implements IReader
} }
/** /**
* Loads Spreadsheet from file * Loads Spreadsheet from file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return Spreadsheet * @return Spreadsheet
*/ */
public function load($pFilename) public function load($pFilename)
@ -201,7 +206,7 @@ class HTML extends BaseReader implements IReader
} }
/** /**
* Set input encoding * Set input encoding.
* *
* @param string $pValue Input encoding * @param string $pValue Input encoding
*/ */
@ -213,7 +218,7 @@ class HTML extends BaseReader implements IReader
} }
/** /**
* Get input encoding * Get input encoding.
* *
* @return string * @return string
*/ */
@ -284,10 +289,9 @@ class HTML extends BaseReader implements IReader
if (is_string($cellContent)) { if (is_string($cellContent)) {
// simply append the text if the cell content is a plain text string // simply append the text if the cell content is a plain text string
$cellContent .= $domText; $cellContent .= $domText;
} else { }
// but if we have a rich text run instead, we need to append it correctly // but if we have a rich text run instead, we need to append it correctly
// TODO // TODO
}
} elseif ($child instanceof DOMElement) { } elseif ($child instanceof DOMElement) {
$attributeArray = []; $attributeArray = [];
foreach ($child->attributes as $attribute) { foreach ($child->attributes as $attribute) {
@ -493,11 +497,13 @@ class HTML extends BaseReader implements IReader
} }
/** /**
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance * Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param Spreadsheet $spreadsheet * @param Spreadsheet $spreadsheet
*
* @throws Exception * @throws Exception
*
* @return Spreadsheet * @return Spreadsheet
*/ */
public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
@ -534,7 +540,7 @@ class HTML extends BaseReader implements IReader
} }
/** /**
* Get sheet index * Get sheet index.
* *
* @return int * @return int
*/ */
@ -544,9 +550,10 @@ class HTML extends BaseReader implements IReader
} }
/** /**
* Set sheet index * Set sheet index.
* *
* @param int $pValue Sheet index * @param int $pValue Sheet index
*
* @return HTML * @return HTML
*/ */
public function setSheetIndex($pValue = 0) public function setSheetIndex($pValue = 0)
@ -557,9 +564,10 @@ class HTML extends BaseReader implements IReader
} }
/** /**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks * Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks.
* *
* @param string $xml * @param string $xml
*
* @throws Exception * @throws Exception
*/ */
public function securityScan($xml) public function securityScan($xml)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader; namespace PhpOffice\PhpSpreadsheet\Reader;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -31,6 +32,7 @@ interface IReadFilter
* @param $column Column address (as a string value like "A", or "IV") * @param $column Column address (as a string value like "A", or "IV")
* @param $row Row number * @param $row Row number
* @param $worksheetName Optional worksheet name * @param $worksheetName Optional worksheet name
*
* @return bool * @return bool
*/ */
public function readCell($column, $row, $worksheetName = ''); public function readCell($column, $row, $worksheetName = '');

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader; namespace PhpOffice\PhpSpreadsheet\Reader;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -29,15 +30,18 @@ interface IReader
* Can the current IReader read the file? * Can the current IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
*
* @return bool * @return bool
*/ */
public function canRead($pFilename); public function canRead($pFilename);
/** /**
* Loads PhpSpreadsheet from file * Loads PhpSpreadsheet from file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return PhpSpreadsheet * @return PhpSpreadsheet
*/ */
public function load($pFilename); public function load($pFilename);

View File

@ -7,7 +7,7 @@ use DateTimeZone;
use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Shared\File;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -24,20 +24,21 @@ use PhpOffice\PhpSpreadsheet\Shared\File;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Ods extends BaseReader implements IReader class Ods extends BaseReader implements IReader
{ {
/** /**
* Formats * Formats.
* *
* @var array * @var array
*/ */
private $styles = []; private $styles = [];
/** /**
* Create a new Ods Reader instance * Create a new Ods Reader instance.
*/ */
public function __construct() public function __construct()
{ {
@ -48,7 +49,9 @@ class Ods extends BaseReader implements IReader
* Can the current IReader read the file? * Can the current IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return bool * @return bool
*/ */
public function canRead($pFilename) public function canRead($pFilename)
@ -93,9 +96,10 @@ class Ods extends BaseReader implements IReader
} }
/** /**
* Reads names of the worksheets from a file, without parsing the whole file to a PhpSpreadsheet object * Reads names of the worksheets from a file, without parsing the whole file to a PhpSpreadsheet object.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetNames($pFilename) public function listWorksheetNames($pFilename)
@ -146,9 +150,10 @@ class Ods extends BaseReader implements IReader
} }
/** /**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
@ -237,10 +242,12 @@ class Ods extends BaseReader implements IReader
} }
/** /**
* Loads PhpSpreadsheet from file * Loads PhpSpreadsheet from file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet * @return \PhpOffice\PhpSpreadsheet\Spreadsheet
*/ */
public function load($pFilename) public function load($pFilename)
@ -267,11 +274,13 @@ class Ods extends BaseReader implements IReader
} }
/** /**
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance * Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet
*
* @throws Exception * @throws Exception
*
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet * @return \PhpOffice\PhpSpreadsheet\Spreadsheet
*/ */
public function loadIntoExisting($pFilename, \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) public function loadIntoExisting($pFilename, \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet)
@ -496,7 +505,7 @@ class Ods extends BaseReader implements IReader
$type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC; $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value']; $dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) { if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue; $dataValue = (int) $dataValue;
} }
$formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_PERCENTAGE_00; $formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_PERCENTAGE_00;
break; break;
@ -504,7 +513,7 @@ class Ods extends BaseReader implements IReader
$type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC; $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value']; $dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) { if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue; $dataValue = (int) $dataValue;
} }
$formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; $formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
break; break;
@ -512,8 +521,8 @@ class Ods extends BaseReader implements IReader
$type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC; $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value']; $dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) { if (floor($dataValue) == $dataValue) {
if ($dataValue == (integer) $dataValue) { if ($dataValue == (int) $dataValue) {
$dataValue = (integer) $dataValue; $dataValue = (int) $dataValue;
} else { } else {
$dataValue = (float) $dataValue; $dataValue = (float) $dataValue;
} }

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader; namespace PhpOffice\PhpSpreadsheet\Reader;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,41 +20,42 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class SYLK extends BaseReader implements IReader class SYLK extends BaseReader implements IReader
{ {
/** /**
* Input encoding * Input encoding.
* *
* @var string * @var string
*/ */
private $inputEncoding = 'ANSI'; private $inputEncoding = 'ANSI';
/** /**
* Sheet index to read * Sheet index to read.
* *
* @var int * @var int
*/ */
private $sheetIndex = 0; private $sheetIndex = 0;
/** /**
* Formats * Formats.
* *
* @var array * @var array
*/ */
private $formats = []; private $formats = [];
/** /**
* Format Count * Format Count.
* *
* @var int * @var int
*/ */
private $format = 0; private $format = 0;
/** /**
* Create a new SYLK Reader instance * Create a new SYLK Reader instance.
*/ */
public function __construct() public function __construct()
{ {
@ -62,10 +63,12 @@ class SYLK extends BaseReader implements IReader
} }
/** /**
* Validate that the current file is a SYLK file * Validate that the current file is a SYLK file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return bool * @return bool
*/ */
public function canRead($pFilename) public function canRead($pFilename)
@ -94,7 +97,7 @@ class SYLK extends BaseReader implements IReader
} }
/** /**
* Set input encoding * Set input encoding.
* *
* @param string $pValue Input encoding * @param string $pValue Input encoding
*/ */
@ -106,7 +109,7 @@ class SYLK extends BaseReader implements IReader
} }
/** /**
* Get input encoding * Get input encoding.
* *
* @return string * @return string
*/ */
@ -116,9 +119,10 @@ class SYLK extends BaseReader implements IReader
} }
/** /**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
@ -157,7 +161,7 @@ class SYLK extends BaseReader implements IReader
if ($dataType == 'C') { if ($dataType == 'C') {
// Read cell value data // Read cell value data
foreach ($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) { switch ($rowDatum[0]) {
case 'C': case 'C':
case 'X': case 'X':
$columnIndex = substr($rowDatum, 1) - 1; $columnIndex = substr($rowDatum, 1) - 1;
@ -184,10 +188,12 @@ class SYLK extends BaseReader implements IReader
} }
/** /**
* Loads PhpSpreadsheet from file * Loads PhpSpreadsheet from file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet * @return \PhpOffice\PhpSpreadsheet\Spreadsheet
*/ */
public function load($pFilename) public function load($pFilename)
@ -200,11 +206,13 @@ class SYLK extends BaseReader implements IReader
} }
/** /**
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance * Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet
*
* @throws Exception * @throws Exception
*
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet * @return \PhpOffice\PhpSpreadsheet\Spreadsheet
*/ */
public function loadIntoExisting($pFilename, \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) public function loadIntoExisting($pFilename, \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet)
@ -244,7 +252,7 @@ class SYLK extends BaseReader implements IReader
if ($dataType == 'P') { if ($dataType == 'P') {
$formatArray = []; $formatArray = [];
foreach ($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) { switch ($rowDatum[0]) {
case 'P': case 'P':
$formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1)); $formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1));
break; break;
@ -258,7 +266,7 @@ class SYLK extends BaseReader implements IReader
case 'S': case 'S':
$styleSettings = substr($rowDatum, 1); $styleSettings = substr($rowDatum, 1);
for ($i = 0; $i < strlen($styleSettings); ++$i) { for ($i = 0; $i < strlen($styleSettings); ++$i) {
switch ($styleSettings{$i}) { switch ($styleSettings[$i]) {
case 'I': case 'I':
$formatArray['font']['italic'] = true; $formatArray['font']['italic'] = true;
break; break;
@ -288,7 +296,7 @@ class SYLK extends BaseReader implements IReader
$hasCalculatedValue = false; $hasCalculatedValue = false;
$cellData = $cellDataFormula = ''; $cellData = $cellDataFormula = '';
foreach ($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) { switch ($rowDatum[0]) {
case 'C': case 'C':
case 'X': case 'X':
$column = substr($rowDatum, 1); $column = substr($rowDatum, 1);
@ -322,7 +330,7 @@ class SYLK extends BaseReader implements IReader
$rowReference = $row; $rowReference = $row;
} }
// Bracketed R references are relative to the current row // Bracketed R references are relative to the current row
if ($rowReference{0} == '[') { if ($rowReference[0] == '[') {
$rowReference = $row + trim($rowReference, '[]'); $rowReference = $row + trim($rowReference, '[]');
} }
$columnReference = $cellReference[4][0]; $columnReference = $cellReference[4][0];
@ -331,7 +339,7 @@ class SYLK extends BaseReader implements IReader
$columnReference = $column; $columnReference = $column;
} }
// Bracketed C references are relative to the current column // Bracketed C references are relative to the current column
if ($columnReference{0} == '[') { if ($columnReference[0] == '[') {
$columnReference = $column + trim($columnReference, '[]'); $columnReference = $column + trim($columnReference, '[]');
} }
$A1CellReference = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnReference - 1) . $rowReference; $A1CellReference = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnReference - 1) . $rowReference;
@ -361,7 +369,7 @@ class SYLK extends BaseReader implements IReader
$formatStyle = $columnWidth = $styleSettings = ''; $formatStyle = $columnWidth = $styleSettings = '';
$styleData = []; $styleData = [];
foreach ($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) { switch ($rowDatum[0]) {
case 'C': case 'C':
case 'X': case 'X':
$column = substr($rowDatum, 1); $column = substr($rowDatum, 1);
@ -379,7 +387,7 @@ class SYLK extends BaseReader implements IReader
case 'S': case 'S':
$styleSettings = substr($rowDatum, 1); $styleSettings = substr($rowDatum, 1);
for ($i = 0; $i < strlen($styleSettings); ++$i) { for ($i = 0; $i < strlen($styleSettings); ++$i) {
switch ($styleSettings{$i}) { switch ($styleSettings[$i]) {
case 'I': case 'I':
$styleData['font']['italic'] = true; $styleData['font']['italic'] = true;
break; break;
@ -428,7 +436,7 @@ class SYLK extends BaseReader implements IReader
} }
} else { } else {
foreach ($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) { switch ($rowDatum[0]) {
case 'C': case 'C':
case 'X': case 'X':
$column = substr($rowDatum, 1); $column = substr($rowDatum, 1);
@ -450,7 +458,7 @@ class SYLK extends BaseReader implements IReader
} }
/** /**
* Get sheet index * Get sheet index.
* *
* @return int * @return int
*/ */
@ -460,9 +468,10 @@ class SYLK extends BaseReader implements IReader
} }
/** /**
* Set sheet index * Set sheet index.
* *
* @param int $pValue Sheet index * @param int $pValue Sheet index
*
* @return SYLK * @return SYLK
*/ */
public function setSheetIndex($pValue = 0) public function setSheetIndex($pValue = 0)

File diff suppressed because it is too large Load Diff

View File

@ -5,11 +5,12 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
class Color class Color
{ {
/** /**
* Read color * Read color.
* *
* @param int $color Indexed color * @param int $color Indexed color
* @param array $palette Color palette * @param array $palette Color palette
* @param int $version * @param int $version
*
* @return array RGB color value, example: array('rgb' => 'FF0000') * @return array RGB color value, example: array('rgb' => 'FF0000')
*/ */
public static function map($color, $palette, $version) public static function map($color, $palette, $version)
@ -20,16 +21,13 @@ class Color
} elseif (isset($palette) && isset($palette[$color - 8])) { } elseif (isset($palette) && isset($palette[$color - 8])) {
// palette color, color index 0x08 maps to pallete index 0 // palette color, color index 0x08 maps to pallete index 0
return $palette[$color - 8]; return $palette[$color - 8];
} else { }
// default color table // default color table
if ($version == \PhpOffice\PhpSpreadsheet\Reader\Xls::XLS_BIFF8) { if ($version == \PhpOffice\PhpSpreadsheet\Reader\Xls::XLS_BIFF8) {
return Color\BIFF8::lookup($color); return Color\BIFF8::lookup($color);
} else { }
// BIFF5 // BIFF5
return Color\BIFF5::lookup($color); return Color\BIFF5::lookup($color);
}
}
return $color; return $color;
} }
} }

View File

@ -64,9 +64,10 @@ class BIFF5
]; ];
/** /**
* Map color array from BIFF5 built-in color index * Map color array from BIFF5 built-in color index.
* *
* @param int $color * @param int $color
*
* @return array * @return array
*/ */
public static function lookup($color) public static function lookup($color)

View File

@ -64,9 +64,10 @@ class BIFF8
]; ];
/** /**
* Map color array from BIFF8 built-in color index * Map color array from BIFF8 built-in color index.
* *
* @param int $color * @param int $color
*
* @return array * @return array
*/ */
public static function lookup($color) public static function lookup($color)

View File

@ -18,9 +18,10 @@ class BuiltIn
]; ];
/** /**
* Map built-in color to RGB value * Map built-in color to RGB value.
* *
* @param int $color Indexed color * @param int $color Indexed color
*
* @return array * @return array
*/ */
public static function lookup($color) public static function lookup($color)

View File

@ -15,9 +15,10 @@ class ErrorCode
]; ];
/** /**
* Map error code, e.g. '#N/A' * Map error code, e.g. '#N/A'.
* *
* @param int $code * @param int $code
*
* @return string|bool * @return string|bool
*/ */
public static function lookup($code) public static function lookup($code)

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader\Xls; namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -45,21 +46,21 @@ class Escher
const TERTIARYOPT = 0xF122; const TERTIARYOPT = 0xF122;
/** /**
* Escher stream data (binary) * Escher stream data (binary).
* *
* @var string * @var string
*/ */
private $data; private $data;
/** /**
* Size in bytes of the Escher stream data * Size in bytes of the Escher stream data.
* *
* @var int * @var int
*/ */
private $dataSize; private $dataSize;
/** /**
* Current position of stream pointer in Escher stream data * Current position of stream pointer in Escher stream data.
* *
* @var int * @var int
*/ */
@ -73,7 +74,7 @@ class Escher
private $object; private $object;
/** /**
* Create a new Escher instance * Create a new Escher instance.
* *
* @param mixed $object * @param mixed $object
*/ */
@ -166,7 +167,7 @@ class Escher
} }
/** /**
* Read a generic record * Read a generic record.
*/ */
private function readDefault() private function readDefault()
{ {
@ -187,7 +188,7 @@ class Escher
} }
/** /**
* Read DggContainer record (Drawing Group Container) * Read DggContainer record (Drawing Group Container).
*/ */
private function readDggContainer() private function readDggContainer()
{ {
@ -205,7 +206,7 @@ class Escher
} }
/** /**
* Read Dgg record (Drawing Group) * Read Dgg record (Drawing Group).
*/ */
private function readDgg() private function readDgg()
{ {
@ -217,7 +218,7 @@ class Escher
} }
/** /**
* Read BstoreContainer record (Blip Store Container) * Read BstoreContainer record (Blip Store Container).
*/ */
private function readBstoreContainer() private function readBstoreContainer()
{ {
@ -235,7 +236,7 @@ class Escher
} }
/** /**
* Read BSE record * Read BSE record.
*/ */
private function readBSE() private function readBSE()
{ {
@ -278,16 +279,16 @@ class Escher
$foDelay = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($recordData, 28); $foDelay = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($recordData, 28);
// offset: 32; size: 1; unused1 // offset: 32; size: 1; unused1
$unused1 = ord($recordData{32}); $unused1 = ord($recordData[32]);
// offset: 33; size: 1; size of nameData in bytes (including null terminator) // offset: 33; size: 1; size of nameData in bytes (including null terminator)
$cbName = ord($recordData{33}); $cbName = ord($recordData[33]);
// offset: 34; size: 1; unused2 // offset: 34; size: 1; unused2
$unused2 = ord($recordData{34}); $unused2 = ord($recordData[34]);
// offset: 35; size: 1; unused3 // offset: 35; size: 1; unused3
$unused3 = ord($recordData{35}); $unused3 = ord($recordData[35]);
// offset: 36; size: $cbName; nameData // offset: 36; size: $cbName; nameData
$nameData = substr($recordData, 36, $cbName); $nameData = substr($recordData, 36, $cbName);
@ -301,7 +302,7 @@ class Escher
} }
/** /**
* Read BlipJPEG record. Holds raw JPEG image data * Read BlipJPEG record. Holds raw JPEG image data.
*/ */
private function readBlipJPEG() private function readBlipJPEG()
{ {
@ -329,7 +330,7 @@ class Escher
} }
// offset: var; size: 1; tag // offset: var; size: 1; tag
$tag = ord($recordData{$pos}); $tag = ord($recordData[$pos]);
$pos += 1; $pos += 1;
// offset: var; size: var; the raw image data // offset: var; size: var; the raw image data
@ -342,7 +343,7 @@ class Escher
} }
/** /**
* Read BlipPNG record. Holds raw PNG image data * Read BlipPNG record. Holds raw PNG image data.
*/ */
private function readBlipPNG() private function readBlipPNG()
{ {
@ -370,7 +371,7 @@ class Escher
} }
// offset: var; size: 1; tag // offset: var; size: 1; tag
$tag = ord($recordData{$pos}); $tag = ord($recordData[$pos]);
$pos += 1; $pos += 1;
// offset: var; size: var; the raw image data // offset: var; size: var; the raw image data
@ -383,7 +384,7 @@ class Escher
} }
/** /**
* Read OPT record. This record may occur within DggContainer record or SpContainer * Read OPT record. This record may occur within DggContainer record or SpContainer.
*/ */
private function readOPT() private function readOPT()
{ {
@ -402,7 +403,7 @@ class Escher
} }
/** /**
* Read TertiaryOPT record * Read TertiaryOPT record.
*/ */
private function readTertiaryOPT() private function readTertiaryOPT()
{ {
@ -419,7 +420,7 @@ class Escher
} }
/** /**
* Read SplitMenuColors record * Read SplitMenuColors record.
*/ */
private function readSplitMenuColors() private function readSplitMenuColors()
{ {
@ -431,7 +432,7 @@ class Escher
} }
/** /**
* Read DgContainer record (Drawing Container) * Read DgContainer record (Drawing Container).
*/ */
private function readDgContainer() private function readDgContainer()
{ {
@ -449,7 +450,7 @@ class Escher
} }
/** /**
* Read Dg record (Drawing) * Read Dg record (Drawing).
*/ */
private function readDg() private function readDg()
{ {
@ -461,7 +462,7 @@ class Escher
} }
/** /**
* Read SpgrContainer record (Shape Group Container) * Read SpgrContainer record (Shape Group Container).
*/ */
private function readSpgrContainer() private function readSpgrContainer()
{ {
@ -489,7 +490,7 @@ class Escher
} }
/** /**
* Read SpContainer record (Shape Container) * Read SpContainer record (Shape Container).
*/ */
private function readSpContainer() private function readSpContainer()
{ {
@ -509,7 +510,7 @@ class Escher
} }
/** /**
* Read Spgr record (Shape Group) * Read Spgr record (Shape Group).
*/ */
private function readSpgr() private function readSpgr()
{ {
@ -521,7 +522,7 @@ class Escher
} }
/** /**
* Read Sp record (Shape) * Read Sp record (Shape).
*/ */
private function readSp() private function readSp()
{ {
@ -538,7 +539,7 @@ class Escher
} }
/** /**
* Read ClientTextbox record * Read ClientTextbox record.
*/ */
private function readClientTextbox() private function readClientTextbox()
{ {
@ -555,7 +556,7 @@ class Escher
} }
/** /**
* Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet * Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet.
*/ */
private function readClientAnchor() private function readClientAnchor()
{ {
@ -609,7 +610,7 @@ class Escher
} }
/** /**
* Read ClientData record * Read ClientData record.
*/ */
private function readClientData() private function readClientData()
{ {
@ -621,7 +622,7 @@ class Escher
} }
/** /**
* Read OfficeArtRGFOPTE table of property-value pairs * Read OfficeArtRGFOPTE table of property-value pairs.
* *
* @param string $data Binary data * @param string $data Binary data
* @param int $n Number of properties * @param int $n Number of properties

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader\Xls; namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -32,7 +33,7 @@ class MD5
private $d; private $d;
/** /**
* MD5 stream constructor * MD5 stream constructor.
*/ */
public function __construct() public function __construct()
{ {
@ -40,7 +41,7 @@ class MD5
} }
/** /**
* Reset the MD5 stream context * Reset the MD5 stream context.
*/ */
public function reset() public function reset()
{ {
@ -51,7 +52,7 @@ class MD5
} }
/** /**
* Get MD5 stream context * Get MD5 stream context.
* *
* @return string * @return string
*/ */
@ -70,7 +71,7 @@ class MD5
} }
/** /**
* Add data to context * Add data to context.
* *
* @param string $data Data to add * @param string $data Data to add
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader\Xls; namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -31,7 +32,7 @@ class RC4
protected $j = 0; protected $j = 0;
/** /**
* RC4 stream decryption/encryption constrcutor * RC4 stream decryption/encryption constrcutor.
* *
* @param string $key Encryption key/passphrase * @param string $key Encryption key/passphrase
*/ */
@ -54,7 +55,7 @@ class RC4
} }
/** /**
* Symmetric decryption/encryption function * Symmetric decryption/encryption function.
* *
* @param string $data Data to encrypt/decrypt * @param string $data Data to encrypt/decrypt
* *

View File

@ -25,9 +25,10 @@ class Border
/** /**
* Map border style * Map border style
* OpenOffice documentation: 2.5.11 * OpenOffice documentation: 2.5.11.
* *
* @param int $index * @param int $index
*
* @return string * @return string
*/ */
public static function lookup($index) public static function lookup($index)

View File

@ -30,9 +30,10 @@ class FillPattern
/** /**
* Get fill pattern from index * Get fill pattern from index
* OpenOffice documentation: 2.5.12 * OpenOffice documentation: 2.5.12.
* *
* @param int $index * @param int $index
*
* @return string * @return string
*/ */
public static function lookup($index) public static function lookup($index)

View File

@ -5,7 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Shared\File;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -22,27 +22,28 @@ use PhpOffice\PhpSpreadsheet\Shared\File;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Xlsx extends BaseReader implements IReader class Xlsx extends BaseReader implements IReader
{ {
/** /**
* ReferenceHelper instance * ReferenceHelper instance.
* *
* @var \PhpOffice\PhpSpreadsheet\ReferenceHelper * @var \PhpOffice\PhpSpreadsheet\ReferenceHelper
*/ */
private $referenceHelper = null; private $referenceHelper = null;
/** /**
* Xlsx\Theme instance * Xlsx\Theme instance.
* *
* @var Xlsx\Theme * @var Xlsx\Theme
*/ */
private static $theme = null; private static $theme = null;
/** /**
* Create a new Xlsx Reader instance * Create a new Xlsx Reader instance.
*/ */
public function __construct() public function __construct()
{ {
@ -54,7 +55,9 @@ class Xlsx extends BaseReader implements IReader
* Can the current IReader read the file? * Can the current IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return bool * @return bool
*/ */
public function canRead($pFilename) public function canRead($pFilename)
@ -98,9 +101,10 @@ class Xlsx extends BaseReader implements IReader
} }
/** /**
* Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object * Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetNames($pFilename) public function listWorksheetNames($pFilename)
@ -140,9 +144,10 @@ class Xlsx extends BaseReader implements IReader
} }
/** /**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*/ */
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
@ -248,10 +253,9 @@ class Xlsx extends BaseReader implements IReader
return false; return false;
} elseif ($value == '1') { } elseif ($value == '1') {
return true; return true;
} else {
return (bool) $c->v;
} }
return (bool) $c->v;
return $value; return $value;
} }
@ -315,10 +319,12 @@ class Xlsx extends BaseReader implements IReader
} }
/** /**
* Loads Spreadsheet from file * Loads Spreadsheet from file.
* *
* @param string $pFilename * @param string $pFilename
*
* @throws Exception * @throws Exception
*
* @return Spreadsheet * @return Spreadsheet
*/ */
public function load($pFilename) public function load($pFilename)
@ -553,14 +559,14 @@ class Xlsx extends BaseReader implements IReader
} }
$quotePrefix = false; $quotePrefix = false;
if (isset($xf['quotePrefix'])) { if (isset($xf['quotePrefix'])) {
$quotePrefix = (boolean) $xf['quotePrefix']; $quotePrefix = (bool) $xf['quotePrefix'];
} }
$style = (object) [ $style = (object) [
'numFmt' => $numFmt, 'numFmt' => $numFmt,
'font' => $xmlStyles->fonts->font[intval($xf['fontId'])], 'font' => $xmlStyles->fonts->font[(int) ($xf['fontId'])],
'fill' => $xmlStyles->fills->fill[intval($xf['fillId'])], 'fill' => $xmlStyles->fills->fill[(int) ($xf['fillId'])],
'border' => $xmlStyles->borders->border[intval($xf['borderId'])], 'border' => $xmlStyles->borders->border[(int) ($xf['borderId'])],
'alignment' => $xf->alignment, 'alignment' => $xf->alignment,
'protection' => $xf->protection, 'protection' => $xf->protection,
'quotePrefix' => $quotePrefix, 'quotePrefix' => $quotePrefix,
@ -586,9 +592,9 @@ class Xlsx extends BaseReader implements IReader
$cellStyle = (object) [ $cellStyle = (object) [
'numFmt' => $numFmt, 'numFmt' => $numFmt,
'font' => $xmlStyles->fonts->font[intval($xf['fontId'])], 'font' => $xmlStyles->fonts->font[(int) ($xf['fontId'])],
'fill' => $xmlStyles->fills->fill[intval($xf['fillId'])], 'fill' => $xmlStyles->fills->fill[(int) ($xf['fillId'])],
'border' => $xmlStyles->borders->border[intval($xf['borderId'])], 'border' => $xmlStyles->borders->border[(int) ($xf['borderId'])],
'alignment' => $xf->alignment, 'alignment' => $xf->alignment,
'protection' => $xf->protection, 'protection' => $xf->protection,
'quotePrefix' => $quotePrefix, 'quotePrefix' => $quotePrefix,
@ -615,11 +621,11 @@ class Xlsx extends BaseReader implements IReader
// Cell Styles // Cell Styles
if ($xmlStyles->cellStyles) { if ($xmlStyles->cellStyles) {
foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) { foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) {
if (intval($cellStyle['builtinId']) == 0) { if ((int) ($cellStyle['builtinId']) == 0) {
if (isset($cellStyles[intval($cellStyle['xfId'])])) { if (isset($cellStyles[(int) ($cellStyle['xfId'])])) {
// Set default style // Set default style
$style = new \PhpOffice\PhpSpreadsheet\Style(); $style = new \PhpOffice\PhpSpreadsheet\Style();
self::readStyle($style, $cellStyles[intval($cellStyle['xfId'])]); self::readStyle($style, $cellStyles[(int) ($cellStyle['xfId'])]);
// normal style, currently not using it for anything // normal style, currently not using it for anything
} }
@ -690,10 +696,10 @@ class Xlsx extends BaseReader implements IReader
if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) { if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) {
if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) { if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) {
$docSheet->getSheetView()->setZoomScale(intval($xmlSheet->sheetViews->sheetView['zoomScale'])); $docSheet->getSheetView()->setZoomScale((int) ($xmlSheet->sheetViews->sheetView['zoomScale']));
} }
if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) { if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) {
$docSheet->getSheetView()->setZoomScaleNormal(intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])); $docSheet->getSheetView()->setZoomScaleNormal((int) ($xmlSheet->sheetViews->sheetView['zoomScaleNormal']));
} }
if (isset($xmlSheet->sheetViews->sheetView['view'])) { if (isset($xmlSheet->sheetViews->sheetView['view'])) {
$docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']); $docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']);
@ -715,11 +721,11 @@ class Xlsx extends BaseReader implements IReader
$ySplit = 0; $ySplit = 0;
if (isset($xmlSheet->sheetViews->sheetView->pane['xSplit'])) { if (isset($xmlSheet->sheetViews->sheetView->pane['xSplit'])) {
$xSplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['xSplit']); $xSplit = 1 + (int) ($xmlSheet->sheetViews->sheetView->pane['xSplit']);
} }
if (isset($xmlSheet->sheetViews->sheetView->pane['ySplit'])) { if (isset($xmlSheet->sheetViews->sheetView->pane['ySplit'])) {
$ySplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['ySplit']); $ySplit = 1 + (int) ($xmlSheet->sheetViews->sheetView->pane['ySplit']);
} }
$docSheet->freezePaneByColumnAndRow($xSplit, $ySplit); $docSheet->freezePaneByColumnAndRow($xSplit, $ySplit);
@ -786,9 +792,9 @@ class Xlsx extends BaseReader implements IReader
if (isset($xmlSheet->cols) && !$this->readDataOnly) { if (isset($xmlSheet->cols) && !$this->readDataOnly) {
foreach ($xmlSheet->cols->col as $col) { foreach ($xmlSheet->cols->col as $col) {
for ($i = intval($col['min']) - 1; $i < intval($col['max']); ++$i) { for ($i = (int) ($col['min']) - 1; $i < (int) ($col['max']); ++$i) {
if ($col['style'] && !$this->readDataOnly) { if ($col['style'] && !$this->readDataOnly) {
$docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setXfIndex(intval($col['style'])); $docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setXfIndex((int) ($col['style']));
} }
if (self::boolean($col['hidden'])) { if (self::boolean($col['hidden'])) {
$docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setVisible(false); $docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setVisible(false);
@ -797,11 +803,11 @@ class Xlsx extends BaseReader implements IReader
$docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setCollapsed(true); $docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setCollapsed(true);
} }
if ($col['outlineLevel'] > 0) { if ($col['outlineLevel'] > 0) {
$docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col['outlineLevel'])); $docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setOutlineLevel((int) ($col['outlineLevel']));
} }
$docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setWidth(floatval($col['width'])); $docSheet->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i))->setWidth((float) ($col['width']));
if (intval($col['max']) == 16384) { if ((int) ($col['max']) == 16384) {
break; break;
} }
} }
@ -826,19 +832,19 @@ class Xlsx extends BaseReader implements IReader
if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) {
foreach ($xmlSheet->sheetData->row as $row) { foreach ($xmlSheet->sheetData->row as $row) {
if ($row['ht'] && !$this->readDataOnly) { if ($row['ht'] && !$this->readDataOnly) {
$docSheet->getRowDimension(intval($row['r']))->setRowHeight(floatval($row['ht'])); $docSheet->getRowDimension((int) ($row['r']))->setRowHeight((float) ($row['ht']));
} }
if (self::boolean($row['hidden']) && !$this->readDataOnly) { if (self::boolean($row['hidden']) && !$this->readDataOnly) {
$docSheet->getRowDimension(intval($row['r']))->setVisible(false); $docSheet->getRowDimension((int) ($row['r']))->setVisible(false);
} }
if (self::boolean($row['collapsed'])) { if (self::boolean($row['collapsed'])) {
$docSheet->getRowDimension(intval($row['r']))->setCollapsed(true); $docSheet->getRowDimension((int) ($row['r']))->setCollapsed(true);
} }
if ($row['outlineLevel'] > 0) { if ($row['outlineLevel'] > 0) {
$docSheet->getRowDimension(intval($row['r']))->setOutlineLevel(intval($row['outlineLevel'])); $docSheet->getRowDimension((int) ($row['r']))->setOutlineLevel((int) ($row['outlineLevel']));
} }
if ($row['s'] && !$this->readDataOnly) { if ($row['s'] && !$this->readDataOnly) {
$docSheet->getRowDimension(intval($row['r']))->setXfIndex(intval($row['s'])); $docSheet->getRowDimension((int) ($row['r']))->setXfIndex((int) ($row['s']));
} }
foreach ($row->c as $c) { foreach ($row->c as $c) {
@ -860,7 +866,7 @@ class Xlsx extends BaseReader implements IReader
switch ($cellDataType) { switch ($cellDataType) {
case 's': case 's':
if ((string) $c->v != '') { if ((string) $c->v != '') {
$value = $sharedStrings[intval($c->v)]; $value = $sharedStrings[(int) ($c->v)];
if ($value instanceof \PhpOffice\PhpSpreadsheet\RichText) { if ($value instanceof \PhpOffice\PhpSpreadsheet\RichText) {
$value = clone $value; $value = clone $value;
@ -913,8 +919,8 @@ class Xlsx extends BaseReader implements IReader
$value = (int) $value; $value = (int) $value;
} elseif ($value == (float) $value) { } elseif ($value == (float) $value) {
$value = (float) $value; $value = (float) $value;
} elseif ($value == (double) $value) { } elseif ($value == (float) $value) {
$value = (double) $value; $value = (float) $value;
} }
} }
@ -937,8 +943,8 @@ class Xlsx extends BaseReader implements IReader
// Style information? // Style information?
if ($c['s'] && !$this->readDataOnly) { if ($c['s'] && !$this->readDataOnly) {
// no style index means 0, it seems // no style index means 0, it seems
$cell->setXfIndex(isset($styles[intval($c['s'])]) ? $cell->setXfIndex(isset($styles[(int) ($c['s'])]) ?
intval($c['s']) : 0); (int) ($c['s']) : 0);
} }
} }
} }
@ -948,8 +954,8 @@ class Xlsx extends BaseReader implements IReader
if (!$this->readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) { if (!$this->readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) {
foreach ($xmlSheet->conditionalFormatting as $conditional) { foreach ($xmlSheet->conditionalFormatting as $conditional) {
foreach ($conditional->cfRule as $cfRule) { foreach ($conditional->cfRule as $cfRule) {
if (((string) $cfRule['type'] == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_NONE || (string) $cfRule['type'] == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS || (string) $cfRule['type'] == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT || (string) $cfRule['type'] == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_EXPRESSION) && isset($dxfs[intval($cfRule['dxfId'])])) { if (((string) $cfRule['type'] == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_NONE || (string) $cfRule['type'] == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS || (string) $cfRule['type'] == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT || (string) $cfRule['type'] == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_EXPRESSION) && isset($dxfs[(int) ($cfRule['dxfId'])])) {
$conditionals[(string) $conditional['sqref']][intval($cfRule['priority'])] = $cfRule; $conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule;
} }
} }
} }
@ -973,7 +979,7 @@ class Xlsx extends BaseReader implements IReader
} else { } else {
$objConditional->addCondition((string) $cfRule->formula); $objConditional->addCondition((string) $cfRule->formula);
} }
$objConditional->setStyle(clone $dxfs[intval($cfRule['dxfId'])]); $objConditional->setStyle(clone $dxfs[(int) ($cfRule['dxfId'])]);
$conditionalStyles[] = $objConditional; $conditionalStyles[] = $objConditional;
} }
@ -1009,7 +1015,7 @@ class Xlsx extends BaseReader implements IReader
$autoFilter->setRange($autoFilterRange); $autoFilter->setRange($autoFilterRange);
foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) { foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) {
$column = $autoFilter->getColumnByOffset((integer) $filterColumn['colId']); $column = $autoFilter->getColumnByOffset((int) $filterColumn['colId']);
// Check for standard filters // Check for standard filters
if ($filterColumn->filters) { if ($filterColumn->filters) {
$column->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER); $column->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER);
@ -1113,12 +1119,12 @@ class Xlsx extends BaseReader implements IReader
if ($xmlSheet && $xmlSheet->pageMargins && !$this->readDataOnly) { if ($xmlSheet && $xmlSheet->pageMargins && !$this->readDataOnly) {
$docPageMargins = $docSheet->getPageMargins(); $docPageMargins = $docSheet->getPageMargins();
$docPageMargins->setLeft(floatval($xmlSheet->pageMargins['left'])); $docPageMargins->setLeft((float) ($xmlSheet->pageMargins['left']));
$docPageMargins->setRight(floatval($xmlSheet->pageMargins['right'])); $docPageMargins->setRight((float) ($xmlSheet->pageMargins['right']));
$docPageMargins->setTop(floatval($xmlSheet->pageMargins['top'])); $docPageMargins->setTop((float) ($xmlSheet->pageMargins['top']));
$docPageMargins->setBottom(floatval($xmlSheet->pageMargins['bottom'])); $docPageMargins->setBottom((float) ($xmlSheet->pageMargins['bottom']));
$docPageMargins->setHeader(floatval($xmlSheet->pageMargins['header'])); $docPageMargins->setHeader((float) ($xmlSheet->pageMargins['header']));
$docPageMargins->setFooter(floatval($xmlSheet->pageMargins['footer'])); $docPageMargins->setFooter((float) ($xmlSheet->pageMargins['footer']));
} }
if ($xmlSheet && $xmlSheet->pageSetup && !$this->readDataOnly) { if ($xmlSheet && $xmlSheet->pageSetup && !$this->readDataOnly) {
@ -1128,20 +1134,20 @@ class Xlsx extends BaseReader implements IReader
$docPageSetup->setOrientation((string) $xmlSheet->pageSetup['orientation']); $docPageSetup->setOrientation((string) $xmlSheet->pageSetup['orientation']);
} }
if (isset($xmlSheet->pageSetup['paperSize'])) { if (isset($xmlSheet->pageSetup['paperSize'])) {
$docPageSetup->setPaperSize(intval($xmlSheet->pageSetup['paperSize'])); $docPageSetup->setPaperSize((int) ($xmlSheet->pageSetup['paperSize']));
} }
if (isset($xmlSheet->pageSetup['scale'])) { if (isset($xmlSheet->pageSetup['scale'])) {
$docPageSetup->setScale(intval($xmlSheet->pageSetup['scale']), false); $docPageSetup->setScale((int) ($xmlSheet->pageSetup['scale']), false);
} }
if (isset($xmlSheet->pageSetup['fitToHeight']) && intval($xmlSheet->pageSetup['fitToHeight']) >= 0) { if (isset($xmlSheet->pageSetup['fitToHeight']) && (int) ($xmlSheet->pageSetup['fitToHeight']) >= 0) {
$docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup['fitToHeight']), false); $docPageSetup->setFitToHeight((int) ($xmlSheet->pageSetup['fitToHeight']), false);
} }
if (isset($xmlSheet->pageSetup['fitToWidth']) && intval($xmlSheet->pageSetup['fitToWidth']) >= 0) { if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) {
$docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup['fitToWidth']), false); $docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false);
} }
if (isset($xmlSheet->pageSetup['firstPageNumber']) && isset($xmlSheet->pageSetup['useFirstPageNumber']) && if (isset($xmlSheet->pageSetup['firstPageNumber']) && isset($xmlSheet->pageSetup['useFirstPageNumber']) &&
self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) { self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) {
$docPageSetup->setFirstPageNumber(intval($xmlSheet->pageSetup['firstPageNumber'])); $docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber']));
} }
} }
@ -1693,7 +1699,6 @@ class Xlsx extends BaseReader implements IReader
} }
$docSheet->getPageSetup()->setPrintArea(implode(',', $newRangeSets)); $docSheet->getPageSetup()->setPrintArea(implode(',', $newRangeSets));
break; break;
default: default:
break; break;
} }
@ -1731,14 +1736,14 @@ class Xlsx extends BaseReader implements IReader
case '_xlnm.Print_Area': case '_xlnm.Print_Area':
break; break;
default: default:
if ($mapSheetId[(integer) $definedName['localSheetId']] !== null) { if ($mapSheetId[(int) $definedName['localSheetId']] !== null) {
$range = explode('!', (string) $definedName); $range = explode('!', (string) $definedName);
if (count($range) == 2) { if (count($range) == 2) {
$range[0] = str_replace("''", "'", $range[0]); $range[0] = str_replace("''", "'", $range[0]);
$range[0] = str_replace("'", '', $range[0]); $range[0] = str_replace("'", '', $range[0]);
if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) { if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]); $extractedRange = str_replace('$', '', $range[1]);
$scope = $docSheet->getParent()->getSheet($mapSheetId[(integer) $definedName['localSheetId']]); $scope = $docSheet->getParent()->getSheet($mapSheetId[(int) $definedName['localSheetId']]);
$excel->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange((string) $definedName['name'], $worksheet, $extractedRange, true, $scope)); $excel->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange((string) $definedName['name'], $worksheet, $extractedRange, true, $scope));
} }
} }
@ -1772,7 +1777,7 @@ class Xlsx extends BaseReader implements IReader
if ((!$this->readDataOnly) || (!empty($this->loadSheetsOnly))) { if ((!$this->readDataOnly) || (!empty($this->loadSheetsOnly))) {
// active sheet index // active sheet index
$activeTab = intval($xmlWorkbook->bookViews->workbookView['activeTab']); // refers to old sheet index $activeTab = (int) ($xmlWorkbook->bookViews->workbookView['activeTab']); // refers to old sheet index
// keep active sheet index if sheet is still loaded, else first sheet is set as the active // keep active sheet index if sheet is still loaded, else first sheet is set as the active
if (isset($mapSheetId[$activeTab]) && $mapSheetId[$activeTab] !== null) { if (isset($mapSheetId[$activeTab]) && $mapSheetId[$activeTab] !== null) {
@ -1901,7 +1906,7 @@ class Xlsx extends BaseReader implements IReader
if (!empty($gradientFill['type'])) { if (!empty($gradientFill['type'])) {
$docStyle->getFill()->setFillType((string) $gradientFill['type']); $docStyle->getFill()->setFillType((string) $gradientFill['type']);
} }
$docStyle->getFill()->setRotation(floatval($gradientFill['degree'])); $docStyle->getFill()->setRotation((float) ($gradientFill['degree']));
$gradientFill->registerXPathNamespace('sml', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); $gradientFill->registerXPathNamespace('sml', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$docStyle->getFill()->getStartColor()->setARGB(self::readColor(self::getArrayItem($gradientFill->xpath('sml:stop[@position=0]'))->color)); $docStyle->getFill()->getStartColor()->setARGB(self::readColor(self::getArrayItem($gradientFill->xpath('sml:stop[@position=0]'))->color));
$docStyle->getFill()->getEndColor()->setARGB(self::readColor(self::getArrayItem($gradientFill->xpath('sml:stop[@position=1]'))->color)); $docStyle->getFill()->getEndColor()->setARGB(self::readColor(self::getArrayItem($gradientFill->xpath('sml:stop[@position=1]'))->color));
@ -1951,11 +1956,11 @@ class Xlsx extends BaseReader implements IReader
$textRotation = 90 - (int) $style->alignment['textRotation']; $textRotation = 90 - (int) $style->alignment['textRotation'];
} }
$docStyle->getAlignment()->setTextRotation(intval($textRotation)); $docStyle->getAlignment()->setTextRotation((int) $textRotation);
$docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment['wrapText'])); $docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment['wrapText']));
$docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment['shrinkToFit'])); $docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment['shrinkToFit']));
$docStyle->getAlignment()->setIndent(intval((string) $style->alignment['indent']) > 0 ? intval((string) $style->alignment['indent']) : 0); $docStyle->getAlignment()->setIndent((int) ((string) $style->alignment['indent']) > 0 ? (int) ((string) $style->alignment['indent']) : 0);
$docStyle->getAlignment()->setReadorder(intval((string) $style->alignment['readingOrder']) > 0 ? intval((string) $style->alignment['readingOrder']) : 0); $docStyle->getAlignment()->setReadorder((int) ((string) $style->alignment['readingOrder']) > 0 ? (int) ((string) $style->alignment['readingOrder']) : 0);
} }
// protection // protection
@ -2052,6 +2057,8 @@ class Xlsx extends BaseReader implements IReader
/** /**
* @param \PhpOffice\PhpSpreadsheet\Spreadsheet $excel * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $excel
* @param mixed $customUITarget
* @param mixed $zip
*/ */
private function readRibbon(\PhpOffice\PhpSpreadsheet\Spreadsheet $excel, $customUITarget, $zip) private function readRibbon(\PhpOffice\PhpSpreadsheet\Spreadsheet $excel, $customUITarget, $zip)
{ {

View File

@ -5,7 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -22,6 +22,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Functions;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -39,12 +40,12 @@ class Chart
if ($format == 'string') { if ($format == 'string') {
return (string) $attributes[$name]; return (string) $attributes[$name];
} elseif ($format == 'integer') { } elseif ($format == 'integer') {
return (integer) $attributes[$name]; return (int) $attributes[$name];
} elseif ($format == 'boolean') { } elseif ($format == 'boolean') {
return (boolean) ($attributes[$name] === '0' || $attributes[$name] !== 'true') ? false : true; return (bool) ($attributes[$name] === '0' || $attributes[$name] !== 'true') ? false : true;
} else {
return (float) $attributes[$name];
} }
return (float) $attributes[$name];
} }
return null; return null;
@ -497,6 +498,7 @@ class Chart
/** /**
* @param \PhpOffice\PhpSpreadsheet\Chart\Layout $plotArea * @param \PhpOffice\PhpSpreadsheet\Chart\Layout $plotArea
* @param mixed $plotAttributes
*/ */
private static function setChartAttributes(\PhpOffice\PhpSpreadsheet\Chart\Layout $plotArea, $plotAttributes) private static function setChartAttributes(\PhpOffice\PhpSpreadsheet\Chart\Layout $plotArea, $plotAttributes)
{ {

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,41 +20,46 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Theme class Theme
{ {
/** /**
* Theme Name * Theme Name.
* *
* @var string * @var string
*/ */
private $themeName; private $themeName;
/** /**
* Colour Scheme Name * Colour Scheme Name.
* *
* @var string * @var string
*/ */
private $colourSchemeName; private $colourSchemeName;
/** /**
* Colour Map indexed by position * Colour Map indexed by position.
* *
* @var array of string * @var array of string
*/ */
private $colourMapValues; private $colourMapValues;
/** /**
* Colour Map * Colour Map.
* *
* @var array of string * @var array of string
*/ */
private $colourMap; private $colourMap;
/** /**
* Create a new Theme * Create a new Theme.
*
* @param mixed $themeName
* @param mixed $colourSchemeName
* @param mixed $colourMap
*/ */
public function __construct($themeName, $colourSchemeName, $colourMap) public function __construct($themeName, $colourSchemeName, $colourMap)
{ {
@ -65,7 +70,7 @@ class Theme
} }
/** /**
* Get Theme Name * Get Theme Name.
* *
* @return string * @return string
*/ */
@ -75,7 +80,7 @@ class Theme
} }
/** /**
* Get colour Scheme Name * Get colour Scheme Name.
* *
* @return string * @return string
*/ */
@ -85,7 +90,9 @@ class Theme
} }
/** /**
* Get colour Map Value by Position * Get colour Map Value by Position.
*
* @param mixed $index
* *
* @return string * @return string
*/ */

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
@ -33,14 +34,14 @@ class ReferenceHelper
const REFHELPER_REGEXP_COLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}):(\$?[a-z]{1,3})'; const REFHELPER_REGEXP_COLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}):(\$?[a-z]{1,3})';
/** /**
* Instance of this class * Instance of this class.
* *
* @var ReferenceHelper * @var ReferenceHelper
*/ */
private static $instance; private static $instance;
/** /**
* Get an instance of this class * Get an instance of this class.
* *
* @return ReferenceHelper * @return ReferenceHelper
*/ */
@ -54,7 +55,7 @@ class ReferenceHelper
} }
/** /**
* Create a new ReferenceHelper * Create a new ReferenceHelper.
*/ */
protected function __construct() protected function __construct()
{ {
@ -62,10 +63,11 @@ class ReferenceHelper
/** /**
* Compare two column addresses * Compare two column addresses
* Intended for use as a Callback function for sorting column addresses by column * Intended for use as a Callback function for sorting column addresses by column.
* *
* @param string $a First column to test (e.g. 'AA') * @param string $a First column to test (e.g. 'AA')
* @param string $b Second column to test (e.g. 'Z') * @param string $b Second column to test (e.g. 'Z')
*
* @return int * @return int
*/ */
public static function columnSort($a, $b) public static function columnSort($a, $b)
@ -75,10 +77,11 @@ class ReferenceHelper
/** /**
* Compare two column addresses * Compare two column addresses
* Intended for use as a Callback function for reverse sorting column addresses by column * Intended for use as a Callback function for reverse sorting column addresses by column.
* *
* @param string $a First column to test (e.g. 'AA') * @param string $a First column to test (e.g. 'AA')
* @param string $b Second column to test (e.g. 'Z') * @param string $b Second column to test (e.g. 'Z')
*
* @return int * @return int
*/ */
public static function columnReverseSort($a, $b) public static function columnReverseSort($a, $b)
@ -88,10 +91,11 @@ class ReferenceHelper
/** /**
* Compare two cell addresses * Compare two cell addresses
* Intended for use as a Callback function for sorting cell addresses by column and row * Intended for use as a Callback function for sorting cell addresses by column and row.
* *
* @param string $a First cell to test (e.g. 'AA1') * @param string $a First cell to test (e.g. 'AA1')
* @param string $b Second cell to test (e.g. 'Z1') * @param string $b Second cell to test (e.g. 'Z1')
*
* @return int * @return int
*/ */
public static function cellSort($a, $b) public static function cellSort($a, $b)
@ -108,10 +112,11 @@ class ReferenceHelper
/** /**
* Compare two cell addresses * Compare two cell addresses
* Intended for use as a Callback function for sorting cell addresses by column and row * Intended for use as a Callback function for sorting cell addresses by column and row.
* *
* @param string $a First cell to test (e.g. 'AA1') * @param string $a First cell to test (e.g. 'AA1')
* @param string $b Second cell to test (e.g. 'Z1') * @param string $b Second cell to test (e.g. 'Z1')
*
* @return int * @return int
*/ */
public static function cellReverseSort($a, $b) public static function cellReverseSort($a, $b)
@ -127,13 +132,14 @@ class ReferenceHelper
} }
/** /**
* Test whether a cell address falls within a defined range of cells * Test whether a cell address falls within a defined range of cells.
* *
* @param string $cellAddress Address of the cell we're testing * @param string $cellAddress Address of the cell we're testing
* @param int $beforeRow Number of the row we're inserting/deleting before * @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 $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 $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 $pNumCols Number of columns to insert/delete (negative values indicate deletion)
*
* @return bool * @return bool
*/ */
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)
@ -155,7 +161,7 @@ class ReferenceHelper
} }
/** /**
* Update page breaks when inserting/deleting rows/columns * Update page breaks when inserting/deleting rows/columns.
* *
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
@ -188,7 +194,7 @@ class ReferenceHelper
} }
/** /**
* Update cell comments when inserting/deleting rows/columns * Update cell comments when inserting/deleting rows/columns.
* *
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
@ -215,7 +221,7 @@ class ReferenceHelper
} }
/** /**
* Update hyperlinks when inserting/deleting rows/columns * Update hyperlinks when inserting/deleting rows/columns.
* *
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
@ -240,7 +246,7 @@ class ReferenceHelper
} }
/** /**
* Update data validations when inserting/deleting rows/columns * Update data validations when inserting/deleting rows/columns.
* *
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
@ -265,7 +271,7 @@ class ReferenceHelper
} }
/** /**
* Update merged cells when inserting/deleting rows/columns * Update merged cells when inserting/deleting rows/columns.
* *
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
@ -286,7 +292,7 @@ class ReferenceHelper
} }
/** /**
* Update protected cells when inserting/deleting rows/columns * Update protected cells when inserting/deleting rows/columns.
* *
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
@ -310,7 +316,7 @@ class ReferenceHelper
} }
/** /**
* Update column dimensions when inserting/deleting rows/columns * Update column dimensions when inserting/deleting rows/columns.
* *
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
@ -335,7 +341,7 @@ class ReferenceHelper
} }
/** /**
* Update row dimensions when inserting/deleting rows/columns * Update row dimensions when inserting/deleting rows/columns.
* *
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
@ -369,12 +375,13 @@ class ReferenceHelper
} }
/** /**
* Insert a new column or row, updating all possible related data * Insert a new column or row, updating all possible related data.
* *
* @param string $pBefore Insert before this cell address (e.g. 'A1') * @param string $pBefore Insert before this cell address (e.g. 'A1')
* @param int $pNumCols Number of columns 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 int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
*
* @throws Exception * @throws Exception
*/ */
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, Worksheet $pSheet = null) public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, Worksheet $pSheet = null)
@ -626,14 +633,16 @@ class ReferenceHelper
} }
/** /**
* Update references within formulas * Update references within formulas.
* *
* @param string $pFormula Formula to update * @param string $pFormula Formula to update
* @param int $pBefore Insert before this one * @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to insert * @param int $pNumCols Number of columns to insert
* @param int $pNumRows Number of rows to insert * @param int $pNumRows Number of rows to insert
* @param string $sheetName Worksheet name/title * @param string $sheetName Worksheet name/title
*
* @throws Exception * @throws Exception
*
* @return string Updated formula * @return string Updated formula
*/ */
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '')
@ -767,13 +776,15 @@ class ReferenceHelper
} }
/** /**
* Update cell reference * Update cell reference.
* *
* @param string $pCellRange Cell range * @param string $pCellRange Cell range
* @param int $pBefore Insert before this one * @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to increment * @param int $pNumCols Number of columns to increment
* @param int $pNumRows Number of rows to increment * @param int $pNumRows Number of rows to increment
*
* @throws Exception * @throws Exception
*
* @return string Updated cell range * @return string Updated cell range
*/ */
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
@ -788,14 +799,13 @@ class ReferenceHelper
} elseif (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) { } elseif (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {
// Range // Range
return $this->updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows); return $this->updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows);
} else { }
// Return original // Return original
return $pCellRange; return $pCellRange;
} }
}
/** /**
* Update named formulas (i.e. containing worksheet references / named ranges) * Update named formulas (i.e. containing worksheet references / named ranges).
* *
* @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet Object to update * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet Object to update
* @param string $oldName Old name (name to replace) * @param string $oldName Old name (name to replace)
@ -823,13 +833,15 @@ class ReferenceHelper
} }
/** /**
* Update cell range * Update cell range.
* *
* @param string $pCellRange Cell range (e.g. 'B2:D4', 'B:C' or '2:3') * @param string $pCellRange Cell range (e.g. 'B2:D4', 'B:C' or '2:3')
* @param int $pBefore Insert before this one * @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to increment * @param int $pNumCols Number of columns to increment
* @param int $pNumRows Number of rows to increment * @param int $pNumRows Number of rows to increment
*
* @throws Exception * @throws Exception
*
* @return string Updated cell range * @return string Updated cell range
*/ */
private function updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) private function updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
@ -855,19 +867,20 @@ class ReferenceHelper
// Recreate range string // Recreate range string
return Cell::buildRange($range); 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.');
} }
/** /**
* Update single cell reference * Update single cell reference.
* *
* @param string $pCellReference Single cell reference * @param string $pCellReference Single cell reference
* @param int $pBefore Insert before this one * @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to increment * @param int $pNumCols Number of columns to increment
* @param int $pNumRows Number of rows to increment * @param int $pNumRows Number of rows to increment
*
* @throws Exception * @throws Exception
*
* @return string Updated cell reference * @return string Updated cell reference
*/ */
private function updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) private function updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
@ -880,8 +893,8 @@ class ReferenceHelper
list($newColumn, $newRow) = Cell::coordinateFromString($pCellReference); list($newColumn, $newRow) = Cell::coordinateFromString($pCellReference);
// Verify which parts should be updated // Verify which parts should be updated
$updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') && (Cell::columnIndexFromString($newColumn) >= Cell::columnIndexFromString($beforeColumn))); $updateColumn = (($newColumn[0] != '$') && ($beforeColumn[0] != '$') && (Cell::columnIndexFromString($newColumn) >= Cell::columnIndexFromString($beforeColumn)));
$updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') && $newRow >= $beforeRow); $updateRow = (($newRow[0] != '$') && ($beforeRow[0] != '$') && $newRow >= $beforeRow);
// Create new column reference // Create new column reference
if ($updateColumn) { if ($updateColumn) {
@ -895,9 +908,8 @@ class ReferenceHelper
// Return new reference // Return new reference
return $newColumn . $newRow; 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.');
} }
/** /**

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
/** /**
* Copyright (c) 2006 - 2016 PhpSpreadsheet * Copyright (c) 2006 - 2016 PhpSpreadsheet.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,22 +20,24 @@ namespace PhpOffice\PhpSpreadsheet;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class RichText implements IComparable class RichText implements IComparable
{ {
/** /**
* Rich text elements * Rich text elements.
* *
* @var RichText\ITextElement[] * @var RichText\ITextElement[]
*/ */
private $richTextElements; private $richTextElements;
/** /**
* Create a new RichText instance * Create a new RichText instance.
* *
* @param Cell $pCell * @param Cell $pCell
*
* @throws Exception * @throws Exception
*/ */
public function __construct(Cell $pCell = null) public function __construct(Cell $pCell = null)
@ -58,10 +60,12 @@ class RichText implements IComparable
} }
/** /**
* Add text * Add text.
* *
* @param RichText\ITextElement $pText Rich text element * @param RichText\ITextElement $pText Rich text element
*
* @throws Exception * @throws Exception
*
* @return RichText * @return RichText
*/ */
public function addText(RichText\ITextElement $pText = null) public function addText(RichText\ITextElement $pText = null)
@ -72,10 +76,12 @@ class RichText implements IComparable
} }
/** /**
* Create text * Create text.
* *
* @param string $pText Text * @param string $pText Text
*
* @throws Exception * @throws Exception
*
* @return RichText\TextElement * @return RichText\TextElement
*/ */
public function createText($pText = '') public function createText($pText = '')
@ -87,10 +93,12 @@ class RichText implements IComparable
} }
/** /**
* Create text run * Create text run.
* *
* @param string $pText Text * @param string $pText Text
*
* @throws Exception * @throws Exception
*
* @return RichText\Run * @return RichText\Run
*/ */
public function createTextRun($pText = '') public function createTextRun($pText = '')
@ -102,7 +110,7 @@ class RichText implements IComparable
} }
/** /**
* Get plain text * Get plain text.
* *
* @return string * @return string
*/ */
@ -120,7 +128,7 @@ class RichText implements IComparable
} }
/** /**
* Convert to string * Convert to string.
* *
* @return string * @return string
*/ */
@ -130,7 +138,7 @@ class RichText implements IComparable
} }
/** /**
* Get Rich Text elements * Get Rich Text elements.
* *
* @return RichText\ITextElement[] * @return RichText\ITextElement[]
*/ */
@ -140,10 +148,12 @@ class RichText implements IComparable
} }
/** /**
* Set Rich Text elements * Set Rich Text elements.
* *
* @param RichText\ITextElement[] $pElements Array of elements * @param RichText\ITextElement[] $pElements Array of elements
*
* @throws Exception * @throws Exception
*
* @return RichText * @return RichText
*/ */
public function setRichTextElements($pElements = null) public function setRichTextElements($pElements = null)
@ -158,7 +168,7 @@ class RichText implements IComparable
} }
/** /**
* Get hash code * Get hash code.
* *
* @return string Hash code * @return string Hash code
*/ */

View File

@ -18,35 +18,37 @@ namespace PhpOffice\PhpSpreadsheet\RichText;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
interface ITextElement interface ITextElement
{ {
/** /**
* Get text * Get text.
* *
* @return string Text * @return string Text
*/ */
public function getText(); public function getText();
/** /**
* Set text * Set text.
* *
* @param $pText string Text * @param $pText string Text
*
* @return ITextElement * @return ITextElement
*/ */
public function setText($pText = ''); public function setText($pText = '');
/** /**
* Get font * Get font.
* *
* @return \PhpOffice\PhpSpreadsheet\Style\Font * @return \PhpOffice\PhpSpreadsheet\Style\Font
*/ */
public function getFont(); public function getFont();
/** /**
* Get hash code * Get hash code.
* *
* @return string Hash code * @return string Hash code
*/ */

View File

@ -18,20 +18,21 @@ namespace PhpOffice\PhpSpreadsheet\RichText;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class Run extends TextElement implements ITextElement class Run extends TextElement implements ITextElement
{ {
/** /**
* Font * Font.
* *
* @var \PhpOffice\PhpSpreadsheet\Style\Font * @var \PhpOffice\PhpSpreadsheet\Style\Font
*/ */
private $font; private $font;
/** /**
* Create a new Run instance * Create a new Run instance.
* *
* @param string $pText Text * @param string $pText Text
*/ */
@ -43,7 +44,7 @@ class Run extends TextElement implements ITextElement
} }
/** /**
* Get font * Get font.
* *
* @return \PhpOffice\PhpSpreadsheet\Style\Font * @return \PhpOffice\PhpSpreadsheet\Style\Font
*/ */
@ -53,10 +54,12 @@ class Run extends TextElement implements ITextElement
} }
/** /**
* Set font * Set font.
* *
* @param \PhpOffice\PhpSpreadsheet\Style\Font $pFont Font * @param \PhpOffice\PhpSpreadsheet\Style\Font $pFont Font
*
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return ITextElement * @return ITextElement
*/ */
public function setFont(\PhpOffice\PhpSpreadsheet\Style\Font $pFont = null) public function setFont(\PhpOffice\PhpSpreadsheet\Style\Font $pFont = null)
@ -67,7 +70,7 @@ class Run extends TextElement implements ITextElement
} }
/** /**
* Get hash code * Get hash code.
* *
* @return string Hash code * @return string Hash code
*/ */

View File

@ -18,20 +18,21 @@ namespace PhpOffice\PhpSpreadsheet\RichText;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PhpSpreadsheet * @category PhpSpreadsheet
*
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
class TextElement implements ITextElement class TextElement implements ITextElement
{ {
/** /**
* Text * Text.
* *
* @var string * @var string
*/ */
private $text; private $text;
/** /**
* Create a new TextElement instance * Create a new TextElement instance.
* *
* @param string $pText Text * @param string $pText Text
*/ */
@ -42,7 +43,7 @@ class TextElement implements ITextElement
} }
/** /**
* Get text * Get text.
* *
* @return string Text * @return string Text
*/ */
@ -52,9 +53,10 @@ class TextElement implements ITextElement
} }
/** /**
* Set text * Set text.
* *
* @param $pText string Text * @param $pText string Text
*
* @return ITextElement * @return ITextElement
*/ */
public function setText($pText = '') public function setText($pText = '')
@ -65,7 +67,7 @@ class TextElement implements ITextElement
} }
/** /**
* Get font * Get font.
* *
* @return \PhpOffice\PhpSpreadsheet\Style\Font * @return \PhpOffice\PhpSpreadsheet\Style\Font
*/ */
@ -75,7 +77,7 @@ class TextElement implements ITextElement
} }
/** /**
* Get hash code * Get hash code.
* *
* @return string Hash code * @return string Hash code
*/ */

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