Update to PHP-CS-Fixer 2.10

This commit is contained in:
Adrien Crivelli 2018-01-28 15:59:38 +09:00
parent 015c83ccf4
commit c96e2dae02
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
92 changed files with 1159 additions and 1112 deletions

View File

@ -7,161 +7,175 @@ $finder = PhpCsFixer\Finder::create()
->in('tests'); ->in('tests');
return PhpCsFixer\Config::create() return PhpCsFixer\Config::create()
->setRiskyAllowed(true) ->setRiskyAllowed(true)
->setFinder($finder) ->setFinder($finder)
->setRules([ ->setRules([
'align_multiline_comment' => true, 'align_multiline_comment' => true,
'array_syntax' => ['syntax' => 'short'], 'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => true, 'backtick_to_shell_exec' => true,
'blank_line_after_namespace' => true, 'binary_operator_spaces' => true,
'blank_line_after_opening_tag' => true, 'blank_line_after_namespace' => true,
'blank_line_before_return' => true, 'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true, 'blank_line_before_statement' => true,
'braces' => true, 'braces' => true,
'cast_spaces' => true, 'cast_spaces' => true,
'class_definition' => true, 'class_attributes_separation' => ['elements' => ['method', 'property']], // const are often grouped with other related const
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE 'class_definition' => true,
'combine_consecutive_issets' => true, 'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
'combine_consecutive_unsets' => true, 'combine_consecutive_issets' => true,
'concat_space' => ['spacing' => 'one'], 'combine_consecutive_unsets' => true,
'declare_equal_normalize' => true, 'compact_nullable_typehint' => true,
'declare_strict_types' => false, // Too early to adopt strict types 'concat_space' => ['spacing' => 'one'],
'dir_constant' => true, 'declare_equal_normalize' => true,
'doctrine_annotation_array_assignment' => true, 'declare_strict_types' => false, // Too early to adopt strict types
'doctrine_annotation_braces' => true, 'dir_constant' => true,
'doctrine_annotation_indentation' => true, 'doctrine_annotation_array_assignment' => true,
'doctrine_annotation_spaces' => true, 'doctrine_annotation_braces' => true,
'elseif' => true, 'doctrine_annotation_indentation' => true,
'encoding' => true, 'doctrine_annotation_spaces' => true,
'ereg_to_preg' => true, 'elseif' => true,
'full_opening_tag' => true, 'encoding' => true,
'function_declaration' => true, 'ereg_to_preg' => true,
'function_to_constant' => true, 'escape_implicit_backslashes' => true,
'function_typehint_space' => true, 'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
'general_phpdoc_annotation_remove' => false, // No use for that 'explicit_string_variable' => false, // I feel it makes the code actually harder to read
'hash_to_slash_comment' => true, 'final_internal_class' => true,
'header_comment' => false, // We don't use common header in all our files 'full_opening_tag' => true,
'heredoc_to_nowdoc' => false, // Not sure about this one 'function_declaration' => true,
'include' => true, 'function_to_constant' => true,
'indentation_type' => true, 'function_typehint_space' => true,
'is_null' => ['use_yoda_style' => false], 'general_phpdoc_annotation_remove' => false, // No use for that
'linebreak_after_opening_tag' => true, 'hash_to_slash_comment' => true,
'line_ending' => true, 'header_comment' => false, // We don't use common header in all our files
'list_syntax' => ['syntax' => 'long'], // Stay compatiblew with PHP 5.6 'heredoc_to_nowdoc' => false, // Not sure about this one
'lowercase_cast' => true, 'include' => true,
'lowercase_constants' => true, 'increment_style' => true,
'lowercase_keywords' => true, 'indentation_type' => true,
'magic_constant_casing' => true, 'is_null' => ['use_yoda_style' => false],
'mb_str_functions' => false, // No, too dangerous to change that 'linebreak_after_opening_tag' => true,
'method_argument_space' => true, 'line_ending' => true,
'method_separation' => true, 'list_syntax' => ['syntax' => 'long'], // Stay compatiblew with PHP 5.6
'modernize_types_casting' => true, 'lowercase_cast' => true,
'native_function_casing' => true, 'lowercase_constants' => true,
'native_function_invocation'=> false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now 'lowercase_keywords' => true,
'new_with_braces' => true, 'magic_constant_casing' => true,
'no_alias_functions' => true, 'mb_str_functions' => false, // No, too dangerous to change that
'no_blank_lines_after_class_opening' => true, 'method_argument_space' => true,
'no_blank_lines_after_phpdoc' => true, 'method_chaining_indentation' => true,
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace 'method_separation' => true,
'no_break_comment' => true, 'modernize_types_casting' => true,
'no_closing_tag' => true, 'multiline_comment_opening_closing' => true,
'no_empty_comment' => true, 'native_function_casing' => true,
'no_empty_phpdoc' => true, 'native_function_invocation' => false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now
'no_empty_statement' => true, 'new_with_braces' => true,
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'useTrait', 'curly_brace_block', 'parenthesis_brace_block', 'square_brace_block'], 'no_alias_functions' => true,
'no_homoglyph_names' => true, 'no_blank_lines_after_class_opening' => true,
'no_leading_import_slash' => true, 'no_blank_lines_after_phpdoc' => true,
'no_leading_namespace_whitespace' => true, 'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
'no_mixed_echo_print' => true, 'no_break_comment' => true,
'no_multiline_whitespace_around_double_arrow' => true, 'no_closing_tag' => true,
'no_multiline_whitespace_before_semicolons' => true, 'no_empty_comment' => true,
'non_printable_character' => true, 'no_empty_phpdoc' => true,
'no_null_property_initialization' => true, 'no_empty_statement' => true,
'no_php4_constructor' => true, 'no_extra_blank_lines' => true,
'normalize_index_brace' => true, 'no_homoglyph_names' => true,
'no_short_bool_cast' => true, 'no_leading_import_slash' => true,
'no_short_echo_tag' => true, 'no_leading_namespace_whitespace' => true,
'no_singleline_whitespace_before_semicolons' => true, 'no_mixed_echo_print' => true,
'no_spaces_after_function_name' => true, 'no_multiline_whitespace_around_double_arrow' => true,
'no_spaces_around_offset' => true, 'no_multiline_whitespace_before_semicolons' => true,
'no_spaces_inside_parenthesis' => true, 'non_printable_character' => true,
'no_superfluous_elseif' => false, // Might be risky on a huge code base 'no_null_property_initialization' => true,
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces 'no_php4_constructor' => true,
'not_operator_with_successor_space' => false, // idem 'normalize_index_brace' => true,
'no_trailing_comma_in_list_call' => true, 'no_short_bool_cast' => true,
'no_trailing_comma_in_singleline_array' => true, 'no_short_echo_tag' => true,
'no_trailing_whitespace_in_comment' => true, 'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_whitespace' => true, 'no_spaces_after_function_name' => true,
'no_unneeded_control_parentheses' => true, 'no_spaces_around_offset' => true,
'no_unneeded_curly_braces' => true, 'no_spaces_inside_parenthesis' => true,
'no_unneeded_final_method' => true, 'no_superfluous_elseif' => false, // Might be risky on a huge code base
'no_unreachable_default_argument_value' => true, 'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
'no_unused_imports' => true, 'not_operator_with_successor_space' => false, // idem
'no_useless_else' => true, 'no_trailing_comma_in_list_call' => true,
'no_useless_return' => true, 'no_trailing_comma_in_singleline_array' => true,
'no_whitespace_before_comma_in_array' => true, 'no_trailing_whitespace_in_comment' => true,
'no_whitespace_in_blank_line' => true, 'no_trailing_whitespace' => true,
'object_operator_without_whitespace' => true, 'no_unneeded_control_parentheses' => true,
'ordered_class_elements' => false, // We prefer to keep some freedom 'no_unneeded_curly_braces' => true,
'ordered_imports' => true, 'no_unneeded_final_method' => true,
'phpdoc_add_missing_param_annotation' => true, 'no_unreachable_default_argument_value' => true,
'phpdoc_align' => false, // Waste of time 'no_unused_imports' => true,
'phpdoc_annotation_without_dot' => true, 'no_useless_else' => true,
'phpdoc_indent' => true, 'no_useless_return' => true,
'phpdoc_inline_tag' => true, 'no_whitespace_before_comma_in_array' => true,
'phpdoc_no_access' => true, 'no_whitespace_in_blank_line' => true,
'phpdoc_no_alias_tag' => true, 'object_operator_without_whitespace' => true,
'phpdoc_no_empty_return' => true, 'ordered_class_elements' => false, // We prefer to keep some freedom
'phpdoc_no_package' => true, 'ordered_imports' => true,
'phpdoc_no_useless_inheritdoc' => true, 'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true, 'phpdoc_align' => false, // Waste of time
'phpdoc_return_self_reference' => true, 'phpdoc_annotation_without_dot' => true,
'phpdoc_scalar' => true, 'phpdoc_indent' => true,
'phpdoc_separation' => true, 'phpdoc_inline_tag' => true,
'phpdoc_single_line_var_spacing' => true, 'phpdoc_no_access' => true,
'phpdoc_summary' => true, 'phpdoc_no_alias_tag' => true,
'phpdoc_to_comment' => true, 'phpdoc_no_empty_return' => true,
'phpdoc_trim' => true, 'phpdoc_no_package' => true,
'phpdoc_types_order' => true, 'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_types' => true, 'phpdoc_order' => true,
'phpdoc_var_without_name' => true, 'phpdoc_return_self_reference' => true,
'php_unit_construct' => true, 'phpdoc_scalar' => true,
'php_unit_dedicate_assert' => true, 'phpdoc_separation' => true,
'php_unit_fqcn_annotation' => true, 'phpdoc_single_line_var_spacing' => true,
'php_unit_strict' => false, // We sometime actually need assertEquals 'phpdoc_summary' => true,
'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage 'phpdoc_to_comment' => true,
'pow_to_exponentiation' => false, 'phpdoc_trim' => true,
'pre_increment' => true, 'phpdoc_types_order' => true,
'protected_to_private' => true, 'phpdoc_types' => true,
'psr0' => true, 'phpdoc_var_without_name' => true,
'psr4' => true, 'php_unit_construct' => true,
'random_api_migration' => false, // This breaks our unit tests 'php_unit_dedicate_assert' => true,
'return_type_declaration' => true, 'php_unit_expectation' => true,
'self_accessor' => true, 'php_unit_fqcn_annotation' => true,
'semicolon_after_instruction' => false, // Buggy in `samples/index.php` 'php_unit_mock' => true,
'short_scalar_cast' => true, 'php_unit_namespaced' => true,
'silenced_deprecation_error' => true, 'php_unit_no_expectation_annotation' => true,
'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null 'php_unit_strict' => false, // We sometime actually need assertEquals
'single_blank_line_at_eof' => true, 'php_unit_test_annotation' => true,
'single_blank_line_before_namespace' => true, 'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage
'single_class_element_per_statement' => true, 'pow_to_exponentiation' => false,
'single_import_per_statement' => true, 'protected_to_private' => true,
'single_line_after_imports' => true, 'psr0' => true,
'single_line_comment_style' => true, 'psr4' => true,
'single_quote' => true, 'random_api_migration' => false, // This breaks our unit tests
'space_after_semicolon' => true, 'return_type_declaration' => true,
'standardize_not_equals' => true, 'self_accessor' => true,
'strict_comparison' => false, // No, too dangerous to change that 'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
'strict_param' => false, // No, too dangerous to change that 'short_scalar_cast' => true,
'switch_case_semicolon_to_colon' => true, 'silenced_deprecation_error' => true,
'switch_case_space' => true, 'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null
'ternary_operator_spaces' => true, 'single_blank_line_at_eof' => true,
'ternary_to_null_coalescing' => false, // Cannot use that with PHP 5.6 'single_blank_line_before_namespace' => true,
'trailing_comma_in_multiline_array' => true, 'single_class_element_per_statement' => true,
'trim_array_spaces' => true, 'single_import_per_statement' => true,
'unary_operator_spaces' => true, 'single_line_after_imports' => true,
'visibility_required' => true, 'single_line_comment_style' => true,
'void_return' => false, // Cannot use that with PHP 5.6 'single_quote' => true,
'whitespace_after_comma_in_array' => true, 'space_after_semicolon' => true,
'yoda_style' => false, 'standardize_not_equals' => true,
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
'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,
'ternary_to_null_coalescing' => false, // Cannot use that with PHP 5.6
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
'void_return' => false, // Cannot use that with PHP 5.6
'whitespace_after_comma_in_array' => true,
'yoda_style' => false,
]); ]);

View File

