Merge branch 'develop' of https://github.com/PHPOffice/PhpSpreadsheet into develop
|
@ -34,6 +34,7 @@ return PhpCsFixer\Config::create()
|
|||
'hash_to_slash_comment' => true,
|
||||
'header_comment' => false, // We don't use common header in all our files
|
||||
'heredoc_to_nowdoc' => false, // Not sure about this one
|
||||
'is_null' => false, // Risky
|
||||
'include' => true,
|
||||
'indentation_type' => true,
|
||||
'line_ending' => true,
|
||||
|
@ -46,6 +47,7 @@ return PhpCsFixer\Config::create()
|
|||
'method_separation' => true,
|
||||
'modernize_types_casting' => true,
|
||||
'native_function_casing' => 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
|
||||
'new_with_braces' => true,
|
||||
'no_alias_functions' => true,
|
||||
'no_blank_lines_after_class_opening' => true,
|
||||
|
@ -88,7 +90,7 @@ return PhpCsFixer\Config::create()
|
|||
'php_unit_construct' => true,
|
||||
'php_unit_dedicate_assert' => true,
|
||||
'php_unit_fqcn_annotation' => true,
|
||||
'php_unit_strict' => false, // We sometime actually need assertEquals 'phpdoc_align' => false, // Waste of time
|
||||
'php_unit_strict' => false, // We sometime actually need assertEquals
|
||||
'phpdoc_add_missing_param_annotation' => true,
|
||||
'phpdoc_align' => false, // Waste of time
|
||||
'phpdoc_annotation_without_dot' => true,
|
||||
|
@ -98,7 +100,9 @@ return PhpCsFixer\Config::create()
|
|||
'phpdoc_no_alias_tag' => true,
|
||||
'phpdoc_no_empty_return' => true,
|
||||
'phpdoc_no_package' => true,
|
||||
'phpdoc_no_useless_inheritdoc' => true,
|
||||
'phpdoc_order' => true,
|
||||
'phpdoc_return_self_reference' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_separation' => true,
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
|
@ -132,6 +136,7 @@ return PhpCsFixer\Config::create()
|
|||
'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,
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
language: php
|
||||
dist: trusty
|
||||
sudo: false
|
||||
|
||||
php:
|
||||
- 5.6
|
||||
|
@ -11,7 +13,6 @@ matrix:
|
|||
- php: 7.0
|
||||
env: COVERAGE=1
|
||||
allow_failures:
|
||||
- php: 7.1
|
||||
- php: hhvm
|
||||
|
||||
cache:
|
||||
|
|
1623
CHANGELOG.md
|
@ -34,14 +34,10 @@ PhpSpreadsheet is a library written in pure PHP and providing a set of classes t
|
|||
## Requirements
|
||||
|
||||
* PHP version 5.6 or higher
|
||||
* PHP extension php_zip enabled (required if you need PhpSpreadsheet to handle .xlsx .ods or .gnumeric files)
|
||||
* PHP extension php_zip enabled
|
||||
* PHP extension php_xml enabled
|
||||
* PHP extension php_gd2 enabled (optional, but required for exact column width autocalculation)
|
||||
|
||||
*Note:* PHP 5.6.29 has [a bug](https://bugs.php.net/bug.php?id=735300) that
|
||||
prevents SQLite3 caching to work correctly. Use a newer (or older) versions of
|
||||
PHP if you need SQLite3 caching.
|
||||
|
||||
## PHP version support
|
||||
|
||||
Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version
|
||||
|
|
|
@ -27,18 +27,19 @@
|
|||
"ext-mbstring": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlwriter": "*"
|
||||
"ext-xmlwriter": "*",
|
||||
"ext-zip": "*",
|
||||
"psr/simple-cache": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dompdf/dompdf": "^0.7.0",
|
||||
"mpdf/mpdf": "^6.1",
|
||||
"tecnickcom/tcpdf": "^6.2",
|
||||
"squizlabs/php_codesniffer": "^2.7",
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"friendsofphp/php-cs-fixer": "^2.0"
|
||||
"friendsofphp/php-cs-fixer": "^2.0",
|
||||
"dompdf/dompdf": "^0.8.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-zip": "Required to handle .xlsx .ods or .gnumeric files",
|
||||
"ext-gd": "Required for exact column width autocalculation",
|
||||
"ext-dom": "Option to read and write HTML files",
|
||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
||||
|
|
|
@ -4,8 +4,57 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "97eae2a53946fe7524d2f8840bcc791e",
|
||||
"packages": [],
|
||||
"content-hash": "81b6f3fcd32849e29ea13dd37c9af17f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "psr/simple-cache",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/simple-cache.git",
|
||||
"reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/753fa598e8f3b9966c886fe13f370baa45ef0e24",
|
||||
"reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\SimpleCache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interfaces for simple caching",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching",
|
||||
"psr",
|
||||
"psr-16",
|
||||
"simple-cache"
|
||||
],
|
||||
"time": "2017-01-02T13:31:39+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
|
@ -63,28 +112,29 @@
|
|||
},
|
||||
{
|
||||
"name": "dompdf/dompdf",
|
||||
"version": "v0.7.0",
|
||||
"version": "v0.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dompdf/dompdf.git",
|
||||
"reference": "5c98652b1a5beb7e3cc8ec35419b2828dd63ab14"
|
||||
"reference": "0f418c6b58fdeafc2a0e80eb1fa5e644e185089c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/5c98652b1a5beb7e3cc8ec35419b2828dd63ab14",
|
||||
"reference": "5c98652b1a5beb7e3cc8ec35419b2828dd63ab14",
|
||||
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/0f418c6b58fdeafc2a0e80eb1fa5e644e185089c",
|
||||
"reference": "0f418c6b58fdeafc2a0e80eb1fa5e644e185089c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-mbstring": "*",
|
||||
"phenx/php-font-lib": "0.4.*",
|
||||
"phenx/php-svg-lib": "0.1.*",
|
||||
"phenx/php-font-lib": "0.5.*",
|
||||
"phenx/php-svg-lib": "0.2.*",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "3.7.*"
|
||||
"phpunit/phpunit": "4.8.*",
|
||||
"squizlabs/php_codesniffer": "2.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
|
@ -120,20 +170,20 @@
|
|||
],
|
||||
"description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter",
|
||||
"homepage": "https://github.com/dompdf/dompdf",
|
||||
"time": "2016-05-11T00:36:29+00:00"
|
||||
"time": "2017-02-16T02:40:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v2.0.0",
|
||||
"version": "v2.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
|
||||
"reference": "f3baf72eb2f58bf275b372540f5b47d25aed910f"
|
||||
"reference": "c7de769d7b44f2c9de68e1f678b65efd8126f60b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/f3baf72eb2f58bf275b372540f5b47d25aed910f",
|
||||
"reference": "f3baf72eb2f58bf275b372540f5b47d25aed910f",
|
||||
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c7de769d7b44f2c9de68e1f678b65efd8126f60b",
|
||||
"reference": "c7de769d7b44f2c9de68e1f678b65efd8126f60b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -145,6 +195,8 @@
|
|||
"symfony/filesystem": "^2.4 || ^3.0",
|
||||
"symfony/finder": "^2.2 || ^3.0",
|
||||
"symfony/polyfill-php54": "^1.0",
|
||||
"symfony/polyfill-php55": "^1.3",
|
||||
"symfony/polyfill-xml": "^1.3",
|
||||
"symfony/process": "^2.3 || ^3.0",
|
||||
"symfony/stopwatch": "^2.5 || ^3.0"
|
||||
},
|
||||
|
@ -153,18 +205,18 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"gecko-packages/gecko-php-unit": "^2.0",
|
||||
"phpunit/phpunit": "^4.5|^5",
|
||||
"satooshi/php-coveralls": "^1.0"
|
||||
"justinrainbow/json-schema": "^5.0",
|
||||
"phpunit/phpunit": "^4.5 || ^5.0",
|
||||
"satooshi/php-coveralls": "^1.0",
|
||||
"symfony/phpunit-bridge": "^3.2"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-xml": "For better performance."
|
||||
},
|
||||
"bin": [
|
||||
"php-cs-fixer"
|
||||
],
|
||||
"type": "application",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpCsFixer\\": "src/"
|
||||
|
@ -185,7 +237,49 @@
|
|||
}
|
||||
],
|
||||
"description": "A tool to automatically fix PHP code style",
|
||||
"time": "2016-12-01T06:18:06+00:00"
|
||||
"time": "2017-03-15T17:13:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ircmaxell/password-compat",
|
||||
"version": "v1.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ircmaxell/password_compat.git",
|
||||
"reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c",
|
||||
"reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/password.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Anthony Ferrara",
|
||||
"email": "ircmaxell@php.net",
|
||||
"homepage": "http://blog.ircmaxell.com"
|
||||
}
|
||||
],
|
||||
"description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash",
|
||||
"homepage": "https://github.com/ircmaxell/password_compat",
|
||||
"keywords": [
|
||||
"hashing",
|
||||
"password"
|
||||
],
|
||||
"time": "2014-11-20T16:49:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mpdf/mpdf",
|
||||
|
@ -240,16 +334,16 @@
|
|||
},
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.5.5",
|
||||
"version": "1.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||
"reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108"
|
||||
"reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/399c1f9781e222f6eb6cc238796f5200d1b7f108",
|
||||
"reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/5a5a9fc8025a08d8919be87d6884d5a92520cefe",
|
||||
"reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -278,26 +372,29 @@
|
|||
"object",
|
||||
"object graph"
|
||||
],
|
||||
"time": "2016-10-31T17:19:45+00:00"
|
||||
"time": "2017-01-26T22:05:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phenx/php-font-lib",
|
||||
"version": "0.4",
|
||||
"version": "0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PhenX/php-font-lib.git",
|
||||
"reference": "b8af0cacdc3cbf1e41a586fcb78f506f4121a088"
|
||||
"reference": "19ad2bebc35be028fcc0221025fcbf3d436a3962"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PhenX/php-font-lib/zipball/b8af0cacdc3cbf1e41a586fcb78f506f4121a088",
|
||||
"reference": "b8af0cacdc3cbf1e41a586fcb78f506f4121a088",
|
||||
"url": "https://api.github.com/repos/PhenX/php-font-lib/zipball/19ad2bebc35be028fcc0221025fcbf3d436a3962",
|
||||
"reference": "19ad2bebc35be028fcc0221025fcbf3d436a3962",
|
||||
"shasum": ""
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"FontLib\\": "src/"
|
||||
"psr-4": {
|
||||
"FontLib\\": "src/FontLib"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -312,22 +409,25 @@
|
|||
],
|
||||
"description": "A library to read, parse, export and make subsets of different types of font files.",
|
||||
"homepage": "https://github.com/PhenX/php-font-lib",
|
||||
"time": "2015-05-06T20:02:39+00:00"
|
||||
"time": "2017-02-11T10:58:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phenx/php-svg-lib",
|
||||
"version": "0.1",
|
||||
"version": "v0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PhenX/php-svg-lib.git",
|
||||
"reference": "b419766515b3426c6da74b0e29e93d71c4f17099"
|
||||
"reference": "de291bec8449b89acfe85691b5c71434797959dc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PhenX/php-svg-lib/zipball/b419766515b3426c6da74b0e29e93d71c4f17099",
|
||||
"reference": "b419766515b3426c6da74b0e29e93d71c4f17099",
|
||||
"url": "https://api.github.com/repos/PhenX/php-svg-lib/zipball/de291bec8449b89acfe85691b5c71434797959dc",
|
||||
"reference": "de291bec8449b89acfe85691b5c71434797959dc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"sabberworm/php-css-parser": "6.0.*"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
|
@ -346,7 +446,7 @@
|
|||
],
|
||||
"description": "A library to read, parse and export to PDF SVG files.",
|
||||
"homepage": "https://github.com/PhenX/php-svg-lib",
|
||||
"time": "2015-05-06T18:49:49+00:00"
|
||||
"time": "2016-12-13T20:25:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
|
@ -496,27 +596,27 @@
|
|||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
"version": "v1.6.2",
|
||||
"version": "v1.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/prophecy.git",
|
||||
"reference": "6c52c2722f8460122f96f86346600e1077ce22cb"
|
||||
"reference": "93d39f1f7f9326d746203c7c056f300f7f126073"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/6c52c2722f8460122f96f86346600e1077ce22cb",
|
||||
"reference": "6c52c2722f8460122f96f86346600e1077ce22cb",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073",
|
||||
"reference": "93d39f1f7f9326d746203c7c056f300f7f126073",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/instantiator": "^1.0.2",
|
||||
"php": "^5.3|^7.0",
|
||||
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2",
|
||||
"sebastian/comparator": "^1.1",
|
||||
"sebastian/recursion-context": "^1.0|^2.0"
|
||||
"sebastian/comparator": "^1.1|^2.0",
|
||||
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^2.0",
|
||||
"phpspec/phpspec": "^2.5|^3.2",
|
||||
"phpunit/phpunit": "^4.8 || ^5.6.5"
|
||||
},
|
||||
"type": "library",
|
||||
|
@ -555,39 +655,39 @@
|
|||
"spy",
|
||||
"stub"
|
||||
],
|
||||
"time": "2016-11-21T14:58:47+00:00"
|
||||
"time": "2017-03-02T20:05:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "4.0.5",
|
||||
"version": "4.0.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "c19cfc7cbb0e9338d8c469c7eedecc2a428b0971"
|
||||
"reference": "09e2277d14ea467e5a984010f501343ef29ffc69"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c19cfc7cbb0e9338d8c469c7eedecc2a428b0971",
|
||||
"reference": "c19cfc7cbb0e9338d8c469c7eedecc2a428b0971",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/09e2277d14ea467e5a984010f501343ef29ffc69",
|
||||
"reference": "09e2277d14ea467e5a984010f501343ef29ffc69",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"php": "^5.6 || ^7.0",
|
||||
"phpunit/php-file-iterator": "~1.3",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-token-stream": "^1.4.2",
|
||||
"sebastian/code-unit-reverse-lookup": "~1.0",
|
||||
"phpunit/php-file-iterator": "^1.3",
|
||||
"phpunit/php-text-template": "^1.2",
|
||||
"phpunit/php-token-stream": "^1.4.2 || ^2.0",
|
||||
"sebastian/code-unit-reverse-lookup": "^1.0",
|
||||
"sebastian/environment": "^1.3.2 || ^2.0",
|
||||
"sebastian/version": "~1.0|~2.0"
|
||||
"sebastian/version": "^1.0 || ^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-xdebug": ">=2.1.4",
|
||||
"phpunit/phpunit": "^5.4"
|
||||
"ext-xdebug": "^2.1.4",
|
||||
"phpunit/phpunit": "^5.7"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-dom": "*",
|
||||
"ext-xdebug": ">=2.4.0",
|
||||
"ext-xmlwriter": "*"
|
||||
"ext-xdebug": "^2.5.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
|
@ -618,7 +718,7 @@
|
|||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2017-01-20T15:06:43+00:00"
|
||||
"time": "2017-03-01T09:12:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
|
@ -710,25 +810,30 @@
|
|||
},
|
||||
{
|
||||
"name": "phpunit/php-timer",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-timer.git",
|
||||
"reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260"
|
||||
"reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260",
|
||||
"reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
|
||||
"reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": "^5.3.3 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4|~5"
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
|
@ -750,20 +855,20 @@
|
|||
"keywords": [
|
||||
"timer"
|
||||
],
|
||||
"time": "2016-05-12T18:03:57+00:00"
|
||||
"time": "2017-02-26T11:10:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-token-stream",
|
||||
"version": "1.4.9",
|
||||
"version": "1.4.11",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
|
||||
"reference": "3b402f65a4cc90abf6e1104e388b896ce209631b"
|
||||
"reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3b402f65a4cc90abf6e1104e388b896ce209631b",
|
||||
"reference": "3b402f65a4cc90abf6e1104e388b896ce209631b",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7",
|
||||
"reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -799,20 +904,20 @@
|
|||
"keywords": [
|
||||
"tokenizer"
|
||||
],
|
||||
"time": "2016-11-15T14:06:22+00:00"
|
||||
"time": "2017-02-27T10:12:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "5.7.6",
|
||||
"version": "5.7.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "caf8141b89691498d91aaac6c82e9cd5f685ae86"
|
||||
"reference": "68752b665d3875f9a38a357e3ecb35c79f8673bf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/caf8141b89691498d91aaac6c82e9cd5f685ae86",
|
||||
"reference": "caf8141b89691498d91aaac6c82e9cd5f685ae86",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/68752b665d3875f9a38a357e3ecb35c79f8673bf",
|
||||
"reference": "68752b665d3875f9a38a357e3ecb35c79f8673bf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -829,14 +934,14 @@
|
|||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-timer": "^1.0.6",
|
||||
"phpunit/phpunit-mock-objects": "^3.2",
|
||||
"sebastian/comparator": "~1.2.2",
|
||||
"sebastian/comparator": "^1.2.4",
|
||||
"sebastian/diff": "~1.2",
|
||||
"sebastian/environment": "^1.3.4 || ^2.0",
|
||||
"sebastian/exporter": "~2.0",
|
||||
"sebastian/global-state": "^1.0 || ^2.0",
|
||||
"sebastian/global-state": "^1.1",
|
||||
"sebastian/object-enumerator": "~2.0",
|
||||
"sebastian/resource-operations": "~1.0",
|
||||
"sebastian/version": "~1.0|~2.0",
|
||||
"sebastian/version": "~1.0.3|~2.0",
|
||||
"symfony/yaml": "~2.1|~3.0"
|
||||
},
|
||||
"conflict": {
|
||||
|
@ -881,7 +986,7 @@
|
|||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2017-01-22T08:39:59+00:00"
|
||||
"time": "2017-03-19T16:52:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
|
@ -990,24 +1095,65 @@
|
|||
"time": "2016-10-10T12:19:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/code-unit-reverse-lookup",
|
||||
"version": "1.0.0",
|
||||
"name": "sabberworm/php-css-parser",
|
||||
"version": "6.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
|
||||
"reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe"
|
||||
"url": "https://github.com/sabberworm/PHP-CSS-Parser.git",
|
||||
"reference": "9ea4b00c569b19f731d0c2e0e802055877ff40c2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe",
|
||||
"reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe",
|
||||
"url": "https://api.github.com/repos/sabberworm/PHP-CSS-Parser/zipball/9ea4b00c569b19f731d0c2e0e802055877ff40c2",
|
||||
"reference": "9ea4b00c569b19f731d0c2e0e802055877ff40c2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6"
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Sabberworm\\CSS": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Raphael Schweikert"
|
||||
}
|
||||
],
|
||||
"description": "Parser for CSS Files written in PHP",
|
||||
"homepage": "http://www.sabberworm.com/blog/2010/6/10/php-css-parser",
|
||||
"keywords": [
|
||||
"css",
|
||||
"parser",
|
||||
"stylesheet"
|
||||
],
|
||||
"time": "2015-08-24T08:48:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/code-unit-reverse-lookup",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
|
||||
"reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
|
||||
"reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~5"
|
||||
"phpunit/phpunit": "^5.7 || ^6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
|
@ -1032,20 +1178,20 @@
|
|||
],
|
||||
"description": "Looks up which function or method a line of code belongs to",
|
||||
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
|
||||
"time": "2016-02-13T06:45:14+00:00"
|
||||
"time": "2017-03-04T06:30:41+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
"version": "1.2.2",
|
||||
"version": "1.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||
"reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f"
|
||||
"reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/6a1ed12e8b2409076ab22e3897126211ff8b1f7f",
|
||||
"reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be",
|
||||
"reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1096,7 +1242,7 @@
|
|||
"compare",
|
||||
"equality"
|
||||
],
|
||||
"time": "2016-11-19T09:18:40+00:00"
|
||||
"time": "2017-01-29T09:50:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/diff",
|
||||
|
@ -1320,16 +1466,16 @@
|
|||
},
|
||||
{
|
||||
"name": "sebastian/object-enumerator",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/object-enumerator.git",
|
||||
"reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35"
|
||||
"reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35",
|
||||
"reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7",
|
||||
"reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1362,7 +1508,7 @@
|
|||
],
|
||||
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
|
||||
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
|
||||
"time": "2016-11-19T07:35:10+00:00"
|
||||
"time": "2017-02-18T15:18:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/recursion-context",
|
||||
|
@ -1553,16 +1699,16 @@
|
|||
},
|
||||
{
|
||||
"name": "squizlabs/php_codesniffer",
|
||||
"version": "2.7.1",
|
||||
"version": "2.8.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
||||
"reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f"
|
||||
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9b324f3a1132459a7274a0ace2e1b766ba80930f",
|
||||
"reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f",
|
||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d",
|
||||
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1627,20 +1773,20 @@
|
|||
"phpcs",
|
||||
"standards"
|
||||
],
|
||||
"time": "2016-11-30T04:02:31+00:00"
|
||||
"time": "2017-03-01T22:17:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "4f9e449e76996adf310498a8ca955c6deebe29dd"
|
||||
"reference": "28fb243a2b5727774ca309ec2d92da240f1af0dd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/4f9e449e76996adf310498a8ca955c6deebe29dd",
|
||||
"reference": "4f9e449e76996adf310498a8ca955c6deebe29dd",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/28fb243a2b5727774ca309ec2d92da240f1af0dd",
|
||||
"reference": "28fb243a2b5727774ca309ec2d92da240f1af0dd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1690,20 +1836,20 @@
|
|||
],
|
||||
"description": "Symfony Console Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-08T20:47:33+00:00"
|
||||
"time": "2017-03-06T19:30:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/debug.git",
|
||||
"reference": "810ba5c1c5352a4ddb15d4719e8936751dff0b05"
|
||||
"reference": "b90c9f91ad8ac37d9f114e369042d3226b34dc1a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/debug/zipball/810ba5c1c5352a4ddb15d4719e8936751dff0b05",
|
||||
"reference": "810ba5c1c5352a4ddb15d4719e8936751dff0b05",
|
||||
"url": "https://api.github.com/repos/symfony/debug/zipball/b90c9f91ad8ac37d9f114e369042d3226b34dc1a",
|
||||
"reference": "b90c9f91ad8ac37d9f114e369042d3226b34dc1a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1747,20 +1893,20 @@
|
|||
],
|
||||
"description": "Symfony Debug Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-02T20:32:22+00:00"
|
||||
"time": "2017-02-18T17:28:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
"reference": "9137eb3a3328e413212826d63eeeb0217836e2b6"
|
||||
"reference": "b7a1b9e0a0f623ce43b4c8d775eb138f190c9d8d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9137eb3a3328e413212826d63eeeb0217836e2b6",
|
||||
"reference": "9137eb3a3328e413212826d63eeeb0217836e2b6",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b7a1b9e0a0f623ce43b4c8d775eb138f190c9d8d",
|
||||
"reference": "b7a1b9e0a0f623ce43b4c8d775eb138f190c9d8d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1807,20 +1953,20 @@
|
|||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-02T20:32:22+00:00"
|
||||
"time": "2017-02-21T09:12:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/filesystem.git",
|
||||
"reference": "a0c6ef2dc78d33b58d91d3a49f49797a184d06f4"
|
||||
"reference": "bc0f17bed914df2cceb989972c3b996043c4da4a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/filesystem/zipball/a0c6ef2dc78d33b58d91d3a49f49797a184d06f4",
|
||||
"reference": "a0c6ef2dc78d33b58d91d3a49f49797a184d06f4",
|
||||
"url": "https://api.github.com/repos/symfony/filesystem/zipball/bc0f17bed914df2cceb989972c3b996043c4da4a",
|
||||
"reference": "bc0f17bed914df2cceb989972c3b996043c4da4a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1856,20 +2002,20 @@
|
|||
],
|
||||
"description": "Symfony Filesystem Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-08T20:47:33+00:00"
|
||||
"time": "2017-03-06T19:30:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
"reference": "8c71141cae8e2957946b403cc71a67213c0380d6"
|
||||
"reference": "92d7476d2df60cd851a3e13e078664b1deb8ce10"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/8c71141cae8e2957946b403cc71a67213c0380d6",
|
||||
"reference": "8c71141cae8e2957946b403cc71a67213c0380d6",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/92d7476d2df60cd851a3e13e078664b1deb8ce10",
|
||||
"reference": "92d7476d2df60cd851a3e13e078664b1deb8ce10",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1905,7 +2051,7 @@
|
|||
],
|
||||
"description": "Symfony Finder Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-02T20:32:22+00:00"
|
||||
"time": "2017-02-21T09:12:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
|
@ -2025,17 +2171,131 @@
|
|||
"time": "2016-11-14T01:06:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v3.2.2",
|
||||
"name": "symfony/polyfill-php55",
|
||||
"version": "v1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "350e810019fc52dd06ae844b6a6d382f8a0e8893"
|
||||
"url": "https://github.com/symfony/polyfill-php55.git",
|
||||
"reference": "03e3f0350bca2220e3623a0e340eef194405fc67"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/350e810019fc52dd06ae844b6a6d382f8a0e8893",
|
||||
"reference": "350e810019fc52dd06ae844b6a6d382f8a0e8893",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/03e3f0350bca2220e3623a0e340eef194405fc67",
|
||||
"reference": "03e3f0350bca2220e3623a0e340eef194405fc67",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ircmaxell/password-compat": "~1.0",
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php55\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2016-11-14T01:06:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-xml",
|
||||
"version": "v1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-xml.git",
|
||||
"reference": "64b6a864f18ab4fddad49f5025f805f6781dfabd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-xml/zipball/64b6a864f18ab4fddad49f5025f805f6781dfabd",
|
||||
"reference": "64b6a864f18ab4fddad49f5025f805f6781dfabd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-xml": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Xml\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for xml's utf8_encode and utf8_decode functions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2016-11-14T01:06:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v3.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "68bfa8c83f24c0ac04ea7193bcdcda4519f41892"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/68bfa8c83f24c0ac04ea7193bcdcda4519f41892",
|
||||
"reference": "68bfa8c83f24c0ac04ea7193bcdcda4519f41892",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2071,20 +2331,20 @@
|
|||
],
|
||||
"description": "Symfony Process Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-02T20:32:22+00:00"
|
||||
"time": "2017-03-04T12:23:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/stopwatch",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/stopwatch.git",
|
||||
"reference": "9aa0b51889c01bca474853ef76e9394b02264464"
|
||||
"reference": "c5ee0f8650c84b4d36a5f76b3b504233feaabf75"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/9aa0b51889c01bca474853ef76e9394b02264464",
|
||||
"reference": "9aa0b51889c01bca474853ef76e9394b02264464",
|
||||
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/c5ee0f8650c84b4d36a5f76b3b504233feaabf75",
|
||||
"reference": "c5ee0f8650c84b4d36a5f76b3b504233feaabf75",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2120,20 +2380,20 @@
|
|||
],
|
||||
"description": "Symfony Stopwatch Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-02T20:32:22+00:00"
|
||||
"time": "2017-02-18T17:28:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "50eadbd7926e31842893c957eca362b21592a97d"
|
||||
"reference": "093e416ad096355149e265ea2e4cc1f9ee40ab1a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/50eadbd7926e31842893c957eca362b21592a97d",
|
||||
"reference": "50eadbd7926e31842893c957eca362b21592a97d",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/093e416ad096355149e265ea2e4cc1f9ee40ab1a",
|
||||
"reference": "093e416ad096355149e265ea2e4cc1f9ee40ab1a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2175,7 +2435,7 @@
|
|||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-03T13:51:32+00:00"
|
||||
"time": "2017-03-07T16:47:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tecnickcom/tcpdf",
|
||||
|
@ -2301,7 +2561,8 @@
|
|||
"ext-mbstring": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlwriter": "*"
|
||||
"ext-xmlwriter": "*",
|
||||
"ext-zip": "*"
|
||||
},
|
||||
"platform-dev": []
|
||||
}
|
||||
|
|
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Returns the average of selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
include 'PHPExcel.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
$spreadsheet = new PHPExcel();
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Counts the cells that contain numbers in a database.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
include 'PHPExcel.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
$spreadsheet = new PHPExcel();
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Extracts a single value from a column of a list or database that matches conditions that you specify.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
include 'PHPExcel.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
$spreadsheet = new PHPExcel();
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Returns the maximum value from selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
include 'PHPExcel.php';
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new PHPExcel();
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Returns the minimum value from selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
include 'PHPExcel.php';
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new PHPExcel();
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Multiplies the values in a column of a list or database that match conditions that you specify.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
include 'PHPExcel.php';
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new PHPExcel();
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Estimates the standard deviation based on a sample of selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
include 'PHPExcel.php';
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new PHPExcel();
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Calculates the standard deviation based on the entire population of selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
include 'PHPExcel.php';
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new PHPExcel();
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Estimates variance based on a sample from selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
include 'PHPExcel.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
$spreadsheet = new PhpSpreadsheet();
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -10,7 +10,7 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Calculation Examples</title>
|
||||
<title>PhpSpreadsheet Calculation Examples</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Calculates variance based on the entire population of selected database entries,</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
/** Include PHPExcel */
|
||||
include 'PHPExcel.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
$spreadsheet = new PHPExcel();
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -10,7 +10,7 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Calculation Examples</title>
|
||||
<title>PhpSpreadsheet Calculation Examples</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Returns the serial number of a particular date.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
/** Include PHPExcel */
|
||||
include 'PHPExcel.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
$spreadsheet = new PHPExcel();
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -77,3 +73,5 @@ echo '<hr />';
|
|||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -10,7 +10,7 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Calculation Examples</title>
|
||||
<title>PhpSpreadsheet Calculation Examples</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Converts a date in the form of text to a serial number.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
/** Include PHPExcel */
|
||||
include 'PHPExcel.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
$spreadsheet = new PHPExcel();
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -51,7 +47,7 @@ echo '<hr />';
|
|||
|
||||
// Test the formulae
|
||||
?>
|
||||
<p><strong>Warning: </strong>The PHPExcel DATEVALUE() function accepts a wider range of date formats than MS Excel's DATEFORMAT() function.</p>
|
||||
<p><strong>Warning: </strong>The PhpSpreadsheet DATEVALUE() function accepts a wider range of date formats than MS Excel's DATEFORMAT() function.</p>
|
||||
<table border="1" cellspacing="0">
|
||||
<tr>
|
||||
<th>Date String</th>
|
||||
|
@ -70,3 +66,5 @@ echo '<hr />';
|
|||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -10,7 +10,7 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Calculation Examples</title>
|
||||
<title>PhpSpreadsheet Calculation Examples</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Returns the serial number of a particular time.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
/** Include PHPExcel */
|
||||
include 'PHPExcel.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
$spreadsheet = new PHPExcel();
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -75,3 +71,5 @@ echo '<hr />';
|
|||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -10,7 +10,7 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Calculation Examples</title>
|
||||
<title>PhpSpreadsheet Calculation Examples</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -19,14 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h2>Converts a time in the form of text to a serial number.</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
/** Include PHPExcel */
|
||||
include 'PHPExcel.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
$spreadsheet = new PHPExcel();
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -66,3 +62,5 @@ echo '<hr />';
|
|||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -10,14 +10,14 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Calculation Function Examples</title>
|
||||
<title>PhpSpreadsheet Calculation Function Examples</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
echo '<h1>PHPExcel Calculation Function Examples</h1>';
|
||||
echo '<h1>PhpSpreadsheet Calculation Function Examples</h1>';
|
||||
|
||||
$exampleTypeList = glob('./*', GLOB_ONLYDIR);
|
||||
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #01</title>
|
||||
<title>PhpSpreadsheet Reader Example #01</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #01</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #01</h1>
|
||||
<h2>Simple File Reader using \PhpOffice\PhpSpreadsheet\IOFactory::load()</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
|
||||
|
|
|
@ -5,23 +5,19 @@ set_time_limit(0);
|
|||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/* Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #02</title>
|
||||
<title>PhpSpreadsheet Reader Example #02</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #02</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #02</h1>
|
||||
<h2>Simple File Reader using a Specified Reader</h2>
|
||||
<?php
|
||||
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #03</title>
|
||||
<title>PhpSpreadsheet Reader Example #03</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #03</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #03</h1>
|
||||
<h2>Simple File Reader using the \PhpOffice\PhpSpreadsheet\IOFactory to Return a Reader</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #04</title>
|
||||
<title>PhpSpreadsheet Reader Example #04</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #04</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #04</h1>
|
||||
<h2>Simple File Reader using the \PhpOffice\PhpSpreadsheet\IOFactory to Identify a Reader to Use</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #05</title>
|
||||
<title>PhpSpreadsheet Reader Example #05</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #05</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #05</h1>
|
||||
<h2>Simple File Reader using the "Read Data Only" Option</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #06</title>
|
||||
<title>PhpSpreadsheet Reader Example #06</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #06</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #06</h1>
|
||||
<h2>Simple File Reader Loading All WorkSheets</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #07</title>
|
||||
<title>PhpSpreadsheet Reader Example #07</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #07</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #07</h1>
|
||||
<h2>Simple File Reader Loading a Single Named WorkSheet</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #08</title>
|
||||
<title>PhpSpreadsheet Reader Example #08</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #08</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #08</h1>
|
||||
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #09</title>
|
||||
<title>PhpSpreadsheet Reader Example #09</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #09</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #09</h1>
|
||||
<h2>Simple File Reader Using a Read Filter</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #10</title>
|
||||
<title>PhpSpreadsheet Reader Example #10</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #10</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #10</h1>
|
||||
<h2>Simple File Reader Using a Configurable Read Filter</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #11</title>
|
||||
<title>PhpSpreadsheet Reader Example #11</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #11</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #11</h1>
|
||||
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 1)</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
@ -78,7 +74,7 @@ for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
|||
$chunkFilter = new chunkReadFilter($startRow, $chunkSize);
|
||||
/* Tell the Reader that we want to use the new Read Filter that we've just Instantiated **/
|
||||
$reader->setReadFilter($chunkFilter);
|
||||
/* Load only the rows that match our filter from $inputFileName to a PHPExcel Object **/
|
||||
/* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object **/
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
// Do some processing here
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #12</title>
|
||||
<title>PhpSpreadsheet Reader Example #12</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #12</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #12</h1>
|
||||
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 2)</h2>
|
||||
<?php
|
||||
|
||||
/** Set Include path to point at the PHPExcel Classes folder **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** Include \PhpOffice\PhpSpreadsheet\IOFactory **/
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
@ -81,7 +77,7 @@ for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
|||
echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '<br />';
|
||||
/* Tell the Read Filter, the limits on which rows we want to read this iteration **/
|
||||
$chunkFilter->setRows($startRow, $chunkSize);
|
||||
/* Load only the rows that match our filter from $inputFileName to a PHPExcel Object **/
|
||||
/* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object **/
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
// Do some processing here
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #13</title>
|
||||
<title>PhpSpreadsheet Reader Example #13</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #13</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #13</h1>
|
||||
<h2>Simple File Reader for Multiple CSV Files</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Csv';
|
||||
$inputFileNames = ['./sampleData/example1.csv', './sampleData/example2.csv'];
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #15</title>
|
||||
<title>PhpSpreadsheet Reader Example #14</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #14</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #14</h1>
|
||||
<h2>Reading a Large CSV file in "Chunks" to split across multiple Worksheets</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Csv';
|
||||
$inputFileName = './sampleData/example2.csv';
|
||||
|
@ -69,8 +70,8 @@ $chunkFilter = new chunkReadFilter();
|
|||
$reader->setReadFilter($chunkFilter)
|
||||
->setContiguous(true);
|
||||
|
||||
/* Instantiate a new PHPExcel object manually **/
|
||||
$spreadsheet = new PHPExcel();
|
||||
/* Instantiate a new PhpSpreadsheet object manually **/
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
/* Set a sheet index **/
|
||||
$sheet = 0;
|
||||
|
@ -83,7 +84,7 @@ for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
|||
|
||||
/* Increment the worksheet index pointer for the Reader **/
|
||||
$reader->setSheetIndex($sheet);
|
||||
/* Load only the rows that match our filter into a new worksheet in the PHPExcel Object **/
|
||||
/* Load only the rows that match our filter into a new worksheet in the PhpSpreadsheet Object **/
|
||||
$reader->loadIntoExisting($inputFileName, $spreadsheet);
|
||||
/* Set the worksheet title (to reference the "sheet" of data that we've loaded) **/
|
||||
/* and increment the sheet index as well **/
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #15</title>
|
||||
<title>PhpSpreadsheet Reader Example #15</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #15</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #15</h1>
|
||||
<h2>Simple File Reader for Tab-Separated Value File using the Advanced Value Binder</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
\PhpOffice\PhpSpreadsheet\Cell::setValueBinder(new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder());
|
||||
|
||||
|
|
|
@ -10,26 +10,22 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #16</title>
|
||||
<title>PhpSpreadsheet Reader Example #16</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #16</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #16</h1>
|
||||
<h2>Handling Loader Exceptions using Try/Catch</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileName = './sampleData/example_1.xls';
|
||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
|
||||
try {
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
|
||||
} catch (\PHPExcel\Reader\Exception $e) {
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #17</title>
|
||||
<title>PhpSpreadsheet Reader Example #17</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #17</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #17</h1>
|
||||
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #18</title>
|
||||
<title>PhpSpreadsheet Reader Example #18</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #18</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #18</h1>
|
||||
<h2>Reading list of WorkSheets without loading entire file</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,20 +10,16 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #19</title>
|
||||
<title>PhpSpreadsheet Reader Example #19</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #19</h1>
|
||||
<h1>PhpSpreadsheet Reader Example #19</h1>
|
||||
<h2>Reading WorkSheet information without loading entire file</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
|
|
|
@ -10,27 +10,23 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reading WorkBook Data Example #01</title>
|
||||
<title>PhpSpreadsheet Reading WorkBook Data Example #01</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reading WorkBook Data Example #01</h1>
|
||||
<h1>PhpSpreadsheet Reading WorkBook Data Example #01</h1>
|
||||
<h2>Read the WorkBook Properties</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
/* Create a new Reader of the type defined in $inputFileType **/
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
/* Load $inputFileName to a PHPExcel Object **/
|
||||
/* Load $inputFileName to a PhpSpreadsheet Object **/
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
echo '<hr />';
|
||||
|
|
|
@ -10,27 +10,23 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reading WorkBook Data Example #02</title>
|
||||
<title>PhpSpreadsheet Reading WorkBook Data Example #02</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reading WorkBook Data Example #02</h1>
|
||||
<h1>PhpSpreadsheet Reading WorkBook Data Example #02</h1>
|
||||
<h2>Read a list of Custom Properties for a WorkBook</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xlsx';
|
||||
$inputFileName = './sampleData/example1.xlsx';
|
||||
|
||||
/* Create a new Reader of the type defined in $inputFileType **/
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
/* Load $inputFileName to a PHPExcel Object **/
|
||||
/* Load $inputFileName to a PhpSpreadsheet Object **/
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
echo '<hr />';
|
||||
|
|
|
@ -10,27 +10,23 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reading WorkBook Data Example #03</title>
|
||||
<title>PhpSpreadsheet Reading WorkBook Data Example #03</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reading WorkBook Data Example #03</h1>
|
||||
<h1>PhpSpreadsheet Reading WorkBook Data Example #03</h1>
|
||||
<h2>Read Custom Property Values for a WorkBook</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xlsx';
|
||||
$inputFileName = './sampleData/example1.xlsx';
|
||||
|
||||
/* Create a new Reader of the type defined in $inputFileType **/
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
/* Load $inputFileName to a PHPExcel Object **/
|
||||
/* Load $inputFileName to a PhpSpreadsheet Object **/
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
echo '<hr />';
|
||||
|
|
|
@ -10,38 +10,34 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reading WorkBook Data Example #04</title>
|
||||
<title>PhpSpreadsheet Reading WorkBook Data Example #04</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reading WorkBook Data Example #04</h1>
|
||||
<h1>PhpSpreadsheet Reading WorkBook Data Example #04</h1>
|
||||
<h2>Get a List of the Worksheets in a WorkBook</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** \PhpOffice\PhpSpreadsheet\IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
$inputFileName = './sampleData/example2.xls';
|
||||
|
||||
/* Create a new Reader of the type defined in $inputFileType **/
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
/* Load $inputFileName to a PHPExcel Object **/
|
||||
/* Load $inputFileName to a PhpSpreadsheet Object **/
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo 'Reading the number of Worksheets in the WorkBook<br />';
|
||||
/* Use the PHPExcel object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook */
|
||||
/* Use the PhpSpreadsheet object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook */
|
||||
$sheetCount = $spreadsheet->getSheetCount();
|
||||
echo 'There ',(($sheetCount == 1) ? 'is' : 'are'),' ',$sheetCount,' WorkSheet',(($sheetCount == 1) ? '' : 's'),' in the WorkBook<br /><br />';
|
||||
|
||||
echo 'Reading the names of Worksheets in the WorkBook<br />';
|
||||
/* Use the PHPExcel object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook */
|
||||
/* Use the PhpSpreadsheet object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook */
|
||||
$sheetNames = $spreadsheet->getSheetNames();
|
||||
foreach ($sheetNames as $sheetIndex => $sheetName) {
|
||||
echo 'WorkSheet #',$sheetIndex,' is named "',$sheetName,'"<br />';
|
||||
|
|
|
@ -10,7 +10,7 @@ date_default_timezone_set('Europe/London');
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Examples</title>
|
||||
<title>PhpSpreadsheet Examples</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -20,7 +20,7 @@ date_default_timezone_set('Europe/London');
|
|||
$exampleTypeList = glob('./*', GLOB_ONLYDIR);
|
||||
|
||||
foreach ($exampleTypeList as $exampleType) {
|
||||
echo '<h1>PHPExcel ' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Examples</h1>';
|
||||
echo '<h1>PhpSpreadsheet ' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Examples</h1>';
|
||||
|
||||
$exampleList = glob('./' . $exampleType . '/*.php');
|
||||
|
||||
|
|
49
docs/faq.md
|
@ -1,48 +1,18 @@
|
|||
# Frequently asked questions
|
||||
|
||||
The up-to-date F.A.Q. page for PHPExcel can be found on
|
||||
<http://www.codeplex.com/PHPExcel/Wiki/View.aspx?title=FAQ&referringTitle=Requirements>.
|
||||
|
||||
## There seems to be a problem with character encoding...
|
||||
|
||||
It is necessary to use UTF-8 encoding for all texts in PhpSpreadsheet.
|
||||
If the script uses different encoding then you can convert those texts
|
||||
with PHP's iconv() or mb\_convert\_encoding() functions.
|
||||
|
||||
## PHP complains about ZipArchive not being found
|
||||
|
||||
Make sure you meet all requirements, especially php\_zip extension
|
||||
should be enabled.
|
||||
|
||||
The ZipArchive class is only required when reading or writing formats
|
||||
that use Zip compression (Xlsx and Ods). Since version 1.7.6 the PCLZip
|
||||
library has been bundled with PhpSpreadsheet as an alternative to the
|
||||
ZipArchive class.
|
||||
|
||||
This can be enabled by calling:
|
||||
|
||||
``` php
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setZipClass(\PhpOffice\PhpSpreadsheet\Settings::PCLZIP);
|
||||
```
|
||||
|
||||
*before* calling the save method of the Xlsx Writer.
|
||||
|
||||
You can revert to using ZipArchive by calling:
|
||||
|
||||
``` php
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setZipClass(\PhpOffice\PhpSpreadsheet\Settings::ZIPARCHIVE);
|
||||
```
|
||||
|
||||
At present, this only allows you to write Xlsx files without the need
|
||||
for ZipArchive (not to read Xlsx or Ods)
|
||||
with PHP's `iconv()` or `mb_convert_encoding()` functions.
|
||||
|
||||
## Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate yyy bytes) in zzz on line aaa
|
||||
|
||||
PhpSpreadsheet holds an "in memory" representation of a spreadsheet, so
|
||||
it is susceptible to PHP's memory limitations. The memory made available
|
||||
to PHP can be increased by editing the value of the memory\_limit
|
||||
directive in your php.ini file, or by using ini\_set('memory\_limit',
|
||||
'128M') within your code (ISP permitting).
|
||||
to PHP can be increased by editing the value of the `memory_limit`
|
||||
directive in your php.ini file, or by using
|
||||
`ini_set('memory_limit', '128M')` within your code.
|
||||
|
||||
Some Readers and Writers are faster than others, and they also use
|
||||
differing amounts of memory. You can find some indication of the
|
||||
|
@ -83,8 +53,8 @@ reference](./references/features-cross-reference.md).
|
|||
|
||||
## Formulas don't seem to be calculated in Excel2003 using compatibility pack?
|
||||
|
||||
This is normal behaviour of the compatibility pack, Xlsx displays this
|
||||
correctly. Use \PhpOffice\PhpSpreadsheet\Writer\Xls if you really need
|
||||
This is normal behaviour of the compatibility pack, `Xlsx` displays this
|
||||
correctly. Use `\PhpOffice\PhpSpreadsheet\Writer\Xls` if you really need
|
||||
calculated values, or force recalculation in Excel2003.
|
||||
|
||||
## Setting column width is not 100% accurate
|
||||
|
@ -93,7 +63,8 @@ Trying to set column width, I experience one problem. When I open the
|
|||
file in Excel, the actual width is 0.71 less than it should be.
|
||||
|
||||
The short answer is that PhpSpreadsheet uses a measure where padding is
|
||||
included. See section: "Setting a column's width" for more details.
|
||||
included. See [how to seta column's width](./topics/recipes.md#setting-a-columns-width)
|
||||
for more details.
|
||||
|
||||
## How do I use PhpSpreadsheet with my framework
|
||||
|
||||
|
@ -108,8 +79,8 @@ included. See section: "Setting a column's width" for more details.
|
|||
within CakePHP
|
||||
- Integrating [PhpSpreadsheet into Kohana
|
||||
3](http://www.flynsarmy.com/2010/07/phpexcel-module-for-kohana-3/)
|
||||
and \[Интеграция PHPExcel и Kohana
|
||||
Framework\]\[http://szpargalki.blogspot.com/2011/02/phpexcel-kohana-framework.html\]
|
||||
and [Интеграция PHPExcel и Kohana
|
||||
Framework](http://szpargalki.blogspot.com/2011/02/phpexcel-kohana-framework.html)
|
||||
- Using [PhpSpreadsheet with
|
||||
TYPO3](http://typo3.org/documentation/document-library/extension-manuals/phpexcel_library/1.1.1/view/toc/0/)
|
||||
|
||||
|
|
1644
docs/index.md
|
@ -1,10 +1,15 @@
|
|||
# Features cross reference
|
||||
|
||||
- <span style="text-align: center; color: green;">✔</span> Supported
|
||||
- <span style="text-align: center; color: orange;">●</span> Partially supported
|
||||
- <span style="text-align: center; color: red;">✖</span> Not supported
|
||||
- N/A Cannot be supported
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th colspan="7">Writers</th>
|
||||
<th colspan="5">Writers</th>
|
||||
<th colspan="7">Readers</th>
|
||||
<th colspan="6">Writers</th>
|
||||
<th colspan="2">Methods</th>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -12,12 +17,13 @@
|
|||
<th>XLS</th>
|
||||
<th>XLSX</th>
|
||||
<th>Excel2003XML</th>
|
||||
<th>OOCalc</th>
|
||||
<th>Ods</th>
|
||||
<th>Gnumeric</th>
|
||||
<th>CSV</th>
|
||||
<th>SYLK</th>
|
||||
<th>XLS</th>
|
||||
<th>XLSX</th>
|
||||
<th>Ods</th>
|
||||
<th>CSV</th>
|
||||
<th>HTML</th>
|
||||
<th>PDF</th>
|
||||
|
@ -33,11 +39,12 @@
|
|||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
@ -50,11 +57,12 @@
|
|||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td>$reader->getReadDataOnly()</td>
|
||||
<td>$reader->setReadDataOnly()</td>
|
||||
</tr>
|
||||
|
@ -67,11 +75,12 @@
|
|||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td>$reader->getLoadSheetsOnly()</td>
|
||||
<td>$reader->setLoadSheetsOnly()<br>$reader->setLoadAllSheets()</td>
|
||||
</tr>
|
||||
|
@ -84,11 +93,12 @@
|
|||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">-</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td>$reader->getReadFilter()</td>
|
||||
<td>$reader->setReadFilter()</td>
|
||||
</tr>
|
||||
|
@ -103,6 +113,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: orange;">●</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: orange;">●</td>
|
||||
|
@ -120,6 +131,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: orange;">●</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: orange;">●</td>
|
||||
|
@ -137,6 +149,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
|
@ -154,6 +167,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
|
@ -171,6 +185,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
|
@ -188,6 +203,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
|
@ -205,6 +221,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
|
@ -222,6 +239,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
|
@ -239,6 +257,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
|
@ -256,6 +275,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
|
@ -273,6 +293,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: orange;">●</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -290,6 +311,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -307,6 +329,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -324,6 +347,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -341,6 +365,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -358,6 +383,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -375,6 +401,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -392,6 +419,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -409,6 +437,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -448,6 +477,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Boolean</td>
|
||||
|
@ -465,6 +495,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Integer</td>
|
||||
|
@ -482,6 +513,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Floating Point</td>
|
||||
|
@ -499,6 +531,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">String</td>
|
||||
|
@ -516,6 +549,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Error</td>
|
||||
|
@ -533,6 +567,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Formula</td>
|
||||
|
@ -550,6 +585,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Array</td>
|
||||
|
@ -567,6 +603,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Rich Text</td>
|
||||
|
@ -578,6 +615,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td></td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
|
@ -601,6 +639,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Rows and Column Properties</strong></td>
|
||||
|
@ -618,6 +657,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Row Height/Column Width</td>
|
||||
|
@ -635,6 +675,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Hidden</td>
|
||||
|
@ -652,6 +693,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Worksheet Properties</strong></td>
|
||||
|
@ -669,6 +711,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Frozen Panes</td>
|
||||
|
@ -686,6 +729,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Coloured Tabs</td>
|
||||
|
@ -703,6 +747,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Cell Formatting</strong></td>
|
||||
|
@ -720,6 +765,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Number Format Mask</td>
|
||||
|
@ -737,6 +783,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Alignment</td>
|
||||
|
@ -754,6 +801,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Horizontal</td>
|
||||
|
@ -771,6 +819,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Vertical</td>
|
||||
|
@ -788,6 +837,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Wrapping</td>
|
||||
|
@ -805,6 +855,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Shring-to-Fit</td>
|
||||
|
@ -822,6 +873,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Indent</td>
|
||||
|
@ -839,6 +891,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Background Colour</td>
|
||||
|
@ -856,6 +909,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Patterned</td>
|
||||
|
@ -873,6 +927,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Font Attributes</td>
|
||||
|
@ -885,6 +940,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: orange;">●</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
@ -902,6 +958,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
@ -919,6 +976,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
@ -936,6 +994,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
@ -953,6 +1012,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
@ -970,6 +1030,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
@ -987,6 +1048,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
@ -1004,6 +1066,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
@ -1021,6 +1084,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
@ -1043,6 +1107,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Line Style</td>
|
||||
|
@ -1060,6 +1125,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Position</td>
|
||||
|
@ -1077,6 +1143,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 3em;">Diagonal</td>
|
||||
|
@ -1094,23 +1161,25 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Hyperlinks</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td>$cell->getHyperlink()->getUrl($url)</td>
|
||||
<td>$cell->getHyperlink()->setUrl($url)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">http</td>
|
||||
|
@ -1128,6 +1197,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">Merged Cells</td>
|
||||
|
@ -1145,6 +1215,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Cell Comments</strong></td>
|
||||
|
@ -1157,6 +1228,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: orange;">●</td>
|
||||
<td style="text-align: center; color: orange;">●</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
|
@ -1174,6 +1246,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
|
@ -1191,6 +1264,7 @@
|
|||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td></td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
|
@ -1199,20 +1273,21 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><strong>Cell Validation</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td style="text-align: center;">N/A</td>
|
||||
<td>$cell->getDataValidation()</td>
|
||||
<td>$cell->setDataValidation()</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>AutoFilters</strong></td>
|
||||
|
@ -1228,8 +1303,9 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>$spreadsheet->getActivesheet()->getAutoFilter()</td>
|
||||
<td>$spreadsheet->getActivesheet()->setAutoFilter()</td>
|
||||
<td></td>
|
||||
<td>$sheet->getAutoFilter()</td>
|
||||
<td>$sheet->setAutoFilter()</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 1em;">AutoFilter Expressions</td>
|
||||
|
@ -1247,6 +1323,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Filter</td>
|
||||
|
@ -1264,6 +1341,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Custom Filter</td>
|
||||
|
@ -1281,6 +1359,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">DateGroup Filter</td>
|
||||
|
@ -1298,6 +1377,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Dynamic Filter</td>
|
||||
|
@ -1315,6 +1395,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Colour Filter</td>
|
||||
|
@ -1332,6 +1413,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Icon Filter</td>
|
||||
|
@ -1349,6 +1431,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 2em;">Top 10 Filter</td>
|
||||
|
@ -1366,6 +1449,49 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Macros</strong></td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: green;">✔</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td style="text-align: center; color: red;">✖</td>
|
||||
<td>$spreadsheet->getMacrosCode();</td>
|
||||
<td>$spreadsheet->setMacrosCode();</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>XLS</th>
|
||||
<th>XLSX</th>
|
||||
<th>Excel2003XML</th>
|
||||
<th>Ods</th>
|
||||
<th>Gnumeric</th>
|
||||
<th>CSV</th>
|
||||
<th>SYLK</th>
|
||||
<th>XLS</th>
|
||||
<th>XLSX</th>
|
||||
<th>Ods</th>
|
||||
<th>CSV</th>
|
||||
<th>HTML</th>
|
||||
<th>PDF</th>
|
||||
<th>Getters</th>
|
||||
<th>Setters</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th colspan="7">Readers</th>
|
||||
<th colspan="6">Writers</th>
|
||||
<th colspan="2">Methods</th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -0,0 +1,482 @@
|
|||
# Accessing cells
|
||||
|
||||
Accessing cells in a Spreadsheet should be pretty straightforward. This
|
||||
topic lists some of the options to access a cell.
|
||||
|
||||
## Setting a cell value by coordinate
|
||||
|
||||
Setting a cell value by coordinate can be done using the worksheet's
|
||||
`setCellValue()` method.
|
||||
|
||||
``` php
|
||||
// Set cell A1 with a string value
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A1', 'PhpSpreadsheet');
|
||||
|
||||
// Set cell A2 with a numeric value
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A2', 12345.6789);
|
||||
|
||||
// Set cell A3 with a boolean value
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A3', TRUE);
|
||||
|
||||
// Set cell A4 with a formula
|
||||
$spreadsheet->getActiveSheet()->setCellValue(
|
||||
'A4',
|
||||
'=IF(A3, CONCATENATE(A1, " ", A2), CONCATENATE(A2, " ", A1))'
|
||||
);
|
||||
```
|
||||
|
||||
Alternatively, you can retrieve the cell object, and then call the
|
||||
cell’s `setValue()` method:
|
||||
|
||||
``` php
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getCell('B8')
|
||||
->setValue('Some value');
|
||||
```
|
||||
|
||||
## Excel DataTypes
|
||||
|
||||
MS Excel supports 7 basic datatypes:
|
||||
|
||||
- string
|
||||
- number
|
||||
- boolean
|
||||
- null
|
||||
- formula
|
||||
- error
|
||||
- Inline (or rich text) string
|
||||
|
||||
By default, when you call the worksheet's `setCellValue()` method or the
|
||||
cell's `setValue()` method, PhpSpreadsheet will use the appropriate
|
||||
datatype for PHP nulls, booleans, floats or integers; or cast any string
|
||||
data value that you pass to the method into the most appropriate
|
||||
datatype, so numeric strings will be cast to numbers, while string
|
||||
values beginning with `=` will be converted to a formula. Strings that
|
||||
aren't numeric, or that don't begin with a leading `=` will be treated
|
||||
as genuine string values.
|
||||
|
||||
This "conversion" is handled by a cell "value binder", and you can write
|
||||
custom "value binders" to change the behaviour of these "conversions".
|
||||
The standard PhpSpreadsheet package also provides an "advanced value
|
||||
binder" that handles a number of more complex conversions, such as
|
||||
converting strings with a fractional format like "3/4" to a number value
|
||||
(0.75 in this case) and setting an appropriate "fraction" number format
|
||||
mask. Similarly, strings like "5%" will be converted to a value of 0.05,
|
||||
and a percentage number format mask applied, and strings containing
|
||||
values that look like dates will be converted to Excel serialized
|
||||
datetimestamp values, and a corresponding mask applied. This is
|
||||
particularly useful when loading data from csv files, or setting cell
|
||||
values from a database.
|
||||
|
||||
Formats handled by the advanced value binder include:
|
||||
|
||||
- TRUE or FALSE (dependent on locale settings) are converted to booleans.
|
||||
- Numeric strings identified as scientific (exponential) format are
|
||||
converted to numbers.
|
||||
- Fractions and vulgar fractions are converted to numbers, and
|
||||
an appropriate number format mask applied.
|
||||
- Percentages are converted
|
||||
to numbers, divided by 100, and an appropriate number format mask
|
||||
applied.
|
||||
- Dates and times are converted to Excel timestamp values
|
||||
(numbers), and an appropriate number format mask applied.
|
||||
- When strings contain a newline character (`\n`), then the cell styling is
|
||||
set to wrap.
|
||||
|
||||
You can read more about value binders later in this section of the
|
||||
documentation.
|
||||
|
||||
### Setting a date and/or time value in a cell
|
||||
|
||||
Date or time values are held as timestamp in Excel (a simple floating
|
||||
point value), and a number format mask is used to show how that value
|
||||
should be formatted; so if we want to store a date in a cell, we need to
|
||||
calculate the correct Excel timestamp, and set a number format mask.
|
||||
|
||||
``` php
|
||||
// Get the current date/time and convert to an Excel date/time
|
||||
$dateTimeNow = time();
|
||||
$excelDateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel( $dateTimeNow );
|
||||
// Set cell A6 with the Excel date/time value
|
||||
$spreadsheet->getActiveSheet()->setCellValue(
|
||||
'A6',
|
||||
$excelDateValue
|
||||
);
|
||||
// Set the number format mask so that the excel timestamp will be displayed as a human-readable date/time
|
||||
$spreadsheet->getActiveSheet()->getStyle('A6')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(
|
||||
\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME
|
||||
);
|
||||
```
|
||||
|
||||
### Setting a number with leading zeroes
|
||||
|
||||
By default, PhpSpreadsheet will automatically detect the value type and
|
||||
set it to the appropriate Excel numeric datatype. This type conversion
|
||||
is handled by a value binder, as described in the section of this
|
||||
document entitled "Using value binders to facilitate data entry".
|
||||
|
||||
Numbers don't have leading zeroes, so if you try to set a numeric value
|
||||
that does have leading zeroes (such as a telephone number) then these
|
||||
will be normally be lost as the value is cast to a number, so
|
||||
"01513789642" will be displayed as 1513789642.
|
||||
|
||||
There are two ways you can force PhpSpreadsheet to override this
|
||||
behaviour.
|
||||
|
||||
Firstly, you can set the datatype explicitly as a string so that it is
|
||||
not converted to a number.
|
||||
|
||||
``` php
|
||||
// Set cell A8 with a numeric value, but tell PhpSpreadsheet it should be treated as a string
|
||||
$spreadsheet->getActiveSheet()->setCellValueExplicit(
|
||||
'A8',
|
||||
"01513789642",
|
||||
\PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING
|
||||
);
|
||||
```
|
||||
|
||||
Alternatively, you can use a number format mask to display the value
|
||||
with leading zeroes.
|
||||
|
||||
``` php
|
||||
// Set cell A9 with a numeric value
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A9', 1513789642);
|
||||
// Set a number format mask to display the value as 11 digits with leading zeroes
|
||||
$spreadsheet->getActiveSheet()->getStyle('A9')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(
|
||||
'00000000000'
|
||||
);
|
||||
```
|
||||
|
||||
With number format masking, you can even break up the digits into groups
|
||||
to make the value more easily readable.
|
||||
|
||||
``` php
|
||||
// Set cell A10 with a numeric value
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A10', 1513789642);
|
||||
// Set a number format mask to display the value as 11 digits with leading zeroes
|
||||
$spreadsheet->getActiveSheet()->getStyle('A10')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(
|
||||
'0000-000-0000'
|
||||
);
|
||||
```
|
||||
|
||||
![07-simple-example-1.png](./images/07-simple-example-1.png)
|
||||
|
||||
**Note** that not all complex format masks such as this one will work
|
||||
when retrieving a formatted value to display "on screen", or for certain
|
||||
writers such as HTML or PDF, but it will work with the true spreadsheet
|
||||
writers (Xlsx and Xls).
|
||||
|
||||
## Setting a range of cells from an array
|
||||
|
||||
It is also possible to set a range of cell values in a single call by
|
||||
passing an array of values to the `fromArray()` method.
|
||||
|
||||
``` php
|
||||
$arrayData = array(
|
||||
array(NULL, 2010, 2011, 2012),
|
||||
array('Q1', 12, 15, 21),
|
||||
array('Q2', 56, 73, 86),
|
||||
array('Q3', 52, 61, 69),
|
||||
array('Q4', 30, 32, 0),
|
||||
);
|
||||
$spreadsheet->getActiveSheet()
|
||||
->fromArray(
|
||||
$arrayData, // The data to set
|
||||
NULL, // Array values with this value will not be set
|
||||
'C3' // Top left coordinate of the worksheet range where
|
||||
// we want to set these values (default is A1)
|
||||
);
|
||||
```
|
||||
|
||||
![07-simple-example-2.png](./images/07-simple-example-2.png)
|
||||
|
||||
If you pass a 2-d array, then this will be treated as a series of rows
|
||||
and columns. A 1-d array will be treated as a single row, which is
|
||||
particularly useful if you're fetching an array of data from a database.
|
||||
|
||||
``` php
|
||||
$rowArray = array('Value1', 'Value2', 'Value3', 'Value4');
|
||||
$spreadsheet->getActiveSheet()
|
||||
->fromArray(
|
||||
$rowArray, // The data to set
|
||||
NULL, // Array values with this value will not be set
|
||||
'C3' // Top left coordinate of the worksheet range where
|
||||
// we want to set these values (default is A1)
|
||||
);
|
||||
```
|
||||
|
||||
![07-simple-example-3.png](./images/07-simple-example-3.png)
|
||||
|
||||
If you have a simple 1-d array, and want to write it as a column, then
|
||||
the following will convert it into an appropriately structured 2-d array
|
||||
that can be fed to the `fromArray()` method:
|
||||
|
||||
``` php
|
||||
$rowArray = array('Value1', 'Value2', 'Value3', 'Value4');
|
||||
$columnArray = array_chunk($rowArray, 1);
|
||||
$spreadsheet->getActiveSheet()
|
||||
->fromArray(
|
||||
$columnArray, // The data to set
|
||||
NULL, // Array values with this value will not be set
|
||||
'C3' // Top left coordinate of the worksheet range where
|
||||
// we want to set these values (default is A1)
|
||||
);
|
||||
```
|
||||
|
||||
![07-simple-example-4.png](./images/07-simple-example-4.png)
|
||||
|
||||
## Retrieving a cell value by coordinate
|
||||
|
||||
To retrieve the value of a cell, the cell should first be retrieved from
|
||||
the worksheet using the `getCell()` method. A cell's value can be read
|
||||
using the `getValue()` method.
|
||||
|
||||
``` php
|
||||
// Get the value fom cell A1
|
||||
$cellValue = $spreadsheet->getActiveSheet()->getCell('A1')
|
||||
->getValue();
|
||||
```
|
||||
|
||||
This will retrieve the raw, unformatted value contained in the cell.
|
||||
|
||||
If a cell contains a formula, and you need to retrieve the calculated
|
||||
value rather than the formula itself, then use the cell's
|
||||
`getCalculatedValue()` method. This is further explained in .
|
||||
|
||||
``` php
|
||||
// Get the value fom cell A4
|
||||
$cellValue = $spreadsheet->getActiveSheet()->getCell('A4')
|
||||
->getCalculatedValue();
|
||||
```
|
||||
|
||||
Alternatively, if you want to see the value with any cell formatting
|
||||
applied (e.g. for a human-readable date or time value), then you can use
|
||||
the cell's `getFormattedValue()` method.
|
||||
|
||||
``` php
|
||||
// Get the value fom cell A6
|
||||
$cellValue = $spreadsheet->getActiveSheet()->getCell('A6')
|
||||
->getFormattedValue();
|
||||
```
|
||||
|
||||
## Setting a cell value by column and row
|
||||
|
||||
Setting a cell value by coordinate can be done using the worksheet's
|
||||
`setCellValueByColumnAndRow()` method.
|
||||
|
||||
``` php
|
||||
// Set cell B5 with a string value
|
||||
$spreadsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 5, 'PhpSpreadsheet');
|
||||
```
|
||||
|
||||
**Note** that column references start with `0` for column `A`, rather
|
||||
than from `1`.
|
||||
|
||||
## Retrieving a cell value by column and row
|
||||
|
||||
To retrieve the value of a cell, the cell should first be retrieved from
|
||||
the worksheet using the getCellByColumnAndRow method. A cell’s value can
|
||||
be read again using the following line of code:
|
||||
|
||||
``` php
|
||||
// Get the value fom cell B5
|
||||
$cellValue = $spreadsheet->getActiveSheet()->getCellByColumnAndRow(1, 5)
|
||||
->getValue();
|
||||
```
|
||||
|
||||
If you need the calculated value of a cell, use the following code. This
|
||||
is further explained in .
|
||||
|
||||
``` php
|
||||
// Get the value fom cell A4
|
||||
$cellValue = $spreadsheet->getActiveSheet()->getCellByColumnAndRow(0, 4)
|
||||
->getCalculatedValue();
|
||||
```
|
||||
|
||||
## Retrieving a range of cell values to an array
|
||||
|
||||
It is also possible to retrieve a range of cell values to an array in a
|
||||
single call using the `toArray()`, `rangeToArray()` or
|
||||
`namedRangeToArray()` methods.
|
||||
|
||||
``` php
|
||||
$dataArray = $spreadsheet->getActiveSheet()
|
||||
->rangeToArray(
|
||||
'C3:E5', // The worksheet range that we want to retrieve
|
||||
NULL, // Value that should be returned for empty cells
|
||||
TRUE, // Should formulas be calculated (the equivalent of getCalculatedValue() for each cell)
|
||||
TRUE, // Should values be formatted (the equivalent of getFormattedValue() for each cell)
|
||||
TRUE // Should the array be indexed by cell row and cell column
|
||||
);
|
||||
```
|
||||
|
||||
These methods will all return a 2-d array of rows and columns. The
|
||||
`toArray()` method will return the whole worksheet; `rangeToArray()`
|
||||
will return a specified range or cells; while `namedRangeToArray()` will
|
||||
return the cells within a defined `named range`.
|
||||
|
||||
## Looping through cells
|
||||
|
||||
### Looping through cells using iterators
|
||||
|
||||
The easiest way to loop cells is by using iterators. Using iterators,
|
||||
one can use foreach to loop worksheets, rows within a worksheet, and
|
||||
cells within a row.
|
||||
|
||||
Below is an example where we read all the values in a worksheet and
|
||||
display them in a table.
|
||||
|
||||
``` php
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
||||
$reader->setReadDataOnly(TRUE);
|
||||
$spreadsheet = $reader->load("test.xlsx");
|
||||
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
echo '<table>' . PHP_EOL;
|
||||
foreach ($worksheet->getRowIterator() as $row) {
|
||||
echo '<tr>' . PHP_EOL;
|
||||
$cellIterator = $row->getCellIterator();
|
||||
$cellIterator->setIterateOnlyExistingCells(FALSE); // This loops through all cells,
|
||||
// even if a cell value is not set.
|
||||
// By default, only cells that have a value
|
||||
// set will be iterated.
|
||||
foreach ($cellIterator as $cell) {
|
||||
echo '<td>' .
|
||||
$cell->getValue() .
|
||||
'</td>' . PHP_EOL;
|
||||
}
|
||||
echo '</tr>' . PHP_EOL;
|
||||
}
|
||||
echo '</table>' . PHP_EOL;
|
||||
```
|
||||
|
||||
Note that we have set the cell iterator's
|
||||
`setIterateOnlyExistingCells()` to FALSE. This makes the iterator loop
|
||||
all cells within the worksheet range, even if they have not been set.
|
||||
|
||||
The cell iterator will return a **NULL** as the cell value if it is not
|
||||
set in the worksheet. Setting the cell iterator's
|
||||
setIterateOnlyExistingCells() to FALSE will loop all cells in the
|
||||
worksheet that can be available at that moment. This will create new
|
||||
cells if required and increase memory usage! Only use it if it is
|
||||
intended to loop all cells that are possibly available.
|
||||
|
||||
### Looping through cells using indexes
|
||||
|
||||
One can use the possibility to access cell values by column and row
|
||||
index like (0,1) instead of 'A1' for reading and writing cell values in
|
||||
loops.
|
||||
|
||||
Note: In PhpSpreadsheet column index is 0-based while row index is
|
||||
1-based. That means 'A1' \~ (0,1)
|
||||
|
||||
Below is an example where we read all the values in a worksheet and
|
||||
display them in a table.
|
||||
|
||||
``` php
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
||||
$reader->setReadDataOnly(TRUE);
|
||||
$spreadsheet = $reader->load("test.xlsx");
|
||||
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
// Get the highest row and column numbers referenced in the worksheet
|
||||
$highestRow = $worksheet->getHighestRow(); // e.g. 10
|
||||
$highestColumn = $worksheet->getHighestColumn(); // e.g 'F'
|
||||
$highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($highestColumn); // e.g. 5
|
||||
|
||||
echo '<table>' . "\n";
|
||||
for ($row = 1; $row <= $highestRow; ++$row) {
|
||||
echo '<tr>' . PHP_EOL;
|
||||
for ($col = 0; $col <= $highestColumnIndex; ++$col) {
|
||||
echo '<td>' .
|
||||
$worksheet->getCellByColumnAndRow($col, $row)
|
||||
->getValue() .
|
||||
'</td>' . PHP_EOL;
|
||||
}
|
||||
echo '</tr>' . PHP_EOL;
|
||||
}
|
||||
echo '</table>' . PHP_EOL;
|
||||
```
|
||||
|
||||
Alternatively, you can take advantage of PHP's "Perl-style" character
|
||||
incrementors to loop through the cells by coordinate:
|
||||
|
||||
``` php
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
||||
$reader->setReadDataOnly(TRUE);
|
||||
$spreadsheet = $reader->load("test.xlsx");
|
||||
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
// Get the highest row number and column letter referenced in the worksheet
|
||||
$highestRow = $worksheet->getHighestRow(); // e.g. 10
|
||||
$highestColumn = $worksheet->getHighestColumn(); // e.g 'F'
|
||||
// Increment the highest column letter
|
||||
$highestColumn++;
|
||||
|
||||
echo '<table>' . "\n";
|
||||
for ($row = 1; $row <= $highestRow; ++$row) {
|
||||
echo '<tr>' . PHP_EOL;
|
||||
for ($col = 'A'; $col != $highestColumn; ++$col) {
|
||||
echo '<td>' .
|
||||
$worksheet->getCell($col . $row)
|
||||
->getValue() .
|
||||
'</td>' . PHP_EOL;
|
||||
}
|
||||
echo '</tr>' . PHP_EOL;
|
||||
}
|
||||
echo '</table>' . PHP_EOL;
|
||||
```
|
||||
|
||||
Note that we can't use a <= comparison here, because 'AA' would match
|
||||
as <= 'B', so we increment the highest column letter and then loop
|
||||
while \$col != the incremented highest column.
|
||||
|
||||
## Using value binders to facilitate data entry
|
||||
|
||||
Internally, PhpSpreadsheet uses a default
|
||||
\PhpOffice\PhpSpreadsheet\Cell\IValueBinder implementation
|
||||
(\PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder) to determine data
|
||||
types of entered data using a cell's `setValue()` method (the
|
||||
`setValueExplicit()` method bypasses this check).
|
||||
|
||||
Optionally, the default behaviour of PhpSpreadsheet can be modified,
|
||||
allowing easier data entry. For example, a
|
||||
\PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder class is available.
|
||||
It automatically converts percentages, number in scientific format, and
|
||||
dates entered as strings to the correct format, also setting the cell's
|
||||
style information. The following example demonstrates how to set the
|
||||
value binder in PhpSpreadsheet:
|
||||
|
||||
``` php
|
||||
/** PhpSpreadsheet */
|
||||
require_once 'src/Boostrap.php';
|
||||
|
||||
// Set value binder
|
||||
\PhpOffice\PhpSpreadsheet\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// ...
|
||||
// Add some data, resembling some different data types
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A4', 'Percentage value:');
|
||||
// Converts the string value to 0.1 and sets percentage cell style
|
||||
$spreadsheet->getActiveSheet()->setCellValue('B4', '10%');
|
||||
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A5', 'Date/time value:');
|
||||
// Converts the string value to an Excel datestamp and sets the date format cell style
|
||||
$spreadsheet->getActiveSheet()->setCellValue('B5', '21 December 1983');
|
||||
```
|
||||
|
||||
**Creating your own value binder is easy.** When advanced value binding
|
||||
is required, you can implement the
|
||||
\PhpOffice\PhpSpreadsheet\Cell\IValueBinder interface or extend the
|
||||
\PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder or
|
||||
\PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder classes.
|
|
@ -0,0 +1,75 @@
|
|||
# Architecture
|
||||
|
||||
## Schematical
|
||||
|
||||
![01-schematic.png](./images/01-schematic.png "Basic Architecture Schematic")
|
||||
|
||||
## AutoLoader
|
||||
|
||||
PhpSpreadsheet relies on Composer autoloader. So before working with
|
||||
PhpSpreadsheet in standalone, be sure to run `composer install`. Or add it to a
|
||||
pre-existing project with `composer require phpoffice/phpspreadsheet`.
|
||||
|
||||
## Spreadsheet in memory
|
||||
|
||||
PhpSpreadsheet's architecture is built in a way that it can serve as an
|
||||
in-memory spreadsheet. This means that, if one would want to create a
|
||||
web based view of a spreadsheet which communicates with PhpSpreadsheet's
|
||||
object model, he would only have to write the front-end code.
|
||||
|
||||
Just like desktop spreadsheet software, PhpSpreadsheet represents a
|
||||
spreadsheet containing one or more worksheets, which contain cells with
|
||||
data, formulas, images, ...
|
||||
|
||||
## Readers and writers
|
||||
|
||||
On its own, the `Spreadsheet` class does not provide the functionality
|
||||
to read from or write to a persisted spreadsheet (on disk or in a
|
||||
database). To provide that functionality, readers and writers can be
|
||||
used.
|
||||
|
||||
By default, the PhpSpreadsheet package provides some readers and
|
||||
writers, including one for the Open XML spreadsheet format (a.k.a. Excel
|
||||
2007 file format). You are not limited to the default readers and
|
||||
writers, as you are free to implement the
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReader and
|
||||
\PhpOffice\PhpSpreadsheet\Writer\IWriter interface in a custom class.
|
||||
|
||||
![02-readers-writers.png](./images/02-readers-writers.png "Readers/Writers")
|
||||
|
||||
## Fluent interfaces
|
||||
|
||||
PhpSpreadsheet supports fluent interfaces in most locations. This means
|
||||
that you can easily "chain" calls to specific methods without requiring
|
||||
a new PHP statement. For example, take the following code:
|
||||
|
||||
``` php
|
||||
$spreadsheet->getProperties()->setCreator("Maarten Balliauw");
|
||||
$spreadsheet->getProperties()->setLastModifiedBy("Maarten Balliauw");
|
||||
$spreadsheet->getProperties()->setTitle("Office 2007 XLSX Test Document");
|
||||
$spreadsheet->getProperties()->setSubject("Office 2007 XLSX Test Document");
|
||||
$spreadsheet->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
|
||||
$spreadsheet->getProperties()->setKeywords("office 2007 openxml php");
|
||||
$spreadsheet->getProperties()->setCategory("Test result file");
|
||||
```
|
||||
|
||||
This can be rewritten as:
|
||||
|
||||
``` php
|
||||
$spreadsheet->getProperties()
|
||||
->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
```
|
||||
|
||||
> **Using fluent interfaces is not required** Fluent interfaces have
|
||||
> been implemented to provide a convenient programming API. Use of them
|
||||
> is not required, but can make your code easier to read and maintain.
|
||||
> It can also improve performance, as you are reducing the overall
|
||||
> number of calls to PhpSpreadsheet methods: in the above example, the
|
||||
> `getProperties()` method is being called only once rather than 7 times
|
||||
> in the non-fluent version.
|
|
@ -142,7 +142,7 @@ $columnFilter->createRule()
|
|||
```
|
||||
|
||||
This creates two filter rules: the column will be filtered by values
|
||||
that match “France” OR “Germany”. For Simple Filters, you can create as
|
||||
that match "France" OR "Germany". For Simple Filters, you can create as
|
||||
many rules as you want
|
||||
|
||||
Simple filters are always a comparison match of EQUALS, and multiple
|
||||
|
@ -238,7 +238,7 @@ $columnFilter->setFilterType(
|
|||
And then define our rules.
|
||||
|
||||
The following shows a simple wildcard filter to show all column entries
|
||||
beginning with the letter 'U'.
|
||||
beginning with the letter `U`.
|
||||
|
||||
``` php
|
||||
$columnFilter->createRule()
|
||||
|
@ -487,7 +487,7 @@ saved.
|
|||
### Applying the Filter
|
||||
|
||||
If you wish to execute your filter from within a script, you need to do
|
||||
this manually. You can do this using the autofilters showHideRows()
|
||||
this manually. You can do this using the autofilters `showHideRows()`
|
||||
method.
|
||||
|
||||
``` php
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
As PhpSpreadsheet represents an in-memory spreadsheet, it also offers
|
||||
formula calculation capabilities. A cell can be of a value type
|
||||
(containing a number or text), or a formula type (containing a formula
|
||||
which can be evaluated). For example, the formula "=SUM(A1:A10)"
|
||||
which can be evaluated). For example, the formula `=SUM(A1:A10)`
|
||||
evaluates to the sum of values in A1, A2, ..., A10.
|
||||
|
||||
To calculate a formula, you can call the cell containing the formula’s
|
||||
method getCalculatedValue(), for example:
|
||||
method `getCalculatedValue()`, for example:
|
||||
|
||||
``` php
|
||||
$spreadsheet->getActiveSheet()->getCell('E11')->getCalculatedValue();
|
||||
|
@ -57,7 +57,7 @@ Not all functions are supported, for a comprehensive list, read the
|
|||
|
||||
#### Operator precedence
|
||||
|
||||
In Excel '+' wins over '&', just like '\*' wins over '+' in ordinary
|
||||
In Excel `+` wins over `&`, just like `*` wins over `+` in ordinary
|
||||
algebra. The former rule is not what one finds using the calculation
|
||||
engine shipped with PhpSpreadsheet.
|
||||
|
||||
|
@ -69,9 +69,9 @@ Reference for operator precedence in PHP: <http://www.php.net/operators>
|
|||
#### Formulas involving numbers and text
|
||||
|
||||
Formulas involving numbers and text may produce unexpected results or
|
||||
even unreadable file contents. For example, the formula '=3+"Hello "' is
|
||||
even unreadable file contents. For example, the formula `=3+"Hello "` is
|
||||
expected to produce an error in Excel (\#VALUE!). Due to the fact that
|
||||
PHP converts “Hello” to a numeric value (zero), the result of this
|
||||
PHP converts `"Hello "` to a numeric value (zero), the result of this
|
||||
formula is evaluated as 3 instead of evaluating as an error. This also
|
||||
causes the Excel document being generated as containing unreadable
|
||||
content.
|
||||
|
@ -94,14 +94,14 @@ return either an Excel timestamp or a PHP timestamp or date object.
|
|||
|
||||
It is possible for scripts to change the data type used for returning
|
||||
date values by calling the
|
||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType()
|
||||
`\PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType()`
|
||||
method:
|
||||
|
||||
``` php
|
||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType($returnDateType);
|
||||
```
|
||||
|
||||
where the following constants can be used for \$returnDateType
|
||||
where the following constants can be used for `$returnDateType`:
|
||||
|
||||
- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_NUMERIC`
|
||||
- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_OBJECT`
|
||||
|
@ -155,7 +155,7 @@ Excel date values by calling the
|
|||
\PhpOffice\PhpSpreadsheet\Shared\Date::setExcelCalendar($baseDate);
|
||||
```
|
||||
|
||||
where the following constants can be used for \$baseDate
|
||||
where the following constants can be used for `$baseDate`:
|
||||
|
||||
- \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR\_WINDOWS\_1900
|
||||
- \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR\_MAC\_1904
|
||||
|
@ -202,9 +202,9 @@ However, if you pass through a value such as '31/12/2008' that would be
|
|||
considered an error by a US-based server, but which is not ambiguous,
|
||||
then PhpSpreadsheet will attempt to correct this to 31st December 2008.
|
||||
If the content of the string doesn’t match any of the formats recognised
|
||||
by the php date/time object implementation of strtotime() (which can
|
||||
handle a wider range of formats than the normal strtotime() function),
|
||||
then the function will return a '\#VALUE' error. However, Excel
|
||||
by the php date/time object implementation of `strtotime()` (which can
|
||||
handle a wider range of formats than the normal `strtotime()` function),
|
||||
then the function will return a `#VALUE` error. However, Excel
|
||||
recommends that you should always use date/timestamps for your date
|
||||
functions, and the recommendation for PhpSpreadsheet is the same: avoid
|
||||
strings because the result is not predictable.
|
||||
|
@ -238,12 +238,12 @@ rather than converted to Excel date timestamp values.
|
|||
|
||||
### Helper Methods
|
||||
|
||||
In addition to the setExcelCalendar() and getExcelCalendar() methods, a
|
||||
In addition to the `setExcelCalendar()` and `getExcelCalendar()` methods, a
|
||||
number of other methods are available in the
|
||||
\PhpOffice\PhpSpreadsheet\Shared\Date class that can help when working
|
||||
with dates:
|
||||
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::ExcelToPHP(\$excelDate)
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::ExcelToPHP($excelDate)
|
||||
|
||||
Converts a date/time from an Excel date timestamp to return a PHP
|
||||
serialized date/timestamp.
|
||||
|
@ -251,17 +251,17 @@ serialized date/timestamp.
|
|||
Note that this method does not trap for Excel dates that fall outside of
|
||||
the valid range for a PHP date timestamp.
|
||||
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::ExcelToPHPObject(\$excelDate)
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::ExcelToPHPObject($excelDate)
|
||||
|
||||
Converts a date from an Excel date/timestamp to return a PHP DateTime
|
||||
object.
|
||||
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(\$PHPDate)
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDate)
|
||||
|
||||
Converts a PHP serialized date/timestamp or a PHP DateTime object to
|
||||
return an Excel date timestamp.
|
||||
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::FormattedPHPToExcel(\$year, \$month, \$day, \$hours=0, \$minutes=0, \$seconds=0)
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0)
|
||||
|
||||
Takes year, month and day values (and optional hour, minute and second
|
||||
values) and returns an Excel date timestamp value.
|
||||
|
@ -1114,7 +1114,7 @@ ym | Months Excluding Years | Complete calendar months between the da
|
|||
yd | Days Excluding Years | Complete calendar days between the dates as if they were of the same year.
|
||||
md | Days Excluding Years And Months | Complete calendar days between the dates as if they were of the same month and same year.
|
||||
|
||||
The unit value is not case sensitive, and defaults to "d".
|
||||
The unit value is not case sensitive, and defaults to `d`.
|
||||
|
||||
##### Return Value
|
||||
|
||||
|
@ -1290,8 +1290,8 @@ $retVal = call_user_func_array(
|
|||
|
||||
##### Notes
|
||||
|
||||
DATEVALUE uses the php date/time object implementation of strtotime()
|
||||
(which can handle a wider range of formats than the normal strtotime()
|
||||
DATEVALUE uses the php date/time object implementation of `strtotime()`
|
||||
(which can handle a wider range of formats than the normal `strtotime()`
|
||||
function), and it is also called for any date parameter passed to other
|
||||
date functions (such as DATEDIF) when the parameter value is a string.
|
||||
|
||||
|
@ -1449,7 +1449,7 @@ $retVal = call_user_func_array(
|
|||
when a PHP Boolean is used for the third (optional) parameter (as shown
|
||||
in the example above), and the writer will generate and error. It will
|
||||
work if a numeric 0 or 1 is used for the method parameter; or if the
|
||||
Excel TRUE() and FALSE() functions are used instead.
|
||||
Excel `TRUE()` and `FALSE()` functions are used instead.
|
||||
|
||||
#### EDATE
|
||||
|
||||
|
@ -1824,7 +1824,7 @@ The NOW function returns the current date and time.
|
|||
|
||||
##### Parameters
|
||||
|
||||
There are now parameters for the NOW() function.
|
||||
There are no parameters for the `NOW()` function.
|
||||
|
||||
##### Return Value
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
# Creating a spreadsheet
|
||||
|
||||
## The `Spreadsheet` class
|
||||
|
||||
The `Spreadsheet` class is the core of PhpSpreadsheet. It contains
|
||||
references to the contained worksheets, document security settings and
|
||||
document meta data.
|
||||
|
||||
To simplify the PhpSpreadsheet concept: the `Spreadsheet` class
|
||||
represents your workbook.
|
||||
|
||||
Typically, you will create a workbook in one of two ways, either by
|
||||
loading it from a spreadsheet file, or creating it manually. A third
|
||||
option, though less commonly used, is cloning an existing workbook that
|
||||
has been created using one of the previous two methods.
|
||||
|
||||
### Loading a Workbook from a file
|
||||
|
||||
Details of the different spreadsheet formats supported, and the options
|
||||
available to read them into a Spreadsheet object are described fully in
|
||||
the [Reading Files](./reading-files.md) document.
|
||||
|
||||
``` php
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
/** Load $inputFileName to a Spreadsheet object **/
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
|
||||
```
|
||||
|
||||
### Creating a new workbook
|
||||
|
||||
If you want to create a new workbook, rather than load one from file,
|
||||
then you simply need to instantiate it as a new Spreadsheet object.
|
||||
|
||||
``` php
|
||||
/** Create a new Spreadsheet Object **/
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
```
|
||||
|
||||
A new workbook will always be created with a single worksheet.
|
||||
|
||||
## Clearing a Workbook from memory
|
||||
|
||||
The PhpSpreadsheet object contains cyclic references (e.g. the workbook
|
||||
is linked to the worksheets, and the worksheets are linked to their
|
||||
parent workbook) which cause problems when PHP tries to clear the
|
||||
objects from memory when they are `unset()`, or at the end of a function
|
||||
when they are in local scope. The result of this is "memory leaks",
|
||||
which can easily use a large amount of PHP's limited memory.
|
||||
|
||||
This can only be resolved manually: if you need to unset a workbook,
|
||||
then you also need to "break" these cyclic references before doing so.
|
||||
PhpSpreadsheet provides the `disconnectWorksheets()` method for this
|
||||
purpose.
|
||||
|
||||
``` php
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
unset($spreadsheet);
|
||||
```
|
|
@ -78,10 +78,10 @@ library.
|
|||
Comma Separated Value (CSV) file format is a common structuring strategy
|
||||
for text format files. In CSV flies, each line in the file represents a
|
||||
row of data and (within each line of the file) the different data fields
|
||||
(or columns) are separated from one another using a comma (","). If a
|
||||
(or columns) are separated from one another using a comma (`,`). If a
|
||||
data field contains a comma, then it should be enclosed (typically in
|
||||
quotation marks ("). Sometimes tabs "\t", or the pipe symbol ("|"), or a
|
||||
semi-colon (";") are used as separators instead of a comma, although
|
||||
quotation marks (`"`). Sometimes tabs `\t`, or the pipe symbol (`|`), or a
|
||||
semi-colon (`;`) are used as separators instead of a comma, although
|
||||
other symbols can be used. Because CSV is a text-only format, it doesn't
|
||||
support any data formatting options.
|
||||
|
||||
|
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
@ -0,0 +1,15 @@
|
|||
# Useful links and tools
|
||||
|
||||
There are some links and tools which are very useful when developing
|
||||
using PhpSpreadsheet.
|
||||
|
||||
## OpenXML / SpreadsheetML
|
||||
|
||||
- [File format
|
||||
documentation](http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm)
|
||||
- [OpenXML Explained
|
||||
e-book](http://openxmldeveloper.org/articles/1970.aspx)
|
||||
- [Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint
|
||||
2007 File
|
||||
Formats](http://www.microsoft.com/downloads/details.aspx?familyid=941b3470-3ae9-4aee-8f43-c6bb74cd1466&displaylang=en)
|
||||
- [OpenXML Package Explorer](http://www.codeplex.com/PackageExplorer/)
|
|
@ -0,0 +1,108 @@
|
|||
# Memory saving
|
||||
|
||||
PhpSpreadsheet uses an average of about 1k per cell in your worksheets, so
|
||||
large workbooks can quickly use up available memory. Cell caching
|
||||
provides a mechanism that allows PhpSpreadsheet to maintain the cell
|
||||
objects in a smaller size of memory, or off-memory (eg: on disk, in APCu,
|
||||
memcache or redis). This allows you to reduce the memory usage for large
|
||||
workbooks, although at a cost of speed to access cell data.
|
||||
|
||||
By default, PhpSpreadsheet holds all cell objects in memory, but
|
||||
you can specify alternatives by providing your own
|
||||
[PSR-16](http://www.php-fig.org/psr/psr-16/) implementation. PhpSpreadsheet keys
|
||||
are automatically namespaced, and cleaned up after use, so a single cache
|
||||
instance may be shared across several usage of PhpSpreadsheet or even with other
|
||||
cache usages.
|
||||
|
||||
To enable cell caching, you must provide your own implementation of cache like so:
|
||||
|
||||
``` php
|
||||
$cache = new MyCustomPsr16Implementation();
|
||||
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCache($cache);
|
||||
```
|
||||
|
||||
A separate cache is maintained for each individual worksheet, and is
|
||||
automatically created when the worksheet is instantiated based on the
|
||||
settings that you have configured. You cannot change
|
||||
the configuration settings once you have started to read a workbook, or
|
||||
have created your first worksheet.
|
||||
|
||||
## Beware of TTL
|
||||
|
||||
As opposed to common cache concept, PhpSpreadsheet data cannot be re-generated
|
||||
from scratch. If some data is stored and later is not retrievable,
|
||||
PhpSpreadsheet will throw an exception.
|
||||
|
||||
That means that the data stored in cache **must not be deleted** by a
|
||||
third-party or via TTL mechanism.
|
||||
|
||||
So be sure that TTL is either de-activated or long enough to cover the entire
|
||||
usage of PhpSpreadsheet.
|
||||
|
||||
## Common use cases
|
||||
|
||||
PhpSpreadsheet does not ship with alternative cache implementation. It is up to
|
||||
you to select the most appropriate implementation for your environnement. You
|
||||
can either implement [PSR-16](http://www.php-fig.org/psr/psr-16/) from scratch,
|
||||
or use [pre-existing libraries](https://packagist.org/search/?q=psr-16).
|
||||
|
||||
One such library is [PHP Cache](http://www.php-cache.com/) which
|
||||
provides a wide range of alternatives. Refers to their documentation for
|
||||
details, but here are a few suggestions that should get you started.
|
||||
|
||||
|
||||
### APCu
|
||||
|
||||
Require the packages into your project:
|
||||
|
||||
```sh
|
||||
composer require cache/simple-cache-bridge cache/apcu-adapter
|
||||
```
|
||||
|
||||
Configure PhpSpreadsheet with something like:
|
||||
|
||||
```php
|
||||
$pool = new \Cache\Adapter\Apcu\ApcuCachePool();
|
||||
$simpleCache = new \Cache\Bridge\SimpleCache\SimpleCacheBridge($pool);
|
||||
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCache($simpleCache);
|
||||
```
|
||||
|
||||
### Redis
|
||||
|
||||
Require the packages into your project:
|
||||
|
||||
```sh
|
||||
composer require cache/simple-cache-bridge cache/redis-adapter
|
||||
```
|
||||
|
||||
Configure PhpSpreadsheet with something like:
|
||||
|
||||
```php
|
||||
$client = new \Redis();
|
||||
$client->connect('127.0.0.1', 6379);
|
||||
$pool = new \Cache\Adapter\Redis\RedisCachePool($client);
|
||||
$simpleCache = new \Cache\Bridge\SimpleCache\SimpleCacheBridge($pool);
|
||||
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCache($simpleCache);
|
||||
```
|
||||
|
||||
### Memcache
|
||||
|
||||
Require the packages into your project:
|
||||
|
||||
```sh
|
||||
composer require cache/simple-cache-bridge cache/memcache-adapter
|
||||
```
|
||||
|
||||
Configure PhpSpreadsheet with something like:
|
||||
|
||||
```php
|
||||
$client = new \Memcache();
|
||||
$client->connect('localhost', 11211);
|
||||
$pool = new \Cache\Adapter\Memcache\MemcacheCachePool($client);
|
||||
$simpleCache = new \Cache\Bridge\SimpleCache\SimpleCacheBridge($pool);
|
||||
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCache($simpleCache);
|
||||
```
|
|
@ -132,3 +132,63 @@ to do is to specify a renderer like so:
|
|||
$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_MPDF;
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName);
|
||||
```
|
||||
|
||||
## PclZip and ZipArchive
|
||||
|
||||
Support for PclZip were dropped in favor of the more complete and modern
|
||||
[PHP extension ZipArchive](http://php.net/manual/en/book.zip.php).
|
||||
So the following were removed:
|
||||
|
||||
- `PclZip`
|
||||
- `PHPExcel_Settings::setZipClass()`
|
||||
- `PHPExcel_Settings::getZipClass()`
|
||||
- `PHPExcel_Shared_ZipArchive`
|
||||
- `PHPExcel_Shared_ZipStreamWrapper`
|
||||
|
||||
|
||||
## Cell caching
|
||||
|
||||
Cell caching was heavily refactored to leverage
|
||||
[PSR-16](http://www.php-fig.org/psr/psr-16/). That means most classes
|
||||
related to that feature were removed:
|
||||
|
||||
- `PHPExcel_CachedObjectStorage_APC`
|
||||
- `PHPExcel_CachedObjectStorage_DiscISAM`
|
||||
- `PHPExcel_CachedObjectStorage_ICache`
|
||||
- `PHPExcel_CachedObjectStorage_Igbinary`
|
||||
- `PHPExcel_CachedObjectStorage_Memcache`
|
||||
- `PHPExcel_CachedObjectStorage_Memory`
|
||||
- `PHPExcel_CachedObjectStorage_MemoryGZip`
|
||||
- `PHPExcel_CachedObjectStorage_MemorySerialized`
|
||||
- `PHPExcel_CachedObjectStorage_PHPTemp`
|
||||
- `PHPExcel_CachedObjectStorage_SQLite`
|
||||
- `PHPExcel_CachedObjectStorage_SQLite3`
|
||||
- `PHPExcel_CachedObjectStorage_Wincache`
|
||||
|
||||
In addition to that, `\PhpOffice\PhpSpreadsheet::getCellCollection()` was renamed
|
||||
to `\PhpOffice\PhpSpreadsheet::getCoordinates()` and
|
||||
`\PhpOffice\PhpSpreadsheet::getCellCacheController()` to
|
||||
`\PhpOffice\PhpSpreadsheet::getCellCollection()` for clarity.
|
||||
|
||||
Refer to [the new documentation](./memory_saving.md) to see how to migrate.
|
||||
|
||||
## Dropped conditionally returned cell
|
||||
|
||||
For all the following methods, it is no more possible to change the type of
|
||||
returned value. It always return the Worksheet and never the Cell or Rule:
|
||||
|
||||
- Worksheet::setCellValue()
|
||||
- Worksheet::setCellValueByColumnAndRow()
|
||||
- Worksheet::setCellValueExplicit()
|
||||
- Worksheet::setCellValueExplicitByColumnAndRow()
|
||||
- Worksheet::addRule()
|
||||
|
||||
Migration would be similar to:
|
||||
|
||||
``` php
|
||||
// Before
|
||||
$cell = $worksheet->setCellValue('A1', 'value', true);
|
||||
|
||||
// After
|
||||
$cell = $worksheet->getCell('A1')->setValue('value');
|
||||
```
|
||||
|
|
|
@ -0,0 +1,839 @@
|
|||
# Reading and writing to file
|
||||
|
||||
As you already know from the [architecture](./architecture.md#readers-and-writers),
|
||||
reading and writing to a
|
||||
persisted storage is not possible using the base PhpSpreadsheet classes.
|
||||
For this purpose, PhpSpreadsheet provides readers and writers, which are
|
||||
implementations of \PhpOffice\PhpSpreadsheet\Reader\IReader and
|
||||
\PhpOffice\PhpSpreadsheet\Writer\IWriter.
|
||||
|
||||
## \PhpOffice\PhpSpreadsheet\IOFactory
|
||||
|
||||
The PhpSpreadsheet API offers multiple methods to create a
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReader or
|
||||
\PhpOffice\PhpSpreadsheet\Writer\IWriter instance:
|
||||
|
||||
Direct creation via \PhpOffice\PhpSpreadsheet\IOFactory. All examples
|
||||
underneath demonstrate the direct creation method. Note that you can
|
||||
also use the \PhpOffice\PhpSpreadsheet\IOFactory class to do this.
|
||||
|
||||
### Creating \PhpOffice\PhpSpreadsheet\Reader\IReader using \PhpOffice\PhpSpreadsheet\IOFactory
|
||||
|
||||
There are 2 methods for reading in a file into PhpSpreadsheet: using
|
||||
automatic file type resolving or explicitly.
|
||||
|
||||
Automatic file type resolving checks the different
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReader distributed with
|
||||
PhpSpreadsheet. If one of them can load the specified file name, the
|
||||
file is loaded using that \PhpOffice\PhpSpreadsheet\Reader\IReader.
|
||||
Explicit mode requires you to specify which
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReader should be used.
|
||||
|
||||
You can create a \PhpOffice\PhpSpreadsheet\Reader\IReader instance using
|
||||
\PhpOffice\PhpSpreadsheet\IOFactory in automatic file type resolving
|
||||
mode using the following code sample:
|
||||
|
||||
``` php
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load("05featuredemo.xlsx");
|
||||
```
|
||||
|
||||
A typical use of this feature is when you need to read files uploaded by
|
||||
your users, and you don’t know whether they are uploading xls or xlsx
|
||||
files.
|
||||
|
||||
If you need to set some properties on the reader, (e.g. to only read
|
||||
data, see more about this later), then you may instead want to use this
|
||||
variant:
|
||||
|
||||
``` php
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile("05featuredemo.xlsx");
|
||||
$reader->setReadDataOnly(true);
|
||||
$reader->load("05featuredemo.xlsx");
|
||||
```
|
||||
|
||||
You can create a \PhpOffice\PhpSpreadsheet\Reader\IReader instance using
|
||||
\PhpOffice\PhpSpreadsheet\IOFactory in explicit mode using the following
|
||||
code sample:
|
||||
|
||||
``` php
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
|
||||
$spreadsheet = $reader->load("05featuredemo.xlsx");
|
||||
```
|
||||
|
||||
Note that automatic type resolving mode is slightly slower than explicit
|
||||
mode.
|
||||
|
||||
### Creating \PhpOffice\PhpSpreadsheet\Writer\IWriter using \PhpOffice\PhpSpreadsheet\IOFactory
|
||||
|
||||
You can create a PhpOffice\PhpSpreadsheet\Writer\IWriter instance using
|
||||
\PhpOffice\PhpSpreadsheet\IOFactory:
|
||||
|
||||
``` php
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, "Xlsx");
|
||||
$writer->save("05featuredemo.xlsx");
|
||||
```
|
||||
|
||||
## Excel 2007 (SpreadsheetML) file format
|
||||
|
||||
Xlsx file format is the main file format of PhpSpreadsheet. It allows
|
||||
outputting the in-memory spreadsheet to a .xlsx file.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Reader\Xlsx
|
||||
|
||||
#### Reading a spreadsheet
|
||||
|
||||
You can read an .xlsx file using the following code:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
|
||||
$spreadsheet = $reader->load("05featuredemo.xlsx");
|
||||
```
|
||||
|
||||
#### Read data only
|
||||
|
||||
You can set the option setReadDataOnly on the reader, to instruct the
|
||||
reader to ignore styling, data validation, … and just read cell data:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
|
||||
$reader->setReadDataOnly(true);
|
||||
$spreadsheet = $reader->load("05featuredemo.xlsx");
|
||||
```
|
||||
|
||||
#### Read specific sheets only
|
||||
|
||||
You can set the option setLoadSheetsOnly on the reader, to instruct the
|
||||
reader to only load the sheets with a given name:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
|
||||
$reader->setLoadSheetsOnly( array("Sheet 1", "My special sheet") );
|
||||
$spreadsheet = $reader->load("05featuredemo.xlsx");
|
||||
```
|
||||
|
||||
#### Read specific cells only
|
||||
|
||||
You can set the option setReadFilter on the reader, to instruct the
|
||||
reader to only load the cells which match a given rule. A read filter
|
||||
can be any class which implements
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReadFilter. By default, all cells are
|
||||
read using the \PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter.
|
||||
|
||||
The following code will only read row 1 and rows 20 – 30 of any sheet in
|
||||
the Excel file:
|
||||
|
||||
``` php
|
||||
class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter {
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '') {
|
||||
// Read title row and rows 20 - 30
|
||||
if ($row == 1 || ($row >= 20 && $row <= 30)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
|
||||
$reader->setReadFilter( new MyReadFilter() );
|
||||
$spreadsheet = $reader->load("06largescale.xlsx");
|
||||
```
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Writer\Xlsx
|
||||
|
||||
#### Writing a spreadsheet
|
||||
|
||||
You can write an .xlsx file using the following code:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
|
||||
$writer->save("05featuredemo.xlsx");
|
||||
```
|
||||
|
||||
#### Formula pre-calculation
|
||||
|
||||
By default, this writer pre-calculates all formulas in the spreadsheet.
|
||||
This can be slow on large spreadsheets, and maybe even unwanted. You can
|
||||
however disable formula pre-calculation:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
|
||||
$writer->setPreCalculateFormulas(false);
|
||||
$writer->save("05featuredemo.xlsx");
|
||||
```
|
||||
|
||||
#### Office 2003 compatibility pack
|
||||
|
||||
Because of a bug in the Office2003 compatibility pack, there can be some
|
||||
small issues when opening Xlsx spreadsheets (mostly related to formula
|
||||
calculation). You can enable Office2003 compatibility with the following
|
||||
code:
|
||||
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
|
||||
$writer->setOffice2003Compatibility(true);
|
||||
$writer->save("05featuredemo.xlsx");
|
||||
|
||||
**Office2003 compatibility should only be used when needed** Office2003
|
||||
compatibility option should only be used when needed. This option
|
||||
disables several Office2007 file format options, resulting in a
|
||||
lower-featured Office2007 spreadsheet when this option is used.
|
||||
|
||||
## Excel 5 (BIFF) file format
|
||||
|
||||
Xls file format is the old Excel file format, implemented in
|
||||
PhpSpreadsheet to provide a uniform manner to create both .xlsx and .xls
|
||||
files. It is basically a modified version of [PEAR
|
||||
Spreadsheet\_Excel\_Writer](http://pear.php.net/package/Spreadsheet_Excel_Writer),
|
||||
although it has been extended and has fewer limitations and more
|
||||
features than the old PEAR library. This can read all BIFF versions that
|
||||
use OLE2: BIFF5 (introduced with office 95) through BIFF8, but cannot
|
||||
read earlier versions.
|
||||
|
||||
Xls file format will not be developed any further, it just provides an
|
||||
additional file format for PhpSpreadsheet.
|
||||
|
||||
**Excel5 (BIFF) limitations** Please note that BIFF file format has some
|
||||
limits regarding to styling cells and handling large spreadsheets via
|
||||
PHP.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Reader\Xls
|
||||
|
||||
#### Reading a spreadsheet
|
||||
|
||||
You can read an .xls file using the following code:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
|
||||
$spreadsheet = $reader->load("05featuredemo.xls");
|
||||
```
|
||||
|
||||
#### Read data only
|
||||
|
||||
You can set the option setReadDataOnly on the reader, to instruct the
|
||||
reader to ignore styling, data validation, … and just read cell data:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
|
||||
$reader->setReadDataOnly(true);
|
||||
$spreadsheet = $reader->load("05featuredemo.xls");
|
||||
```
|
||||
|
||||
#### Read specific sheets only
|
||||
|
||||
You can set the option setLoadSheetsOnly on the reader, to instruct the
|
||||
reader to only load the sheets with a given name:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
|
||||
$reader->setLoadSheetsOnly( array("Sheet 1", "My special sheet") );
|
||||
$spreadsheet = $reader->load("05featuredemo.xls");
|
||||
```
|
||||
|
||||
#### Read specific cells only
|
||||
|
||||
You can set the option setReadFilter on the reader, to instruct the
|
||||
reader to only load the cells which match a given rule. A read filter
|
||||
can be any class which implements
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReadFilter. By default, all cells are
|
||||
read using the \PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter.
|
||||
|
||||
The following code will only read row 1 and rows 20 to 30 of any sheet
|
||||
in the Excel file:
|
||||
|
||||
``` php
|
||||
class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter {
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '') {
|
||||
// Read title row and rows 20 - 30
|
||||
if ($row == 1 || ($row >= 20 && $row <= 30)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
|
||||
$reader->setReadFilter( new MyReadFilter() );
|
||||
$spreadsheet = $reader->load("06largescale.xls");
|
||||
```
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Writer\Xls
|
||||
|
||||
#### Writing a spreadsheet
|
||||
|
||||
You can write an .xls file using the following code:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xls($spreadsheet);
|
||||
$writer->save("05featuredemo.xls");
|
||||
```
|
||||
|
||||
## Excel 2003 XML file format
|
||||
|
||||
Excel 2003 XML file format is a file format which can be used in older
|
||||
versions of Microsoft Excel.
|
||||
|
||||
**Excel 2003 XML limitations** Please note that Excel 2003 XML format
|
||||
has some limits regarding to styling cells and handling large
|
||||
spreadsheets via PHP.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Reader\Xml
|
||||
|
||||
#### Reading a spreadsheet
|
||||
|
||||
You can read an Excel 2003 .xml file using the following code:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xml();
|
||||
$spreadsheet = $reader->load("05featuredemo.xml");
|
||||
```
|
||||
|
||||
#### Read specific cells only
|
||||
|
||||
You can set the option setReadFilter on the reader, to instruct the
|
||||
reader to only load the cells which match a given rule. A read filter
|
||||
can be any class which implements
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReadFilter. By default, all cells are
|
||||
read using the \PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter.
|
||||
|
||||
The following code will only read row 1 and rows 20 to 30 of any sheet
|
||||
in the Excel file:
|
||||
|
||||
``` php
|
||||
class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter {
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '') {
|
||||
// Read title row and rows 20 - 30
|
||||
if ($row == 1 || ($row >= 20 && $row <= 30)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xml();
|
||||
$reader->setReadFilter( new MyReadFilter() );
|
||||
$spreadsheet = $reader->load("06largescale.xml");
|
||||
```
|
||||
|
||||
## Symbolic LinK (SYLK)
|
||||
|
||||
Symbolic Link (SYLK) is a Microsoft file format typically used to
|
||||
exchange data between applications, specifically spreadsheets. SYLK
|
||||
files conventionally have a .slk suffix. Composed of only displayable
|
||||
ANSI characters, it can be easily created and processed by other
|
||||
applications, such as databases.
|
||||
|
||||
**SYLK limitations** Please note that SYLK file format has some limits
|
||||
regarding to styling cells and handling large spreadsheets via PHP.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Reader\Slk
|
||||
|
||||
#### Reading a spreadsheet
|
||||
|
||||
You can read an .slk file using the following code:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Slk();
|
||||
$spreadsheet = $reader->load("05featuredemo.slk");
|
||||
```
|
||||
|
||||
#### Read specific cells only
|
||||
|
||||
You can set the option setReadFilter on the reader, to instruct the
|
||||
reader to only load the cells which match a given rule. A read filter
|
||||
can be any class which implements
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReadFilter. By default, all cells are
|
||||
read using the \PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter.
|
||||
|
||||
The following code will only read row 1 and rows 20 to 30 of any sheet
|
||||
in the SYLK file:
|
||||
|
||||
``` php
|
||||
class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter {
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '') {
|
||||
// Read title row and rows 20 - 30
|
||||
if ($row == 1 || ($row >= 20 && $row <= 30)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Slk();
|
||||
$reader->setReadFilter( new MyReadFilter() );
|
||||
$spreadsheet = $reader->load("06largescale.slk");
|
||||
```
|
||||
|
||||
## Open/Libre Office (.ods)
|
||||
|
||||
Open Office or Libre Office .ods files are the standard file format for
|
||||
Open Office or Libre Office Calc files.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Reader\Ods
|
||||
|
||||
#### Reading a spreadsheet
|
||||
|
||||
You can read an .ods file using the following code:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Ods();
|
||||
$spreadsheet = $reader->load("05featuredemo.ods");
|
||||
```
|
||||
|
||||
#### Read specific cells only
|
||||
|
||||
You can set the option setReadFilter on the reader, to instruct the
|
||||
reader to only load the cells which match a given rule. A read filter
|
||||
can be any class which implements
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReadFilter. By default, all cells are
|
||||
read using the \PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter.
|
||||
|
||||
The following code will only read row 1 and rows 20 to 30 of any sheet
|
||||
in the Calc file:
|
||||
|
||||
``` php
|
||||
class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter {
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '') {
|
||||
// Read title row and rows 20 - 30
|
||||
if ($row == 1 || ($row >= 20 && $row <= 30)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$reader = new PhpOffice\PhpSpreadsheet\Reader\Ods();
|
||||
$reader->setReadFilter( new MyReadFilter() );
|
||||
$spreadsheet = $reader->load("06largescale.ods");
|
||||
```
|
||||
|
||||
## CSV (Comma Separated Values)
|
||||
|
||||
CSV (Comma Separated Values) are often used as an import/export file
|
||||
format with other systems. PhpSpreadsheet allows reading and writing to
|
||||
CSV files.
|
||||
|
||||
**CSV limitations** Please note that CSV file format has some limits
|
||||
regarding to styling cells, number formatting, ...
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Reader\Csv
|
||||
|
||||
#### Reading a CSV file
|
||||
|
||||
You can read a .csv file using the following code:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
|
||||
$spreadsheet = $reader->load("sample.csv");
|
||||
```
|
||||
|
||||
#### Setting CSV options
|
||||
|
||||
Often, CSV files are not really "comma separated", or use semicolon (`;`)
|
||||
as a separator. You can instruct
|
||||
\PhpOffice\PhpSpreadsheet\Reader\Csv some options before reading a CSV
|
||||
file.
|
||||
|
||||
The separator will be auto-detected, so in most cases it should not be necessary
|
||||
to specify it. But in cases where auto-detection does not fit the use-case, then
|
||||
it can be set manually.
|
||||
|
||||
Note that \PhpOffice\PhpSpreadsheet\Reader\Csv by default assumes that
|
||||
the loaded CSV file is UTF-8 encoded. If you are reading CSV files that
|
||||
were created in Microsoft Office Excel the correct input encoding may
|
||||
rather be Windows-1252 (CP1252). Always make sure that the input
|
||||
encoding is set appropriately.
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
|
||||
$reader->setInputEncoding('CP1252');
|
||||
$reader->setDelimiter(';');
|
||||
$reader->setEnclosure('');
|
||||
$reader->setLineEnding("\r\n");
|
||||
$reader->setSheetIndex(0);
|
||||
|
||||
$spreadsheet = $reader->load("sample.csv");
|
||||
```
|
||||
|
||||
#### Read a specific worksheet
|
||||
|
||||
CSV files can only contain one worksheet. Therefore, you can specify
|
||||
which sheet to read from CSV:
|
||||
|
||||
``` php
|
||||
$reader->setSheetIndex(0);
|
||||
```
|
||||
|
||||
#### Read into existing spreadsheet
|
||||
|
||||
When working with CSV files, it might occur that you want to import CSV
|
||||
data into an existing `Spreadsheet` object. The following code loads a
|
||||
CSV file into an existing `$spreadsheet` containing some sheets, and
|
||||
imports onto the 6th sheet:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
|
||||
$reader->setDelimiter(';');
|
||||
$reader->setEnclosure('');
|
||||
$reader->setLineEnding("\r\n");
|
||||
$reader->setSheetIndex(5);
|
||||
|
||||
$reader->loadIntoExisting("05featuredemo.csv", $spreadsheet);
|
||||
```
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Writer\Csv
|
||||
|
||||
#### Writing a CSV file
|
||||
|
||||
You can write a .csv file using the following code:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet);
|
||||
$writer->save("05featuredemo.csv");
|
||||
```
|
||||
|
||||
#### Setting CSV options
|
||||
|
||||
Often, CSV files are not really "comma separated", or use semicolon (`;`)
|
||||
as a separator. You can instruct
|
||||
\PhpOffice\PhpSpreadsheet\Writer\Csv some options before writing a CSV
|
||||
file:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet);
|
||||
$writer->setDelimiter(';');
|
||||
$writer->setEnclosure('');
|
||||
$writer->setLineEnding("\r\n");
|
||||
$writer->setSheetIndex(0);
|
||||
|
||||
$writer->save("05featuredemo.csv");
|
||||
```
|
||||
|
||||
#### Write a specific worksheet
|
||||
|
||||
CSV files can only contain one worksheet. Therefore, you can specify
|
||||
which sheet to write to CSV:
|
||||
|
||||
``` php
|
||||
$writer->setSheetIndex(0);
|
||||
```
|
||||
|
||||
#### Formula pre-calculation
|
||||
|
||||
By default, this writer pre-calculates all formulas in the spreadsheet.
|
||||
This can be slow on large spreadsheets, and maybe even unwanted. You can
|
||||
however disable formula pre-calculation:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet);
|
||||
$writer->setPreCalculateFormulas(false);
|
||||
$writer->save("05featuredemo.csv");
|
||||
```
|
||||
|
||||
#### Writing UTF-8 CSV files
|
||||
|
||||
A CSV file can be marked as UTF-8 by writing a BOM file header. This can
|
||||
be enabled by using the following code:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet);
|
||||
$writer->setUseBOM(true);
|
||||
$writer->save("05featuredemo.csv");
|
||||
```
|
||||
|
||||
#### Decimal and thousands separators
|
||||
|
||||
If the worksheet you are exporting contains numbers with decimal or
|
||||
thousands separators then you should think about what characters you
|
||||
want to use for those before doing the export.
|
||||
|
||||
By default PhpSpreadsheet looks up in the server's locale settings to
|
||||
decide what characters to use. But to avoid problems it is recommended
|
||||
to set the characters explicitly as shown below.
|
||||
|
||||
English users will want to use this before doing the export:
|
||||
|
||||
``` php
|
||||
\PhpOffice\PhpSpreadsheet\Shared\StringHelper::setDecimalSeparator('.');
|
||||
\PhpOffice\PhpSpreadsheet\Shared\StringHelper::setThousandsSeparator(',');
|
||||
```
|
||||
|
||||
German users will want to use the opposite values.
|
||||
|
||||
``` php
|
||||
\PhpOffice\PhpSpreadsheet\Shared\StringHelper::setDecimalSeparator(',');
|
||||
\PhpOffice\PhpSpreadsheet\Shared\StringHelper::setThousandsSeparator('.');
|
||||
```
|
||||
|
||||
Note that the above code sets decimal and thousand separators as global
|
||||
options. This also affects how HTML and PDF is exported.
|
||||
|
||||
## HTML
|
||||
|
||||
PhpSpreadsheet allows you to read or write a spreadsheet as HTML format,
|
||||
for quick representation of the data in it to anyone who does not have a
|
||||
spreadsheet application on their PC, or loading files saved by other
|
||||
scripts that simply create HTML markup and give it a .xls file
|
||||
extension.
|
||||
|
||||
**HTML limitations** Please note that HTML file format has some limits
|
||||
regarding to styling cells, number formatting, ...
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Reader\Html
|
||||
|
||||
#### Reading a spreadsheet
|
||||
|
||||
You can read an .html or .htm file using the following code:
|
||||
|
||||
``` php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Html();
|
||||
|
||||
$spreadsheet = $reader->load("05featuredemo.html");
|
||||
```
|
||||
|
||||
**HTML limitations** Please note that HTML reader is still experimental
|
||||
and does not yet support merged cells or nested tables cleanly
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Writer\Html
|
||||
|
||||
Please note that \PhpOffice\PhpSpreadsheet\Writer\Html only outputs the
|
||||
first worksheet by default.
|
||||
|
||||
#### Writing a spreadsheet
|
||||
|
||||
You can write a .htm file using the following code:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
|
||||
|
||||
$writer->save("05featuredemo.htm");
|
||||
```
|
||||
|
||||
#### Write all worksheets
|
||||
|
||||
HTML files can contain one or more worksheets. If you want to write all
|
||||
sheets into a single HTML file, use the following code:
|
||||
|
||||
``` php
|
||||
$writer->writeAllSheets();
|
||||
```
|
||||
|
||||
#### Write a specific worksheet
|
||||
|
||||
HTML files can contain one or more worksheets. Therefore, you can
|
||||
specify which sheet to write to HTML:
|
||||
|
||||
``` php
|
||||
$writer->setSheetIndex(0);
|
||||
```
|
||||
|
||||
#### Setting the images root of the HTML file
|
||||
|
||||
There might be situations where you want to explicitly set the included
|
||||
images root. For example, one might want to see
|
||||
|
||||
``` html
|
||||
<img style="position: relative; left: 0px; top: 0px; width: 140px; height: 78px;" src="http://www.domain.com/*images/logo.jpg" border="0">
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
``` html
|
||||
<img style="position: relative; left: 0px; top: 0px; width: 140px; height: 78px;" src="./images/logo.jpg" border="0">.
|
||||
```
|
||||
|
||||
You can use the following code to achieve this result:
|
||||
|
||||
``` php
|
||||
$writer->setImagesRoot('http://www.example.com');
|
||||
```
|
||||
|
||||
#### Formula pre-calculation
|
||||
|
||||
By default, this writer pre-calculates all formulas in the spreadsheet.
|
||||
This can be slow on large spreadsheets, and maybe even unwanted. You can
|
||||
however disable formula pre-calculation:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
|
||||
$writer->setPreCalculateFormulas(false);
|
||||
|
||||
$writer->save("05featuredemo.htm");
|
||||
```
|
||||
|
||||
#### Embedding generated HTML in a web page
|
||||
|
||||
There might be a situation where you want to embed the generated HTML in
|
||||
an existing website. \PhpOffice\PhpSpreadsheet\Writer\Html provides
|
||||
support to generate only specific parts of the HTML code, which allows
|
||||
you to use these parts in your website.
|
||||
|
||||
Supported methods:
|
||||
|
||||
- `generateHTMLHeader()`
|
||||
- `generateStyles()`
|
||||
- `generateSheetData()`
|
||||
- `generateHTMLFooter()`
|
||||
|
||||
Here's an example which retrieves all parts independently and merges
|
||||
them into a resulting HTML page:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
|
||||
echo $writer->generateHTMLHeader();
|
||||
?>
|
||||
|
||||
<style>
|
||||
<!--
|
||||
html {
|
||||
font-family: Times New Roman;
|
||||
font-size: 9pt;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
<?php
|
||||
echo $writer->generateStyles(false); // do not write <style> and </style>
|
||||
?>
|
||||
|
||||
-->
|
||||
</style>
|
||||
|
||||
<?php
|
||||
echo $writer->generateSheetData();
|
||||
echo $writer->generateHTMLFooter();
|
||||
?>
|
||||
```
|
||||
|
||||
#### Writing UTF-8 HTML files
|
||||
|
||||
A HTML file can be marked as UTF-8 by writing a BOM file header. This
|
||||
can be enabled by using the following code:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
|
||||
$writer->setUseBOM(true);
|
||||
|
||||
$writer->save("05featuredemo.htm");
|
||||
```
|
||||
|
||||
#### Decimal and thousands separators
|
||||
|
||||
See section \PhpOffice\PhpSpreadsheet\Writer\Csv how to control the
|
||||
appearance of these.
|
||||
|
||||
## PDF
|
||||
|
||||
PhpSpreadsheet allows you to write a spreadsheet into PDF format, for
|
||||
fast distribution of represented data.
|
||||
|
||||
**PDF limitations** Please note that PDF file format has some limits
|
||||
regarding to styling cells, number formatting, ...
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\Writer\Pdf
|
||||
|
||||
PhpSpreadsheet’s PDF Writer is a wrapper for a 3rd-Party PDF Rendering
|
||||
library such as tcPDF, mPDF or DomPDF. You must now install a PDF
|
||||
rendering library yourself; but PhpSpreadsheet will work with a number
|
||||
of different libraries.
|
||||
|
||||
Currently, the following libraries are supported:
|
||||
|
||||
Library | Downloadable from | PhpSpreadsheet Internal Constant
|
||||
--------|-------------------------------------|---------------------------------
|
||||
tcPDF | https://github.com/tecnickcom/tcpdf | PDF_RENDERER_TCPDF
|
||||
mPDF | https://github.com/mpdf/mpdf | PDF_RENDERER_MPDF
|
||||
domPDF | https://github.com/dompdf/dompdf | PDF_RENDERER_DOMPDF
|
||||
|
||||
The different libraries have different strengths and weaknesses. Some
|
||||
generate better formatted output than others, some are faster or use
|
||||
less memory than others, while some generate smaller .pdf files. It is
|
||||
the developers choice which one they wish to use, appropriate to their
|
||||
own circumstances.
|
||||
|
||||
Before instantiating a Writer to generate PDF output, you will need to
|
||||
indicate which Rendering library you are using.
|
||||
|
||||
``` php
|
||||
$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_MPDF;
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName);
|
||||
```
|
||||
|
||||
#### Writing a spreadsheet
|
||||
|
||||
Once you have identified the Renderer that you wish to use for PDF
|
||||
generation, you can write a .pdf file using the following code:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf($spreadsheet);
|
||||
$writer->save("05featuredemo.pdf");
|
||||
```
|
||||
|
||||
Please note that \PhpOffice\PhpSpreadsheet\Writer\Pdf only outputs the
|
||||
first worksheet by default.
|
||||
|
||||
#### Write all worksheets
|
||||
|
||||
PDF files can contain one or more worksheets. If you want to write all
|
||||
sheets into a single PDF file, use the following code:
|
||||
|
||||
``` php
|
||||
$writer->writeAllSheets();
|
||||
```
|
||||
|
||||
#### Write a specific worksheet
|
||||
|
||||
PDF files can contain one or more worksheets. Therefore, you can specify
|
||||
which sheet to write to PDF:
|
||||
|
||||
``` php
|
||||
$writer->setSheetIndex(0);
|
||||
```
|
||||
|
||||
#### Formula pre-calculation
|
||||
|
||||
By default, this writer pre-calculates all formulas in the spreadsheet.
|
||||
This can be slow on large spreadsheets, and maybe even unwanted. You can
|
||||
however disable formula pre-calculation:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf($spreadsheet);
|
||||
$writer->setPreCalculateFormulas(false);
|
||||
|
||||
$writer->save("05featuredemo.pdf");
|
||||
```
|
||||
|
||||
#### Decimal and thousands separators
|
||||
|
||||
See section \PhpOffice\PhpSpreadsheet\Writer\Csv how to control the
|
||||
appearance of these.
|
||||
|
||||
## Generating Excel files from templates (read, modify, write)
|
||||
|
||||
Readers and writers are the tools that allow you to generate Excel files
|
||||
from templates. This requires less coding effort than generating the
|
||||
Excel file from scratch, especially if your template has many styles,
|
||||
page setup properties, headers etc.
|
||||
|
||||
Here is an example how to open a template file, fill in a couple of
|
||||
fields and save it again:
|
||||
|
||||
``` php
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('template.xlsx');
|
||||
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$worksheet->getCell('A1')->setValue('John');
|
||||
$worksheet->getCell('A2')->setValue('Smith');
|
||||
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
$writer->save('write.xls');
|
||||
```
|
||||
|
||||
Notice that it is ok to load an xlsx file and generate an xls file.
|
|
@ -12,14 +12,13 @@ spreadsheet files. This can lead to:
|
|||
- Server Side Request Forgery
|
||||
- Command Execution (depending on the installed PHP wrappers)
|
||||
|
||||
To prevent this, PhpSpreadsheet sets `libxml_disable_entity_loader` to
|
||||
`true` for the XML-based Readers by default.
|
||||
To prevent this, by default every XML-based Reader looks for XML entities declared inside the DOCTYPE and if any is found an exception is raised.
|
||||
|
||||
## Loading a Spreadsheet File
|
||||
|
||||
The simplest way to load a workbook file is to let PhpSpreadsheet's IO
|
||||
Factory identify the file type and load it, calling the static load()
|
||||
method of the \PhpOffice\PhpSpreadsheet\IOFactory class.
|
||||
Factory identify the file type and load it, calling the static `load()`
|
||||
method of the `\PhpOffice\PhpSpreadsheet\IOFactory` class.
|
||||
|
||||
``` php
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
@ -31,7 +30,7 @@ $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
|
|||
> See Examples/Reader/exampleReader01.php for a working example of this
|
||||
> code.
|
||||
|
||||
The load() method will attempt to identify the file type, and
|
||||
The `load()` method will attempt to identify the file type, and
|
||||
instantiate a loader for that file type; using it to load the file and
|
||||
store the data and any formatting in a `Spreadsheet` object.
|
||||
|
||||
|
@ -52,7 +51,7 @@ actually reading the file into a `Spreadsheet` object.
|
|||
|
||||
If you know the file type of the spreadsheet file that you need to load,
|
||||
you can instantiate a new reader object for that file type, then use the
|
||||
reader's load() method to read the file to a `Spreadsheet` object. It is
|
||||
reader's `load()` method to read the file to a `Spreadsheet` object. It is
|
||||
possible to instantiate the reader objects for each of the different
|
||||
supported filetype by name. However, you may get unpredictable results
|
||||
if the file isn't of the right type (e.g. it is a CSV with an extension
|
||||
|
@ -76,7 +75,7 @@ $spreadsheet = $reader->load($inputFileName);
|
|||
> See Examples/Reader/exampleReader02.php for a working example of this
|
||||
> code.
|
||||
|
||||
Alternatively, you can use the IO Factory's createReader() method to
|
||||
Alternatively, you can use the IO Factory's `createReader()` method to
|
||||
instantiate the reader object for you, simply telling it the file type
|
||||
of the reader that you want instantiating.
|
||||
|
||||
|
@ -121,7 +120,7 @@ $spreadsheet = $reader->load($inputFileName);
|
|||
|
||||
Once you have created a reader object for the workbook that you want to
|
||||
load, you have the opportunity to set additional options before
|
||||
executing the load() method.
|
||||
executing the `load()` method.
|
||||
|
||||
### Reading Only Data from a Spreadsheet File
|
||||
|
||||
|
@ -173,7 +172,7 @@ setLoadSheetsOnly() method to identify those sheets you are interested
|
|||
in reading.
|
||||
|
||||
To read a single sheet, you can pass that sheet name as a parameter to
|
||||
the setLoadSheetsOnly() method.
|
||||
the `setLoadSheetsOnly()` method.
|
||||
|
||||
``` php
|
||||
$inputFileType = 'Xls';
|
||||
|
@ -192,7 +191,7 @@ $spreadsheet = $reader->load($inputFileName);
|
|||
> code.
|
||||
|
||||
If you want to read more than just a single sheet, you can pass a list
|
||||
of sheet names as an array parameter to the setLoadSheetsOnly() method.
|
||||
of sheet names as an array parameter to the `setLoadSheetsOnly()` method.
|
||||
|
||||
``` php
|
||||
$inputFileType = 'Xls';
|
||||
|
@ -210,7 +209,7 @@ $spreadsheet = $reader->load($inputFileName);
|
|||
> See Examples/Reader/exampleReader08.php for a working example of this
|
||||
> code.
|
||||
|
||||
To reset this option to the default, you can call the setLoadAllSheets()
|
||||
To reset this option to the default, you can call the `setLoadAllSheets()`
|
||||
method.
|
||||
|
||||
``` php
|
||||
|
@ -242,8 +241,8 @@ If you are only interested in reading part of a worksheet, then you can
|
|||
write a filter class that identifies whether or not individual cells
|
||||
should be read by the loader. A read filter must implement the
|
||||
\PhpOffice\PhpSpreadsheet\Reader\IReadFilter interface, and contain a
|
||||
readCell() method that accepts arguments of \$column, \$row and
|
||||
\$worksheetName, and return a boolean true or false that indicates
|
||||
readCell() method that accepts arguments of `$column`, `$row` and
|
||||
`$worksheetName`, and return a boolean true or false that indicates
|
||||
whether a workbook cell identified by those arguments should be read or
|
||||
not.
|
||||
|
||||
|
@ -320,7 +319,7 @@ $filterSubset = new MyReadFilter(9,15,range('G','K'));
|
|||
> code.
|
||||
|
||||
This can be particularly useful for conserving memory, by allowing you
|
||||
to read and process a large workbook in “chunks”: an example of this
|
||||
to read and process a large workbook in "chunks": an example of this
|
||||
usage might be when transferring data from an Excel worksheet to a
|
||||
database.
|
||||
|
||||
|
@ -387,13 +386,13 @@ CSV | YES | HTML | NO | | |
|
|||
### Combining Multiple Files into a Single Spreadsheet Object
|
||||
|
||||
While you can limit the number of worksheets that are read from a
|
||||
workbook file using the setLoadSheetsOnly() method, certain readers also
|
||||
workbook file using the `setLoadSheetsOnly()` method, certain readers also
|
||||
allow you to combine several individual "sheets" from different files
|
||||
into a single `Spreadsheet` object, where each individual file is a
|
||||
single worksheet within that workbook. For each file that you read, you
|
||||
need to indicate which worksheet index it should be loaded into using
|
||||
the setSheetIndex() method of the \$reader, then use the
|
||||
loadIntoExisting() method rather than the load() method to actually read
|
||||
the `setSheetIndex()` method of the `$reader`, then use the
|
||||
`loadIntoExisting()` method rather than the `load()` method to actually read
|
||||
the file into that worksheet.
|
||||
|
||||
``` php
|
||||
|
@ -451,9 +450,9 @@ Xlsx Microsoft Office Open XML SpreadsheetML .xlsx file is limited to
|
|||
by available disk space. This means that we wouldn’t ordinarily be able
|
||||
to read all the rows from a very large CSV file that exceeded those
|
||||
limits, and save it as an Xls or Xlsx file. However, by using Read
|
||||
Filters to read the CSV file in “chunks” (using the chunkReadFilter
|
||||
Class that we defined in section REF \_Ref275604563 \r \p 5.3 above),
|
||||
and the setSheetIndex() method of the \$reader, we can split the CSV
|
||||
Filters to read the CSV file in "chunks" (using the chunkReadFilter
|
||||
Class that we defined in [the above section](#reading-only-specific-columns-and-rows-from-a-file-read-filters),
|
||||
and the `setSheetIndex()` method of the `$reader`, we can split the CSV
|
||||
file across several individual worksheets.
|
||||
|
||||
``` php
|
||||
|
@ -504,7 +503,7 @@ for ($startRow = 2; $startRow <= 1000000; $startRow += $chunkSize) {
|
|||
This code will read 65,530 rows at a time from the CSV file that we’re
|
||||
loading, and store each "chunk" in a new worksheet.
|
||||
|
||||
The setContiguous() method for the Reader is important here. It is
|
||||
The `setContiguous()` method for the Reader is important here. It is
|
||||
applicable only when working with a Read Filter, and identifies whether
|
||||
or not the cells should be stored by their position within the CSV file,
|
||||
or their position relative to the filter.
|
||||
|
@ -524,15 +523,17 @@ CSV | YES | HTML | NO
|
|||
|
||||
### Pipe or Tab Separated Value Files
|
||||
|
||||
The CSV loader defaults to loading a file where comma is used as the
|
||||
separator, but you can modify this to load tab- or pipe-separated value
|
||||
files using the setDelimiter() method.
|
||||
The CSV loader will attempt to auto-detect the separator used in the file. If it
|
||||
cannot auto-detect, it will default to the comma. If this does not fit your
|
||||
use-case, you can manually specify a separator by using the `setDelimiter()`
|
||||
method.
|
||||
|
||||
``` php
|
||||
$inputFileType = 'Csv';
|
||||
$inputFileName = './sampleData/example1.tsv';
|
||||
|
||||
/** Create a new Reader of the type defined in $inputFileType **/ $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
/** Create a new Reader of the type defined in $inputFileType **/
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
/** Set the delimiter to a TAB character **/
|
||||
$reader->setDelimiter("\t");
|
||||
// $reader->setDelimiter('|');
|
||||
|
@ -547,8 +548,11 @@ $spreadsheet = $reader->load($inputFileName);
|
|||
In addition to the delimiter, you can also use the following methods to
|
||||
set other attributes for the data load:
|
||||
|
||||
setEnclosure() | default is " setLineEnding() | default is PHP\_EOL
|
||||
setInputEncoding() | default is UTF-8
|
||||
Method | Default
|
||||
-------------------|----------
|
||||
setEnclosure() | `"`
|
||||
setLineEnding() | `PHP_EOL`
|
||||
setInputEncoding() | `UTF-8`
|
||||
|
||||
Setting CSV delimiter applies to:
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ Please note that these do NOT offer complete documentation on specific
|
|||
PhpSpreadsheet API functions, but just a bump to get you started. If you
|
||||
need specific API functions, please refer to the API documentation.
|
||||
|
||||
For example, REF \_Ref191885321 \w \h 4.4.7 REF \_Ref191885321
|
||||
\h Setting a worksheet's page orientation and size covers setting a page
|
||||
For example, [setting a worksheet's page orientation and size
|
||||
](#setting-a-worksheets-page-orientation-and-size) covers setting a page
|
||||
orientation to A4. Other paper formats, like US Letter, are not covered
|
||||
in this document, but in the PhpSpreadsheet API documentation.
|
||||
|
||||
|
@ -119,9 +119,9 @@ in an English version of Microsoft Office Excel, and PhpSpreadsheet
|
|||
handles all formulae internally in this format. This means that the
|
||||
following rules hold:
|
||||
|
||||
- Decimal separator is '.' (period)
|
||||
- Function argument separator is ',' (comma)
|
||||
- Matrix row separator is ';' (semicolon)
|
||||
- Decimal separator is `.` (period)
|
||||
- Function argument separator is `,` (comma)
|
||||
- Matrix row separator is `;` (semicolon)
|
||||
- English function names must be used
|
||||
|
||||
This is regardless of which language version of Microsoft Office Excel
|
||||
|
@ -132,16 +132,16 @@ will take care of displaying the formula according the applications
|
|||
language. Translation is taken care of by the application!
|
||||
|
||||
The following line of code writes the formula
|
||||
'=IF(C4>500,"profit","loss")' into the cell B8. Note that the
|
||||
formula must start with "=" to make PhpSpreadsheet recognise this as a
|
||||
`=IF(C4>500,"profit","loss")` into the cell B8. Note that the
|
||||
formula must start with `=` to make PhpSpreadsheet recognise this as a
|
||||
formula.
|
||||
|
||||
``` php
|
||||
$spreadsheet->getActiveSheet()->setCellValue('B8','=IF(C4>500,"profit","loss")');
|
||||
```
|
||||
|
||||
If you want to write a string beginning with an "=" character to a
|
||||
cell, then you should use the setCellValueExplicit() method.
|
||||
If you want to write a string beginning with an `=` character to a
|
||||
cell, then you should use the `setCellValueExplicit()` method.
|
||||
|
||||
``` php
|
||||
$spreadsheet->getActiveSheet()
|
||||
|
@ -159,7 +159,7 @@ $formula = $spreadsheet->getActiveSheet()->getCell('B8')->getValue();
|
|||
```
|
||||
|
||||
If you need the calculated value of a cell, use the following code. This
|
||||
is further explained in REF \_Ref191885372 \w \h \* MERGEFORMAT 4.4.35.
|
||||
is further explained in [the calculation engine](./calculation-engine.md).
|
||||
|
||||
``` php
|
||||
$value = $spreadsheet->getActiveSheet()->getCell('B8')->getCalculatedValue();
|
||||
|
@ -239,7 +239,7 @@ $spreadsheet->getActiveSheet()->getStyle('A1')->getAlignment()->setWrapText(true
|
|||
|
||||
**Tip**
|
||||
|
||||
Read more about formatting cells using getStyle() elsewhere.
|
||||
Read more about formatting cells using `getStyle()` elsewhere.
|
||||
|
||||
**Tip**
|
||||
|
||||
|
@ -332,7 +332,7 @@ $spreadsheet->getActiveSheet()->getPageSetup()->setFitToHeight(0);
|
|||
As you can see, it is not necessary to call setFitToPage(TRUE) since
|
||||
setFitToWidth(...) and setFitToHeight(...) triggers this.
|
||||
|
||||
If you use setFitToWidth() you should in general also specify
|
||||
If you use `setFitToWidth()` you should in general also specify
|
||||
setFitToHeight() explicitly like in the example. Be careful relying on
|
||||
the initial values.
|
||||
|
||||
|
@ -474,7 +474,9 @@ $spreadsheet->getActiveSheet()->setBreak( 'D10' , \PhpOffice\PhpSpreadsheet\Work
|
|||
|
||||
To show/hide gridlines when printing, use the following code:
|
||||
|
||||
\$spreadsheet->getActiveSheet()->setShowGridlines(true);
|
||||
```php
|
||||
$spreadsheet->getActiveSheet()->setShowGridlines(true);
|
||||
```
|
||||
|
||||
### Setting rows/columns to repeat at top/left
|
||||
|
||||
|
@ -738,7 +740,7 @@ vertical/horizontal, left/right/top/bottom/diagonal.
|
|||
This border hierarchy can be utilized to achieve various effects in an
|
||||
easy manner.
|
||||
|
||||
### Valid array keys for style applyFromArray()
|
||||
### Valid array keys for style `applyFromArray()`
|
||||
|
||||
The following table lists the valid array keys for
|
||||
\PhpOffice\PhpSpreadsheet\Style applyFromArray() classes. If the "Maps
|
||||
|
@ -1001,15 +1003,15 @@ $validation->setFormula1('"Item A,Item B,Item C"');
|
|||
```
|
||||
|
||||
When using a data validation list like above, make sure you put the list
|
||||
between " and " and that you split the items with a comma (,).
|
||||
between `"` and `"` and that you split the items with a comma (`,`).
|
||||
|
||||
It is important to remember that any string participating in an Excel
|
||||
formula is allowed to be maximum 255 characters (not bytes). This sets a
|
||||
limit on how many items you can have in the string "Item A,Item B,Item
|
||||
C". Therefore it is normally a better idea to type the item values
|
||||
directly in some cell range, say A1:A3, and instead use, say,
|
||||
$validation->setFormula1('Sheet!$A$1:$A\$3');. Another benefit is that
|
||||
the item values themselves can contain the comma "," character itself.
|
||||
`$validation->setFormula1('Sheet!$A$1:$A$3')`. Another benefit is that
|
||||
the item values themselves can contain the comma `,` character itself.
|
||||
|
||||
If you need data validation on multiple cells, one can clone the
|
||||
ruleset:
|
||||
|
@ -1039,20 +1041,26 @@ $spreadsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
|||
The measure for column width in PhpSpreadsheet does **not** correspond
|
||||
exactly to the measure you may be used to in Microsoft Office Excel.
|
||||
Column widths are difficult to deal with in Excel, and there are several
|
||||
measures for the column width.1) **Inner width in character units**
|
||||
(e.g. 8.43 this is probably what you are familiar with in Excel)2)
|
||||
**Full width in pixels** (e.g. 64 pixels)3) **Full width in character
|
||||
units** (e.g. 9.140625, value -1 indicates unset width)**PHPExcel always
|
||||
operates with 3) "Full width in character units"** which is in fact the
|
||||
measures for the column width.
|
||||
|
||||
1. Inner width in character units
|
||||
(e.g. 8.43 this is probably what you are familiar with in Excel)
|
||||
2. Full width in pixels (e.g. 64 pixels)
|
||||
3. Full width in character units (e.g. 9.140625, value -1 indicates unset width)
|
||||
|
||||
**PhpSpreadsheet always
|
||||
operates with "3. Full width in character units"** which is in fact the
|
||||
only value that is stored in any Excel file, hence the most reliable
|
||||
measure. Unfortunately, **Microsoft Office Excel does not present you
|
||||
with this measure**. Instead measures 1) and 2) are computed by the
|
||||
with this measure**. Instead measures 1 and 2 are computed by the
|
||||
application when the file is opened and these values are presented in
|
||||
various dialogues and tool tips.The character width unit is the width of
|
||||
a '0' (zero) glyph in the workbooks default font. Therefore column
|
||||
various dialogues and tool tips.
|
||||
|
||||
The character width unit is the width of
|
||||
a `0` (zero) glyph in the workbooks default font. Therefore column
|
||||
widths measured in character units in two different workbooks can only
|
||||
be compared if they have the same default workbook font.If you have some
|
||||
Excel file and need to know the column widths in measure 3), you can
|
||||
Excel file and need to know the column widths in measure 3, you can
|
||||
read the Excel file with PhpSpreadsheet and echo the retrieved values.
|
||||
|
||||
## Show/hide a column
|
||||
|
@ -1487,7 +1495,7 @@ visible via the user interface.
|
|||
|
||||
## Right-to-left worksheet
|
||||
|
||||
Worksheets can be set individually whether column "A" should start at
|
||||
Worksheets can be set individually whether column `A` should start at
|
||||
left or right side. Default is left. Here is how to set columns from
|
||||
right-to-left.
|
||||
|
||||
|
|
|
@ -5,177 +5,20 @@ before instantiating a `Spreadsheet` object or loading a workbook file,
|
|||
there are a number of configuration options that can be set which will
|
||||
affect the subsequent behaviour of the script.
|
||||
|
||||
## Cell Caching
|
||||
## Cell collection caching
|
||||
|
||||
PhpSpreadsheet uses an average of about 1k/cell in your worksheets, so
|
||||
large workbooks can quickly use up available memory. Cell caching
|
||||
provides a mechanism that allows PhpSpreadsheet to maintain the cell
|
||||
objects in a smaller size of memory, on disk, or in APC, memcache or
|
||||
Wincache, rather than in PHP memory. This allows you to reduce the
|
||||
memory usage for large workbooks, although at a cost of speed to access
|
||||
cell data.
|
||||
By default, PhpSpreadsheet holds all cell objects in memory, but
|
||||
you can specify alternatives to reduce memory consumption at the cost of speed.
|
||||
Read more about [memory saving](./memory_saving.md).
|
||||
|
||||
By default, PhpSpreadsheet still holds all cell objects in memory, but
|
||||
you can specify alternatives. To enable cell caching, you must call the
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod() method,
|
||||
passing in the caching method that you wish to use.
|
||||
To enable cell caching, you must provide your own implementation of cache like so:
|
||||
|
||||
``` php
|
||||
$cacheMethod = \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE_IN_MEMORY;
|
||||
$cache = new MyCustomPsr16Implementation();
|
||||
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod($cacheMethod);
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCache($cache);
|
||||
```
|
||||
|
||||
setCacheStorageMethod() will return a boolean true on success, false on
|
||||
failure (for example if trying to cache to APC when APC is not enabled).
|
||||
|
||||
A separate cache is maintained for each individual worksheet, and is
|
||||
automatically created when the worksheet is instantiated based on the
|
||||
caching method and settings that you have configured. You cannot change
|
||||
the configuration settings once you have started to read a workbook, or
|
||||
have created your first worksheet.
|
||||
|
||||
Currently, the following caching methods are available.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_IN\_MEMORY
|
||||
|
||||
The default. If you don't initialise any caching method, then this is
|
||||
the method that PhpSpreadsheet will use. Cell objects are maintained in
|
||||
PHP memory as at present.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_IN\_MEMORY\_SERIALIZED
|
||||
|
||||
Using this caching method, cells are held in PHP memory as an array of
|
||||
serialized objects, which reduces the memory footprint with minimal
|
||||
performance overhead.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_IN\_MEMORY\_GZIP
|
||||
|
||||
Like cache\_in\_memory\_serialized, this method holds cells in PHP
|
||||
memory as an array of serialized objects, but gzipped to reduce the
|
||||
memory usage still further, although access to read or write a cell is
|
||||
slightly slower.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_IGBINARY
|
||||
|
||||
Uses PHPs igbinary extension (if its available) to serialize cell
|
||||
objects in memory. This is normally faster and uses less memory than
|
||||
standard PHP serialization, but isnt available in most hosting
|
||||
environments.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_TO\_DISCISAM
|
||||
|
||||
When using CACHE\_TO\_DISCISAM all cells are held in a temporary disk
|
||||
file, with only an index to their location in that file maintained in
|
||||
PHP memory. This is slower than any of the CACHE\_IN\_MEMORY methods,
|
||||
but significantly reduces the memory footprint. By default,
|
||||
PhpSpreadsheet will use PHP's temp directory for the cache file, but you
|
||||
can specify a different directory when initialising CACHE\_TO\_DISCISAM.
|
||||
|
||||
``` php
|
||||
$cacheMethod = \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE_TO_DISCISAM;
|
||||
$cacheSettings = array(
|
||||
'dir' => '/usr/local/tmp'
|
||||
);
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||
```
|
||||
|
||||
The temporary disk file is automatically deleted when your script
|
||||
terminates.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_TO\_PHPTEMP
|
||||
|
||||
Like CACHE\_TO\_DISCISAM, when using CACHE\_TO\_PHPTEMP all cells are
|
||||
held in the php://temp I/O stream, with only an index to their location
|
||||
maintained in PHP memory. In PHP, the php://memory wrapper stores data
|
||||
in the memory: php://temp behaves similarly, but uses a temporary file
|
||||
for storing the data when a certain memory limit is reached. The default
|
||||
is 1 MB, but you can change this when initialising CACHE\_TO\_PHPTEMP.
|
||||
|
||||
``` php
|
||||
$cacheMethod = \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE_TO_PHPTEMP;
|
||||
$cacheSettings = array(
|
||||
'memoryCacheSize' => '8MB'
|
||||
);
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||
```
|
||||
|
||||
The php://temp file is automatically deleted when your script
|
||||
terminates.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_TO\_APC
|
||||
|
||||
When using CACHE\_TO\_APC, cell objects are maintained in APC with only
|
||||
an index maintained in PHP memory to identify that the cell exists. By
|
||||
default, an APC cache timeout of 600 seconds is used, which should be
|
||||
enough for most applications: although it is possible to change this
|
||||
when initialising CACHE\_TO\_APC.
|
||||
|
||||
``` php
|
||||
$cacheMethod = \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE_TO_APC;
|
||||
$cacheSettings = array(
|
||||
'cacheTime' => 600
|
||||
);
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||
```
|
||||
|
||||
When your script terminates all entries will be cleared from APC,
|
||||
regardless of the cacheTime value, so it cannot be used for persistent
|
||||
storage using this mechanism.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_TO\_MEMCACHE
|
||||
|
||||
When using CACHE\_TO\_MEMCACHE, cell objects are maintained in memcache
|
||||
with only an index maintained in PHP memory to identify that the cell
|
||||
exists.
|
||||
|
||||
By default, PhpSpreadsheet looks for a memcache server on localhost at
|
||||
port 11211. It also sets a memcache timeout limit of 600 seconds. If you
|
||||
are running memcache on a different server or port, then you can change
|
||||
these defaults when you initialise CACHE\_TO\_MEMCACHE:
|
||||
|
||||
``` php
|
||||
$cacheMethod = \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE_TO_MEMCACHE;
|
||||
$cacheSettings = array(
|
||||
'memcacheServer' => 'localhost',
|
||||
'memcachePort' => 11211,
|
||||
'cacheTime' => 600
|
||||
);
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||
```
|
||||
|
||||
When your script terminates all entries will be cleared from memcache,
|
||||
regardless of the cacheTime value, so it cannot be used for persistent
|
||||
storage using this mechanism.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_TO\_WINCACHE
|
||||
|
||||
When using CACHE\_TO\_WINCACHE, cell objects are maintained in Wincache
|
||||
with only an index maintained in PHP memory to identify that the cell
|
||||
exists. By default, a Wincache cache timeout of 600 seconds is used,
|
||||
which should be enough for most applications: although it is possible to
|
||||
change this when initialising CACHE\_TO\_WINCACHE.
|
||||
|
||||
``` php
|
||||
$cacheMethod = \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE_TO_WINCACHE;
|
||||
$cacheSettings = array(
|
||||
'cacheTime' => 600
|
||||
);
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||
```
|
||||
|
||||
When your script terminates all entries will be cleared from Wincache,
|
||||
regardless of the cacheTime value, so it cannot be used for persistent
|
||||
storage using this mechanism.
|
||||
|
||||
### \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE\_TO\_SQLITE3;
|
||||
|
||||
Uses an SQLite 3 "in-memory" database for caching cell data. Unlike
|
||||
other caching methods, neither cells nor an index are held in PHP memory
|
||||
- an indexed database table makes it unnecessary to hold any index in
|
||||
PHP memory, which makes this the most memory-efficient of the cell
|
||||
caching methods.
|
||||
|
||||
## Language/Locale
|
||||
|
||||
Some localisation elements have been included in PhpSpreadsheet. You can
|
||||
|
@ -190,12 +33,13 @@ if (!$validLocale) {
|
|||
}
|
||||
```
|
||||
|
||||
If Brazilian Portuguese language files aren't available, then Portuguese
|
||||
will be enabled instead: if Portuguese language files aren't available,
|
||||
then the setLocale() method will return an error, and American English
|
||||
- If Brazilian Portuguese language files aren't available, then Portuguese
|
||||
will be enabled instead
|
||||
- If Portuguese language files aren't available,
|
||||
then the `setLocale()` method will return an error, and American English
|
||||
(en\_us) settings will be used throughout.
|
||||
|
||||
More details of the features available once a locale has been set,
|
||||
including a list of the languages and locales currently supported, can
|
||||
be found in the section of this document entitled "Locale Settings for
|
||||
Formulae".
|
||||
be found in [Locale Settings for
|
||||
Formulae](./recipes.md#locale-settings-for-formulae).
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
# Worksheets
|
||||
|
||||
A worksheet is a collection of cells, formulae, images, graphs, etc. It
|
||||
holds all data necessary to represent a spreadsheet worksheet.
|
||||
|
||||
When you load a workbook from a spreadsheet file, it will be loaded with
|
||||
all its existing worksheets (unless you specified that only certain
|
||||
sheets should be loaded). When you load from non-spreadsheet files (such
|
||||
as a CSV or HTML file) or from spreadsheet formats that don't identify
|
||||
worksheets by name (such as SYLK), then a single worksheet called
|
||||
"WorkSheet1" will be created containing the data from that file.
|
||||
|
||||
When you instantiate a new workbook, PhpSpreadsheet will create it with
|
||||
a single worksheet called "WorkSheet1".
|
||||
|
||||
The `getSheetCount()` method will tell you the number of worksheets in
|
||||
the workbook; while the `getSheetNames()` method will return a list of
|
||||
all worksheets in the workbook, indexed by the order in which their
|
||||
"tabs" would appear when opened in MS Excel (or other appropriate
|
||||
Spreadsheet program).
|
||||
|
||||
Individual worksheets can be accessed by name, or by their index
|
||||
position in the workbook. The index position represents the order that
|
||||
each worksheet "tab" is shown when the workbook is opened in MS Excel
|
||||
(or other appropriate Spreadsheet program). To access a sheet by its
|
||||
index, use the `getSheet()` method.
|
||||
|
||||
``` php
|
||||
// Get the second sheet in the workbook
|
||||
// Note that sheets are indexed from 0
|
||||
$spreadsheet->getSheet(1);
|
||||
```
|
||||
|
||||
If you don't specify a sheet index, then the first worksheet will be
|
||||
returned.
|
||||
|
||||
Methods also exist allowing you to reorder the worksheets in the
|
||||
workbook.
|
||||
|
||||
To access a sheet by name, use the `getSheetByName()` method, specifying
|
||||
the name of the worksheet that you want to access.
|
||||
|
||||
``` php
|
||||
// Retrieve the worksheet called 'Worksheet 1'
|
||||
$spreadsheet->getSheetByName('Worksheet 1');
|
||||
```
|
||||
|
||||
Alternatively, one worksheet is always the currently active worksheet,
|
||||
and you can access that directly. The currently active worksheet is the
|
||||
one that will be active when the workbook is opened in MS Excel (or
|
||||
other appropriate Spreadsheet program).
|
||||
|
||||
``` php
|
||||
// Retrieve the current active worksheet
|
||||
$spreadsheet->getActiveSheet();
|
||||
```
|
||||
|
||||
You can change the currently active sheet by index or by name using the
|
||||
`setActiveSheetIndex()` and `setActiveSheetIndexByName()` methods.
|
||||
|
||||
## Adding a new Worksheet
|
||||
|
||||
You can add a new worksheet to the workbook using the `createSheet()`
|
||||
method of the `Spreadsheet` object. By default, this will be created as
|
||||
a new "last" sheet; but you can also specify an index position as an
|
||||
argument, and the worksheet will be inserted at that position, shuffling
|
||||
all subsequent worksheets in the collection down a place.
|
||||
|
||||
``` php
|
||||
$spreadsheet->createSheet();
|
||||
```
|
||||
|
||||
A new worksheet created using this method will be called
|
||||
"Worksheet<n>" where "<n>" is the lowest number possible to
|
||||
guarantee that the title is unique.
|
||||
|
||||
Alternatively, you can instantiate a new worksheet (setting the title to
|
||||
whatever you choose) and then insert it into your workbook using the
|
||||
addSheet() method.
|
||||
|
||||
``` php
|
||||
// Create a new worksheet called "My Data"
|
||||
$myWorkSheet = new \PhpOffice\PhpSpreadsheet\Worksheet($spreadsheet, 'My Data');
|
||||
|
||||
// Attach the "My Data" worksheet as the first worksheet in the Spreadsheet object
|
||||
$spreadsheet->addSheet($myWorkSheet, 0);
|
||||
```
|
||||
|
||||
If you don't specify an index position as the second argument, then the
|
||||
new worksheet will be added after the last existing worksheet.
|
||||
|
||||
## Copying Worksheets
|
||||
|
||||
Sheets within the same workbook can be copied by creating a clone of the
|
||||
worksheet you wish to copy, and then using the `addSheet()` method to
|
||||
insert the clone into the workbook.
|
||||
|
||||
``` php
|
||||
$clonedWorksheet = clone $spreadsheet->getSheetByName('Worksheet 1');
|
||||
$clonedWorksheet->setTitle('Copy of Worksheet 1')
|
||||
$spreadsheet->addSheet($clonedWorksheet);
|
||||
```
|
||||
|
||||
You can also copy worksheets from one workbook to another, though this
|
||||
is more complex as PhpSpreadsheet also has to replicate the styling
|
||||
between the two workbooks. The `addExternalSheet()` method is provided for
|
||||
this purpose.
|
||||
|
||||
$clonedWorksheet = clone $spreadsheet1->getSheetByName('Worksheet 1');
|
||||
$spreadsheet->addExternalSheet($clonedWorksheet);
|
||||
|
||||
In both cases, it is the developer's responsibility to ensure that
|
||||
worksheet names are not duplicated. PhpSpreadsheet will throw an
|
||||
exception if you attempt to copy worksheets that will result in a
|
||||
duplicate name.
|
||||
|
||||
## Removing a Worksheet
|
||||
|
||||
You can delete a worksheet from a workbook, identified by its index
|
||||
position, using the `removeSheetByIndex()` method
|
||||
|
||||
``` php
|
||||
$sheetIndex = $spreadsheet->getIndex(
|
||||
$spreadsheet->getSheetByName('Worksheet 1')
|
||||
);
|
||||
$spreadsheet->removeSheetByIndex($sheetIndex);
|
||||
```
|
||||
|
||||
If the currently active worksheet is deleted, then the sheet at the
|
||||
previous index position will become the currently active sheet.
|
|
@ -14,7 +14,6 @@
|
|||
<whitelist>
|
||||
<directory suffix=".php">./src</directory>
|
||||
<exclude>
|
||||
<directory>./src/PhpSpreadsheet/Shared/PCLZip</directory>
|
||||
<directory>./src/PhpSpreadsheet/Shared/JAMA</directory>
|
||||
<directory>./src/PhpSpreadsheet/Writer/PDF</directory>
|
||||
</exclude>
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
$spreadsheet->getProperties()->setCreator('Maarten Balliauw')
|
||||
->setLastModifiedBy('Maarten Balliauw')
|
||||
->setTitle('PhpSpreadsheet Test Document')
|
||||
->setSubject('PhpSpreadsheet Test Document')
|
||||
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
|
||||
->setKeywords('office PhpSpreadsheet php')
|
||||
->setCategory('Test result file');
|
||||
|
||||
// Add some data
|
||||
$helper->log('Add some data');
|
||||
$spreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
->setCellValue('C1', 'Hello')
|
||||
->setCellValue('D2', 'world!');
|
||||
|
||||
// Miscellaneous glyphs, UTF-8
|
||||
$spreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A8', "Hello\nWorld");
|
||||
$spreadsheet->getActiveSheet()->getRowDimension(8)->setRowHeight(-1);
|
||||
$spreadsheet->getActiveSheet()->getStyle('A8')->getAlignment()->setWrapText(true);
|
||||
|
||||
// Rename worksheet
|
||||
$helper->log('Rename worksheet');
|
||||
$spreadsheet->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
// Save Excel 2007 file
|
||||
$helper->log('Write to Xlsx format');
|
||||
|
||||
// Use PCLZip rather than ZipArchive to create the Xlsx OfficeOpenXML file
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setZipClass(\PhpOffice\PhpSpreadsheet\Settings::PCLZIP);
|
||||
|
||||
// Save
|
||||
$helper->write($spreadsheet, __FILE__, ['Xlsx']);
|
|
@ -53,6 +53,6 @@ header('Content-Type: application/pdf');
|
|||
header('Content-Disposition: attachment;filename="01simple.pdf"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'PDF');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Pdf');
|
||||
$writer->save('php://output');
|
||||
exit;
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$cacheMethod = \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE_IN_MEMORY_GZIP;
|
||||
if (\PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod($cacheMethod)) {
|
||||
$helper->log('Enable Cell Caching using ' . $cacheMethod . ' method');
|
||||
} else {
|
||||
$helper->log('ERROR: Unable to set Cell Caching using ' . $cacheMethod . ' method, reverting to memory');
|
||||
}
|
||||
|
||||
$spreadsheet = require __DIR__ . '/templates/largeSpreadsheet.php';
|
||||
|
||||
// Save
|
||||
$helper->write($spreadsheet, __FILE__);
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$cacheMethod = \PhpOffice\PhpSpreadsheet\CachedObjectStorageFactory::CACHE_TO_SQLITE3;
|
||||
if (\PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod($cacheMethod)) {
|
||||
$helper->log('Enable Cell Caching using ' . $cacheMethod . ' method');
|
||||
} else {
|
||||
$helper->log('ERROR: Unable to set Cell Caching using ' . $cacheMethod . ' method, reverting to memory');
|
||||
}
|
||||
|
||||
$spreadsheet = require __DIR__ . '/templates/largeSpreadsheet.php';
|
||||
|
||||
// Save
|
||||
$helper->write($spreadsheet, __FILE__);
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create temporary file that will be read
|
||||
$sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
$filename = $helper->getTemporaryFilename();
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet);
|
||||
$writer->save($filename);
|
||||
|
||||
// Use PCLZip rather than ZipArchive to read the Xlsx OfficeOpenXML file
|
||||
\PhpSpreadsheet\Settings::setZipClass(\PhpOffice\PhpSpreadsheet\Settings::PCLZIP);
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$helper->logRead('Xlsx', $filename, $callStartTime);
|
||||
$callEndTime = microtime(true);
|
||||
|
||||
// Save
|
||||
$helper->write($spreadsheet, __FILE__);
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Use PCLZip rather than ZipArchive to read the Xlsx OfficeOpenXML file
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setZipClass(\PhpOffice\PhpSpreadsheet\Settings::PCLZIP);
|
||||
|
||||
$filename = __DIR__ . '/templates/OOCalcTest.ods';
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$helper->logRead('Ods', $filename, $callStartTime);
|
||||
|
||||
// Save
|
||||
$helper->write($spreadsheet, __FILE__);
|
|
@ -91,7 +91,7 @@ foreach ($inputFileNames as $inputFileName) {
|
|||
|
||||
// Save
|
||||
$filename = $helper->getFilename($inputFileName);
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'PDF');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Pdf');
|
||||
$writer->setIncludeCharts(true);
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($filename);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
require __DIR__ . '/Header.php';
|
||||
?>
|
||||
<form action="Quadratic2.php" method="POST">
|
||||
<form action="45_Quadratic_equation_solver.php" method="POST">
|
||||
Enter the coefficients for the Ax<sup>2</sup> + Bx + C = 0
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td><b>A </b></td>
|
||||
|
@ -28,13 +28,13 @@ if (isset($_POST['submit'])) {
|
|||
echo '<hr /><b>Roots:</b><br />';
|
||||
|
||||
$discriminantFormula = '=POWER(' . $_POST['B'] . ',2) - (4 * ' . $_POST['A'] . ' * ' . $_POST['C'] . ')';
|
||||
$discriminant = PhpSpreadsheet_Calculation::getInstance()->calculateFormula($discriminantFormula);
|
||||
$discriminant = \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->calculateFormula($discriminantFormula);
|
||||
|
||||
$r1Formula = '=IMDIV(IMSUM(-' . $_POST['B'] . ',IMSQRT(' . $discriminant . ')),2 * ' . $_POST['A'] . ')';
|
||||
$r2Formula = '=IF(' . $discriminant . '=0,"Only one root",IMDIV(IMSUB(-' . $_POST['B'] . ',IMSQRT(' . $discriminant . ')),2 * ' . $_POST['A'] . '))';
|
||||
|
||||
echo PhpSpreadsheet_Calculation::getInstance()->calculateFormula($r1Formula) . '<br />';
|
||||
echo PhpSpreadsheet_Calculation::getInstance()->calculateFormula($r2Formula) . '<br />';
|
||||
echo \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->calculateFormula($r1Formula) . '<br />';
|
||||
echo \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->calculateFormula($r2Formula) . '<br />';
|
||||
$callEndTime = microtime(true);
|
||||
$helper->logEndingNotes();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ $requirements = [
|
|||
'PHP extension XML' => extension_loaded('xml'),
|
||||
'PHP extension xmlwriter' => extension_loaded('xmlwriter'),
|
||||
'PHP extension mbstring' => extension_loaded('mbstring'),
|
||||
'PHP extension ZipArchive (optional)' => extension_loaded('zip'),
|
||||
'PHP extension ZipArchive' => extension_loaded('zip'),
|
||||
'PHP extension GD (optional)' => extension_loaded('gd'),
|
||||
'PHP extension dom (optional)' => extension_loaded('dom'),
|
||||
];
|
||||
|
|
|
@ -1,287 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class APC extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $cacheTime = 600;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
if (!apc_store(
|
||||
$this->cachePrefix . $this->currentObjectID . '.cache',
|
||||
serialize($this->currentObject),
|
||||
$this->cacheTime
|
||||
)) {
|
||||
$this->__destruct();
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Failed to store cell ' . $this->currentObjectID . ' in APC');
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
$this->cellCache[$pCoord] = true;
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in apc
|
||||
$success = apc_fetch($this->cachePrefix . $pCoord . '.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in APC cache');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = apc_fetch($this->cachePrefix . $pCoord . '.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in APC cache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
// Delete the entry from APC
|
||||
apc_delete($this->cachePrefix . $pCoord . '.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
if ($cellID != $this->currentObjectID) {
|
||||
$obj = apc_fetch($this->cachePrefix . $cellID . '.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Cell entry ' . $cellID . ' no longer exists in APC');
|
||||
}
|
||||
if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Failed to store cell ' . $cellID . ' in APC');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if ($this->currentObject !== null) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the APC cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
|
||||
* @param array $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent, $arguments)
|
||||
{
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if ($this->cachePrefix === null) {
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
$this->cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
apc_delete($this->cachePrefix . $cellID . '.cache');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!function_exists('apc_store')) {
|
||||
return false;
|
||||
}
|
||||
if (apc_sma_info() === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,377 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
abstract class CacheBase
|
||||
{
|
||||
/**
|
||||
* Parent worksheet.
|
||||
*
|
||||
* @var \PhpOffice\PhpSpreadsheet\Worksheet
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* The currently active Cell.
|
||||
*
|
||||
* @var \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
protected $currentObject = null;
|
||||
|
||||
/**
|
||||
* Coordinate address of the currently active Cell.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $currentObjectID = null;
|
||||
|
||||
/**
|
||||
* Flag indicating whether the currently active Cell requires saving.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $currentCellIsDirty = true;
|
||||
|
||||
/**
|
||||
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
||||
* and indexed by their coordinate address within the worksheet.
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
protected $cellCache = [];
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
// Set our parent worksheet.
|
||||
// This is maintained within the cache controller to facilitate re-attaching it to \PhpOffice\PhpSpreadsheet\Cell objects when
|
||||
// they are woken from a serialized state
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the parent worksheet for this cell collection.
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Worksheet
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry exists in the cache
|
||||
return isset($this->cellCache[$pCoord]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another.
|
||||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
if ($fromAddress === $this->currentObjectID) {
|
||||
$this->currentObjectID = $toAddress;
|
||||
}
|
||||
$this->currentCellIsDirty = true;
|
||||
if (isset($this->cellCache[$fromAddress])) {
|
||||
$this->cellCache[$toAddress] = &$this->cellCache[$fromAddress];
|
||||
unset($this->cellCache[$fromAddress]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function updateCacheData(\PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
return $this->addCacheData($cell->getCoordinate(), $cell);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID && !is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
if (is_object($this->cellCache[$pCoord])) {
|
||||
$this->cellCache[$pCoord]->detach();
|
||||
}
|
||||
unset($this->cellCache[$pCoord]);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
return array_keys($this->cellCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the list of all cell addresses currently held in cache by row and column.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSortedCellList()
|
||||
{
|
||||
$sortKeys = [];
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $column, $row);
|
||||
$sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
|
||||
}
|
||||
ksort($sortKeys);
|
||||
|
||||
return array_values($sortKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get highest worksheet column and highest row that have cell records.
|
||||
*
|
||||
* @return array Highest column name and highest row number
|
||||
*/
|
||||
public function getHighestRowAndColumn()
|
||||
{
|
||||
// Lookup highest column and highest row
|
||||
$col = ['A' => '1A'];
|
||||
$row = [1];
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
$row[$r] = $r;
|
||||
$col[$c] = strlen($c) . $c;
|
||||
}
|
||||
if (!empty($row)) {
|
||||
// Determine highest column and row
|
||||
$highestRow = max($row);
|
||||
$highestColumn = substr(max($col), 1);
|
||||
}
|
||||
|
||||
return [
|
||||
'row' => $highestRow,
|
||||
'column' => $highestColumn,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cell address of the currently active cell object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentAddress()
|
||||
{
|
||||
return $this->currentObjectID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the column address of the currently active cell object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentColumn()
|
||||
{
|
||||
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
|
||||
return $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the row address of the currently active cell object.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrentRow()
|
||||
{
|
||||
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
|
||||
return (int) $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get highest worksheet column.
|
||||
*
|
||||
* @param string $row Return the highest column for the specified row,
|
||||
* or the highest column of any row if no row number is passed
|
||||
*
|
||||
* @return string Highest column name
|
||||
*/
|
||||
public function getHighestColumn($row = null)
|
||||
{
|
||||
if ($row == null) {
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
|
||||
return $colRow['column'];
|
||||
}
|
||||
|
||||
$columnList = [1];
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($r != $row) {
|
||||
continue;
|
||||
}
|
||||
$columnList[] = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($c);
|
||||
}
|
||||
|
||||
return \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex(max($columnList) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get highest worksheet row.
|
||||
*
|
||||
* @param string $column Return the highest row for the specified column,
|
||||
* or the highest row of any column if no column letter is passed
|
||||
*
|
||||
* @return int Highest row number
|
||||
*/
|
||||
public function getHighestRow($column = null)
|
||||
{
|
||||
if ($column == null) {
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
|
||||
return $colRow['row'];
|
||||
}
|
||||
|
||||
$rowList = [0];
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($c != $column) {
|
||||
continue;
|
||||
}
|
||||
$rowList[] = $r;
|
||||
}
|
||||
|
||||
return max($rowList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a unique ID for cache referencing.
|
||||
*
|
||||
* @return string Unique Reference
|
||||
*/
|
||||
protected function getUniqueID()
|
||||
{
|
||||
if (function_exists('posix_getpid')) {
|
||||
$baseUnique = posix_getpid();
|
||||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
|
||||
return uniqid($baseUnique, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
*/
|
||||
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
$this->currentCellIsDirty;
|
||||
$this->storeData();
|
||||
|
||||
$this->parent = $parent;
|
||||
if (($this->currentObject !== null) && (is_object($this->currentObject))) {
|
||||
$this->currentObject->attach($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a row, deleting all cells in that row.
|
||||
*
|
||||
* @param string $row Row number to remove
|
||||
*/
|
||||
public function removeRow($row)
|
||||
{
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($r == $row) {
|
||||
$this->deleteCacheData($coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a column, deleting all cells in that column.
|
||||
*
|
||||
* @param string $column Column ID to remove
|
||||
*/
|
||||
public function removeColumn($column)
|
||||
{
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($c == $column) {
|
||||
$this->deleteCacheData($coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class DiscISAM extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Name of the file for this cache.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $fileName = null;
|
||||
|
||||
/**
|
||||
* File handle for this cache file.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $fileHandle = null;
|
||||
|
||||
/**
|
||||
* Directory/Folder where the cache file is located.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cacheDirectory = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
fseek($this->fileHandle, 0, SEEK_END);
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = [
|
||||
'ptr' => ftell($this->fileHandle),
|
||||
'sz' => fwrite($this->fileHandle, serialize($this->currentObject)),
|
||||
];
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
|
||||
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
*/
|
||||
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newFileName = $this->cacheDirectory . '/PhpSpreadsheet.' . $baseUnique . '.cache';
|
||||
// Copy the existing cell cache file
|
||||
copy($this->fileName, $newFileName);
|
||||
$this->fileName = $newFileName;
|
||||
// Open the copied cell cache file
|
||||
$this->fileHandle = fopen($this->fileName, 'a+');
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent, $arguments)
|
||||
{
|
||||
$this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null))
|
||||
? $arguments['dir']
|
||||
: \PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir();
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->fileHandle)) {
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$this->fileName = $this->cacheDirectory . '/PhpSpreadsheet.' . $baseUnique . '.cache';
|
||||
$this->fileHandle = fopen($this->fileName, 'a+');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->fileHandle)) {
|
||||
fclose($this->fileHandle);
|
||||
unlink($this->fileName);
|
||||
}
|
||||
$this->fileHandle = null;
|
||||
}
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
interface ICache
|
||||
{
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell);
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function updateCacheData(\PhpOffice\PhpSpreadsheet\Cell $cell);
|
||||
|
||||
/**
|
||||
* Fetch a cell from cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to retrieve
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord);
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList();
|
||||
|
||||
/**
|
||||
* Get the list of all cell addresses currently held in cache sorted by column and row.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSortedCellList();
|
||||
|
||||
/**
|
||||
* Clone the cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
*/
|
||||
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent);
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable();
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Igbinary extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = igbinary_serialize($this->currentObject);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
// function _storeData()
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = igbinary_unserialize($this->cellCache[$pCoord]);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
// function getCacheData()
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
// function unsetWorksheetCells()
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!function_exists('igbinary_serialize')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,313 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Memcache extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $cacheTime = 600;
|
||||
|
||||
/**
|
||||
* Memcache interface.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $memcache = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$obj = serialize($this->currentObject);
|
||||
if (!$this->memcache->replace($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
|
||||
if (!$this->memcache->add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception("Failed to store cell {$this->currentObjectID} in MemCache");
|
||||
}
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
$this->cellCache[$pCoord] = true;
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in Memcache
|
||||
$success = $this->memcache->get($this->cachePrefix . $pCoord . '.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in MemCache');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = $this->memcache->get($this->cachePrefix . $pCoord . '.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception("Cell entry {$pCoord} no longer exists in MemCache");
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
// Delete the entry from Memcache
|
||||
$this->memcache->delete($this->cachePrefix . $pCoord . '.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
if ($cellID != $this->currentObjectID) {
|
||||
$obj = $this->memcache->get($this->cachePrefix . $cellID . '.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception("Cell entry {$cellID} no longer exists in MemCache");
|
||||
}
|
||||
if (!$this->memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception("Failed to store cell {$cellID} in MemCache");
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the Memcache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
|
||||
* @param mixed[] $arguments Additional initialisation arguments
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent, $arguments)
|
||||
{
|
||||
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
||||
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->cachePrefix)) {
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
|
||||
// Set a new Memcache object and connect to the Memcache server
|
||||
$this->memcache = new \Memcache();
|
||||
if (!$this->memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, [$this, 'failureCallback'])) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception("Could not connect to MemCache server at {$memcacheServer}:{$memcachePort}");
|
||||
}
|
||||
$this->cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Memcache error handler.
|
||||
*
|
||||
* @param string $host Memcache server
|
||||
* @param int $port Memcache port
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function failureCallback($host, $port)
|
||||
{
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception("memcache {$host}:{$port} failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
$this->memcache->delete($this->cachePrefix . $cellID . '.cache');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!function_exists('memcache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Memory extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Dummy method callable from CacheBase, but unused by Memory cache.
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
$this->cellCache[$pCoord] = $cell;
|
||||
|
||||
// Set current entry to the new/updated entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
$this->currentObjectID = null;
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
// Return requested entry
|
||||
return $this->cellCache[$pCoord];
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
*/
|
||||
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
|
||||
$newCollection = [];
|
||||
foreach ($this->cellCache as $k => &$cell) {
|
||||
$newCollection[$k] = clone $cell;
|
||||
$newCollection[$k]->attach($this);
|
||||
}
|
||||
|
||||
$this->cellCache = $newCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
|
||||
foreach ($this->cellCache as $k => &$cell) {
|
||||
$cell->detach();
|
||||
$this->cellCache[$k] = null;
|
||||
}
|
||||
unset($cell);
|
||||
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class MemoryGZip extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject), 9);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class MemorySerialized extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($this->cellCache[$pCoord]);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class PHPTemp extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Name of the file for this cache.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $fileHandle = null;
|
||||
|
||||
/**
|
||||
* Memory limit to use before reverting to file cache.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $memoryCacheSize = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
fseek($this->fileHandle, 0, SEEK_END);
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = [
|
||||
'ptr' => ftell($this->fileHandle),
|
||||
'sz' => fwrite($this->fileHandle, serialize($this->currentObject)),
|
||||
];
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
|
||||
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
*/
|
||||
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Open a new stream for the cell cache data
|
||||
$newFileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
|
||||
// Copy the existing cell cache data to the new stream
|
||||
fseek($this->fileHandle, 0);
|
||||
while (!feof($this->fileHandle)) {
|
||||
fwrite($newFileHandle, fread($this->fileHandle, 1024));
|
||||
}
|
||||
$this->fileHandle = $newFileHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
||||
// Close down the php://temp file
|
||||
$this->__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
|
||||
* @param mixed[] $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent, $arguments)
|
||||
{
|
||||
$this->memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : 1 * 1024 * 1024;
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->fileHandle)) {
|
||||
$this->fileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->fileHandle)) {
|
||||
fclose($this->fileHandle);
|
||||
}
|
||||
$this->fileHandle = null;
|
||||
}
|
||||
}
|
|
@ -1,359 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class SQLite3 extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Database table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $TableName = null;
|
||||
|
||||
/**
|
||||
* Database handle.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $DBHandle = null;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 select query.
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $selectQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 insert query.
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $insertQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 update query.
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $updateQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 delete query.
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $deleteQuery;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
|
||||
$this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
|
||||
$result = $this->insertQuery->execute();
|
||||
if ($result === false) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$cellResult = $this->selectQuery->execute();
|
||||
if ($cellResult === false) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||
if ($cellData === false) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
$this->currentObject = unserialize($cellData['value']);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$cellResult = $this->selectQuery->execute();
|
||||
if ($cellResult === false) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
return ($cellData === false) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$result = $this->deleteQuery->execute();
|
||||
if ($result === false) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another.
|
||||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
if ($fromAddress === $this->currentObjectID) {
|
||||
$this->currentObjectID = $toAddress;
|
||||
}
|
||||
|
||||
$this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
|
||||
$result = $this->deleteQuery->execute();
|
||||
if ($result === false) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
|
||||
$this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
|
||||
$result = $this->updateQuery->execute();
|
||||
if ($result === false) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$query = 'SELECT id FROM kvp_' . $this->TableName;
|
||||
$cellIdsResult = $this->DBHandle->query($query);
|
||||
if ($cellIdsResult === false) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$cellKeys = [];
|
||||
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
||||
return $cellKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
$this->currentCellIsDirty;
|
||||
$this->storeData();
|
||||
|
||||
// Get a new id for the new table name
|
||||
$tableName = str_replace('.', '_', $this->getUniqueID());
|
||||
if (!$this->DBHandle->exec('CREATE TABLE kvp_' . $tableName . ' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||
AS SELECT * FROM kvp_' . $this->TableName)
|
||||
) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
// Copy the existing cell cache file
|
||||
$this->TableName = $tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->DBHandle)) {
|
||||
$this->TableName = str_replace('.', '_', $this->getUniqueID());
|
||||
$_DBName = ':memory:';
|
||||
|
||||
$this->DBHandle = new \SQLite3($_DBName);
|
||||
if ($this->DBHandle === false) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
if (!$this->DBHandle->exec('CREATE TABLE kvp_' . $this->TableName . ' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
$this->selectQuery = $this->DBHandle->prepare('SELECT value FROM kvp_' . $this->TableName . ' WHERE id = :id');
|
||||
$this->insertQuery = $this->DBHandle->prepare('INSERT OR REPLACE INTO kvp_' . $this->TableName . ' VALUES(:id,:data)');
|
||||
$this->updateQuery = $this->DBHandle->prepare('UPDATE kvp_' . $this->TableName . ' SET id=:toId WHERE id=:fromId');
|
||||
$this->deleteQuery = $this->DBHandle->prepare('DELETE FROM kvp_' . $this->TableName . ' WHERE id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->DBHandle)) {
|
||||
$this->DBHandle->exec('DROP TABLE kvp_' . $this->TableName);
|
||||
$this->DBHandle->close();
|
||||
}
|
||||
$this->DBHandle = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!class_exists('SQLite3', false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,292 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\CachedObjectStorage;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Wincache extends CacheBase implements ICache
|
||||
{
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $cacheTime = 600;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object.
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$obj = serialize($this->currentObject);
|
||||
if (wincache_ucache_exists($this->cachePrefix . $this->currentObjectID . '.cache')) {
|
||||
if (!wincache_ucache_set($this->cachePrefix . $this->currentObjectID . '.cache', $obj, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Failed to store cell ' . $this->currentObjectID . ' in WinCache');
|
||||
}
|
||||
} else {
|
||||
if (!wincache_ucache_add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Failed to store cell ' . $this->currentObjectID . ' in WinCache');
|
||||
}
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to update
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell
|
||||
*/
|
||||
public function addCacheData($pCoord, \PhpOffice\PhpSpreadsheet\Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
$this->cellCache[$pCoord] = true;
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set in the current \PhpOffice\PhpSpreadsheet\CachedObjectStorage\ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in cache
|
||||
$success = wincache_ucache_exists($this->cachePrefix . $pCoord . '.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Wincache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in WinCache');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate.
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
$obj = null;
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->cachePrefix . $pCoord . '.cache', $success);
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in WinCache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address.
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
// Delete the entry from Wincache
|
||||
wincache_ucache_delete($this->cachePrefix . $pCoord . '.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The new worksheet that we're copying to
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function copyCellCollection(\PhpOffice\PhpSpreadsheet\Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
if ($cellID != $this->currentObjectID) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->cachePrefix . $cellID . '.cache', $success);
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Cell entry ' . $cellID . ' no longer exists in Wincache');
|
||||
}
|
||||
if (!wincache_ucache_add($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new \PhpOffice\PhpSpreadsheet\Exception('Failed to store cell ' . $cellID . ' in Wincache');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent.
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the WinCache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->cellCache = [];
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection.
|
||||
*
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet $parent The worksheet for this cell collection
|
||||
* @param mixed[] $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent, $arguments)
|
||||
{
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->cachePrefix)) {
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
$this->cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
wincache_ucache_delete($this->cachePrefix . $cellID . '.cache');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!function_exists('wincache_ucache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,228 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
*
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class CachedObjectStorageFactory
|
||||
{
|
||||
const CACHE_IN_MEMORY = 'Memory';
|
||||
const CACHE_IN_MEMORY_GZIP = 'MemoryGZip';
|
||||
const CACHE_IN_MEMORY_SERIALIZED = 'MemorySerialized';
|
||||
const CACHE_IGBINARY = 'Igbinary';
|
||||
const CACHE_TO_DISCISAM = 'DiscISAM';
|
||||
const CACHE_TO_APC = 'APC';
|
||||
const CACHE_TO_MEMCACHE = 'Memcache';
|
||||
const CACHE_TO_PHPTEMP = 'PHPTemp';
|
||||
const CACHE_TO_WINCACHE = 'Wincache';
|
||||
const CACHE_TO_SQLITE3 = 'SQLite3';
|
||||
|
||||
/**
|
||||
* Name of the method used for cell cacheing.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $cacheStorageMethod;
|
||||
|
||||
/**
|
||||
* Name of the class used for cell cacheing.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $cacheStorageClass;
|
||||
|
||||
/**
|
||||
* List of all possible cache storage methods.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $storageMethods = [
|
||||
self::CACHE_IN_MEMORY,
|
||||
self::CACHE_IN_MEMORY_GZIP,
|
||||
self::CACHE_IN_MEMORY_SERIALIZED,
|
||||
self::CACHE_IGBINARY,
|
||||
self::CACHE_TO_PHPTEMP,
|
||||
self::CACHE_TO_DISCISAM,
|
||||
self::CACHE_TO_APC,
|
||||
self::CACHE_TO_MEMCACHE,
|
||||
self::CACHE_TO_WINCACHE,
|
||||
self::CACHE_TO_SQLITE3,
|
||||
];
|
||||
|
||||
/**
|
||||
* Default arguments for each cache storage method.
|
||||
*
|
||||
* @var array of mixed array
|
||||
*/
|
||||
private static $storageMethodDefaultParameters = [
|
||||
self::CACHE_IN_MEMORY => [],
|
||||
self::CACHE_IN_MEMORY_GZIP => [],
|
||||
self::CACHE_IN_MEMORY_SERIALIZED => [],
|
||||
self::CACHE_IGBINARY => [],
|
||||
self::CACHE_TO_PHPTEMP => [
|
||||
'memoryCacheSize' => '1MB',
|
||||
],
|
||||
self::CACHE_TO_DISCISAM => [
|
||||
'dir' => null,
|
||||
],
|
||||
self::CACHE_TO_APC => [
|
||||
'cacheTime' => 600,
|
||||
],
|
||||
self::CACHE_TO_MEMCACHE => [
|
||||
'memcacheServer' => 'localhost',
|
||||
'memcachePort' => 11211,
|
||||
'cacheTime' => 600,
|
||||
],
|
||||
self::CACHE_TO_WINCACHE => [
|
||||
'cacheTime' => 600,
|
||||
],
|
||||
self::CACHE_TO_SQLITE3 => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* Arguments for the active cache storage method.
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private static $storageMethodParameters = [];
|
||||
|
||||
/**
|
||||
* Return the current cache storage method.
|
||||
*
|
||||
* @return string|null
|
||||
**/
|
||||
public static function getCacheStorageMethod()
|
||||
{
|
||||
return self::$cacheStorageMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current cache storage class.
|
||||
*
|
||||
* @return string
|
||||
**/
|
||||
public static function getCacheStorageClass()
|
||||
{
|
||||
return self::$cacheStorageClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of all possible cache storage methods.
|
||||
*
|
||||
* @return string[]
|
||||
**/
|
||||
public static function getAllCacheStorageMethods()
|
||||
{
|
||||
return self::$storageMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of all available cache storage methods.
|
||||
*
|
||||
* @return string[]
|
||||
**/
|
||||
public static function getCacheStorageMethods()
|
||||
{
|
||||
$activeMethods = [];
|
||||
foreach (self::$storageMethods as $storageMethod) {
|
||||
$cacheStorageClass = '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\' . $storageMethod;
|
||||
if (call_user_func([$cacheStorageClass, 'cacheMethodIsAvailable'])) {
|
||||
$activeMethods[] = $storageMethod;
|
||||
}
|
||||
}
|
||||
|
||||
return $activeMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify the cache storage method to use.
|
||||
*
|
||||
* @param string $method Name of the method to use for cell cacheing
|
||||
* @param mixed[] $arguments Additional arguments to pass to the cell caching class
|
||||
* when instantiating
|
||||
*
|
||||
* @return bool
|
||||
**/
|
||||
public static function initialize($method = self::CACHE_IN_MEMORY, $arguments = [])
|
||||
{
|
||||
if (!in_array($method, self::$storageMethods)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cacheStorageClass = '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\' . $method;
|
||||
if (!call_user_func([$cacheStorageClass, 'cacheMethodIsAvailable'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self::$storageMethodParameters[$method] = self::$storageMethodDefaultParameters[$method];
|
||||
foreach ($arguments as $argument => $value) {
|
||||
if (isset(self::$storageMethodParameters[$method][$argument])) {
|
||||
self::$storageMethodParameters[$method][$argument] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$cacheStorageMethod === null) {
|
||||
self::$cacheStorageClass = '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\' . $method;
|
||||
self::$cacheStorageMethod = $method;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the cache storage.
|
||||
*
|
||||
* @param Worksheet $parent Enable cell caching for this worksheet
|
||||
*
|
||||
* @return CachedObjectStorage\ICache
|
||||
**/
|
||||
public static function getInstance(Worksheet $parent)
|
||||
{
|
||||
$cacheMethodIsAvailable = true;
|
||||
if (self::$cacheStorageMethod === null) {
|
||||
$cacheMethodIsAvailable = self::initialize();
|
||||
}
|
||||
|
||||
if ($cacheMethodIsAvailable) {
|
||||
$instance = new self::$cacheStorageClass(
|
||||
$parent,
|
||||
self::$storageMethodParameters[self::$cacheStorageMethod]
|
||||
);
|
||||
if ($instance !== null) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cache storage.
|
||||
**/
|
||||
public static function finalize()
|
||||
{
|
||||
self::$cacheStorageMethod = null;
|
||||
self::$cacheStorageClass = null;
|
||||
self::$storageMethodParameters = [];
|
||||
}
|
||||
}
|
|
@ -74,7 +74,7 @@ class Logger
|
|||
*
|
||||
* @param bool $pValue
|
||||
*/
|
||||
public function setWriteDebugLog($pValue = false)
|
||||
public function setWriteDebugLog($pValue)
|
||||
{
|
||||
$this->writeDebugLog = $pValue;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class Logger
|
|||
*
|
||||
* @param bool $pValue
|
||||
*/
|
||||
public function setEchoDebugLog($pValue = false)
|
||||
public function setEchoDebugLog($pValue)
|
||||
{
|
||||
$this->echoDebugLog = $pValue;
|
||||
}
|
||||
|
|
|
@ -2177,7 +2177,7 @@ class Calculation
|
|||
*
|
||||
* @param bool $pValue
|
||||
*/
|
||||
public function setCalculationCacheEnabled($pValue = true)
|
||||
public function setCalculationCacheEnabled($pValue)
|
||||
{
|
||||
$this->calculationCacheEnabled = $pValue;
|
||||
$this->clearCalculationCache();
|
||||
|
@ -2246,11 +2246,11 @@ class Calculation
|
|||
/**
|
||||
* Set the locale code.
|
||||
*
|
||||
* @param string $locale The locale to use for formula translation
|
||||
* @param string $locale The locale to use for formula translation, eg: 'en_us'
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setLocale($locale = 'en_us')
|
||||
public function setLocale($locale)
|
||||
{
|
||||
// Identify our locale and language
|
||||
$language = $locale = strtolower($locale);
|
||||
|
@ -3664,7 +3664,7 @@ class Calculation
|
|||
$this->debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->showTypeDetails($cellValue));
|
||||
} else {
|
||||
$this->debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in current worksheet');
|
||||
if ($pCellParent->isDataSet($cellRef)) {
|
||||
if ($pCellParent->has($cellRef)) {
|
||||
$cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, false);
|
||||
$pCell->attach($pCellParent);
|
||||
} else {
|
||||
|
@ -3765,6 +3765,11 @@ class Calculation
|
|||
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $token, $matches)) {
|
||||
$namedRange = $matches[6];
|
||||
$this->debugLog->writeDebugLog('Evaluating Named Range ', $namedRange);
|
||||
|
||||
if (substr($namedRange, 0, 6) === '_xlfn.') {
|
||||
return $this->raiseFormulaError("undefined named range / function '$token'");
|
||||
}
|
||||
|
||||
$cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellWorksheet : null), false);
|
||||
$pCell->attach($pCellParent);
|
||||
$this->debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->showTypeDetails($cellValue));
|
||||
|
|
|
@ -142,11 +142,11 @@ class FormulaToken
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Token Type.
|
||||
* Set Token Type (represented by TOKEN_TYPE_*).
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenType($value = self::TOKEN_TYPE_UNKNOWN)
|
||||
public function setTokenType($value)
|
||||
{
|
||||
$this->tokenType = $value;
|
||||
}
|
||||
|
@ -162,11 +162,11 @@ class FormulaToken
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Token SubType.
|
||||
* Set Token SubType (represented by TOKEN_SUBTYPE_*).
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenSubType($value = self::TOKEN_SUBTYPE_NOTHING)
|
||||
public function setTokenSubType($value)
|
||||
{
|
||||
$this->tokenSubType = $value;
|
||||
}
|
||||
|
|
|
@ -497,93 +497,107 @@ class LookupRef
|
|||
* Excel Function:
|
||||
* =MATCH(lookup_value, lookup_array, [match_type])
|
||||
*
|
||||
* @param lookup_value The value that you want to match in lookup_array
|
||||
* @param lookup_array The range of cells being searched
|
||||
* @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
|
||||
* @param mixed $lookup_value
|
||||
* @param mixed $lookup_array
|
||||
* @param mixed $match_type
|
||||
* @param mixed $lookupValue The value that you want to match in lookup_array
|
||||
* @param mixed $lookupArray The range of cells being searched
|
||||
* @param mixed $matchType The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
|
||||
*
|
||||
* @return int The relative position of the found item
|
||||
*/
|
||||
public static function MATCH($lookup_value, $lookup_array, $match_type = 1)
|
||||
public static function MATCH($lookupValue, $lookupArray, $matchType = 1)
|
||||
{
|
||||
$lookup_array = Functions::flattenArray($lookup_array);
|
||||
$lookup_value = Functions::flattenSingleValue($lookup_value);
|
||||
$match_type = (is_null($match_type)) ? 1 : (int) Functions::flattenSingleValue($match_type);
|
||||
$lookupArray = Functions::flattenArray($lookupArray);
|
||||
$lookupValue = Functions::flattenSingleValue($lookupValue);
|
||||
$matchType = (is_null($matchType)) ? 1 : (int) Functions::flattenSingleValue($matchType);
|
||||
|
||||
// MATCH is not case sensitive
|
||||
$lookup_value = strtolower($lookup_value);
|
||||
$lookupValue = strtolower($lookupValue);
|
||||
|
||||
// lookup_value type has to be number, text, or logical values
|
||||
if ((!is_numeric($lookup_value)) && (!is_string($lookup_value)) && (!is_bool($lookup_value))) {
|
||||
// Lookup_value type has to be number, text, or logical values
|
||||
if ((!is_numeric($lookupValue)) && (!is_string($lookupValue)) && (!is_bool($lookupValue))) {
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
// match_type is 0, 1 or -1
|
||||
if (($match_type !== 0) && ($match_type !== -1) && ($match_type !== 1)) {
|
||||
// Match_type is 0, 1 or -1
|
||||
if (($matchType !== 0) && ($matchType !== -1) && ($matchType !== 1)) {
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
// lookup_array should not be empty
|
||||
$lookupArraySize = count($lookup_array);
|
||||
// Lookup_array should not be empty
|
||||
$lookupArraySize = count($lookupArray);
|
||||
if ($lookupArraySize <= 0) {
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
// lookup_array should contain only number, text, or logical values, or empty (null) cells
|
||||
foreach ($lookup_array as $i => $lookupArrayValue) {
|
||||
// Lookup_array should contain only number, text, or logical values, or empty (null) cells
|
||||
foreach ($lookupArray as $i => $lookupArrayValue) {
|
||||
// check the type of the value
|
||||
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
|
||||
(!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) {
|
||||
(!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))
|
||||
) {
|
||||
return Functions::NA();
|
||||
}
|
||||
// convert strings to lowercase for case-insensitive testing
|
||||
// Convert strings to lowercase for case-insensitive testing
|
||||
if (is_string($lookupArrayValue)) {
|
||||
$lookup_array[$i] = strtolower($lookupArrayValue);
|
||||
$lookupArray[$i] = strtolower($lookupArrayValue);
|
||||
}
|
||||
if ((is_null($lookupArrayValue)) && (($match_type == 1) || ($match_type == -1))) {
|
||||
$lookup_array = array_slice($lookup_array, 0, $i - 1);
|
||||
if ((is_null($lookupArrayValue)) && (($matchType == 1) || ($matchType == -1))) {
|
||||
$lookupArray = array_slice($lookupArray, 0, $i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// if match_type is 1 or -1, the list has to be ordered
|
||||
if ($match_type == 1) {
|
||||
asort($lookup_array);
|
||||
$keySet = array_keys($lookup_array);
|
||||
} elseif ($match_type == -1) {
|
||||
arsort($lookup_array);
|
||||
$keySet = array_keys($lookup_array);
|
||||
if ($matchType == 1) {
|
||||
// If match_type is 1 the list has to be processed from last to first
|
||||
|
||||
$lookupArray = array_reverse($lookupArray);
|
||||
$keySet = array_reverse(array_keys($lookupArray));
|
||||
}
|
||||
|
||||
// **
|
||||
// find the match
|
||||
// **
|
||||
foreach ($lookup_array as $i => $lookupArrayValue) {
|
||||
if (($match_type == 0) && ($lookupArrayValue == $lookup_value)) {
|
||||
|
||||
if ($matchType == 0 || $matchType == 1) {
|
||||
foreach ($lookupArray as $i => $lookupArrayValue) {
|
||||
if (($matchType == 0) && ($lookupArrayValue == $lookupValue)) {
|
||||
// exact match
|
||||
return ++$i;
|
||||
} elseif (($match_type == -1) && ($lookupArrayValue <= $lookup_value)) {
|
||||
} elseif (($matchType == 1) && ($lookupArrayValue <= $lookupValue)) {
|
||||
$i = array_search($i, $keySet);
|
||||
// if match_type is -1 <=> find the smallest value that is greater than or equal to lookup_value
|
||||
if ($i < 1) {
|
||||
// 1st cell was already smaller than the lookup_value
|
||||
break;
|
||||
|
||||
// The current value is the (first) match
|
||||
return $i + 1;
|
||||
}
|
||||
// the previous cell was the match
|
||||
return $keySet[$i - 1] + 1;
|
||||
} elseif (($match_type == 1) && ($lookupArrayValue >= $lookup_value)) {
|
||||
$i = array_search($i, $keySet);
|
||||
// if match_type is 1 <=> find the largest value that is less than or equal to lookup_value
|
||||
if ($i < 1) {
|
||||
// 1st cell was already bigger than the lookup_value
|
||||
break;
|
||||
}
|
||||
// the previous cell was the match
|
||||
return $keySet[$i - 1] + 1;
|
||||
} else {
|
||||
// matchType = -1
|
||||
|
||||
// "Special" case: since the array it's supposed to be ordered in descending order, the
|
||||
// Excel algorithm gives up immediately if the first element is smaller than the searched value
|
||||
if ($lookupArray[0] < $lookupValue) {
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
$maxValueKey = null;
|
||||
|
||||
// The basic algorithm is:
|
||||
// Iterate and keep the highest match until the next element is smaller than the searched value.
|
||||
// Return immediately if perfect match is found
|
||||
foreach ($lookupArray as $i => $lookupArrayValue) {
|
||||
if ($lookupArrayValue == $lookupValue) {
|
||||
// Another "special" case. If a perfect match is found,
|
||||
// the algorithm gives up immediately
|
||||
return $i + 1;
|
||||
} elseif ($lookupArrayValue >= $lookupValue) {
|
||||
$maxValueKey = $i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// unsuccessful in finding a match, return #N/A error value
|
||||
if ($maxValueKey !== null) {
|
||||
return $maxValueKey;
|
||||
}
|
||||
}
|
||||
|
||||
// Unsuccessful in finding a match, return #N/A error value
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
|
|
|
@ -493,7 +493,7 @@ class TextData
|
|||
$instance = floor(Functions::flattenSingleValue($instance));
|
||||
|
||||
if ($instance == 0) {
|
||||
return \PhpOffice\PhpSpreadsheet\Shared\StringHelper::mbStrReplace($fromText, $toText, $text);
|
||||
return str_replace($fromText, $toText, $text);
|
||||
}
|
||||
|
||||
$pos = -1;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Collection\Cells;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||
*
|
||||
|
@ -67,9 +69,9 @@ class Cell
|
|||
private $dataType;
|
||||
|
||||
/**
|
||||
* Parent worksheet.
|
||||
* Collection of cells.
|
||||
*
|
||||
* @var CachedObjectStorage\CacheBase
|
||||
* @var Cells
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
|
@ -86,11 +88,13 @@ class Cell
|
|||
private $formulaAttributes;
|
||||
|
||||
/**
|
||||
* Send notification to the cache controller.
|
||||
**/
|
||||
public function notifyCacheController()
|
||||
* Update the cell into the cell collection.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function updateInCollection()
|
||||
{
|
||||
$this->parent->updateCacheData($this);
|
||||
$this->parent->update($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -100,7 +104,7 @@ class Cell
|
|||
$this->parent = null;
|
||||
}
|
||||
|
||||
public function attach(CachedObjectStorage\CacheBase $parent)
|
||||
public function attach(Cells $parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
@ -114,13 +118,13 @@ class Cell
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($pValue = null, $pDataType = null, Worksheet $pSheet = null)
|
||||
public function __construct($pValue, $pDataType, Worksheet $pSheet)
|
||||
{
|
||||
// Initialise cell value
|
||||
$this->value = $pValue;
|
||||
|
||||
// Set worksheet cache
|
||||
$this->parent = $pSheet->getCellCacheController();
|
||||
$this->parent = $pSheet->getCellCollection();
|
||||
|
||||
// Set datatype?
|
||||
if ($pDataType !== null) {
|
||||
|
@ -160,7 +164,7 @@ class Cell
|
|||
*/
|
||||
public function getCoordinate()
|
||||
{
|
||||
return $this->parent->getCurrentAddress();
|
||||
return $this->parent->getCurrentCoordinate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,7 +202,7 @@ class Cell
|
|||
*
|
||||
* @return Cell
|
||||
*/
|
||||
public function setValue($pValue = null)
|
||||
public function setValue($pValue)
|
||||
{
|
||||
if (!self::getValueBinder()->bindValue($this, $pValue)) {
|
||||
throw new Exception('Value could not be bound to cell.');
|
||||
|
@ -211,13 +215,13 @@ class Cell
|
|||
* Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder).
|
||||
*
|
||||
* @param mixed $pValue Value
|
||||
* @param string $pDataType Explicit data type
|
||||
* @param string $pDataType Explicit data type, see Cell\DataType::TYPE_*
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Cell
|
||||
*/
|
||||
public function setValueExplicit($pValue = null, $pDataType = Cell\DataType::TYPE_STRING)
|
||||
public function setValueExplicit($pValue, $pDataType)
|
||||
{
|
||||
// set the value according to data type
|
||||
switch ($pDataType) {
|
||||
|
@ -253,14 +257,12 @@ class Cell
|
|||
// set the datatype
|
||||
$this->dataType = $pDataType;
|
||||
|
||||
return $this->notifyCacheController();
|
||||
return $this->updateInCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get calculated cell value.
|
||||
*
|
||||
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
|
||||
*
|
||||
* @param bool $resetLog Whether the calculation engine logger should be reset or not
|
||||
*
|
||||
* @throws Exception
|
||||
|
@ -309,13 +311,13 @@ class Cell
|
|||
*
|
||||
* @return Cell
|
||||
*/
|
||||
public function setCalculatedValue($pValue = null)
|
||||
public function setCalculatedValue($pValue)
|
||||
{
|
||||
if ($pValue !== null) {
|
||||
$this->calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
|
||||
}
|
||||
|
||||
return $this->notifyCacheController();
|
||||
return $this->updateInCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -346,18 +348,18 @@ class Cell
|
|||
/**
|
||||
* Set cell data type.
|
||||
*
|
||||
* @param string $pDataType
|
||||
* @param string $pDataType see Cell\DataType::TYPE_*
|
||||
*
|
||||
* @return Cell
|
||||
*/
|
||||
public function setDataType($pDataType = Cell\DataType::TYPE_STRING)
|
||||
public function setDataType($pDataType)
|
||||
{
|
||||
if ($pDataType == Cell\DataType::TYPE_STRING2) {
|
||||
$pDataType = Cell\DataType::TYPE_STRING;
|
||||
}
|
||||
$this->dataType = $pDataType;
|
||||
|
||||
return $this->notifyCacheController();
|
||||
return $this->updateInCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -419,7 +421,7 @@ class Cell
|
|||
|
||||
$this->getWorksheet()->setDataValidation($this->getCoordinate(), $pDataValidation);
|
||||
|
||||
return $this->notifyCacheController();
|
||||
return $this->updateInCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -471,13 +473,13 @@ class Cell
|
|||
|
||||
$this->getWorksheet()->setHyperlink($this->getCoordinate(), $pHyperlink);
|
||||
|
||||
return $this->notifyCacheController();
|
||||
return $this->updateInCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent worksheet.
|
||||
* Get cell collection.
|
||||
*
|
||||
* @return CachedObjectStorage\CacheBase
|
||||
* @return Cells
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
|
@ -557,9 +559,9 @@ class Cell
|
|||
*/
|
||||
public function rebindParent(Worksheet $parent)
|
||||
{
|
||||
$this->parent = $parent->getCellCacheController();
|
||||
$this->parent = $parent->getCellCollection();
|
||||
|
||||
return $this->notifyCacheController();
|
||||
return $this->updateInCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -569,7 +571,7 @@ class Cell
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInRange($pRange = 'A1:A1')
|
||||
public function isInRange($pRange)
|
||||
{
|
||||
list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange);
|
||||
|
||||
|
@ -585,13 +587,13 @@ class Cell
|
|||
/**
|
||||
* Coordinate from string.
|
||||
*
|
||||
* @param string $pCoordinateString
|
||||
* @param string $pCoordinateString eg: 'A1'
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string[] Array containing column and row (indexes 0 and 1)
|
||||
*/
|
||||
public static function coordinateFromString($pCoordinateString = 'A1')
|
||||
public static function coordinateFromString($pCoordinateString)
|
||||
{
|
||||
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
|
||||
return [$matches[1], $matches[2]];
|
||||
|
@ -614,7 +616,7 @@ class Cell
|
|||
*
|
||||
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
|
||||
*/
|
||||
public static function absoluteReference($pCoordinateString = 'A1')
|
||||
public static function absoluteReference($pCoordinateString)
|
||||
{
|
||||
if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) {
|
||||
// Split out any worksheet name from the reference
|
||||
|
@ -649,7 +651,7 @@ class Cell
|
|||
*
|
||||
* @return string Absolute coordinate e.g. '$A$1'
|
||||
*/
|
||||
public static function absoluteCoordinate($pCoordinateString = 'A1')
|
||||
public static function absoluteCoordinate($pCoordinateString)
|
||||
{
|
||||
if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) {
|
||||
// Split out any worksheet name from the coordinate
|
||||
|
@ -682,7 +684,7 @@ class Cell
|
|||
* e.g. array('B4','D9') or array(array('B4','D9'),array('H2','O11'))
|
||||
* or array('B4')
|
||||
*/
|
||||
public static function splitRange($pRange = 'A1:A1')
|
||||
public static function splitRange($pRange)
|
||||
{
|
||||
// Ensure $pRange is a valid range
|
||||
if (empty($pRange)) {
|
||||
|
@ -707,10 +709,10 @@ class Cell
|
|||
*
|
||||
* @return string String representation of $pRange
|
||||
*/
|
||||
public static function buildRange($pRange)
|
||||
public static function buildRange(array $pRange)
|
||||
{
|
||||
// Verify range
|
||||
if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) {
|
||||
if (empty($pRange) || !is_array($pRange[0])) {
|
||||
throw new Exception('Range does not contain any information');
|
||||
}
|
||||
|
||||
|
@ -733,7 +735,7 @@ class Cell
|
|||
* @return array Range coordinates array(Start Cell, End Cell)
|
||||
* where Start Cell and End Cell are arrays (Column Number, Row Number)
|
||||
*/
|
||||
public static function rangeBoundaries($pRange = 'A1:A1')
|
||||
public static function rangeBoundaries($pRange)
|
||||
{
|
||||
// Ensure $pRange is a valid range
|
||||
if (empty($pRange)) {
|
||||
|
@ -768,7 +770,7 @@ class Cell
|
|||
*
|
||||
* @return array Range dimension (width, height)
|
||||
*/
|
||||
public static function rangeDimension($pRange = 'A1:A1')
|
||||
public static function rangeDimension($pRange)
|
||||
{
|
||||
// Calculate range outer borders
|
||||
list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange);
|
||||
|
@ -784,7 +786,7 @@ class Cell
|
|||
* @return array Range coordinates array(Start Cell, End Cell)
|
||||
* where Start Cell and End Cell are arrays (Column ID, Row Number)
|
||||
*/
|
||||
public static function getRangeBoundaries($pRange = 'A1:A1')
|
||||
public static function getRangeBoundaries($pRange)
|
||||
{
|
||||
// Ensure $pRange is a valid range
|
||||
if (empty($pRange)) {
|
||||
|
@ -807,11 +809,11 @@ class Cell
|
|||
/**
|
||||
* Column index from string.
|
||||
*
|
||||
* @param string $pString
|
||||
* @param string $pString eg 'A'
|
||||
*
|
||||
* @return int Column index (base 1 !!!)
|
||||
*/
|
||||
public static function columnIndexFromString($pString = 'A')
|
||||
public static function columnIndexFromString($pString)
|
||||
{
|
||||
// Using a lookup cache adds a slight memory overhead, but boosts speed
|
||||
// caching using a static within the method is faster than a class static,
|
||||
|
@ -854,11 +856,11 @@ class Cell
|
|||
/**
|
||||
* String from columnindex.
|
||||
*
|
||||
* @param int $pColumnIndex Column index (base 0 !!!)
|
||||
* @param int $pColumnIndex Column index (A = 0)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function stringFromColumnIndex($pColumnIndex = 0)
|
||||
public static function stringFromColumnIndex($pColumnIndex)
|
||||
{
|
||||
// Using a lookup cache adds a slight memory overhead, but boosts speed
|
||||
// caching using a static within the method is faster than a class static,
|
||||
|
@ -889,7 +891,7 @@ class Cell
|
|||
*
|
||||
* @return array Array containing single cell references
|
||||
*/
|
||||
public static function extractAllCellReferencesInRange($pRange = 'A1')
|
||||
public static function extractAllCellReferencesInRange($pRange)
|
||||
{
|
||||
// Returnvalue
|
||||
$returnValue = [];
|
||||
|
@ -988,12 +990,8 @@ class Cell
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setValueBinder(Cell\IValueBinder $binder = null)
|
||||
public static function setValueBinder(Cell\IValueBinder $binder)
|
||||
{
|
||||
if ($binder === null) {
|
||||
throw new Exception('A \\PhpOffice\\PhpSpreadsheet\\Cell\\IValueBinder is required for PhpSpreadsheet to function correctly.');
|
||||
}
|
||||
|
||||
self::$valueBinder = $binder;
|
||||
}
|
||||
|
||||
|
@ -1029,15 +1027,15 @@ class Cell
|
|||
*
|
||||
* @return Cell
|
||||
*/
|
||||
public function setXfIndex($pValue = 0)
|
||||
public function setXfIndex($pValue)
|
||||
{
|
||||
$this->xfIndex = $pValue;
|
||||
|
||||
return $this->notifyCacheController();
|
||||
return $this->updateInCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
|
||||
* Set the formula attributes.
|
||||
*
|
||||
* @param mixed $pAttributes
|
||||
*/
|
||||
|
@ -1049,7 +1047,7 @@ class Cell
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
|
||||
* Get the formula attributes.
|
||||
*/
|
||||
public function getFormulaAttributes()
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ class DataType
|
|||
*
|
||||
* @return mixed Sanitized value
|
||||
*/
|
||||
public static function checkString($pValue = null)
|
||||
public static function checkString($pValue)
|
||||
{
|
||||
if ($pValue instanceof \PhpOffice\PhpSpreadsheet\RichText) {
|
||||
// TODO: Sanitize Rich-Text string (max. character count is 32,767)
|
||||
|
@ -93,7 +93,7 @@ class DataType
|
|||
*
|
||||
* @return string Sanitized value
|
||||
*/
|
||||
public static function checkErrorCode($pValue = null)
|
||||
public static function checkErrorCode($pValue)
|
||||
{
|
||||
$pValue = (string) $pValue;
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class DataValidation
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $operator = '';
|
||||
private $operator = self::OPERATOR_BETWEEN;
|
||||
|
||||
/**
|
||||
* Allow Blank.
|
||||
|
@ -166,7 +166,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setFormula1($value = '')
|
||||
public function setFormula1($value)
|
||||
{
|
||||
$this->formula1 = $value;
|
||||
|
||||
|
@ -190,7 +190,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setFormula2($value = '')
|
||||
public function setFormula2($value)
|
||||
{
|
||||
$this->formula2 = $value;
|
||||
|
||||
|
@ -214,7 +214,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setType($value = self::TYPE_NONE)
|
||||
public function setType($value)
|
||||
{
|
||||
$this->type = $value;
|
||||
|
||||
|
@ -234,11 +234,11 @@ class DataValidation
|
|||
/**
|
||||
* Set Error style.
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $value see self::STYLE_*
|
||||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setErrorStyle($value = self::STYLE_STOP)
|
||||
public function setErrorStyle($value)
|
||||
{
|
||||
$this->errorStyle = $value;
|
||||
|
||||
|
@ -262,7 +262,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setOperator($value = '')
|
||||
public function setOperator($value)
|
||||
{
|
||||
$this->operator = $value;
|
||||
|
||||
|
@ -286,7 +286,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setAllowBlank($value = false)
|
||||
public function setAllowBlank($value)
|
||||
{
|
||||
$this->allowBlank = $value;
|
||||
|
||||
|
@ -310,7 +310,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setShowDropDown($value = false)
|
||||
public function setShowDropDown($value)
|
||||
{
|
||||
$this->showDropDown = $value;
|
||||
|
||||
|
@ -334,7 +334,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setShowInputMessage($value = false)
|
||||
public function setShowInputMessage($value)
|
||||
{
|
||||
$this->showInputMessage = $value;
|
||||
|
||||
|
@ -358,7 +358,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setShowErrorMessage($value = false)
|
||||
public function setShowErrorMessage($value)
|
||||
{
|
||||
$this->showErrorMessage = $value;
|
||||
|
||||
|
@ -382,7 +382,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setErrorTitle($value = '')
|
||||
public function setErrorTitle($value)
|
||||
{
|
||||
$this->errorTitle = $value;
|
||||
|
||||
|
@ -406,7 +406,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setError($value = '')
|
||||
public function setError($value)
|
||||
{
|
||||
$this->error = $value;
|
||||
|
||||
|
@ -430,7 +430,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setPromptTitle($value = '')
|
||||
public function setPromptTitle($value)
|
||||
{
|
||||
$this->promptTitle = $value;
|
||||
|
||||
|
@ -454,7 +454,7 @@ class DataValidation
|
|||
*
|
||||
* @return DataValidation
|
||||
*/
|
||||
public function setPrompt($value = '')
|
||||
public function setPrompt($value)
|
||||
{
|
||||
$this->prompt = $value;
|
||||
|
||||
|
|