@ -54,8 +54,8 @@
"phpunit/phpunit": "^5.7", "phpunit/phpunit": "^5.7",
"dompdf/dompdf": "^0.8.0", "dompdf/dompdf": "^0.8.0",
"mpdf/mpdf": "^7.0.0", "mpdf/mpdf": "^7.0.0",
"friendsofphp/php-cs-fixer": "^2.7", "jpgraph/jpgraph": "^4.0",
"jpgraph/jpgraph": "^4.0" "friendsofphp/php-cs-fixer": "@stable"
}, },
"suggest": { "suggest": {
"ext-gd": "Required for exact column width autocalculation", "ext-gd": "Required for exact column width autocalculation",

322
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "804bbe054403d6532308f8a65f19adc2", "content-hash": "e61a906bd83393400add286703f10557",
"packages": [ "packages": [
{ {
"name": "psr/simple-cache", "name": "psr/simple-cache",
@ -120,30 +120,30 @@
}, },
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
"version": "v1.4.0", "version": "v1.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/annotations.git", "url": "https://github.com/doctrine/annotations.git",
"reference": "54cacc9b81758b14e3ce750f205a393d52339e97" "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5",
"reference": "54cacc9b81758b14e3ce750f205a393d52339e97", "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/lexer": "1.*", "doctrine/lexer": "1.*",
"php": "^5.6 || ^7.0" "php": "^7.1"
}, },
"require-dev": { "require-dev": {
"doctrine/cache": "1.*", "doctrine/cache": "1.*",
"phpunit/phpunit": "^5.7" "phpunit/phpunit": "^6.4"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.4.x-dev" "dev-master": "1.6.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -184,7 +184,7 @@
"docblock", "docblock",
"parser" "parser"
], ],
"time": "2017-02-24T16:22:25+00:00" "time": "2017-12-06T07:11:42+00:00"
}, },
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
@ -358,16 +358,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v2.7.0", "version": "v2.10.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "e4e93a120117e879cfc1f231fbf29274707cd834" "reference": "513a3765b56dd029175f9f32995566657ee89dda"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/e4e93a120117e879cfc1f231fbf29274707cd834", "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/513a3765b56dd029175f9f32995566657ee89dda",
"reference": "e4e93a120117e879cfc1f231fbf29274707cd834", "reference": "513a3765b56dd029175f9f32995566657ee89dda",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -375,29 +375,32 @@
"doctrine/annotations": "^1.2", "doctrine/annotations": "^1.2",
"ext-json": "*", "ext-json": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"gecko-packages/gecko-php-unit": "^2.0", "gecko-packages/gecko-php-unit": "^2.0 || ^3.0",
"php": "^5.6 || >=7.0 <7.3", "php": "^5.6 || >=7.0 <7.3",
"php-cs-fixer/diff": "^1.0", "php-cs-fixer/diff": "^1.2",
"symfony/console": "^3.2", "symfony/console": "^3.2 || ^4.0",
"symfony/event-dispatcher": "^3.0", "symfony/event-dispatcher": "^3.0 || ^4.0",
"symfony/filesystem": "^3.0", "symfony/filesystem": "^3.0 || ^4.0",
"symfony/finder": "^3.0", "symfony/finder": "^3.0 || ^4.0",
"symfony/options-resolver": "^3.0", "symfony/options-resolver": "^3.0 || ^4.0",
"symfony/polyfill-php70": "^1.0", "symfony/polyfill-php70": "^1.0",
"symfony/polyfill-php72": "^1.4", "symfony/polyfill-php72": "^1.4",
"symfony/process": "^3.0", "symfony/process": "^3.0 || ^4.0",
"symfony/stopwatch": "^3.0" "symfony/stopwatch": "^3.0 || ^4.0"
}, },
"conflict": { "conflict": {
"hhvm": "*" "hhvm": "*"
}, },
"require-dev": { "require-dev": {
"johnkary/phpunit-speedtrap": "^1.1", "johnkary/phpunit-speedtrap": "^1.1 || ^2.0@dev",
"justinrainbow/json-schema": "^5.0", "justinrainbow/json-schema": "^5.0",
"keradus/cli-executor": "^1.0",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.0",
"php-cs-fixer/accessible-object": "^1.0", "php-cs-fixer/accessible-object": "^1.0",
"phpunit/phpunit": "^4.8.35 || ^5.4.3", "phpunit/phpunit": "^5.7.23 || ^6.4.3",
"satooshi/php-coveralls": "^1.0", "phpunitgoodpractices/traits": "^1.0",
"symfony/phpunit-bridge": "^3.2.2" "symfony/phpunit-bridge": "^3.2.2 || ^4.0"
}, },
"suggest": { "suggest": {
"ext-mbstring": "For handling non-UTF8 characters in cache signature.", "ext-mbstring": "For handling non-UTF8 characters in cache signature.",
@ -409,7 +412,7 @@
"type": "application", "type": "application",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.7-dev" "dev-master": "2.10-dev"
} }
}, },
"autoload": { "autoload": {
@ -417,11 +420,12 @@
"PhpCsFixer\\": "src/" "PhpCsFixer\\": "src/"
}, },
"classmap": [ "classmap": [
"tests/Test/Assert/AssertTokensTrait.php",
"tests/Test/AbstractFixerTestCase.php", "tests/Test/AbstractFixerTestCase.php",
"tests/Test/AbstractIntegrationTestCase.php", "tests/Test/AbstractIntegrationTestCase.php",
"tests/Test/Assert/AssertTokensTrait.php",
"tests/Test/IntegrationCase.php", "tests/Test/IntegrationCase.php",
"tests/Test/IntegrationCaseFactory.php" "tests/Test/IntegrationCaseFactory.php",
"tests/TestCase.php"
] ]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -439,27 +443,27 @@
} }
], ],
"description": "A tool to automatically fix PHP code style", "description": "A tool to automatically fix PHP code style",
"time": "2017-09-29T15:19:05+00:00" "time": "2018-01-10T17:16:15+00:00"
}, },
{ {
"name": "gecko-packages/gecko-php-unit", "name": "gecko-packages/gecko-php-unit",
"version": "v2.2", "version": "v3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/GeckoPackages/GeckoPHPUnit.git", "url": "https://github.com/GeckoPackages/GeckoPHPUnit.git",
"reference": "ab525fac9a9ffea219687f261b02008b18ebf2d1" "reference": "6a866551dffc2154c1b091bae3a7877d39c25ca3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/GeckoPackages/GeckoPHPUnit/zipball/ab525fac9a9ffea219687f261b02008b18ebf2d1", "url": "https://api.github.com/repos/GeckoPackages/GeckoPHPUnit/zipball/6a866551dffc2154c1b091bae3a7877d39c25ca3",
"reference": "ab525fac9a9ffea219687f261b02008b18ebf2d1", "reference": "6a866551dffc2154c1b091bae3a7877d39c25ca3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.3.6 || ^7.0" "php": "^7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.4.3" "phpunit/phpunit": "^6.0"
}, },
"suggest": { "suggest": {
"ext-dom": "When testing with xml.", "ext-dom": "When testing with xml.",
@ -467,6 +471,11 @@
"phpunit/phpunit": "This is an extension for it so make sure you have it some way." "phpunit/phpunit": "This is an extension for it so make sure you have it some way."
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"GeckoPackages\\PHPUnit\\": "src/PHPUnit" "GeckoPackages\\PHPUnit\\": "src/PHPUnit"
@ -483,7 +492,7 @@
"filesystem", "filesystem",
"phpunit" "phpunit"
], ],
"time": "2017-08-23T07:39:54+00:00" "time": "2017-08-23T07:46:41+00:00"
}, },
{ {
"name": "ircmaxell/password-compat", "name": "ircmaxell/password-compat",
@ -800,23 +809,24 @@
}, },
{ {
"name": "php-cs-fixer/diff", "name": "php-cs-fixer/diff",
"version": "v1.1.0", "version": "v1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-CS-Fixer/diff.git", "url": "https://github.com/PHP-CS-Fixer/diff.git",
"reference": "d068edadcb8f7bc2ea3d3769cdbaf609026ec4f4" "reference": "f0ef6133d674137e902fdf8a6f2e8e97e14a087b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/d068edadcb8f7bc2ea3d3769cdbaf609026ec4f4", "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/f0ef6133d674137e902fdf8a6f2e8e97e14a087b",
"reference": "d068edadcb8f7bc2ea3d3769cdbaf609026ec4f4", "reference": "f0ef6133d674137e902fdf8a6f2e8e97e14a087b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.6 || ^7.0" "php": "^5.6 || ^7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.4.3" "phpunit/phpunit": "^4.8.35 || ^5.4.3",
"symfony/process": "^3.3"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -825,9 +835,6 @@
] ]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [ "authors": [
{ {
"name": "Kore Nordmann", "name": "Kore Nordmann",
@ -836,6 +843,9 @@
{ {
"name": "Sebastian Bergmann", "name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de" "email": "sebastian@phpunit.de"
},
{
"name": "SpacePossum"
} }
], ],
"description": "sebastian/diff v2 backport support for PHP5.6", "description": "sebastian/diff v2 backport support for PHP5.6",
@ -843,7 +853,7 @@
"keywords": [ "keywords": [
"diff" "diff"
], ],
"time": "2017-09-23T16:02:08+00:00" "time": "2017-10-19T09:58:18+00:00"
}, },
{ {
"name": "phpdocumentor/reflection-common", "name": "phpdocumentor/reflection-common",
@ -2174,44 +2184,44 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v3.3.9", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf" "reference": "fe0e69d7162cba0885791cf7eea5f0d7bc0f897e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf", "url": "https://api.github.com/repos/symfony/console/zipball/fe0e69d7162cba0885791cf7eea5f0d7bc0f897e",
"reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf", "reference": "fe0e69d7162cba0885791cf7eea5f0d7bc0f897e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.5.9|>=7.0.8", "php": "^7.1.3",
"symfony/debug": "~2.8|~3.0",
"symfony/polyfill-mbstring": "~1.0" "symfony/polyfill-mbstring": "~1.0"
}, },
"conflict": { "conflict": {
"symfony/dependency-injection": "<3.3" "symfony/dependency-injection": "<3.4",
"symfony/process": "<3.3"
}, },
"require-dev": { "require-dev": {
"psr/log": "~1.0", "psr/log": "~1.0",
"symfony/config": "~3.3", "symfony/config": "~3.4|~4.0",
"symfony/dependency-injection": "~3.3", "symfony/dependency-injection": "~3.4|~4.0",
"symfony/event-dispatcher": "~2.8|~3.0", "symfony/event-dispatcher": "~3.4|~4.0",
"symfony/filesystem": "~2.8|~3.0", "symfony/lock": "~3.4|~4.0",
"symfony/process": "~2.8|~3.0" "symfony/process": "~3.4|~4.0"
}, },
"suggest": { "suggest": {
"psr/log": "For using the console logger", "psr/log": "For using the console logger",
"symfony/event-dispatcher": "", "symfony/event-dispatcher": "",
"symfony/filesystem": "", "symfony/lock": "",
"symfony/process": "" "symfony/process": ""
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.3-dev" "dev-master": "4.0-dev"
} }
}, },
"autoload": { "autoload": {
@ -2238,90 +2248,34 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-09-06T16:40:18+00:00" "time": "2018-01-03T07:38:00+00:00"
},
{
"name": "symfony/debug",
"version": "v3.3.9",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "8beb24eec70b345c313640962df933499373a944"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/8beb24eec70b345c313640962df933499373a944",
"reference": "8beb24eec70b345c313640962df933499373a944",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8",
"psr/log": "~1.0"
},
"conflict": {
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
},
"require-dev": {
"symfony/http-kernel": "~2.8|~3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Debug\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2017-09-01T13:23:39+00:00"
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v3.3.9", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/event-dispatcher.git", "url": "https://github.com/symfony/event-dispatcher.git",
"reference": "54ca9520a00386f83bca145819ad3b619aaa2485" "reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/54ca9520a00386f83bca145819ad3b619aaa2485", "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/74d33aac36208c4d6757807d9f598f0133a3a4eb",
"reference": "54ca9520a00386f83bca145819ad3b619aaa2485", "reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.5.9|>=7.0.8" "php": "^7.1.3"
}, },
"conflict": { "conflict": {
"symfony/dependency-injection": "<3.3" "symfony/dependency-injection": "<3.4"
}, },
"require-dev": { "require-dev": {
"psr/log": "~1.0", "psr/log": "~1.0",
"symfony/config": "~2.8|~3.0", "symfony/config": "~3.4|~4.0",
"symfony/dependency-injection": "~3.3", "symfony/dependency-injection": "~3.4|~4.0",
"symfony/expression-language": "~2.8|~3.0", "symfony/expression-language": "~3.4|~4.0",
"symfony/stopwatch": "~2.8|~3.0" "symfony/stopwatch": "~3.4|~4.0"
}, },
"suggest": { "suggest": {
"symfony/dependency-injection": "", "symfony/dependency-injection": "",
@ -2330,7 +2284,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.3-dev" "dev-master": "4.0-dev"
} }
}, },
"autoload": { "autoload": {
@ -2357,29 +2311,29 @@
], ],
"description": "Symfony EventDispatcher Component", "description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00" "time": "2018-01-03T07:38:00+00:00"
}, },
{ {
"name": "symfony/filesystem", "name": "symfony/filesystem",
"version": "v3.3.9", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/filesystem.git", "url": "https://github.com/symfony/filesystem.git",
"reference": "b32a0e5f928d0fa3d1dd03c78d020777e50c10cb" "reference": "760e47a4ee64b4c48f4b30017011e09d4c0f05ed"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/b32a0e5f928d0fa3d1dd03c78d020777e50c10cb", "url": "https://api.github.com/repos/symfony/filesystem/zipball/760e47a4ee64b4c48f4b30017011e09d4c0f05ed",
"reference": "b32a0e5f928d0fa3d1dd03c78d020777e50c10cb", "reference": "760e47a4ee64b4c48f4b30017011e09d4c0f05ed",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.5.9|>=7.0.8" "php": "^7.1.3"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.3-dev" "dev-master": "4.0-dev"
} }
}, },
"autoload": { "autoload": {
@ -2406,29 +2360,29 @@
], ],
"description": "Symfony Filesystem Component", "description": "Symfony Filesystem Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00" "time": "2018-01-03T07:38:00+00:00"
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v3.3.9", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
"reference": "b2260dbc80f3c4198f903215f91a1ac7fe9fe09e" "reference": "8b08180f2b7ccb41062366b9ad91fbc4f1af8601"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/b2260dbc80f3c4198f903215f91a1ac7fe9fe09e", "url": "https://api.github.com/repos/symfony/finder/zipball/8b08180f2b7ccb41062366b9ad91fbc4f1af8601",
"reference": "b2260dbc80f3c4198f903215f91a1ac7fe9fe09e", "reference": "8b08180f2b7ccb41062366b9ad91fbc4f1af8601",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.5.9|>=7.0.8" "php": "^7.1.3"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.3-dev" "dev-master": "4.0-dev"
} }
}, },
"autoload": { "autoload": {
@ -2455,29 +2409,29 @@
], ],
"description": "Symfony Finder Component", "description": "Symfony Finder Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00" "time": "2018-01-03T07:38:00+00:00"
}, },
{ {
"name": "symfony/options-resolver", "name": "symfony/options-resolver",
"version": "v3.3.9", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/options-resolver.git", "url": "https://github.com/symfony/options-resolver.git",
"reference": "ee4e22978fe885b54ee5da8c7964f0a5301abfb6" "reference": "30d9240b30696a69e893534c9fc4a5c72ab6689b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/ee4e22978fe885b54ee5da8c7964f0a5301abfb6", "url": "https://api.github.com/repos/symfony/options-resolver/zipball/30d9240b30696a69e893534c9fc4a5c72ab6689b",
"reference": "ee4e22978fe885b54ee5da8c7964f0a5301abfb6", "reference": "30d9240b30696a69e893534c9fc4a5c72ab6689b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.5.9|>=7.0.8" "php": "^7.1.3"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.3-dev" "dev-master": "4.0-dev"
} }
}, },
"autoload": { "autoload": {
@ -2509,20 +2463,20 @@
"configuration", "configuration",
"options" "options"
], ],
"time": "2017-07-29T21:54:42+00:00" "time": "2018-01-03T07:38:00+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.5.0", "version": "v1.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803" "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7c8fae0ac1d216eb54349e6a8baa57d515fe8803", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
"reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803", "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2534,7 +2488,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.5-dev" "dev-master": "1.6-dev"
} }
}, },
"autoload": { "autoload": {
@ -2568,7 +2522,7 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2017-06-14T15:44:48+00:00" "time": "2017-10-11T12:05:26+00:00"
}, },
{ {
"name": "symfony/polyfill-php54", "name": "symfony/polyfill-php54",
@ -2686,16 +2640,16 @@
}, },
{ {
"name": "symfony/polyfill-php70", "name": "symfony/polyfill-php70",
"version": "v1.5.0", "version": "v1.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php70.git", "url": "https://github.com/symfony/polyfill-php70.git",
"reference": "b6482e68974486984f59449ecea1fbbb22ff840f" "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/b6482e68974486984f59449ecea1fbbb22ff840f", "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff",
"reference": "b6482e68974486984f59449ecea1fbbb22ff840f", "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2705,7 +2659,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.5-dev" "dev-master": "1.6-dev"
} }
}, },
"autoload": { "autoload": {
@ -2741,20 +2695,20 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2017-06-14T15:44:48+00:00" "time": "2017-10-11T12:05:26+00:00"
}, },
{ {
"name": "symfony/polyfill-php72", "name": "symfony/polyfill-php72",
"version": "v1.5.0", "version": "v1.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php72.git", "url": "https://github.com/symfony/polyfill-php72.git",
"reference": "8abc9097f5001d310f0edba727469c988acc6ea7" "reference": "6de4f4884b97abbbed9f0a84a95ff2ff77254254"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/8abc9097f5001d310f0edba727469c988acc6ea7", "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/6de4f4884b97abbbed9f0a84a95ff2ff77254254",
"reference": "8abc9097f5001d310f0edba727469c988acc6ea7", "reference": "6de4f4884b97abbbed9f0a84a95ff2ff77254254",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2763,7 +2717,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.5-dev" "dev-master": "1.6-dev"
} }
}, },
"autoload": { "autoload": {
@ -2796,7 +2750,7 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2017-07-11T13:25:55+00:00" "time": "2017-10-11T12:05:26+00:00"
}, },
{ {
"name": "symfony/polyfill-xml", "name": "symfony/polyfill-xml",
@ -2858,25 +2812,25 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v3.3.9", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "b7666e9b438027a1ea0e1ee813ec5042d5d7f6f0" "reference": "2145b3e8137e463b1051b79440a59b38220944f0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/b7666e9b438027a1ea0e1ee813ec5042d5d7f6f0", "url": "https://api.github.com/repos/symfony/process/zipball/2145b3e8137e463b1051b79440a59b38220944f0",
"reference": "b7666e9b438027a1ea0e1ee813ec5042d5d7f6f0", "reference": "2145b3e8137e463b1051b79440a59b38220944f0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.5.9|>=7.0.8" "php": "^7.1.3"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.3-dev" "dev-master": "4.0-dev"
} }
}, },
"autoload": { "autoload": {
@ -2903,29 +2857,29 @@
], ],
"description": "Symfony Process Component", "description": "Symfony Process Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00" "time": "2018-01-03T07:38:00+00:00"
}, },
{ {
"name": "symfony/stopwatch", "name": "symfony/stopwatch",
"version": "v3.3.9", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/stopwatch.git", "url": "https://github.com/symfony/stopwatch.git",
"reference": "9a5610a8d6a50985a7be485c0ba745c22607beeb" "reference": "d52321f0e2b596bd03b5d1dd6eebe71caa925704"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/9a5610a8d6a50985a7be485c0ba745c22607beeb", "url": "https://api.github.com/repos/symfony/stopwatch/zipball/d52321f0e2b596bd03b5d1dd6eebe71caa925704",
"reference": "9a5610a8d6a50985a7be485c0ba745c22607beeb", "reference": "d52321f0e2b596bd03b5d1dd6eebe71caa925704",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.5.9|>=7.0.8" "php": "^7.1.3"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.3-dev" "dev-master": "4.0-dev"
} }
}, },
"autoload": { "autoload": {
@ -2952,7 +2906,7 @@
], ],
"description": "Symfony Stopwatch Component", "description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00" "time": "2018-01-03T07:38:00+00:00"
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
@ -3125,7 +3079,9 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {
"friendsofphp/php-cs-fixer": 0
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {

View File

@ -11,20 +11,20 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('PhpSpreadsheet Test Document') ->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('office PhpSpreadsheet php') ->setKeywords('office PhpSpreadsheet php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create the worksheet // Create the worksheet
$helper->log('Add data'); $helper->log('Add data');
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Year') $spreadsheet->getActiveSheet()->setCellValue('A1', 'Year')
->setCellValue('B1', 'Quarter') ->setCellValue('B1', 'Quarter')
->setCellValue('C1', 'Country') ->setCellValue('C1', 'Country')
->setCellValue('D1', 'Sales'); ->setCellValue('D1', 'Sales');
$dataArray = [ $dataArray = [
['2010', 'Q1', 'United States', 790], ['2010', 'Q1', 'United States', 790],

View File

@ -15,22 +15,22 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('PhpSpreadsheet Test Document') ->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('office PhpSpreadsheet php') ->setKeywords('office PhpSpreadsheet php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create the worksheet // Create the worksheet
$helper->log('Add data'); $helper->log('Add data');
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Financial Year') $spreadsheet->getActiveSheet()->setCellValue('A1', 'Financial Year')
->setCellValue('B1', 'Financial Period') ->setCellValue('B1', 'Financial Period')
->setCellValue('C1', 'Country') ->setCellValue('C1', 'Country')
->setCellValue('D1', 'Date') ->setCellValue('D1', 'Date')
->setCellValue('E1', 'Sales Value') ->setCellValue('E1', 'Sales Value')
->setCellValue('F1', 'Expenditure'); ->setCellValue('F1', 'Expenditure');
$startYear = $endYear = $currentYear = date('Y'); $startYear = $endYear = $currentYear = date('Y');
--$startYear; --$startYear;
++$endYear; ++$endYear;
@ -110,47 +110,47 @@ $helper->log('Set active filters');
// Filter the Country column on a filter value of countries beginning with the letter U (or Japan) // Filter the Country column on a filter value of countries beginning with the letter U (or Japan)
// We use * as a wildcard, so specify as U* and using a wildcard requires customFilter // We use * as a wildcard, so specify as U* and using a wildcard requires customFilter
$autoFilter->getColumn('C') $autoFilter->getColumn('C')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) ->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL, Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
'u*' 'u*'
) )
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
$autoFilter->getColumn('C') $autoFilter->getColumn('C')
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL, Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
'japan' 'japan'
) )
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
// Filter the Date column on a filter value of the first day of every period of the current year // Filter the Date column on a filter value of the first day of every period of the current year
// We us a dateGroup ruletype for this, although it is still a standard filter // We us a dateGroup ruletype for this, although it is still a standard filter
foreach ($periods as $period) { foreach ($periods as $period) {
$endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear)); $endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear));
$autoFilter->getColumn('D') $autoFilter->getColumn('D')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
->createRule()
->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
[
'year' => $currentYear,
'month' => $period,
'day' => $endDate,
]
)
->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP);
}
// Display only sales values that are blank
// Standard filter, operator equals, and value of NULL
$autoFilter->getColumn('E')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER) ->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL, Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
'' [
); 'year' => $currentYear,
'month' => $period,
'day' => $endDate,
]
)
->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP);
}
// Display only sales values that are blank
// Standard filter, operator equals, and value of NULL
$autoFilter->getColumn('E')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
->createRule()
->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
''
);
// Save // Save
$helper->write($spreadsheet, __FILE__); $helper->write($spreadsheet, __FILE__);

View File

@ -15,22 +15,22 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('PhpSpreadsheet Test Document') ->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('office PhpSpreadsheet php') ->setKeywords('office PhpSpreadsheet php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create the worksheet // Create the worksheet
$helper->log('Add data'); $helper->log('Add data');
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Financial Year') $spreadsheet->getActiveSheet()->setCellValue('A1', 'Financial Year')
->setCellValue('B1', 'Financial Period') ->setCellValue('B1', 'Financial Period')
->setCellValue('C1', 'Country') ->setCellValue('C1', 'Country')
->setCellValue('D1', 'Date') ->setCellValue('D1', 'Date')
->setCellValue('E1', 'Sales Value') ->setCellValue('E1', 'Sales Value')
->setCellValue('F1', 'Expenditure'); ->setCellValue('F1', 'Expenditure');
$startYear = $endYear = $currentYear = date('Y'); $startYear = $endYear = $currentYear = date('Y');
--$startYear; --$startYear;
++$endYear; ++$endYear;
@ -110,39 +110,39 @@ $helper->log('Set active filters');
// Filter the Country column on a filter value of Germany // Filter the Country column on a filter value of Germany
// As it's just a simple value filter, we can use FILTERTYPE_FILTER // As it's just a simple value filter, we can use FILTERTYPE_FILTER
$autoFilter->getColumn('C') $autoFilter->getColumn('C')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER) ->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL, Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
'Germany' 'Germany'
); );
// Filter the Date column on a filter value of the year to date // Filter the Date column on a filter value of the year to date
$autoFilter->getColumn('D') $autoFilter->getColumn('D')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER) ->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER)
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL, Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
null, null,
Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE
) )
->setRuleType(Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); ->setRuleType(Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER);
// Display only sales values that are between 400 and 600 // Display only sales values that are between 400 and 600
$autoFilter->getColumn('E') $autoFilter->getColumn('E')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) ->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL, Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL,
400 400
) )
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
$autoFilter->getColumn('E') $autoFilter->getColumn('E')
->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND) ->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND)
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL, Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL,
600 600
) )
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
// Save // Save
$helper->write($spreadsheet, __FILE__); $helper->write($spreadsheet, __FILE__);

View File

@ -15,22 +15,22 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('PhpSpreadsheet Test Document') ->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('office PhpSpreadsheet php') ->setKeywords('office PhpSpreadsheet php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create the worksheet // Create the worksheet
$helper->log('Add data'); $helper->log('Add data');
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Financial Year') $spreadsheet->getActiveSheet()->setCellValue('A1', 'Financial Year')
->setCellValue('B1', 'Financial Period') ->setCellValue('B1', 'Financial Period')
->setCellValue('C1', 'Country') ->setCellValue('C1', 'Country')
->setCellValue('D1', 'Date') ->setCellValue('D1', 'Date')
->setCellValue('E1', 'Sales Value') ->setCellValue('E1', 'Sales Value')
->setCellValue('F1', 'Expenditure'); ->setCellValue('F1', 'Expenditure');
$startYear = $endYear = $currentYear = date('Y'); $startYear = $endYear = $currentYear = date('Y');
--$startYear; --$startYear;
++$endYear; ++$endYear;
@ -110,47 +110,47 @@ $helper->log('Set active filters');
// Filter the Country column on a filter value of countries beginning with the letter U (or Japan) // Filter the Country column on a filter value of countries beginning with the letter U (or Japan)
// We use * as a wildcard, so specify as U* and using a wildcard requires customFilter // We use * as a wildcard, so specify as U* and using a wildcard requires customFilter
$autoFilter->getColumn('C') $autoFilter->getColumn('C')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) ->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL, Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
'u*' 'u*'
) )
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
$autoFilter->getColumn('C') $autoFilter->getColumn('C')
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL, Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
'japan' 'japan'
) )
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
// Filter the Date column on a filter value of the first day of every period of the current year // Filter the Date column on a filter value of the first day of every period of the current year
// We us a dateGroup ruletype for this, although it is still a standard filter // We us a dateGroup ruletype for this, although it is still a standard filter
foreach ($periods as $period) { foreach ($periods as $period) {
$endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear)); $endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear));
$autoFilter->getColumn('D') $autoFilter->getColumn('D')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
->createRule()
->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
[
'year' => $currentYear,
'month' => $period,
'day' => $endDate,
]
)
->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP);
}
// Display only sales values that are blank
// Standard filter, operator equals, and value of NULL
$autoFilter->getColumn('E')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER) ->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
->createRule() ->createRule()
->setRule( ->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL, Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
'' [
); 'year' => $currentYear,
'month' => $period,
'day' => $endDate,
]
)
->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP);
}
// Display only sales values that are blank
// Standard filter, operator equals, and value of NULL
$autoFilter->getColumn('E')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
->createRule()
->setRule(
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
''
);
// Execute filtering // Execute filtering
$helper->log('Execute filtering'); $helper->log('Execute filtering');

View File

@ -11,55 +11,55 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties() $spreadsheet->getProperties()
->setCreator('Maarten Balliauw') ->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('PhpSpreadsheet Test Document') ->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('office PhpSpreadsheet php') ->setKeywords('office PhpSpreadsheet php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello') ->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!') ->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello') ->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!'); ->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8 // Miscellaneous glyphs, UTF-8
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs') ->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A8', "Hello\nWorld"); ->setCellValue('A8', "Hello\nWorld");
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getRowDimension(8) ->getRowDimension(8)
->setRowHeight(-1); ->setRowHeight(-1);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('A8') ->getStyle('A8')
->getAlignment() ->getAlignment()
->setWrapText(true); ->setWrapText(true);
$value = "-ValueA\n-Value B\n-Value C"; $value = "-ValueA\n-Value B\n-Value C";
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A10', $value); ->setCellValue('A10', $value);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getRowDimension(10) ->getRowDimension(10)
->setRowHeight(-1); ->setRowHeight(-1);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('A10') ->getStyle('A10')
->getAlignment() ->getAlignment()
->setWrapText(true); ->setWrapText(true);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('A10') ->getStyle('A10')
->setQuotePrefix(true); ->setQuotePrefix(true);
// Rename worksheet // Rename worksheet
$helper->log('Rename worksheet'); $helper->log('Rename worksheet');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setTitle('Simple'); ->setTitle('Simple');
// Save // Save
$helper->write($spreadsheet, __FILE__); $helper->write($spreadsheet, __FILE__);

View File

@ -18,24 +18,24 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello') ->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!') ->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello') ->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!'); ->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8 // Miscellaneous glyphs, UTF-8
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs') ->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
// Rename worksheet // Rename worksheet
$spreadsheet->getActiveSheet()->setTitle('Simple'); $spreadsheet->getActiveSheet()->setTitle('Simple');

View File

@ -18,24 +18,24 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('PDF Test Document') ->setTitle('PDF Test Document')
->setSubject('PDF Test Document') ->setSubject('PDF Test Document')
->setDescription('Test document for PDF, generated using PHP classes.') ->setDescription('Test document for PDF, generated using PHP classes.')
->setKeywords('pdf php') ->setKeywords('pdf php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello') ->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!') ->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello') ->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!'); ->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8 // Miscellaneous glyphs, UTF-8
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs') ->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
// Rename worksheet // Rename worksheet
$spreadsheet->getActiveSheet()->setTitle('Simple'); $spreadsheet->getActiveSheet()->setTitle('Simple');

View File

@ -18,24 +18,24 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello') ->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!') ->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello') ->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!'); ->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8 // Miscellaneous glyphs, UTF-8
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs') ->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
// Rename worksheet // Rename worksheet
$spreadsheet->getActiveSheet()->setTitle('Simple'); $spreadsheet->getActiveSheet()->setTitle('Simple');

View File

@ -17,24 +17,24 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello') ->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!') ->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello') ->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!'); ->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8 // Miscellaneous glyphs, UTF-8
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs') ->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
// Rename worksheet // Rename worksheet
$spreadsheet->getActiveSheet()->setTitle('Simple'); $spreadsheet->getActiveSheet()->setTitle('Simple');

View File

@ -15,94 +15,94 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties() $spreadsheet->getProperties()
->setCreator('Maarten Balliauw') ->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Set default font // Set default font
$helper->log('Set default font'); $helper->log('Set default font');
$spreadsheet->getDefaultStyle() $spreadsheet->getDefaultStyle()
->getFont() ->getFont()
->setName('Arial') ->setName('Arial')
->setSize(10); ->setSize(10);
// Add some data, resembling some different data types // Add some data, resembling some different data types
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A1', 'String') ->setCellValue('A1', 'String')
->setCellValue('B1', 'Simple') ->setCellValue('B1', 'Simple')
->setCellValue('C1', 'PhpSpreadsheet'); ->setCellValue('C1', 'PhpSpreadsheet');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A2', 'String') ->setCellValue('A2', 'String')
->setCellValue('B2', 'Symbols') ->setCellValue('B2', 'Symbols')
->setCellValue('C2', '!+&=()~§±æþ'); ->setCellValue('C2', '!+&=()~§±æþ');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A3', 'String') ->setCellValue('A3', 'String')
->setCellValue('B3', 'UTF-8') ->setCellValue('B3', 'UTF-8')
->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов'); ->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A4', 'Number') ->setCellValue('A4', 'Number')
->setCellValue('B4', 'Integer') ->setCellValue('B4', 'Integer')
->setCellValue('C4', 12); ->setCellValue('C4', 12);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A5', 'Number') ->setCellValue('A5', 'Number')
->setCellValue('B5', 'Float') ->setCellValue('B5', 'Float')
->setCellValue('C5', 34.56); ->setCellValue('C5', 34.56);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A6', 'Number') ->setCellValue('A6', 'Number')
->setCellValue('B6', 'Negative') ->setCellValue('B6', 'Negative')
->setCellValue('C6', -7.89); ->setCellValue('C6', -7.89);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A7', 'Boolean') ->setCellValue('A7', 'Boolean')
->setCellValue('B7', 'True') ->setCellValue('B7', 'True')
->setCellValue('C7', true); ->setCellValue('C7', true);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A8', 'Boolean') ->setCellValue('A8', 'Boolean')
->setCellValue('B8', 'False') ->setCellValue('B8', 'False')
->setCellValue('C8', false); ->setCellValue('C8', false);
$dateTimeNow = time(); $dateTimeNow = time();
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A9', 'Date/Time') ->setCellValue('A9', 'Date/Time')
->setCellValue('B9', 'Date') ->setCellValue('B9', 'Date')
->setCellValue('C9', Date::PHPToExcel($dateTimeNow)); ->setCellValue('C9', Date::PHPToExcel($dateTimeNow));
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('C9') ->getStyle('C9')
->getNumberFormat() ->getNumberFormat()
->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2); ->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A10', 'Date/Time') ->setCellValue('A10', 'Date/Time')
->setCellValue('B10', 'Time') ->setCellValue('B10', 'Time')
->setCellValue('C10', Date::PHPToExcel($dateTimeNow)); ->setCellValue('C10', Date::PHPToExcel($dateTimeNow));
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('C10') ->getStyle('C10')
->getNumberFormat() ->getNumberFormat()
->setFormatCode(NumberFormat::FORMAT_DATE_TIME4); ->setFormatCode(NumberFormat::FORMAT_DATE_TIME4);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A11', 'Date/Time') ->setCellValue('A11', 'Date/Time')
->setCellValue('B11', 'Date and Time') ->setCellValue('B11', 'Date and Time')
->setCellValue('C11', Date::PHPToExcel($dateTimeNow)); ->setCellValue('C11', Date::PHPToExcel($dateTimeNow));
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('C11') ->getStyle('C11')
->getNumberFormat() ->getNumberFormat()
->setFormatCode(NumberFormat::FORMAT_DATE_DATETIME); ->setFormatCode(NumberFormat::FORMAT_DATE_DATETIME);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A12', 'NULL') ->setCellValue('A12', 'NULL')
->setCellValue('C12', null); ->setCellValue('C12', null);
$richText = new RichText(); $richText = new RichText();
$richText->createText('你好 '); $richText->createText('你好 ');
@ -115,8 +115,8 @@ $payable->getFont()->setColor(new Color(Color::COLOR_DARKGREEN));
$richText->createText(', unless specified otherwise on the invoice.'); $richText->createText(', unless specified otherwise on the invoice.');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A13', 'Rich Text') ->setCellValue('A13', 'Rich Text')
->setCellValue('C13', $richText); ->setCellValue('C13', $richText);
$richText2 = new RichText(); $richText2 = new RichText();
$richText2->createText("black text\n"); $richText2->createText("black text\n");
@ -125,31 +125,31 @@ $red = $richText2->createTextRun('red text');
$red->getFont()->setColor(new Color(Color::COLOR_RED)); $red->getFont()->setColor(new Color(Color::COLOR_RED));
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getCell('C14') ->getCell('C14')
->setValue($richText2); ->setValue($richText2);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('C14') ->getStyle('C14')
->getAlignment()->setWrapText(true); ->getAlignment()->setWrapText(true);
$spreadsheet->getActiveSheet()->setCellValue('A17', 'Hyperlink'); $spreadsheet->getActiveSheet()->setCellValue('A17', 'Hyperlink');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('C17', 'PhpSpreadsheet Web Site'); ->setCellValue('C17', 'PhpSpreadsheet Web Site');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getCell('C17') ->getCell('C17')
->getHyperlink() ->getHyperlink()
->setUrl('https://github.com/PHPOffice/PhpSpreadsheet') ->setUrl('https://github.com/PHPOffice/PhpSpreadsheet')
->setTooltip('Navigate to PhpSpreadsheet website'); ->setTooltip('Navigate to PhpSpreadsheet website');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('C18', '=HYPERLINK("mailto:abc@def.com","abc@def.com")'); ->setCellValue('C18', '=HYPERLINK("mailto:abc@def.com","abc@def.com")');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getColumnDimension('B') ->getColumnDimension('B')
->setAutoSize(true); ->setAutoSize(true);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getColumnDimension('C') ->getColumnDimension('C')
->setAutoSize(true); ->setAutoSize(true);
// Rename worksheet // Rename worksheet
$helper->log('Rename worksheet'); $helper->log('Rename worksheet');

View File

@ -11,63 +11,63 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data, we will use some formulas here // Add some data, we will use some formulas here
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A5', 'Sum:'); ->setCellValue('A5', 'Sum:');
$spreadsheet->getActiveSheet()->setCellValue('B1', 'Range #1') $spreadsheet->getActiveSheet()->setCellValue('B1', 'Range #1')
->setCellValue('B2', 3) ->setCellValue('B2', 3)
->setCellValue('B3', 7) ->setCellValue('B3', 7)
->setCellValue('B4', 13) ->setCellValue('B4', 13)
->setCellValue('B5', '=SUM(B2:B4)'); ->setCellValue('B5', '=SUM(B2:B4)');
$helper->log('Sum of Range #1 is ' . $spreadsheet->getActiveSheet()->getCell('B5')->getCalculatedValue()); $helper->log('Sum of Range #1 is ' . $spreadsheet->getActiveSheet()->getCell('B5')->getCalculatedValue());
$spreadsheet->getActiveSheet()->setCellValue('C1', 'Range #2') $spreadsheet->getActiveSheet()->setCellValue('C1', 'Range #2')
->setCellValue('C2', 5) ->setCellValue('C2', 5)
->setCellValue('C3', 11) ->setCellValue('C3', 11)
->setCellValue('C4', 17) ->setCellValue('C4', 17)
->setCellValue('C5', '=SUM(C2:C4)'); ->setCellValue('C5', '=SUM(C2:C4)');
$helper->log('Sum of Range #2 is ' . $spreadsheet->getActiveSheet()->getCell('C5')->getCalculatedValue()); $helper->log('Sum of Range #2 is ' . $spreadsheet->getActiveSheet()->getCell('C5')->getCalculatedValue());
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A7', 'Total of both ranges:'); ->setCellValue('A7', 'Total of both ranges:');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('B7', '=SUM(B5:C5)'); ->setCellValue('B7', '=SUM(B5:C5)');
$helper->log('Sum of both Ranges is ' . $spreadsheet->getActiveSheet()->getCell('B7')->getCalculatedValue()); $helper->log('Sum of both Ranges is ' . $spreadsheet->getActiveSheet()->getCell('B7')->getCalculatedValue());
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A8', 'Minimum of both ranges:'); ->setCellValue('A8', 'Minimum of both ranges:');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('B8', '=MIN(B2:C4)'); ->setCellValue('B8', '=MIN(B2:C4)');
$helper->log('Minimum value in either Range is ' . $spreadsheet->getActiveSheet()->getCell('B8')->getCalculatedValue()); $helper->log('Minimum value in either Range is ' . $spreadsheet->getActiveSheet()->getCell('B8')->getCalculatedValue());
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A9', 'Maximum of both ranges:'); ->setCellValue('A9', 'Maximum of both ranges:');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('B9', '=MAX(B2:C4)'); ->setCellValue('B9', '=MAX(B2:C4)');
$helper->log('Maximum value in either Range is ' . $spreadsheet->getActiveSheet()->getCell('B9')->getCalculatedValue()); $helper->log('Maximum value in either Range is ' . $spreadsheet->getActiveSheet()->getCell('B9')->getCalculatedValue());
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A10', 'Average of both ranges:'); ->setCellValue('A10', 'Average of both ranges:');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('B10', '=AVERAGE(B2:C4)'); ->setCellValue('B10', '=AVERAGE(B2:C4)');
$helper->log('Average value of both Ranges is ' . $spreadsheet->getActiveSheet()->getCell('B10')->getCalculatedValue()); $helper->log('Average value of both Ranges is ' . $spreadsheet->getActiveSheet()->getCell('B10')->getCalculatedValue());
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getColumnDimension('A') ->getColumnDimension('A')
->setAutoSize(true); ->setAutoSize(true);
// Rename worksheet // Rename worksheet
$helper->log('Rename worksheet'); $helper->log('Rename worksheet');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setTitle('Formulas'); ->setTitle('Formulas');
// //
// If we set Pre Calculated Formulas to true then PhpSpreadsheet will calculate all formulae in the // If we set Pre Calculated Formulas to true then PhpSpreadsheet will calculate all formulae in the

View File

@ -14,12 +14,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data, we will use printing features // Add some data, we will use printing features
$helper->log('Add some data'); $helper->log('Add some data');
@ -31,11 +31,11 @@ for ($i = 1; $i < 200; ++$i) {
// Set header and footer. When no different headers for odd/even are used, odd header is assumed. // Set header and footer. When no different headers for odd/even are used, odd header is assumed.
$helper->log('Set header/footer'); $helper->log('Set header/footer');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getHeaderFooter() ->getHeaderFooter()
->setOddHeader('&L&G&C&HPlease treat this document as confidential!'); ->setOddHeader('&L&G&C&HPlease treat this document as confidential!');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getHeaderFooter() ->getHeaderFooter()
->setOddFooter('&L&B' . $spreadsheet->getProperties()->getTitle() . '&RPage &P of &N'); ->setOddFooter('&L&B' . $spreadsheet->getProperties()->getTitle() . '&RPage &P of &N');
// Add a drawing to the header // Add a drawing to the header
$helper->log('Add a drawing to the header'); $helper->log('Add a drawing to the header');
@ -44,17 +44,17 @@ $drawing->setName('PhpSpreadsheet logo');
$drawing->setPath(__DIR__ . '/../images/PhpSpreadsheet_logo.png'); $drawing->setPath(__DIR__ . '/../images/PhpSpreadsheet_logo.png');
$drawing->setHeight(36); $drawing->setHeight(36);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getHeaderFooter() ->getHeaderFooter()
->addImage($drawing, HeaderFooter::IMAGE_HEADER_LEFT); ->addImage($drawing, HeaderFooter::IMAGE_HEADER_LEFT);
// Set page orientation and size // Set page orientation and size
$helper->log('Set page orientation and size'); $helper->log('Set page orientation and size');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getPageSetup() ->getPageSetup()
->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); ->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getPageSetup() ->getPageSetup()
->setPaperSize(PageSetup::PAPERSIZE_A4); ->setPaperSize(PageSetup::PAPERSIZE_A4);
// Rename worksheet // Rename worksheet
$helper->log('Rename worksheet'); $helper->log('Rename worksheet');

View File

@ -15,36 +15,36 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create a first sheet, representing sales data // Create a first sheet, representing sales data
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Description') $spreadsheet->getActiveSheet()->setCellValue('A1', 'Description')
->setCellValue('B1', 'Amount'); ->setCellValue('B1', 'Amount');
$spreadsheet->getActiveSheet()->setCellValue('A2', 'Paycheck received') $spreadsheet->getActiveSheet()->setCellValue('A2', 'Paycheck received')
->setCellValue('B2', 100); ->setCellValue('B2', 100);
$spreadsheet->getActiveSheet()->setCellValue('A3', 'Cup of coffee bought') $spreadsheet->getActiveSheet()->setCellValue('A3', 'Cup of coffee bought')
->setCellValue('B3', -1.5); ->setCellValue('B3', -1.5);
$spreadsheet->getActiveSheet()->setCellValue('A4', 'Cup of coffee bought') $spreadsheet->getActiveSheet()->setCellValue('A4', 'Cup of coffee bought')
->setCellValue('B4', -1.5); ->setCellValue('B4', -1.5);
$spreadsheet->getActiveSheet()->setCellValue('A5', 'Cup of tea bought') $spreadsheet->getActiveSheet()->setCellValue('A5', 'Cup of tea bought')
->setCellValue('B5', -1.2); ->setCellValue('B5', -1.2);
$spreadsheet->getActiveSheet()->setCellValue('A6', 'Found some money') $spreadsheet->getActiveSheet()->setCellValue('A6', 'Found some money')
->setCellValue('B6', 8); ->setCellValue('B6', 8);
$spreadsheet->getActiveSheet()->setCellValue('A7', 'Total:') $spreadsheet->getActiveSheet()->setCellValue('A7', 'Total:')
->setCellValue('B7', '=SUM(B2:B6)'); ->setCellValue('B7', '=SUM(B2:B6)');
// Set column widths // Set column widths
$helper->log('Set column widths'); $helper->log('Set column widths');
@ -55,25 +55,25 @@ $spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(12);
$helper->log('Add conditional formatting'); $helper->log('Add conditional formatting');
$conditional1 = new Conditional(); $conditional1 = new Conditional();
$conditional1->setConditionType(Conditional::CONDITION_CELLIS) $conditional1->setConditionType(Conditional::CONDITION_CELLIS)
->setOperatorType(Conditional::OPERATOR_BETWEEN) ->setOperatorType(Conditional::OPERATOR_BETWEEN)
->addCondition('200') ->addCondition('200')
->addCondition('400'); ->addCondition('400');
$conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_YELLOW); $conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_YELLOW);
$conditional1->getStyle()->getFont()->setBold(true); $conditional1->getStyle()->getFont()->setBold(true);
$conditional1->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); $conditional1->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
$conditional2 = new Conditional(); $conditional2 = new Conditional();
$conditional2->setConditionType(Conditional::CONDITION_CELLIS) $conditional2->setConditionType(Conditional::CONDITION_CELLIS)
->setOperatorType(Conditional::OPERATOR_LESSTHAN) ->setOperatorType(Conditional::OPERATOR_LESSTHAN)
->addCondition('0'); ->addCondition('0');
$conditional2->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED); $conditional2->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED);
$conditional2->getStyle()->getFont()->setItalic(true); $conditional2->getStyle()->getFont()->setItalic(true);
$conditional2->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); $conditional2->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
$conditional3 = new Conditional(); $conditional3 = new Conditional();
$conditional3->setConditionType(Conditional::CONDITION_CELLIS) $conditional3->setConditionType(Conditional::CONDITION_CELLIS)
->setOperatorType(Conditional::OPERATOR_GREATERTHANOREQUAL) ->setOperatorType(Conditional::OPERATOR_GREATERTHANOREQUAL)
->addCondition('0'); ->addCondition('0');
$conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN); $conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN);
$conditional3->getStyle()->getFont()->setItalic(true); $conditional3->getStyle()->getFont()->setItalic(true);
$conditional3->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); $conditional3->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);

View File

@ -14,44 +14,44 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create a first sheet, representing sales data // Create a first sheet, representing sales data
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A1', '-0.5') ->setCellValue('A1', '-0.5')
->setCellValue('A2', '-0.25') ->setCellValue('A2', '-0.25')
->setCellValue('A3', '0.0') ->setCellValue('A3', '0.0')
->setCellValue('A4', '0.25') ->setCellValue('A4', '0.25')
->setCellValue('A5', '0.5') ->setCellValue('A5', '0.5')
->setCellValue('A6', '0.75') ->setCellValue('A6', '0.75')
->setCellValue('A7', '1.0') ->setCellValue('A7', '1.0')
->setCellValue('A8', '1.25'); ->setCellValue('A8', '1.25');
$spreadsheet->getActiveSheet()->getStyle('A1:A8') $spreadsheet->getActiveSheet()->getStyle('A1:A8')
->getNumberFormat() ->getNumberFormat()
->setFormatCode( ->setFormatCode(
NumberFormat::FORMAT_PERCENTAGE_00 NumberFormat::FORMAT_PERCENTAGE_00
); );
// Add conditional formatting // Add conditional formatting
$helper->log('Add conditional formatting'); $helper->log('Add conditional formatting');
$conditional1 = new Conditional(); $conditional1 = new Conditional();
$conditional1->setConditionType(Conditional::CONDITION_CELLIS) $conditional1->setConditionType(Conditional::CONDITION_CELLIS)
->setOperatorType(Conditional::OPERATOR_LESSTHAN) ->setOperatorType(Conditional::OPERATOR_LESSTHAN)
->addCondition('0'); ->addCondition('0');
$conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED); $conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED);
$conditional3 = new Conditional(); $conditional3 = new Conditional();
$conditional3->setConditionType(Conditional::CONDITION_CELLIS) $conditional3->setConditionType(Conditional::CONDITION_CELLIS)
->setOperatorType(Conditional::OPERATOR_GREATERTHANOREQUAL) ->setOperatorType(Conditional::OPERATOR_GREATERTHANOREQUAL)
->addCondition('1'); ->addCondition('1');
$conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN); $conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN);
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles(); $conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles();

View File

@ -12,21 +12,21 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create a first sheet // Create a first sheet
$helper->log('Add data and page breaks'); $helper->log('Add data and page breaks');
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname') $spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname')
->setCellValue('B1', 'Lastname') ->setCellValue('B1', 'Lastname')
->setCellValue('C1', 'Phone') ->setCellValue('C1', 'Phone')
->setCellValue('D1', 'Fax') ->setCellValue('D1', 'Fax')
->setCellValue('E1', 'Is Client ?'); ->setCellValue('E1', 'Is Client ?');
// Add data // Add data
for ($i = 2; $i <= 50; ++$i) { for ($i = 2; $i <= 50; ++$i) {
@ -49,15 +49,15 @@ $spreadsheet->getActiveSheet()->setTitle('Printing Options');
// Set print headers // Set print headers
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getHeaderFooter()->setOddHeader('&C&24&K0000FF&B&U&A'); ->getHeaderFooter()->setOddHeader('&C&24&K0000FF&B&U&A');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getHeaderFooter()->setEvenHeader('&C&24&K0000FF&B&U&A'); ->getHeaderFooter()->setEvenHeader('&C&24&K0000FF&B&U&A');
// Set print footers // Set print footers
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getHeaderFooter()->setOddFooter('&R&D &T&C&F&LPage &P / &N'); ->getHeaderFooter()->setOddFooter('&R&D &T&C&F&LPage &P / &N');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getHeaderFooter()->setEvenFooter('&L&D &T&C&F&RPage &P / &N'); ->getHeaderFooter()->setEvenFooter('&L&D &T&C&F&RPage &P / &N');
// Save // Save
$helper->write($spreadsheet, __FILE__); $helper->write($spreadsheet, __FILE__);

View File

@ -11,12 +11,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$helper->log('Add some data'); $helper->log('Add some data');

View File

@ -12,12 +12,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Mark Baker') $spreadsheet->getProperties()->setCreator('Mark Baker')
->setLastModifiedBy('Mark Baker') ->setLastModifiedBy('Mark Baker')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$helper->log('Add some data'); $helper->log('Add some data');
@ -38,10 +38,10 @@ $helper->log('Set cell protection');
$helper->log('Set sheet security'); $helper->log('Set sheet security');
$spreadsheet->getActiveSheet()->getProtection()->setSheet(true); $spreadsheet->getActiveSheet()->getProtection()->setSheet(true);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('A2:B2') ->getStyle('A2:B2')
->getProtection()->setLocked( ->getProtection()->setLocked(
Protection::PROTECTION_UNPROTECTED Protection::PROTECTION_UNPROTECTED
); );
// Save // Save
$helper->write($spreadsheet, __FILE__); $helper->write($spreadsheet, __FILE__);

View File

@ -12,9 +12,9 @@ $spreadsheet = new Spreadsheet();
// Add some data, we will use some formulas here // Add some data, we will use some formulas here
$helper->log('Add some data and formulas'); $helper->log('Add some data and formulas');
$spreadsheet->getActiveSheet()->setCellValue('A1', '=B1') $spreadsheet->getActiveSheet()->setCellValue('A1', '=B1')
->setCellValue('A2', '=B2+1') ->setCellValue('A2', '=B2+1')
->setCellValue('B1', '=A1+1') ->setCellValue('B1', '=A1+1')
->setCellValue('B2', '=A2'); ->setCellValue('B2', '=A2');
Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 100; Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 100;

View File

@ -12,28 +12,28 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create a first sheet // Create a first sheet
$helper->log('Add data'); $helper->log('Add data');
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Cell B3 and B5 contain data validation...') $spreadsheet->getActiveSheet()->setCellValue('A1', 'Cell B3 and B5 contain data validation...')
->setCellValue('A3', 'Number:') ->setCellValue('A3', 'Number:')
->setCellValue('B3', '10') ->setCellValue('B3', '10')
->setCellValue('A5', 'List:') ->setCellValue('A5', 'List:')
->setCellValue('B5', 'Item A') ->setCellValue('B5', 'Item A')
->setCellValue('A7', 'List #2:') ->setCellValue('A7', 'List #2:')
->setCellValue('B7', 'Item #2') ->setCellValue('B7', 'Item #2')
->setCellValue('D2', 'Item #1') ->setCellValue('D2', 'Item #1')
->setCellValue('D3', 'Item #2') ->setCellValue('D3', 'Item #2')
->setCellValue('D4', 'Item #3') ->setCellValue('D4', 'Item #3')
->setCellValue('D5', 'Item #4') ->setCellValue('D5', 'Item #4')
->setCellValue('D6', 'Item #5'); ->setCellValue('D6', 'Item #5');
// Set data validation // Set data validation
$helper->log('Set data validation'); $helper->log('Set data validation');

View File

@ -7,8 +7,8 @@ $spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
$helper->log('Write to CSV format'); $helper->log('Write to CSV format');
$writer = IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',') $writer = IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',')
->setEnclosure('"') ->setEnclosure('"')
->setSheetIndex(0); ->setSheetIndex(0);
$callStartTime = microtime(true); $callStartTime = microtime(true);
$filename = $helper->getTemporaryFilename('csv'); $filename = $helper->getTemporaryFilename('csv');
@ -18,8 +18,8 @@ $helper->logWrite($writer, $filename, $callStartTime);
$helper->log('Read from CSV format'); $helper->log('Read from CSV format');
$reader = IOFactory::createReader('Csv')->setDelimiter(',') $reader = IOFactory::createReader('Csv')->setDelimiter(',')
->setEnclosure('"') ->setEnclosure('"')
->setSheetIndex(0); ->setSheetIndex(0);
$callStartTime = microtime(true); $callStartTime = microtime(true);
$spreadsheetFromCSV = $reader->load($filename); $spreadsheetFromCSV = $reader->load($filename);

View File

@ -12,22 +12,22 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname:') $spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname:')
->setCellValue('A2', 'Lastname:') ->setCellValue('A2', 'Lastname:')
->setCellValue('A3', 'Fullname:') ->setCellValue('A3', 'Fullname:')
->setCellValue('B1', 'Maarten') ->setCellValue('B1', 'Maarten')
->setCellValue('B2', 'Balliauw') ->setCellValue('B2', 'Balliauw')
->setCellValue('B3', '=B1 & " " & B2'); ->setCellValue('B3', '=B1 & " " & B2');
// Define named ranges // Define named ranges
$helper->log('Define named ranges'); $helper->log('Define named ranges');
@ -50,11 +50,11 @@ $spreadsheet->createSheet();
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->setActiveSheetIndex(1); $spreadsheet->setActiveSheetIndex(1);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname:') $spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname:')
->setCellValue('A2', 'Lastname:') ->setCellValue('A2', 'Lastname:')
->setCellValue('A3', 'Fullname:') ->setCellValue('A3', 'Fullname:')
->setCellValue('B1', '=PersonFN') ->setCellValue('B1', '=PersonFN')
->setCellValue('B2', '=PersonLN') ->setCellValue('B2', '=PersonLN')
->setCellValue('B3', '=PersonFN & " " & PersonLN'); ->setCellValue('B3', '=PersonFN & " " & PersonLN');
// Resolve range // Resolve range
$helper->log('Resolve range'); $helper->log('Resolve range');

View File

@ -13,12 +13,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$helper->log('Add some data'); $helper->log('Add some data');

View File

@ -14,12 +14,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$helper->log('Add some data'); $helper->log('Add some data');

View File

@ -12,12 +12,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Generate an image // Generate an image
$helper->log('Generate an image'); $helper->log('Generate an image');

View File

@ -21,12 +21,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Set default font // Set default font
$helper->log('Set default font'); $helper->log('Set default font');
@ -41,88 +41,88 @@ $spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(14);
// Add some data, resembling some different data types // Add some data, resembling some different data types
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->getActiveSheet()->setCellValue('A1', 'String value:') $spreadsheet->getActiveSheet()->setCellValue('A1', 'String value:')
->setCellValue('B1', 'Mark Baker'); ->setCellValue('B1', 'Mark Baker');
$spreadsheet->getActiveSheet()->setCellValue('A2', 'Numeric value #1:') $spreadsheet->getActiveSheet()->setCellValue('A2', 'Numeric value #1:')
->setCellValue('B2', 12345); ->setCellValue('B2', 12345);
$spreadsheet->getActiveSheet()->setCellValue('A3', 'Numeric value #2:') $spreadsheet->getActiveSheet()->setCellValue('A3', 'Numeric value #2:')
->setCellValue('B3', -12.345); ->setCellValue('B3', -12.345);
$spreadsheet->getActiveSheet()->setCellValue('A4', 'Numeric value #3:') $spreadsheet->getActiveSheet()->setCellValue('A4', 'Numeric value #3:')
->setCellValue('B4', .12345); ->setCellValue('B4', .12345);
$spreadsheet->getActiveSheet()->setCellValue('A5', 'Numeric value #4:') $spreadsheet->getActiveSheet()->setCellValue('A5', 'Numeric value #4:')
->setCellValue('B5', '12345'); ->setCellValue('B5', '12345');
$spreadsheet->getActiveSheet()->setCellValue('A6', 'Numeric value #5:') $spreadsheet->getActiveSheet()->setCellValue('A6', 'Numeric value #5:')
->setCellValue('B6', '1.2345'); ->setCellValue('B6', '1.2345');
$spreadsheet->getActiveSheet()->setCellValue('A7', 'Numeric value #6:') $spreadsheet->getActiveSheet()->setCellValue('A7', 'Numeric value #6:')
->setCellValue('B7', '.12345'); ->setCellValue('B7', '.12345');
$spreadsheet->getActiveSheet()->setCellValue('A8', 'Numeric value #7:') $spreadsheet->getActiveSheet()->setCellValue('A8', 'Numeric value #7:')
->setCellValue('B8', '1.234e-5'); ->setCellValue('B8', '1.234e-5');
$spreadsheet->getActiveSheet()->setCellValue('A9', 'Numeric value #8:') $spreadsheet->getActiveSheet()->setCellValue('A9', 'Numeric value #8:')
->setCellValue('B9', '-1.234e+5'); ->setCellValue('B9', '-1.234e+5');
$spreadsheet->getActiveSheet()->setCellValue('A10', 'Boolean value:') $spreadsheet->getActiveSheet()->setCellValue('A10', 'Boolean value:')
->setCellValue('B10', 'TRUE'); ->setCellValue('B10', 'TRUE');
$spreadsheet->getActiveSheet()->setCellValue('A11', 'Percentage value #1:') $spreadsheet->getActiveSheet()->setCellValue('A11', 'Percentage value #1:')
->setCellValue('B11', '10%'); ->setCellValue('B11', '10%');
$spreadsheet->getActiveSheet()->setCellValue('A12', 'Percentage value #2:') $spreadsheet->getActiveSheet()->setCellValue('A12', 'Percentage value #2:')
->setCellValue('B12', '12.5%'); ->setCellValue('B12', '12.5%');
$spreadsheet->getActiveSheet()->setCellValue('A13', 'Fraction value #1:') $spreadsheet->getActiveSheet()->setCellValue('A13', 'Fraction value #1:')
->setCellValue('B13', '-1/2'); ->setCellValue('B13', '-1/2');
$spreadsheet->getActiveSheet()->setCellValue('A14', 'Fraction value #2:') $spreadsheet->getActiveSheet()->setCellValue('A14', 'Fraction value #2:')
->setCellValue('B14', '3 1/2'); ->setCellValue('B14', '3 1/2');
$spreadsheet->getActiveSheet()->setCellValue('A15', 'Fraction value #3:') $spreadsheet->getActiveSheet()->setCellValue('A15', 'Fraction value #3:')
->setCellValue('B15', '-12 3/4'); ->setCellValue('B15', '-12 3/4');
$spreadsheet->getActiveSheet()->setCellValue('A16', 'Fraction value #4:') $spreadsheet->getActiveSheet()->setCellValue('A16', 'Fraction value #4:')
->setCellValue('B16', '13/4'); ->setCellValue('B16', '13/4');
$spreadsheet->getActiveSheet()->setCellValue('A17', 'Currency value #1:') $spreadsheet->getActiveSheet()->setCellValue('A17', 'Currency value #1:')
->setCellValue('B17', '$12345'); ->setCellValue('B17', '$12345');
$spreadsheet->getActiveSheet()->setCellValue('A18', 'Currency value #2:') $spreadsheet->getActiveSheet()->setCellValue('A18', 'Currency value #2:')
->setCellValue('B18', '$12345.67'); ->setCellValue('B18', '$12345.67');
$spreadsheet->getActiveSheet()->setCellValue('A19', 'Currency value #3:') $spreadsheet->getActiveSheet()->setCellValue('A19', 'Currency value #3:')
->setCellValue('B19', '$12,345.67'); ->setCellValue('B19', '$12,345.67');
$spreadsheet->getActiveSheet()->setCellValue('A20', 'Date value #1:') $spreadsheet->getActiveSheet()->setCellValue('A20', 'Date value #1:')
->setCellValue('B20', '21 December 1983'); ->setCellValue('B20', '21 December 1983');
$spreadsheet->getActiveSheet()->setCellValue('A21', 'Date value #2:') $spreadsheet->getActiveSheet()->setCellValue('A21', 'Date value #2:')
->setCellValue('B21', '19-Dec-1960'); ->setCellValue('B21', '19-Dec-1960');
$spreadsheet->getActiveSheet()->setCellValue('A22', 'Date value #3:') $spreadsheet->getActiveSheet()->setCellValue('A22', 'Date value #3:')
->setCellValue('B22', '07/12/1982'); ->setCellValue('B22', '07/12/1982');
$spreadsheet->getActiveSheet()->setCellValue('A23', 'Date value #4:') $spreadsheet->getActiveSheet()->setCellValue('A23', 'Date value #4:')
->setCellValue('B23', '24-11-1950'); ->setCellValue('B23', '24-11-1950');
$spreadsheet->getActiveSheet()->setCellValue('A24', 'Date value #5:') $spreadsheet->getActiveSheet()->setCellValue('A24', 'Date value #5:')
->setCellValue('B24', '17-Mar'); ->setCellValue('B24', '17-Mar');
$spreadsheet->getActiveSheet()->setCellValue('A25', 'Time value #1:') $spreadsheet->getActiveSheet()->setCellValue('A25', 'Time value #1:')
->setCellValue('B25', '01:30'); ->setCellValue('B25', '01:30');
$spreadsheet->getActiveSheet()->setCellValue('A26', 'Time value #2:') $spreadsheet->getActiveSheet()->setCellValue('A26', 'Time value #2:')
->setCellValue('B26', '01:30:15'); ->setCellValue('B26', '01:30:15');
$spreadsheet->getActiveSheet()->setCellValue('A27', 'Date/Time value:') $spreadsheet->getActiveSheet()->setCellValue('A27', 'Date/Time value:')
->setCellValue('B27', '19-Dec-1960 01:30'); ->setCellValue('B27', '19-Dec-1960 01:30');
$spreadsheet->getActiveSheet()->setCellValue('A28', 'Formula:') $spreadsheet->getActiveSheet()->setCellValue('A28', 'Formula:')
->setCellValue('B28', '=SUM(B2:B9)'); ->setCellValue('B28', '=SUM(B2:B9)');
// Rename worksheet // Rename worksheet
$helper->log('Rename worksheet'); $helper->log('Rename worksheet');

View File

@ -32,10 +32,10 @@ foreach ($data as $r => $dataRow) {
$spreadsheet->getActiveSheet()->insertNewRowBefore($row, 1); $spreadsheet->getActiveSheet()->insertNewRowBefore($row, 1);
$spreadsheet->getActiveSheet()->setCellValue('A' . $row, $r + 1) $spreadsheet->getActiveSheet()->setCellValue('A' . $row, $r + 1)
->setCellValue('B' . $row, $dataRow['title']) ->setCellValue('B' . $row, $dataRow['title'])
->setCellValue('C' . $row, $dataRow['price']) ->setCellValue('C' . $row, $dataRow['price'])
->setCellValue('D' . $row, $dataRow['quantity']) ->setCellValue('D' . $row, $dataRow['quantity'])
->setCellValue('E' . $row, '=C' . $row . '*D' . $row); ->setCellValue('E' . $row, '=C' . $row . '*D' . $row);
} }
$spreadsheet->getActiveSheet()->removeRow($baseRow - 1, 1); $spreadsheet->getActiveSheet()->removeRow($baseRow - 1, 1);

View File

@ -15,9 +15,9 @@ $helper->logRead($inputFileType, $inputFileName, $callStartTime);
$helper->log('Adjust properties'); $helper->log('Adjust properties');
$spreadsheet->getProperties()->setTitle('Office 2007 XLSX Test Document') $spreadsheet->getProperties()->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test XLSX document, generated using PhpSpreadsheet') ->setDescription('Test XLSX document, generated using PhpSpreadsheet')
->setKeywords('office 2007 openxml php'); ->setKeywords('office 2007 openxml php');
// Save Excel 2007 file // Save Excel 2007 file
$filename = $helper->getFilename(__FILE__); $filename = $helper->getFilename(__FILE__);

View File

@ -15,9 +15,9 @@ $helper->logRead($inputFileType, $inputFileName, $callStartTime);
$helper->log('Adjust properties'); $helper->log('Adjust properties');
$spreadsheet->getProperties()->setTitle('Office 95 XLS Test Document') $spreadsheet->getProperties()->setTitle('Office 95 XLS Test Document')
->setSubject('Office 95 XLS Test Document') ->setSubject('Office 95 XLS Test Document')
->setDescription('Test XLS document, generated using PhpSpreadsheet') ->setDescription('Test XLS document, generated using PhpSpreadsheet')
->setKeywords('office 95 biff php'); ->setKeywords('office 95 biff php');
// Save Excel 95 file // Save Excel 95 file
$filename = $helper->getFilename(__FILE__, 'xls'); $filename = $helper->getFilename(__FILE__, 'xls');

View File

@ -12,18 +12,18 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('PHPOffice') $spreadsheet->getProperties()->setCreator('PHPOffice')
->setLastModifiedBy('PHPOffice') ->setLastModifiedBy('PHPOffice')
->setTitle('PhpSpreadsheet Test Document') ->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('Office PhpSpreadsheet php') ->setKeywords('Office PhpSpreadsheet php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello') ->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!'); ->setCellValue('B2', 'world!');
// Set the page layout view as page layout // Set the page layout view as page layout
$spreadsheet->getActiveSheet()->getSheetView()->setView(SheetView::SHEETVIEW_PAGE_LAYOUT); $spreadsheet->getActiveSheet()->getSheetView()->setView(SheetView::SHEETVIEW_PAGE_LAYOUT);

View File

@ -11,25 +11,25 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('PhpSpreadsheet Test Document') ->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('office PhpSpreadsheet php') ->setKeywords('office PhpSpreadsheet php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$helper->log('Add some data'); $helper->log('Add some data');
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello') ->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!') ->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello') ->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!'); ->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8 // Miscellaneous glyphs, UTF-8
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs') ->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
$spreadsheet->getActiveSheet()->setCellValue('A8', "Hello\nWorld"); $spreadsheet->getActiveSheet()->setCellValue('A8', "Hello\nWorld");
$spreadsheet->getActiveSheet()->getRowDimension(8)->setRowHeight(-1); $spreadsheet->getActiveSheet()->getRowDimension(8)->setRowHeight(-1);
@ -43,10 +43,10 @@ $spreadsheet->getActiveSheet()->setTitle('Simple');
$helper->log('Clone worksheet'); $helper->log('Clone worksheet');
$clonedSheet = clone $spreadsheet->getActiveSheet(); $clonedSheet = clone $spreadsheet->getActiveSheet();
$clonedSheet $clonedSheet
->setCellValue('A1', 'Goodbye') ->setCellValue('A1', 'Goodbye')
->setCellValue('A2', 'cruel') ->setCellValue('A2', 'cruel')
->setCellValue('C1', 'Goodbye') ->setCellValue('C1', 'Goodbye')
->setCellValue('C2', 'cruel'); ->setCellValue('C2', 'cruel');
// Rename cloned worksheet // Rename cloned worksheet
$helper->log('Rename cloned worksheet'); $helper->log('Rename cloned worksheet');

View File

@ -13,13 +13,13 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties() $spreadsheet->getProperties()
->setCreator('PHPOffice') ->setCreator('PHPOffice')
->setLastModifiedBy('PHPOffice') ->setLastModifiedBy('PHPOffice')
->setTitle('PhpSpreadsheet Test Document') ->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('Office PhpSpreadsheet php') ->setKeywords('Office PhpSpreadsheet php')
->setCategory('Test result file'); ->setCategory('Test result file');
function transpose($value) function transpose($value)
{ {
return [$value]; return [$value];
@ -41,7 +41,7 @@ foreach ($continents as $key => $filename) {
// Transpose $countries from a row to a column array // Transpose $countries from a row to a column array
$countries = array_map('transpose', $countries); $countries = array_map('transpose', $countries);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->fromArray($countries, null, $column . '1'); ->fromArray($countries, null, $column . '1');
$spreadsheet->addNamedRange( $spreadsheet->addNamedRange(
new NamedRange( new NamedRange(
$continent, $continent,
@ -50,19 +50,19 @@ foreach ($continents as $key => $filename) {
) )
); );
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getColumnDimension($column) ->getColumnDimension($column)
->setVisible(false); ->setVisible(false);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue($continentColumn . ($key + 1), $continent); ->setCellValue($continentColumn . ($key + 1), $continent);
++$column; ++$column;
} }
// Hide the dropdown data // Hide the dropdown data
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getColumnDimension($continentColumn) ->getColumnDimension($continentColumn)
->setVisible(false); ->setVisible(false);
$spreadsheet->addNamedRange( $spreadsheet->addNamedRange(
new NamedRange( new NamedRange(
@ -74,53 +74,53 @@ $spreadsheet->addNamedRange(
// Set selection cells // Set selection cells
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A1', 'Continent:'); ->setCellValue('A1', 'Continent:');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('B1', 'Select continent'); ->setCellValue('B1', 'Select continent');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('B3', '=' . $column . 1); ->setCellValue('B3', '=' . $column . 1);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('B3', 'Select country'); ->setCellValue('B3', 'Select country');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('A1:A3') ->getStyle('A1:A3')
->getFont()->setBold(true); ->getFont()->setBold(true);
// Set linked validators // Set linked validators
$validation = $spreadsheet->getActiveSheet() $validation = $spreadsheet->getActiveSheet()
->getCell('B1') ->getCell('B1')
->getDataValidation(); ->getDataValidation();
$validation->setType(DataValidation::TYPE_LIST) $validation->setType(DataValidation::TYPE_LIST)
->setErrorStyle(DataValidation::STYLE_INFORMATION) ->setErrorStyle(DataValidation::STYLE_INFORMATION)
->setAllowBlank(false) ->setAllowBlank(false)
->setShowInputMessage(true) ->setShowInputMessage(true)
->setShowErrorMessage(true) ->setShowErrorMessage(true)
->setShowDropDown(true) ->setShowDropDown(true)
->setErrorTitle('Input error') ->setErrorTitle('Input error')
->setError('Continent is not in the list.') ->setError('Continent is not in the list.')
->setPromptTitle('Pick from the list') ->setPromptTitle('Pick from the list')
->setPrompt('Please pick a continent from the drop-down list.') ->setPrompt('Please pick a continent from the drop-down list.')
->setFormula1('=Continents'); ->setFormula1('=Continents');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A3', 'Country:'); ->setCellValue('A3', 'Country:');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('A3') ->getStyle('A3')
->getFont()->setBold(true); ->getFont()->setBold(true);
$validation = $spreadsheet->getActiveSheet() $validation = $spreadsheet->getActiveSheet()
->getCell('B3') ->getCell('B3')
->getDataValidation(); ->getDataValidation();
$validation->setType(DataValidation::TYPE_LIST) $validation->setType(DataValidation::TYPE_LIST)
->setErrorStyle(DataValidation::STYLE_INFORMATION) ->setErrorStyle(DataValidation::STYLE_INFORMATION)
->setAllowBlank(false) ->setAllowBlank(false)
->setShowInputMessage(true) ->setShowInputMessage(true)
->setShowErrorMessage(true) ->setShowErrorMessage(true)
->setShowDropDown(true) ->setShowDropDown(true)
->setErrorTitle('Input error') ->setErrorTitle('Input error')
->setError('Country is not in the list.') ->setError('Country is not in the list.')
->setPromptTitle('Pick from the list') ->setPromptTitle('Pick from the list')
->setPrompt('Please pick a country from the drop-down list.') ->setPrompt('Please pick a country from the drop-down list.')
->setFormula1('=INDIRECT($B$1)'); ->setFormula1('=INDIRECT($B$1)');
$spreadsheet->getActiveSheet()->getColumnDimension('A')->setWidth(12); $spreadsheet->getActiveSheet()->getColumnDimension('A')->setWidth(12);
$spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(30); $spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(30);

View File

@ -12,12 +12,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('PhpSpreadsheet Test Document') ->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('office PhpSpreadsheet php') ->setKeywords('office PhpSpreadsheet php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Add some data // Add some data
$helper->log('Add some data'); $helper->log('Add some data');
@ -55,44 +55,44 @@ $wizard = new HtmlHelper();
$richText = $wizard->toRichTextObject($html1); $richText = $wizard->toRichTextObject($html1);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A1', $richText); ->setCellValue('A1', $richText);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getColumnDimension('A') ->getColumnDimension('A')
->setWidth(48); ->setWidth(48);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getRowDimension(1) ->getRowDimension(1)
->setRowHeight(-1); ->setRowHeight(-1);
$spreadsheet->getActiveSheet()->getStyle('A1') $spreadsheet->getActiveSheet()->getStyle('A1')
->getAlignment() ->getAlignment()
->setWrapText(true); ->setWrapText(true);
$richText = $wizard->toRichTextObject($html2); $richText = $wizard->toRichTextObject($html2);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setCellValue('A2', $richText); ->setCellValue('A2', $richText);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getRowDimension(1) ->getRowDimension(1)
->setRowHeight(-1); ->setRowHeight(-1);
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->getStyle('A2') ->getStyle('A2')
->getAlignment() ->getAlignment()
->setWrapText(true); ->setWrapText(true);
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A3', $wizard->toRichTextObject($html3)); ->setCellValue('A3', $wizard->toRichTextObject($html3));
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A4', $wizard->toRichTextObject($html4)); ->setCellValue('A4', $wizard->toRichTextObject($html4));
$spreadsheet->setActiveSheetIndex(0) $spreadsheet->setActiveSheetIndex(0)
->setCellValue('A5', $wizard->toRichTextObject($html5)); ->setCellValue('A5', $wizard->toRichTextObject($html5));
// Rename worksheet // Rename worksheet
$helper->log('Rename worksheet'); $helper->log('Rename worksheet');
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
->setTitle('Rich Text Examples'); ->setTitle('Rich Text Examples');
// Save // Save
$helper->write($spreadsheet, __FILE__); $helper->write($spreadsheet, __FILE__);

View File

@ -14,7 +14,9 @@ $sheetname = 'Data Sheet #3';
class MyReadFilter implements IReadFilter class MyReadFilter implements IReadFilter
{ {
private $startRow = 0; private $startRow = 0;
private $endRow = 0; private $endRow = 0;
private $columns = []; private $columns = [];
public function __construct($startRow, $endRow, $columns) public function __construct($startRow, $endRow, $columns)

View File

@ -14,6 +14,7 @@ $inputFileName = __DIR__ . '/sampleData/example2.xls';
class ChunkReadFilter implements IReadFilter class ChunkReadFilter implements IReadFilter
{ {
private $startRow = 0; private $startRow = 0;
private $endRow = 0; private $endRow = 0;
/** /**

View File

@ -14,6 +14,7 @@ $inputFileName = __DIR__ . '/sampleData/example2.xls';
class ChunkReadFilter implements IReadFilter class ChunkReadFilter implements IReadFilter
{ {
private $startRow = 0; private $startRow = 0;
private $endRow = 0; private $endRow = 0;
/** /**

View File

@ -15,6 +15,7 @@ $inputFileName = __DIR__ . '/sampleData/example2.csv';
class ChunkReadFilter implements IReadFilter class ChunkReadFilter implements IReadFilter
{ {
private $startRow = 0; private $startRow = 0;
private $endRow = 0; private $endRow = 0;
/** /**

View File

@ -9,12 +9,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set properties'); $helper->log('Set properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create a first sheet // Create a first sheet
$helper->log('Add data'); $helper->log('Add data');
@ -33,8 +33,8 @@ $spreadsheet->getActiveSheet()->getColumnDimension('D')->setVisible(false);
// Set outline levels // Set outline levels
$helper->log('Set outline levels'); $helper->log('Set outline levels');
$spreadsheet->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) $spreadsheet->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
->setVisible(false) ->setVisible(false)
->setCollapsed(true); ->setCollapsed(true);
// Freeze panes // Freeze panes
$helper->log('Freeze panes'); $helper->log('Freeze panes');
@ -47,10 +47,10 @@ $spreadsheet->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEn
// Add data // Add data
for ($i = 2; $i <= 5000; ++$i) { for ($i = 2; $i <= 5000; ++$i) {
$spreadsheet->getActiveSheet()->setCellValue('A' . $i, "FName $i") $spreadsheet->getActiveSheet()->setCellValue('A' . $i, "FName $i")
->setCellValue('B' . $i, "LName $i") ->setCellValue('B' . $i, "LName $i")
->setCellValue('C' . $i, "PhoneNo $i") ->setCellValue('C' . $i, "PhoneNo $i")
->setCellValue('D' . $i, "FaxNo $i") ->setCellValue('D' . $i, "FaxNo $i")
->setCellValue('E' . $i, true); ->setCellValue('E' . $i, true);
} }
return $spreadsheet; return $spreadsheet;

View File

@ -20,12 +20,12 @@ $spreadsheet = new Spreadsheet();
// Set document properties // Set document properties
$helper->log('Set document properties'); $helper->log('Set document properties');
$spreadsheet->getProperties()->setCreator('Maarten Balliauw') $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw')
->setTitle('Office 2007 XLSX Test Document') ->setTitle('Office 2007 XLSX Test Document')
->setSubject('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document')
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
->setKeywords('office 2007 openxml php') ->setKeywords('office 2007 openxml php')
->setCategory('Test result file'); ->setCategory('Test result file');
// Create a first sheet, representing sales data // Create a first sheet, representing sales data
$helper->log('Add some data'); $helper->log('Add some data');

View File

@ -171,6 +171,7 @@ class Calculation
* @var string * @var string
*/ */
private static $localeArgumentSeparator = ','; private static $localeArgumentSeparator = ',';
private static $localeFunctions = []; private static $localeFunctions = [];
/** /**
@ -2355,6 +2356,7 @@ class Calculation
} }
private static $functionReplaceFromExcel = null; private static $functionReplaceFromExcel = null;
private static $functionReplaceToLocale = null; private static $functionReplaceToLocale = null;
public function _translateFormulaToLocale($formula) public function _translateFormulaToLocale($formula)
@ -2383,6 +2385,7 @@ class Calculation
} }
private static $functionReplaceFromLocale = null; private static $functionReplaceFromLocale = null;
private static $functionReplaceToExcel = null; private static $functionReplaceToExcel = null;
public function _translateFormulaToEnglish($formula) public function _translateFormulaToEnglish($formula)
@ -2443,7 +2446,7 @@ class Calculation
} }
// Return strings wrapped in quotes // Return strings wrapped in quotes
return '"' . $value . '"'; return '"' . $value . '"';
// Convert numeric errors to NaN error // Convert numeric errors to NaN error
} elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { } elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
return Functions::NAN(); return Functions::NAN();
} }
@ -3678,7 +3681,7 @@ class Calculation
} }
$stack->push('Value', $cellValue, $cellRef); $stack->push('Value', $cellValue, $cellRef);
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $token, $matches)) { } elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $token, $matches)) {
$functionName = $matches[1]; $functionName = $matches[1];
$argCount = $stack->pop(); $argCount = $stack->pop();
@ -3763,7 +3766,7 @@ class Calculation
$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)) {
$namedRange = $matches[6]; $namedRange = $matches[6];
$this->debugLog->writeDebugLog('Evaluating Named Range ', $namedRange); $this->debugLog->writeDebugLog('Evaluating Named Range ', $namedRange);

View File

@ -1843,7 +1843,7 @@ class Financial
* If you omit guess, it is assumed to be 10 percent. * If you omit guess, it is assumed to be 10 percent.
* *
* @return float * @return float
**/ */
public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1) public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1)
{ {
$nper = (int) Functions::flattenSingleValue($nper); $nper = (int) Functions::flattenSingleValue($nper);

View File

@ -224,7 +224,7 @@ 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}(\.\d+)?E{1}$/", $this->formula[$index]) != 0) { if (preg_match('/^[1-9]{1}(\\.\\d+)?E{1}$/', $this->formula[$index]) != 0) {
$value .= $this->formula[$index]; $value .= $this->formula[$index];
++$index; ++$index;

View File

@ -533,7 +533,7 @@ class Functions
// Range of cells is an error // Range of cells is an error
if (self::isCellValue($a)) { if (self::isCellValue($a)) {
return 16; return 16;
// Test for Matrix // Test for Matrix
} elseif (self::isMatrixValue($a)) { } elseif (self::isMatrixValue($a)) {
return 64; return 64;
} }

View File

@ -73,7 +73,9 @@ class Statistical
// Function cache for logBeta function // Function cache for logBeta function
private static $logBetaCacheP = 0.0; private static $logBetaCacheP = 0.0;
private static $logBetaCacheQ = 0.0; private static $logBetaCacheQ = 0.0;
private static $logBetaCacheResult = 0.0; private static $logBetaCacheResult = 0.0;
/** /**
@ -207,6 +209,7 @@ class Statistical
// Function cache for logGamma // Function cache for logGamma
private static $logGammaCacheResult = 0.0; private static $logGammaCacheResult = 0.0;
private static $logGammaCacheX = 0.0; private static $logGammaCacheX = 0.0;
private static function logGamma($x) private static function logGamma($x)
@ -431,14 +434,14 @@ class Statistical
return exp(0 - $tmp + log(self::SQRT2PI * $summer / $x)); return exp(0 - $tmp + log(self::SQRT2PI * $summer / $x));
} }
/*************************************************************************** /*
* inverse_ncdf.php * inverse_ncdf.php
* ------------------- * -------------------
* begin : Friday, January 16, 2004 * begin : Friday, January 16, 2004
* copyright : (C) 2004 Michael Nickerson * copyright : (C) 2004 Michael Nickerson
* email : nickersonm@yahoo.com * email : nickersonm@yahoo.com
* *
***************************************************************************/ */
private static function inverseNcdf($p) private static function inverseNcdf($p)
{ {
// Inverse ncdf approximation by Peter J. Acklam, implementation adapted to // Inverse ncdf approximation by Peter J. Acklam, implementation adapted to

View File

@ -234,6 +234,7 @@ class Cell
break; break;
default: default:
throw new Exception('Invalid datatype: ' . $pDataType); throw new Exception('Invalid datatype: ' . $pDataType);
break; break;
} }
@ -587,7 +588,7 @@ class Cell
* *
* @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(self $a, self $b)
{ {
if ($a->getRow() < $b->getRow()) { if ($a->getRow() < $b->getRow()) {
return -1; return -1;

View File

@ -30,7 +30,7 @@ abstract class Coordinate
*/ */
public static function coordinateFromString($pCoordinateString) public static function coordinateFromString($pCoordinateString)
{ {
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) { if (preg_match('/^([$]?[A-Z]{1,3})([$]?\\d{1,7})$/', $pCoordinateString, $matches)) {
return [$matches[1], $matches[2]]; return [$matches[1], $matches[2]];
} elseif (self::coordinateIsRange($pCoordinateString)) { } elseif (self::coordinateIsRange($pCoordinateString)) {
throw new Exception('Cell coordinate string can not be a range of cells'); throw new Exception('Cell coordinate string can not be a range of cells');

View File

@ -197,9 +197,9 @@ class GridLines extends Properties
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null)
{ {
$this $this
->activateObject() ->activateObject()
->setGlowSize($size) ->setGlowSize($size)
->setGlowColor($color_value, $color_alpha, $color_type); ->setGlowColor($color_value, $color_alpha, $color_type);
} }
/** /**

View File

@ -503,9 +503,11 @@ class Properties
switch ($propertyType) { switch ($propertyType) {
case 'empty': // Empty case 'empty': // Empty
return ''; return '';
break; break;
case 'null': // Null case 'null': // Null
return null; return null;
break; break;
case 'i1': // 1-Byte Signed Integer case 'i1': // 1-Byte Signed Integer
case 'i2': // 2-Byte Signed Integer case 'i2': // 2-Byte Signed Integer
@ -513,6 +515,7 @@ class Properties
case 'i8': // 8-Byte Signed Integer case 'i8': // 8-Byte Signed Integer
case 'int': // Integer case 'int': // Integer
return (int) $propertyValue; return (int) $propertyValue;
break; break;
case 'ui1': // 1-Byte Unsigned Integer case 'ui1': // 1-Byte Unsigned Integer
case 'ui2': // 2-Byte Unsigned Integer case 'ui2': // 2-Byte Unsigned Integer
@ -520,23 +523,28 @@ class Properties
case 'ui8': // 8-Byte Unsigned Integer case 'ui8': // 8-Byte Unsigned Integer
case 'uint': // Unsigned Integer case 'uint': // Unsigned Integer
return abs((int) $propertyValue); return abs((int) $propertyValue);
break; break;
case 'r4': // 4-Byte Real Number case 'r4': // 4-Byte Real Number
case 'r8': // 8-Byte Real Number case 'r8': // 8-Byte Real Number
case 'decimal': // Decimal case 'decimal': // Decimal
return (float) $propertyValue; return (float) $propertyValue;
break; break;
case 'lpstr': // LPSTR case 'lpstr': // LPSTR
case 'lpwstr': // LPWSTR case 'lpwstr': // LPWSTR
case 'bstr': // Basic String case 'bstr': // Basic String
return $propertyValue; return $propertyValue;
break; break;
case 'date': // Date and Time case 'date': // Date and Time
case 'filetime': // File Time case 'filetime': // File Time
return strtotime($propertyValue); return strtotime($propertyValue);
break; break;
case 'bool': // Boolean case 'bool': // Boolean
return ($propertyValue == 'true') ? true : false; return ($propertyValue == 'true') ? true : false;
break; break;
case 'cy': // Currency case 'cy': // Currency
case 'error': // Error Status Code case 'error': // Error Status Code
@ -552,6 +560,7 @@ class Properties
case 'clsid': // Class ID case 'clsid': // Class ID
case 'cf': // Clipboard Data case 'cf': // Clipboard Data
return $propertyValue; return $propertyValue;
break; break;
} }
@ -572,11 +581,13 @@ class Properties
case 'ui8': // 8-Byte Unsigned Integer case 'ui8': // 8-Byte Unsigned Integer
case 'uint': // Unsigned Integer case 'uint': // Unsigned Integer
return self::PROPERTY_TYPE_INTEGER; return self::PROPERTY_TYPE_INTEGER;
break; break;
case 'r4': // 4-Byte Real Number case 'r4': // 4-Byte Real Number
case 'r8': // 8-Byte Real Number case 'r8': // 8-Byte Real Number
case 'decimal': // Decimal case 'decimal': // Decimal
return self::PROPERTY_TYPE_FLOAT; return self::PROPERTY_TYPE_FLOAT;
break; break;
case 'empty': // Empty case 'empty': // Empty
case 'null': // Null case 'null': // Null
@ -584,13 +595,16 @@ class Properties
case 'lpwstr': // LPWSTR case 'lpwstr': // LPWSTR
case 'bstr': // Basic String case 'bstr': // Basic String
return self::PROPERTY_TYPE_STRING; return self::PROPERTY_TYPE_STRING;
break; break;
case 'date': // Date and Time case 'date': // Date and Time
case 'filetime': // File Time case 'filetime': // File Time
return self::PROPERTY_TYPE_DATE; return self::PROPERTY_TYPE_DATE;
break; break;
case 'bool': // Boolean case 'bool': // Boolean
return self::PROPERTY_TYPE_BOOLEAN; return self::PROPERTY_TYPE_BOOLEAN;
break; break;
case 'cy': // Currency case 'cy': // Currency
case 'error': // Error Status Code case 'error': // Error Status Code
@ -606,6 +620,7 @@ class Properties
case 'clsid': // Class ID case 'clsid': // Class ID
case 'cf': // Clipboard Data case 'cf': // Clipboard Data
return self::PROPERTY_TYPE_UNKNOWN; return self::PROPERTY_TYPE_UNKNOWN;
break; break;
} }

View File

@ -533,14 +533,21 @@ class Html
]; ];
protected $face; protected $face;
protected $size; protected $size;
protected $color; protected $color;
protected $bold = false; protected $bold = false;
protected $italic = false; protected $italic = false;
protected $underline = false; protected $underline = false;
protected $superscript = false; protected $superscript = false;
protected $subscript = false; protected $subscript = false;
protected $strikethrough = false; protected $strikethrough = false;
protected $startTagCallbacks = [ protected $startTagCallbacks = [

View File

@ -219,7 +219,9 @@ class Html extends BaseReader
// Data Array used for testing only, should write to Spreadsheet object on completion of tests // Data Array used for testing only, should write to Spreadsheet object on completion of tests
protected $dataArray = []; protected $dataArray = [];
protected $tableLevel = 0; protected $tableLevel = 0;
protected $nestedColumn = ['A']; protected $nestedColumn = ['A'];
protected function setTableStartColumn($column) protected function setTableStartColumn($column)

View File

@ -660,7 +660,7 @@ class Ods extends BaseReader
$rID = $rowID + $rowAdjust; $rID = $rowID + $rowAdjust;
$cell = $spreadsheet->getActiveSheet() $cell = $spreadsheet->getActiveSheet()
->getCell($columnID . $rID); ->getCell($columnID . $rID);
// Set value // Set value
if ($hasCalculatedValue) { if ($hasCalculatedValue) {

View File

@ -286,7 +286,7 @@ class Slk extends BaseReader
} }
} }
$this->formats['P' . $this->format++] = $formatArray; $this->formats['P' . $this->format++] = $formatArray;
// Read cell value data // Read cell value data
} elseif ($dataType == 'C') { } elseif ($dataType == 'C') {
$hasCalculatedValue = false; $hasCalculatedValue = false;
$cellData = $cellDataFormula = ''; $cellData = $cellDataFormula = '';

View File

@ -2963,7 +2963,7 @@ class Xls extends BaseReader
* *
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
**/ */
private function readSst() private function readSst()
{ {
// offset within (spliced) record data // offset within (spliced) record data
@ -5035,6 +5035,7 @@ class Xls extends BaseReader
case 0x28: case 0x28:
// TODO: Investigate structure for .xls SHEETLAYOUT record as saved by MS Office Excel 2007 // TODO: Investigate structure for .xls SHEETLAYOUT record as saved by MS Office Excel 2007
return; return;
break; break;
} }
} }
@ -5726,6 +5727,7 @@ class Xls extends BaseReader
break; break;
default: default:
throw new Exception('Unrecognized space type in tAttrSpace token'); throw new Exception('Unrecognized space type in tAttrSpace token');
break; break;
} }
// offset: 3; size: 1; number of inserted spaces/carriage returns // offset: 3; size: 1; number of inserted spaces/carriage returns
@ -5736,6 +5738,7 @@ class Xls extends BaseReader
break; break;
default: default:
throw new Exception('Unrecognized attribute flag in tAttr token'); throw new Exception('Unrecognized attribute flag in tAttr token');
break; break;
} }
@ -6586,6 +6589,7 @@ class Xls extends BaseReader
break; break;
default: default:
throw new Exception('Unrecognized function in formula'); throw new Exception('Unrecognized function in formula');
break; break;
} }
$data = ['function' => $function, 'args' => $args]; $data = ['function' => $function, 'args' => $args];
@ -6955,6 +6959,7 @@ class Xls extends BaseReader
break; break;
default: default:
throw new Exception('Unrecognized function in formula'); throw new Exception('Unrecognized function in formula');
break; break;
} }
$data = ['function' => $function, 'args' => $args]; $data = ['function' => $function, 'args' => $args];
@ -7088,6 +7093,7 @@ class Xls extends BaseReader
// Unknown cases // don't know how to deal with // Unknown cases // don't know how to deal with
default: default:
throw new Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula'); throw new Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula');
break; break;
} }
@ -7501,10 +7507,12 @@ class Xls extends BaseReader
} }
return $sheetRange; return $sheetRange;
break; break;
default: default:
// TODO: external sheet support // TODO: external sheet support
throw new Exception('Xls reader only supports internal sheets in formulas'); throw new Exception('Xls reader only supports internal sheets in formulas');
break; break;
} }
} }

View File

@ -6,8 +6,11 @@ class MD5
{ {
// Context // Context
private $a; private $a;
private $b; private $b;
private $c; private $c;
private $d; private $d;
/** /**

View File

@ -6,7 +6,9 @@ class RC4
{ {
// Context // Context
protected $s = []; protected $s = [];
protected $i = 0; protected $i = 0;
protected $j = 0; protected $j = 0;
/** /**

View File

@ -773,7 +773,7 @@ class ReferenceHelper
// Is it in another worksheet? Will not have to update anything. // Is it in another worksheet? Will not have to update anything.
if (strpos($pCellRange, '!') !== false) { if (strpos($pCellRange, '!') !== false) {
return $pCellRange; return $pCellRange;
// Is it a range or a single cell? // Is it a range or a single cell?
} elseif (!Coordinate::coordinateIsRange($pCellRange)) { } elseif (!Coordinate::coordinateIsRange($pCellRange)) {
// Single cell // Single cell
return $this->updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows); return $this->updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows);

View File

@ -509,6 +509,7 @@ class Font
break; break;
default: default:
throw new PhpSpreadsheetException('Unknown font name "' . $name . '". Cannot map to TrueType font file'); throw new PhpSpreadsheetException('Unknown font name "' . $name . '". Cannot map to TrueType font file');
break; break;
} }

View File

@ -37,6 +37,7 @@ class EigenvalueDecomposition
* @var array * @var array
*/ */
private $d = []; private $d = [];
private $e = []; private $e = [];
/** /**
@ -66,6 +67,7 @@ class EigenvalueDecomposition
* @var float * @var float
*/ */
private $cdivr; private $cdivr;
private $cdivi; private $cdivi;
/** /**
@ -439,7 +441,7 @@ class EigenvalueDecomposition
$this->e[$n] = 0.0; $this->e[$n] = 0.0;
--$n; --$n;
$iter = 0; $iter = 0;
// Two roots found // Two roots found
} elseif ($l == $n - 1) { } elseif ($l == $n - 1) {
$w = $this->H[$n][$n - 1] * $this->H[$n - 1][$n]; $w = $this->H[$n][$n - 1] * $this->H[$n - 1][$n];
$p = ($this->H[$n - 1][$n - 1] - $this->H[$n][$n]) / 2.0; $p = ($this->H[$n - 1][$n - 1] - $this->H[$n][$n]) / 2.0;
@ -496,7 +498,7 @@ class EigenvalueDecomposition
} }
$n = $n - 2; $n = $n - 2;
$iter = 0; $iter = 0;
// No convergence yet // No convergence yet
} else { } else {
// Form shift // Form shift
$x = $this->H[$n][$n]; $x = $this->H[$n][$n];

View File

@ -101,6 +101,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
} else { } else {
@ -192,6 +193,7 @@ class Matrix
} }
return $R; return $R;
break; break;
//A($i0...$iF; $j0...$jF) //A($i0...$iF; $j0...$jF)
case 'integer,integer,integer,integer': case 'integer,integer,integer,integer':
@ -214,6 +216,7 @@ class Matrix
} }
return $R; return $R;
break; break;
//$R = array of row indices; $C = array of column indices //$R = array of row indices; $C = array of column indices
case 'array,array': case 'array,array':
@ -236,6 +239,7 @@ class Matrix
} }
return $R; return $R;
break; break;
//A($i0...$iF); $CL = array of column indices //A($i0...$iF); $CL = array of column indices
case 'integer,integer,array': case 'integer,integer,array':
@ -258,6 +262,7 @@ class Matrix
} }
return $R; return $R;
break; break;
//$RL = array of row indices //$RL = array of row indices
case 'array,integer,integer': case 'array,integer,integer':
@ -280,9 +285,11 @@ class Matrix
} }
return $R; return $R;
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
} else { } else {
@ -494,6 +501,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -538,6 +546,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -596,6 +605,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -640,6 +650,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -699,6 +710,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -744,6 +756,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -803,6 +816,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -867,6 +881,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -912,6 +927,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -957,6 +973,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -1095,6 +1112,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);
@ -1153,6 +1171,7 @@ class Matrix
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break; break;
} }
$this->checkMatrixDimensions($M); $this->checkMatrixDimensions($M);

View File

@ -35,7 +35,9 @@ class OLERead
const SIZE_POS = 0x78; const SIZE_POS = 0x78;
public $wrkbook; public $wrkbook;
public $summaryInformation; public $summaryInformation;
public $documentSummaryInformation; public $documentSummaryInformation;
/** /**

View File

@ -8,49 +8,49 @@ class BestFit
* Indicator flag for a calculation error. * Indicator flag for a calculation error.
* *
* @var bool * @var bool
**/ */
protected $error = false; protected $error = false;
/** /**
* Algorithm type to use for best-fit. * Algorithm type to use for best-fit.
* *
* @var string * @var string
**/ */
protected $bestFitType = 'undetermined'; protected $bestFitType = 'undetermined';
/** /**
* Number of entries in the sets of x- and y-value arrays. * Number of entries in the sets of x- and y-value arrays.
* *
* @var int * @var int
**/ */
protected $valueCount = 0; protected $valueCount = 0;
/** /**
* X-value dataseries of values. * X-value dataseries of values.
* *
* @var float[] * @var float[]
**/ */
protected $xValues = []; protected $xValues = [];
/** /**
* Y-value dataseries of values. * Y-value dataseries of values.
* *
* @var float[] * @var float[]
**/ */
protected $yValues = []; protected $yValues = [];
/** /**
* Flag indicating whether values should be adjusted to Y=0. * Flag indicating whether values should be adjusted to Y=0.
* *
* @var bool * @var bool
**/ */
protected $adjustToZero = false; protected $adjustToZero = false;
/** /**
* Y-value series of best-fit values. * Y-value series of best-fit values.
* *
* @var float[] * @var float[]
**/ */
protected $yBestFitValues = []; protected $yBestFitValues = [];
protected $goodnessOfFit = 1; protected $goodnessOfFit = 1;

View File

@ -9,7 +9,7 @@ class ExponentialBestFit extends BestFit
* (Name of this Trend class). * (Name of this Trend class).
* *
* @var string * @var string
**/ */
protected $bestFitType = 'exponential'; protected $bestFitType = 'exponential';
/** /**
@ -18,7 +18,7 @@ class ExponentialBestFit extends BestFit
* @param float $xValue X-Value * @param float $xValue X-Value
* *
* @return float Y-Value * @return float Y-Value
**/ */
public function getValueOfYForX($xValue) public function getValueOfYForX($xValue)
{ {
return $this->getIntersect() * pow($this->getSlope(), ($xValue - $this->xOffset)); return $this->getIntersect() * pow($this->getSlope(), ($xValue - $this->xOffset));
@ -30,7 +30,7 @@ class ExponentialBestFit extends BestFit
* @param float $yValue Y-Value * @param float $yValue Y-Value
* *
* @return float X-Value * @return float X-Value
**/ */
public function getValueOfXForY($yValue) public function getValueOfXForY($yValue)
{ {
return log(($yValue + $this->yOffset) / $this->getIntersect()) / log($this->getSlope()); return log(($yValue + $this->yOffset) / $this->getIntersect()) / log($this->getSlope());
@ -42,7 +42,7 @@ class ExponentialBestFit extends BestFit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return string * @return string
**/ */
public function getEquation($dp = 0) public function getEquation($dp = 0)
{ {
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);
@ -57,7 +57,7 @@ class ExponentialBestFit extends BestFit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return float * @return float
**/ */
public function getSlope($dp = 0) public function getSlope($dp = 0)
{ {
if ($dp != 0) { if ($dp != 0) {
@ -73,7 +73,7 @@ class ExponentialBestFit extends BestFit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return float * @return float
**/ */
public function getIntersect($dp = 0) public function getIntersect($dp = 0)
{ {
if ($dp != 0) { if ($dp != 0) {

View File

@ -9,7 +9,7 @@ class LinearBestFit extends BestFit
* (Name of this Trend class). * (Name of this Trend class).
* *
* @var string * @var string
**/ */
protected $bestFitType = 'linear'; protected $bestFitType = 'linear';
/** /**
@ -18,7 +18,7 @@ class LinearBestFit extends BestFit
* @param float $xValue X-Value * @param float $xValue X-Value
* *
* @return float Y-Value * @return float Y-Value
**/ */
public function getValueOfYForX($xValue) public function getValueOfYForX($xValue)
{ {
return $this->getIntersect() + $this->getSlope() * $xValue; return $this->getIntersect() + $this->getSlope() * $xValue;
@ -30,7 +30,7 @@ class LinearBestFit extends BestFit
* @param float $yValue Y-Value * @param float $yValue Y-Value
* *
* @return float X-Value * @return float X-Value
**/ */
public function getValueOfXForY($yValue) public function getValueOfXForY($yValue)
{ {
return ($yValue - $this->getIntersect()) / $this->getSlope(); return ($yValue - $this->getIntersect()) / $this->getSlope();
@ -42,7 +42,7 @@ class LinearBestFit extends BestFit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return string * @return string
**/ */
public function getEquation($dp = 0) public function getEquation($dp = 0)
{ {
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);

View File

@ -9,7 +9,7 @@ class LogarithmicBestFit extends BestFit
* (Name of this Trend class). * (Name of this Trend class).
* *
* @var string * @var string
**/ */
protected $bestFitType = 'logarithmic'; protected $bestFitType = 'logarithmic';
/** /**
@ -18,7 +18,7 @@ class LogarithmicBestFit extends BestFit
* @param float $xValue X-Value * @param float $xValue X-Value
* *
* @return float Y-Value * @return float Y-Value
**/ */
public function getValueOfYForX($xValue) public function getValueOfYForX($xValue)
{ {
return $this->getIntersect() + $this->getSlope() * log($xValue - $this->xOffset); return $this->getIntersect() + $this->getSlope() * log($xValue - $this->xOffset);
@ -30,7 +30,7 @@ class LogarithmicBestFit extends BestFit
* @param float $yValue Y-Value * @param float $yValue Y-Value
* *
* @return float X-Value * @return float X-Value
**/ */
public function getValueOfXForY($yValue) public function getValueOfXForY($yValue)
{ {
return exp(($yValue - $this->getIntersect()) / $this->getSlope()); return exp(($yValue - $this->getIntersect()) / $this->getSlope());
@ -42,7 +42,7 @@ class LogarithmicBestFit extends BestFit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return string * @return string
**/ */
public function getEquation($dp = 0) public function getEquation($dp = 0)
{ {
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);

View File

@ -11,21 +11,21 @@ class PolynomialBestFit extends BestFit
* (Name of this Trend class). * (Name of this Trend class).
* *
* @var string * @var string
**/ */
protected $bestFitType = 'polynomial'; protected $bestFitType = 'polynomial';
/** /**
* Polynomial order. * Polynomial order.
* *
* @var int * @var int
**/ */
protected $order = 0; protected $order = 0;
/** /**
* Return the order of this polynomial. * Return the order of this polynomial.
* *
* @return int * @return int
**/ */
public function getOrder() public function getOrder()
{ {
return $this->order; return $this->order;
@ -37,7 +37,7 @@ class PolynomialBestFit extends BestFit
* @param float $xValue X-Value * @param float $xValue X-Value
* *
* @return float Y-Value * @return float Y-Value
**/ */
public function getValueOfYForX($xValue) public function getValueOfYForX($xValue)
{ {
$retVal = $this->getIntersect(); $retVal = $this->getIntersect();
@ -57,7 +57,7 @@ class PolynomialBestFit extends BestFit
* @param float $yValue Y-Value * @param float $yValue Y-Value
* *
* @return float X-Value * @return float X-Value
**/ */
public function getValueOfXForY($yValue) public function getValueOfXForY($yValue)
{ {
return ($yValue - $this->getIntersect()) / $this->getSlope(); return ($yValue - $this->getIntersect()) / $this->getSlope();
@ -69,7 +69,7 @@ class PolynomialBestFit extends BestFit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return string * @return string
**/ */
public function getEquation($dp = 0) public function getEquation($dp = 0)
{ {
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);
@ -94,7 +94,7 @@ class PolynomialBestFit extends BestFit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return string * @return string
**/ */
public function getSlope($dp = 0) public function getSlope($dp = 0)
{ {
if ($dp != 0) { if ($dp != 0) {

View File

@ -9,7 +9,7 @@ class PowerBestFit extends BestFit
* (Name of this Trend class). * (Name of this Trend class).
* *
* @var string * @var string
**/ */
protected $bestFitType = 'power'; protected $bestFitType = 'power';
/** /**
@ -18,7 +18,7 @@ class PowerBestFit extends BestFit
* @param float $xValue X-Value * @param float $xValue X-Value
* *
* @return float Y-Value * @return float Y-Value
**/ */
public function getValueOfYForX($xValue) public function getValueOfYForX($xValue)
{ {
return $this->getIntersect() * pow(($xValue - $this->xOffset), $this->getSlope()); return $this->getIntersect() * pow(($xValue - $this->xOffset), $this->getSlope());
@ -30,7 +30,7 @@ class PowerBestFit extends BestFit
* @param float $yValue Y-Value * @param float $yValue Y-Value
* *
* @return float X-Value * @return float X-Value
**/ */
public function getValueOfXForY($yValue) public function getValueOfXForY($yValue)
{ {
return pow((($yValue + $this->yOffset) / $this->getIntersect()), (1 / $this->getSlope())); return pow((($yValue + $this->yOffset) / $this->getIntersect()), (1 / $this->getSlope()));
@ -42,7 +42,7 @@ class PowerBestFit extends BestFit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return string * @return string
**/ */
public function getEquation($dp = 0) public function getEquation($dp = 0)
{ {
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);
@ -57,7 +57,7 @@ class PowerBestFit extends BestFit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return float * @return float
**/ */
public function getIntersect($dp = 0) public function getIntersect($dp = 0)
{ {
if ($dp != 0) { if ($dp != 0) {

View File

@ -20,7 +20,7 @@ class Trend
* Names of the best-fit Trend analysis methods. * Names of the best-fit Trend analysis methods.
* *
* @var string[] * @var string[]
**/ */
private static $trendTypes = [ private static $trendTypes = [
self::TREND_LINEAR, self::TREND_LINEAR,
self::TREND_LOGARITHMIC, self::TREND_LOGARITHMIC,
@ -32,7 +32,7 @@ class Trend
* Names of the best-fit Trend polynomial orders. * Names of the best-fit Trend polynomial orders.
* *
* @var string[] * @var string[]
**/ */
private static $trendTypePolynomialOrders = [ private static $trendTypePolynomialOrders = [
self::TREND_POLYNOMIAL_2, self::TREND_POLYNOMIAL_2,
self::TREND_POLYNOMIAL_3, self::TREND_POLYNOMIAL_3,
@ -45,7 +45,7 @@ class Trend
* Cached results for each method when trying to identify which provides the best fit. * Cached results for each method when trying to identify which provides the best fit.
* *
* @var bestFit[] * @var bestFit[]
**/ */
private static $trendCache = []; private static $trendCache = [];
public static function calculate($trendType = self::TREND_BEST_FIT, $yValues = [], $xValues = [], $const = true) public static function calculate($trendType = self::TREND_BEST_FIT, $yValues = [], $xValues = [], $const = true)

View File

@ -92,6 +92,7 @@ class Spreadsheet
* @var string * @var string
*/ */
private $macrosCode; private $macrosCode;
/** /**
* macrosCertificate : if macros are signed, contains binary data vbaProjectSignature.bin file, null if not signed. * macrosCertificate : if macros are signed, contains binary data vbaProjectSignature.bin file, null if not signed.
* *
@ -281,6 +282,7 @@ class Spreadsheet
switch ($what) { switch ($what) {
case 'all': case 'all':
return $this->ribbonBinObjects; return $this->ribbonBinObjects;
break; break;
case 'names': case 'names':
case 'data': case 'data':

View File

@ -82,6 +82,7 @@ class Border extends Supervisor
case 'outline': case 'outline':
case 'vertical': case 'vertical':
throw new PhpSpreadsheetException('Cannot get shared component for a pseudo-border.'); throw new PhpSpreadsheetException('Cannot get shared component for a pseudo-border.');
break; break;
case 'bottom': case 'bottom':
return $this->parent->getSharedComponent()->getBottom(); return $this->parent->getSharedComponent()->getBottom();

View File

@ -415,6 +415,7 @@ class NumberFormat extends Supervisor
// fractional seconds - no php equivalent // fractional seconds - no php equivalent
'.s' => '', '.s' => '',
]; ];
/** /**
* Search/replace values to convert Excel date/time format masks hours to PHP format masks (24 hr clock). * Search/replace values to convert Excel date/time format masks hours to PHP format masks (24 hr clock).
* *
@ -424,6 +425,7 @@ class NumberFormat extends Supervisor
'hh' => 'H', 'hh' => 'H',
'h' => 'G', 'h' => 'G',
]; ];
/** /**
* Search/replace values to convert Excel date/time format masks hours to PHP format masks (12 hr clock). * Search/replace values to convert Excel date/time format masks hours to PHP format masks (12 hr clock).
* *
@ -687,9 +689,9 @@ class NumberFormat extends Supervisor
// Strip # // Strip #
$format = preg_replace('/\\#/', '0', $format); $format = preg_replace('/\\#/', '0', $format);
$n = "/\[[^\]]+\]/"; $n = '/\\[[^\\]]+\\]/';
$m = preg_replace($n, '', $format); $m = preg_replace($n, '', $format);
$number_regex = "/(0+)(\.?)(0*)/"; $number_regex = '/(0+)(\\.?)(0*)/';
if (preg_match($number_regex, $m, $matches)) { if (preg_match($number_regex, $m, $matches)) {
$left = $matches[1]; $left = $matches[1];
$dec = $matches[2]; $dec = $matches[2];

View File

@ -469,6 +469,7 @@ class AutoFilter
* @var array * @var array
*/ */
private static $fromReplace = ['\*', '\?', '~~', '~.*', '~.?']; private static $fromReplace = ['\*', '\?', '~~', '~.*', '~.?'];
private static $toReplace = ['.*', '.', '~', '\*', '\?']; private static $toReplace = ['.*', '.', '~', '\*', '\?'];
/** /**

View File

@ -223,7 +223,7 @@ class BaseDrawing implements IComparable
// Set new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet // Set new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
$this->setWorksheet($pValue); $this->setWorksheet($pValue);
} else { } else {
throw new PhpSpreadsheetException("A Worksheet has already been assigned. Drawings can only exist on one \PhpOffice\PhpSpreadsheet\Worksheet."); throw new PhpSpreadsheetException('A Worksheet has already been assigned. Drawings can only exist on one \\PhpOffice\\PhpSpreadsheet\\Worksheet.');
} }
} }

View File

@ -201,6 +201,7 @@ class Content extends WriterPart
break; break;
case DataType::TYPE_ERROR: case DataType::TYPE_ERROR:
throw new Exception('Writing of error not implemented yet.'); throw new Exception('Writing of error not implemented yet.');
break; break;
case DataType::TYPE_FORMULA: case DataType::TYPE_FORMULA:
$formulaValue = $cell->getValue(); $formulaValue = $cell->getValue();
@ -223,6 +224,7 @@ class Content extends WriterPart
break; break;
case DataType::TYPE_INLINE: case DataType::TYPE_INLINE:
throw new Exception('Writing of inline not implemented yet.'); throw new Exception('Writing of inline not implemented yet.');
break; break;
case DataType::TYPE_NUMERIC: case DataType::TYPE_NUMERIC:
$objWriter->writeAttribute('office:value-type', 'float'); $objWriter->writeAttribute('office:value-type', 'float');

View File

@ -493,31 +493,31 @@ class Parser
return $this->convertString($token); return $this->convertString($token);
} elseif (is_numeric($token)) { } elseif (is_numeric($token)) {
return $this->convertNumber($token); return $this->convertNumber($token);
// match references like A1 or $A$1 // match references like A1 or $A$1
} elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/', $token)) { } elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/', $token)) {
return $this->convertRef2d($token); return $this->convertRef2d($token);
// match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1 // match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) { } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?(\\d+)$/u', $token)) {
return $this->convertRef3d($token); return $this->convertRef3d($token);
// match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1 // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\\d+)$/u", $token)) {
return $this->convertRef3d($token); return $this->convertRef3d($token);
// match ranges like A1:B2 or $A$1:$B$2 // match ranges like A1:B2 or $A$1:$B$2
} elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/', $token)) { } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/', $token)) {
return $this->convertRange2d($token); return $this->convertRange2d($token);
// match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2 // match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) { } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?([A-Ia-i]?[A-Za-z])?\$?(\\d+)\\:\$?([A-Ia-i]?[A-Za-z])?\$?(\\d+)$/u', $token)) {
return $this->convertRange3d($token); return $this->convertRange3d($token);
// match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 // match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\\d+)\\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\\d+)$/u", $token)) {
return $this->convertRange3d($token); return $this->convertRange3d($token);
// operators (including parentheses) // operators (including parentheses)
} elseif (isset($this->ptg[$token])) { } elseif (isset($this->ptg[$token])) {
return pack('C', $this->ptg[$token]); return pack('C', $this->ptg[$token]);
// match error codes // match error codes
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') { } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token == '#N/A') {
return $this->convertError($token); return $this->convertError($token);
// commented so argument number can be processed correctly. See toReversePolish(). // commented so argument number can be processed correctly. See toReversePolish().
/*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/", $token)) /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/", $token))
{ {
return($this->convertFunction($token, $this->_func_args)); return($this->convertFunction($token, $this->_func_args));
@ -541,7 +541,7 @@ class Parser
private function convertNumber($num) private function convertNumber($num)
{ {
// Integer in the range 0..2**16-1 // Integer in the range 0..2**16-1
if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) { if ((preg_match('/^\\d+$/', $num)) and ($num <= 65535)) {
return pack('Cv', $this->ptg['ptgInt'], $num); return pack('Cv', $this->ptg['ptgInt'], $num);
} }
@ -652,7 +652,7 @@ class Parser
list($cell1, $cell2) = explode(':', $range); list($cell1, $cell2) = explode(':', $range);
// Convert the cell references // Convert the cell references
if (preg_match("/^(\\$)?[A-Ia-i]?[A-Za-z](\\$)?(\d+)$/", $cell1)) { if (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\\d+)$/', $cell1)) {
list($row1, $col1) = $this->cellToPackedRowcol($cell1); list($row1, $col1) = $this->cellToPackedRowcol($cell1);
list($row2, $col2) = $this->cellToPackedRowcol($cell2); list($row2, $col2) = $this->cellToPackedRowcol($cell2);
} else { // It's a rows range (like 26:27) } else { // It's a rows range (like 26:27)
@ -1005,6 +1005,7 @@ class Parser
case '&': case '&':
case '%': case '%':
return $token; return $token;
break; break;
case '>': case '>':
if ($this->lookAhead == '=') { // it's a GE token if ($this->lookAhead == '=') { // it's a GE token
@ -1012,6 +1013,7 @@ class Parser
} }
return $token; return $token;
break; break;
case '<': case '<':
// it's a LE or a NE token // it's a LE or a NE token
@ -1020,24 +1022,25 @@ class Parser
} }
return $token; return $token;
break; break;
default: default:
// if it's a reference A1 or $A$1 or $A1 or A$1 // if it's a reference A1 or $A$1 or $A1 or A$1
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.') and ($this->lookAhead != '!')) { if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.') and ($this->lookAhead != '!')) {
return $token; return $token;
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) { } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) {
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
return $token; return $token;
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) {
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
return $token; return $token;
} elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $token) && !preg_match('/\d/', $this->lookAhead)) { } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $token) && !preg_match('/\d/', $this->lookAhead)) {
// if it's a range A1:A2 or $A$1:$A$2 // if it's a range A1:A2 or $A$1:$A$2
return $token; return $token;
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead)) { } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?([A-Ia-i]?[A-Za-z])?\$?\\d+:\$?([A-Ia-i]?[A-Za-z])?\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead)) {
// If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2 // If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
return $token; return $token;
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead)) {
// If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 // If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
return $token; return $token;
} elseif (is_numeric($token) and (!is_numeric($token . $this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead != '!') and ($this->lookAhead != ':')) { } elseif (is_numeric($token) and (!is_numeric($token . $this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead != '!') and ($this->lookAhead != ':')) {
@ -1046,10 +1049,10 @@ class Parser
} elseif (preg_match('/"([^"]|""){0,255}"/', $token) and $this->lookAhead != '"' and (substr_count($token, '"') % 2 == 0)) { } elseif (preg_match('/"([^"]|""){0,255}"/', $token) and $this->lookAhead != '"' and (substr_count($token, '"') % 2 == 0)) {
// If it's a string (of maximum 255 characters) // If it's a string (of maximum 255 characters)
return $token; return $token;
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') { } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token == '#N/A') {
// If it's an error code // If it's an error code
return $token; return $token;
} elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $token) and ($this->lookAhead == '(')) { } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $token) and ($this->lookAhead == '(')) {
// if it's a function call // if it's a function call
return $token; return $token;
} elseif (substr($token, -1) == ')') { } elseif (substr($token, -1) == ')') {
@ -1147,13 +1150,13 @@ class Parser
$this->advance(); $this->advance();
return $result; return $result;
// If it's an error code // If it's an error code
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $this->currentToken) or $this->currentToken == '#N/A') { } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $this->currentToken) or $this->currentToken == '#N/A') {
$result = $this->createTree($this->currentToken, 'ptgErr', ''); $result = $this->createTree($this->currentToken, 'ptgErr', '');
$this->advance(); $this->advance();
return $result; return $result;
// If it's a negative value // If it's a negative value
} elseif ($this->currentToken == '-') { } elseif ($this->currentToken == '-') {
// catch "-" Term // catch "-" Term
$this->advance(); $this->advance();
@ -1161,7 +1164,7 @@ class Parser
$result = $this->createTree('ptgUminus', $result2, ''); $result = $this->createTree('ptgUminus', $result2, '');
return $result; return $result;
// If it's a positive value // If it's a positive value
} elseif ($this->currentToken == '+') { } elseif ($this->currentToken == '+') {
// catch "+" Term // catch "+" Term
$this->advance(); $this->advance();
@ -1259,13 +1262,13 @@ class Parser
$this->advance(); $this->advance();
return $result; return $result;
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?\d+$/u", $this->currentToken)) { } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $this->currentToken)) {
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
$result = $this->createTree($this->currentToken, '', ''); $result = $this->createTree($this->currentToken, '', '');
$this->advance(); $this->advance();
return $result; return $result;
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?\d+$/u", $this->currentToken)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $this->currentToken)) {
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
$result = $this->createTree($this->currentToken, '', ''); $result = $this->createTree($this->currentToken, '', '');
$this->advance(); $this->advance();
@ -1279,14 +1282,14 @@ class Parser
$this->advance(); $this->advance();
return $result; return $result;
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\d+$/u", $this->currentToken)) { } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?([A-Ia-i]?[A-Za-z])?\$?\\d+:\$?([A-Ia-i]?[A-Za-z])?\$?\\d+$/u', $this->currentToken)) {
// If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2) // If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2)
// must be an error? // must be an error?
$result = $this->createTree($this->currentToken, '', ''); $result = $this->createTree($this->currentToken, '', '');
$this->advance(); $this->advance();
return $result; return $result;
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\d+$/u", $this->currentToken)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+$/u", $this->currentToken)) {
// If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2) // If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2)
// must be an error? // must be an error?
$result = $this->createTree($this->currentToken, '', ''); $result = $this->createTree($this->currentToken, '', '');
@ -1304,7 +1307,7 @@ class Parser
$this->advance(); $this->advance();
return $result; return $result;
} elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->currentToken)) { } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $this->currentToken)) {
// if it's a function call // if it's a function call
$result = $this->func(); $result = $this->func();
@ -1420,9 +1423,9 @@ class Parser
$polish .= $converted_tree; $polish .= $converted_tree;
} }
// if it's a function convert it here (so we can set it's arguments) // if it's a function convert it here (so we can set it's arguments)
if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/", $tree['value']) and if (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/", $tree['value']) and
!preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) and !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) and
!preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/", $tree['value']) and !preg_match('/^[A-Ia-i]?[A-Za-z](\\d+)\\.\\.[A-Ia-i]?[A-Za-z](\\d+)$/', $tree['value']) and
!is_numeric($tree['value']) and !is_numeric($tree['value']) and
!isset($this->ptg[$tree['value']])) { !isset($this->ptg[$tree['value']])) {
// left subtree for a function is always an array. // left subtree for a function is always an array.

View File

@ -599,7 +599,7 @@ class Workbook extends BIFFwriter
// store the DEFINEDNAME record // store the DEFINEDNAME record
$chunk .= $this->writeData($this->writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true)); $chunk .= $this->writeData($this->writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true));
// (exclusive) either repeatColumns or repeatRows // (exclusive) either repeatColumns or repeatRows
} elseif ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) { } elseif ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
// Columns to repeat // Columns to repeat
if ($sheetSetup->isColumnsToRepeatAtLeftSet()) { if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
@ -1066,7 +1066,7 @@ class Workbook extends BIFFwriter
// and start new record data block where we start writing the string // and start new record data block where we start writing the string
$recordData = ''; $recordData = '';
// 2. space remaining is greater than or equal to minimum space needed // 2. space remaining is greater than or equal to minimum space needed
} else { } else {
// initialize effective remaining space, for Unicode strings this may need to be reduced by 1, see below // initialize effective remaining space, for Unicode strings this may need to be reduced by 1, see below
$effective_space_remaining = $space_remaining; $effective_space_remaining = $space_remaining;

View File

@ -1074,7 +1074,7 @@ class Worksheet extends BIFFwriter
// parameters accordingly. // parameters accordingly.
// Split the dir name and sheet name (if it exists) // Split the dir name and sheet name (if it exists)
$dir_long = $url; $dir_long = $url;
if (preg_match("/\#/", $url)) { if (preg_match('/\\#/', $url)) {
$link_type |= 0x08; $link_type |= 0x08;
} }
@ -1082,11 +1082,11 @@ class Worksheet extends BIFFwriter
$link_type = pack('V', $link_type); $link_type = pack('V', $link_type);
// Calculate the up-level dir count e.g.. (..\..\..\ == 3) // Calculate the up-level dir count e.g.. (..\..\..\ == 3)
$up_count = preg_match_all("/\.\.\\\/", $dir_long, $useless); $up_count = preg_match_all("/\\.\\.\\\/", $dir_long, $useless);
$up_count = pack('v', $up_count); $up_count = pack('v', $up_count);
// Store the short dos dir name (null terminated) // Store the short dos dir name (null terminated)
$dir_short = preg_replace("/\.\.\\\/", '', $dir_long) . "\0"; $dir_short = preg_replace("/\\.\\.\\\/", '', $dir_long) . "\0";
// Store the long dir name as a wchar string (non-null terminated) // Store the long dir name as a wchar string (non-null terminated)
$dir_long = $dir_long . "\0"; $dir_long = $dir_long . "\0";

View File

@ -239,11 +239,10 @@ class CoordinateTest extends TestCase
return require 'data/CellBuildRange.php'; return require 'data/CellBuildRange.php';
} }
/**
* @expectedException \TypeError
*/
public function testBuildRangeInvalid() public function testBuildRangeInvalid()
{ {
$this->expectException(\TypeError::class);
if (PHP_MAJOR_VERSION < 7) { if (PHP_MAJOR_VERSION < 7) {
$this->markTestSkipped('Cannot catch type hinting error with PHP 5.6'); $this->markTestSkipped('Cannot catch type hinting error with PHP 5.6');
} }

View File

@ -85,11 +85,10 @@ class CellsTest extends TestCase
self::assertNotNull($collection->get('A2'), 'should be able to get back the cell even when another cell was deleted while this one was the current one'); self::assertNotNull($collection->get('A2'), 'should be able to get back the cell even when another cell was deleted while this one was the current one');
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testThrowsWhenCellCannotBeRetrievedFromCache() public function testThrowsWhenCellCannotBeRetrievedFromCache()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$collection = $this->getMockBuilder(Cells::class) $collection = $this->getMockBuilder(Cells::class)
->setConstructorArgs([new Worksheet(), new Memory()]) ->setConstructorArgs([new Worksheet(), new Memory()])
->setMethods(['has']) ->setMethods(['has'])
@ -101,11 +100,10 @@ class CellsTest extends TestCase
$collection->get('A2'); $collection->get('A2');
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testThrowsWhenCellCannotBeStoredInCache() public function testThrowsWhenCellCannotBeStoredInCache()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$cache = $this->createMock(Memory::class); $cache = $this->createMock(Memory::class);
$cell = $this->createMock(Cell::class); $cell = $this->createMock(Cell::class);
$cache->method('set') $cache->method('set')

View File

@ -7,7 +7,9 @@ use PhpOffice\PhpSpreadsheet\Exception;
class Complex class Complex
{ {
private $realPart = 0; private $realPart = 0;
private $imaginaryPart = 0; private $imaginaryPart = 0;
private $suffix; private $suffix;
public static function _parseComplex($complexNumber) public static function _parseComplex($complexNumber)

View File

@ -117,35 +117,31 @@ class IOFactoryTest extends TestCase
]; ];
} }
/**
* @expectedException \InvalidArgumentException
*/
public function testIdentifyNonExistingFileThrowException() public function testIdentifyNonExistingFileThrowException()
{ {
$this->expectException(\InvalidArgumentException::class);
IOFactory::identify('/non/existing/file'); IOFactory::identify('/non/existing/file');
} }
/**
* @expectedException \InvalidArgumentException
*/
public function testIdentifyExistingDirectoryThrowExceptions() public function testIdentifyExistingDirectoryThrowExceptions()
{ {
$this->expectException(\InvalidArgumentException::class);
IOFactory::identify('.'); IOFactory::identify('.');
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function testRegisterInvalidWriter() public function testRegisterInvalidWriter()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Writer\Exception::class);
IOFactory::registerWriter('foo', 'bar'); IOFactory::registerWriter('foo', 'bar');
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Reader\Exception
*/
public function testRegisterInvalidReader() public function testRegisterInvalidReader()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class);
IOFactory::registerReader('foo', 'bar'); IOFactory::registerReader('foo', 'bar');
} }
} }

View File

@ -11,12 +11,13 @@ class XmlTest extends TestCase
{ {
/** /**
* @dataProvider providerInvalidXML * @dataProvider providerInvalidXML
* @expectedException \PhpOffice\PhpSpreadsheet\Reader\Exception
* *
* @param mixed $filename * @param mixed $filename
*/ */
public function testInvalidXML($filename) public function testInvalidXML($filename)
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class);
$reader = $this->getMockForAbstractClass(BaseReader::class); $reader = $this->getMockForAbstractClass(BaseReader::class);
$expectedResult = 'FAILURE: Should throw an Exception rather than return a value'; $expectedResult = 'FAILURE: Should throw an Exception rather than return a value';
$result = $reader->securityScanFile($filename); $result = $reader->securityScanFile($filename);
@ -35,12 +36,13 @@ class XmlTest extends TestCase
/** /**
* @dataProvider providerInvalidSimpleXML * @dataProvider providerInvalidSimpleXML
* @expectedException \PhpOffice\PhpSpreadsheet\Reader\Exception
* *
* @param $filename * @param $filename
*/ */
public function testInvalidSimpleXML($filename) public function testInvalidSimpleXML($filename)
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class);
$xmlReader = new Xml(); $xmlReader = new Xml();
$xmlReader->trySimpleXMLLoadString($filename); $xmlReader->trySimpleXMLLoadString($filename);
} }

View File

@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase;
class RuleTest extends TestCase class RuleTest extends TestCase
{ {
private $testAutoFilterRuleObject; private $testAutoFilterRuleObject;
private $mockAutoFilterColumnObject; private $mockAutoFilterColumnObject;
public function setUp() public function setUp()

View File

@ -8,7 +8,9 @@ use PHPUnit\Framework\TestCase;
class ColumnTest extends TestCase class ColumnTest extends TestCase
{ {
private $testInitialColumn = 'H'; private $testInitialColumn = 'H';
private $testAutoFilterColumnObject; private $testAutoFilterColumnObject;
private $mockAutoFilterObject; private $mockAutoFilterObject;
public function setUp() public function setUp()
@ -70,11 +72,10 @@ class ColumnTest extends TestCase
self::assertEquals(AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER, $result); self::assertEquals(AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER, $result);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSetInvalidFilterTypeThrowsException() public function testSetInvalidFilterTypeThrowsException()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$expectedResult = 'Unfiltered'; $expectedResult = 'Unfiltered';
$this->testAutoFilterColumnObject->setFilterType($expectedResult); $this->testAutoFilterColumnObject->setFilterType($expectedResult);
@ -95,11 +96,10 @@ class ColumnTest extends TestCase
self::assertEquals(AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND, $result); self::assertEquals(AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND, $result);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSetInvalidJoinThrowsException() public function testSetInvalidJoinThrowsException()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$expectedResult = 'Neither'; $expectedResult = 'Neither';
$this->testAutoFilterColumnObject->setJoin($expectedResult); $this->testAutoFilterColumnObject->setJoin($expectedResult);

View File

@ -11,11 +11,14 @@ use PHPUnit\Framework\TestCase;
class AutoFilterTest extends TestCase class AutoFilterTest extends TestCase
{ {
private $testInitialRange = 'H2:O256'; private $testInitialRange = 'H2:O256';
/** /**
* @var AutoFilter * @var AutoFilter
*/ */
private $testAutoFilterObject; private $testAutoFilterObject;
private $mockWorksheetObject; private $mockWorksheetObject;
private $cellCollection; private $cellCollection;
public function setUp() public function setUp()
@ -95,11 +98,10 @@ class AutoFilterTest extends TestCase
self::assertEquals($expectedResult, $result); self::assertEquals($expectedResult, $result);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSetRangeInvalidRange() public function testSetRangeInvalidRange()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$expectedResult = 'A1'; $expectedResult = 'A1';
$this->testAutoFilterObject->setRange($expectedResult); $this->testAutoFilterObject->setRange($expectedResult);
@ -129,11 +131,10 @@ class AutoFilterTest extends TestCase
} }
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testGetInvalidColumnOffset() public function testGetInvalidColumnOffset()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$invalidColumn = 'G'; $invalidColumn = 'G';
$this->testAutoFilterObject->getColumnOffset($invalidColumn); $this->testAutoFilterObject->getColumnOffset($invalidColumn);
@ -156,11 +157,10 @@ class AutoFilterTest extends TestCase
self::assertInstanceOf(Column::class, $result[$expectedResult]); self::assertInstanceOf(Column::class, $result[$expectedResult]);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSetInvalidColumnWithString() public function testSetInvalidColumnWithString()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$invalidColumn = 'A'; $invalidColumn = 'A';
$this->testAutoFilterObject->setColumn($invalidColumn); $this->testAutoFilterObject->setColumn($invalidColumn);
@ -184,20 +184,18 @@ class AutoFilterTest extends TestCase
self::assertInstanceOf(Column::class, $result[$expectedResult]); self::assertInstanceOf(Column::class, $result[$expectedResult]);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSetInvalidColumnWithObject() public function testSetInvalidColumnWithObject()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$invalidColumn = 'E'; $invalidColumn = 'E';
$this->testAutoFilterObject->setColumn($invalidColumn); $this->testAutoFilterObject->setColumn($invalidColumn);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSetColumnWithInvalidDataType() public function testSetColumnWithInvalidDataType()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$invalidColumn = 123.456; $invalidColumn = 123.456;
$this->testAutoFilterObject->setColumn($invalidColumn); $this->testAutoFilterObject->setColumn($invalidColumn);
} }
@ -262,11 +260,10 @@ class AutoFilterTest extends TestCase
self::assertInstanceOf(Column::class, $result); self::assertInstanceOf(Column::class, $result);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testGetColumnWithoutRangeSet() public function testGetColumnWithoutRangeSet()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
// Clear the range // Clear the range
$this->testAutoFilterObject->setRange(''); $this->testAutoFilterObject->setRange('');
$this->testAutoFilterObject->getColumn('A'); $this->testAutoFilterObject->getColumn('A');

View File

@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase;
class ColumnCellIteratorTest extends TestCase class ColumnCellIteratorTest extends TestCase
{ {
public $mockWorksheet; public $mockWorksheet;
public $mockCell; public $mockCell;
public function setUp() public function setUp()
@ -67,20 +68,18 @@ class ColumnCellIteratorTest extends TestCase
} }
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSeekOutOfRange() public function testSeekOutOfRange()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4);
$iterator->seek(1); $iterator->seek(1);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testPrevOutOfRange() public function testPrevOutOfRange()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4);
$iterator->prev(); $iterator->prev();
} }

View File

@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase;
class ColumnIteratorTest extends TestCase class ColumnIteratorTest extends TestCase
{ {
public $mockWorksheet; public $mockWorksheet;
public $mockColumn; public $mockColumn;
public function setUp() public function setUp()
@ -66,20 +67,18 @@ class ColumnIteratorTest extends TestCase
} }
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSeekOutOfRange() public function testSeekOutOfRange()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D'); $iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D');
$iterator->seek('A'); $iterator->seek('A');
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testPrevOutOfRange() public function testPrevOutOfRange()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D'); $iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D');
$iterator->prev(); $iterator->prev();
} }

View File

@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase;
class ColumnTest extends TestCase class ColumnTest extends TestCase
{ {
public $mockWorksheet; public $mockWorksheet;
public $mockColumn; public $mockColumn;
public function setUp() public function setUp()

View File

@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase;
class RowCellIteratorTest extends TestCase class RowCellIteratorTest extends TestCase
{ {
public $mockWorksheet; public $mockWorksheet;
public $mockCell; public $mockCell;
public function setUp() public function setUp()
@ -69,20 +70,18 @@ class RowCellIteratorTest extends TestCase
} }
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSeekOutOfRange() public function testSeekOutOfRange()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); $iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
$iterator->seek(1); $iterator->seek(1);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testPrevOutOfRange() public function testPrevOutOfRange()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); $iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
$iterator->prev(); $iterator->prev();
} }

View File

@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase;
class RowIteratorTest extends TestCase class RowIteratorTest extends TestCase
{ {
public $mockWorksheet; public $mockWorksheet;
public $mockRow; public $mockRow;
public function setUp() public function setUp()
@ -64,20 +65,18 @@ class RowIteratorTest extends TestCase
} }
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testSeekOutOfRange() public function testSeekOutOfRange()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new RowIterator($this->mockWorksheet, 2, 4); $iterator = new RowIterator($this->mockWorksheet, 2, 4);
$iterator->seek(1); $iterator->seek(1);
} }
/**
* @expectedException \PhpOffice\PhpSpreadsheet\Exception
*/
public function testPrevOutOfRange() public function testPrevOutOfRange()
{ {
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new RowIterator($this->mockWorksheet, 2, 4); $iterator = new RowIterator($this->mockWorksheet, 2, 4);
$iterator->prev(); $iterator->prev();
} }

View File

@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase;
class RowTest extends TestCase class RowTest extends TestCase
{ {
public $mockWorksheet; public $mockWorksheet;
public $mockRow; public $mockRow;
public function setUp() public function setUp()