Merge branch 'master' into Page-Setup-Page-Order

This commit is contained in:
Mark Baker 2020-07-19 12:57:48 +02:00 committed by GitHub
commit 5233e9caaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 480 additions and 758 deletions

View File

@ -5,21 +5,44 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com) The format is based on [Keep a Changelog](https://keepachangelog.com)
and this project adheres to [Semantic Versioning](https://semver.org). and this project adheres to [Semantic Versioning](https://semver.org).
## [Unreleased] ## Unreleased - TBD
### Added ### Added
- Implemented Page Order for Xlsx and Xls Readers, and provided Page Settings (Orientation, Scale, Horizontal/Vertical Centering, Page Order, Margins) support for Ods, Gnumeric and Xls Readers [#1559](https://github.com/PHPOffice/PhpSpreadsheet/pull/1559) - Implemented Page Order for Xlsx and Xls Readers, and provided Page Settings (Orientation, Scale, Horizontal/Vertical Centering, Page Order, Margins) support for Ods, Gnumeric and Xls Readers [#1559](https://github.com/PHPOffice/PhpSpreadsheet/pull/1559)
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed ### Fixed
- Nothing.
## 1.14.1 - 2020-07-19
### Added
- nothing - nothing
### Fixed
- WEBSERVICE is HTTP client agnostic and must be configured via `Settings::setHttpClient()` [#1562](https://github.com/PHPOffice/PhpSpreadsheet/issues/1562)
- Borders were not complete on rowspanned columns using HTML reader [#1473](https://github.com/PHPOffice/PhpSpreadsheet/pull/1473)
### Changed ### Changed
- nothing - nothing
## [1.14.0] - 2020-06-29 ## 1.14.0 - 2020-06-29
### Added ### Added
@ -43,7 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Xls Writer - Correct Timestamp Bug [#1493](https://github.com/PHPOffice/PhpSpreadsheet/pull/1493) - Xls Writer - Correct Timestamp Bug [#1493](https://github.com/PHPOffice/PhpSpreadsheet/pull/1493)
- Don't ouput row and columns without any cells in HTML writer [#1235](https://github.com/PHPOffice/PhpSpreadsheet/issues/1235) - Don't ouput row and columns without any cells in HTML writer [#1235](https://github.com/PHPOffice/PhpSpreadsheet/issues/1235)
## [1.13.0] - 2020-05-31 ## 1.13.0 - 2020-05-31
### Added ### Added
@ -69,7 +92,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Drop partial migration tool in favor of complete migration via RectorPHP [#1445](https://github.com/PHPOffice/PhpSpreadsheet/issues/1445) - Drop partial migration tool in favor of complete migration via RectorPHP [#1445](https://github.com/PHPOffice/PhpSpreadsheet/issues/1445)
- Limit composer package to `src/` [#1424](https://github.com/PHPOffice/PhpSpreadsheet/pull/1424) - Limit composer package to `src/` [#1424](https://github.com/PHPOffice/PhpSpreadsheet/pull/1424)
## [1.12.0] - 2020-04-27 ## 1.12.0 - 2020-04-27
### Added ### Added
@ -85,7 +108,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- MATCH with a static array should return the position of the found value based on the values submitted [#1332](https://github.com/PHPOffice/PhpSpreadsheet/pull/1332) - MATCH with a static array should return the position of the found value based on the values submitted [#1332](https://github.com/PHPOffice/PhpSpreadsheet/pull/1332)
- Fix Xlsx Reader's handling of undefined fill color [#1353](https://github.com/PHPOffice/PhpSpreadsheet/pull/1353) - Fix Xlsx Reader's handling of undefined fill color [#1353](https://github.com/PHPOffice/PhpSpreadsheet/pull/1353)
## [1.11.0] - 2020-03-02 ## 1.11.0 - 2020-03-02
### Added ### Added
@ -104,7 +127,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fix XLSX file loading with autofilter containing '$' [#1326](https://github.com/PHPOffice/PhpSpreadsheet/pull/1326) - Fix XLSX file loading with autofilter containing '$' [#1326](https://github.com/PHPOffice/PhpSpreadsheet/pull/1326)
- PHPDoc - Use `@return $this` for fluent methods [#1362](https://github.com/PHPOffice/PhpSpreadsheet/pull/1362) - PHPDoc - Use `@return $this` for fluent methods [#1362](https://github.com/PHPOffice/PhpSpreadsheet/pull/1362)
## [1.10.1] - 2019-12-02 ## 1.10.1 - 2019-12-02
### Changed ### Changed
@ -119,7 +142,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- ODS writer prevent invalid numeric value if locale decimal separator is comma [#1268](https://github.com/PHPOffice/PhpSpreadsheet/pull/1268) - ODS writer prevent invalid numeric value if locale decimal separator is comma [#1268](https://github.com/PHPOffice/PhpSpreadsheet/pull/1268)
- Xlsx writer actually writes plotVisOnly and dispBlanksAs from chart properties [#1266](https://github.com/PHPOffice/PhpSpreadsheet/pull/1266) - Xlsx writer actually writes plotVisOnly and dispBlanksAs from chart properties [#1266](https://github.com/PHPOffice/PhpSpreadsheet/pull/1266)
## [1.10.0] - 2019-11-18 ## 1.10.0 - 2019-11-18
### Changed ### Changed
@ -144,7 +167,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Validate XIRR inputs and return correct error values [#1120](https://github.com/PHPOffice/PhpSpreadsheet/issues/1120) - Validate XIRR inputs and return correct error values [#1120](https://github.com/PHPOffice/PhpSpreadsheet/issues/1120)
- Allow to read xlsx files with exotic workbook names like "workbook2.xml" [#1183](https://github.com/PHPOffice/PhpSpreadsheet/pull/1183) - Allow to read xlsx files with exotic workbook names like "workbook2.xml" [#1183](https://github.com/PHPOffice/PhpSpreadsheet/pull/1183)
## [1.9.0] - 2019-08-17 ## 1.9.0 - 2019-08-17
### Changed ### Changed
@ -175,20 +198,20 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fix `getCalculatedValue()` error with more than two INDIRECT [#1115](https://github.com/PHPOffice/PhpSpreadsheet/pull/1115) - Fix `getCalculatedValue()` error with more than two INDIRECT [#1115](https://github.com/PHPOffice/PhpSpreadsheet/pull/1115)
- Writer\Html did not hide columns [#985](https://github.com/PHPOffice/PhpSpreadsheet/pull/985) - Writer\Html did not hide columns [#985](https://github.com/PHPOffice/PhpSpreadsheet/pull/985)
## [1.8.2] - 2019-07-08 ## 1.8.2 - 2019-07-08
### Fixed ### Fixed
- Uncaught error when opening ods file and properties aren't defined [#1047](https://github.com/PHPOffice/PhpSpreadsheet/issues/1047) - Uncaught error when opening ods file and properties aren't defined [#1047](https://github.com/PHPOffice/PhpSpreadsheet/issues/1047)
- Xlsx Reader Cell datavalidations bug [#1052](https://github.com/PHPOffice/PhpSpreadsheet/pull/1052) - Xlsx Reader Cell datavalidations bug [#1052](https://github.com/PHPOffice/PhpSpreadsheet/pull/1052)
## [1.8.1] - 2019-07-02 ## 1.8.1 - 2019-07-02
### Fixed ### Fixed
- Allow nullable theme for Xlsx Style Reader class [#1043](https://github.com/PHPOffice/PhpSpreadsheet/issues/1043) - Allow nullable theme for Xlsx Style Reader class [#1043](https://github.com/PHPOffice/PhpSpreadsheet/issues/1043)
## [1.8.0] - 2019-07-01 ## 1.8.0 - 2019-07-01
### Security Fix (CVE-2019-12331) ### Security Fix (CVE-2019-12331)
@ -211,7 +234,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fix a SUMIF warning with some versions of PHP when having different length of arrays provided as input [#873](https://github.com/PHPOffice/PhpSpreadsheet/pull/873) - Fix a SUMIF warning with some versions of PHP when having different length of arrays provided as input [#873](https://github.com/PHPOffice/PhpSpreadsheet/pull/873)
- Fix incorrectly handled backslash-escaped space characters in number format - Fix incorrectly handled backslash-escaped space characters in number format
## [1.7.0] - 2019-05-26 ## 1.7.0 - 2019-05-26
- Added support for inline styles in Html reader (borders, alignment, width, height) - Added support for inline styles in Html reader (borders, alignment, width, height)
- QuotedText cells no longer treated as formulae if the content begins with a `=` - QuotedText cells no longer treated as formulae if the content begins with a `=`
@ -225,7 +248,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fix VLOOKUP - Fix VLOOKUP
- Fix return type hint - Fix return type hint
## [1.6.0] - 2019-01-02 ## 1.6.0 - 2019-01-02
### Added ### Added
@ -253,13 +276,13 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- `master` is the new default branch, `develop` does not exist anymore - `master` is the new default branch, `develop` does not exist anymore
## [1.5.2] - 2018-11-25 ## 1.5.2 - 2018-11-25
### Security ### Security
- Improvements to the design of the XML Security Scanner [#771](https://github.com/PHPOffice/PhpSpreadsheet/issues/771) - Improvements to the design of the XML Security Scanner [#771](https://github.com/PHPOffice/PhpSpreadsheet/issues/771)
## [1.5.1] - 2018-11-20 ## 1.5.1 - 2018-11-20
### Security ### Security
@ -279,7 +302,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Mpdf export can exceed pcre.backtrack_limit [#637](https://github.com/PHPOffice/PhpSpreadsheet/issues/637) - Mpdf export can exceed pcre.backtrack_limit [#637](https://github.com/PHPOffice/PhpSpreadsheet/issues/637)
- Fix index overflow on data values array [#748](https://github.com/PHPOffice/PhpSpreadsheet/pull/748) - Fix index overflow on data values array [#748](https://github.com/PHPOffice/PhpSpreadsheet/pull/748)
## [1.5.0] - 2018-10-21 ## 1.5.0 - 2018-10-21
### Added ### Added
@ -294,7 +317,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- OFFSET should allow omitted height and width [#561](https://github.com/PHPOffice/PhpSpreadsheet/issues/561) - OFFSET should allow omitted height and width [#561](https://github.com/PHPOffice/PhpSpreadsheet/issues/561)
- Correctly determine delimiter when CSV contains line breaks inside enclosures [#716](https://github.com/PHPOffice/PhpSpreadsheet/issues/716) - Correctly determine delimiter when CSV contains line breaks inside enclosures [#716](https://github.com/PHPOffice/PhpSpreadsheet/issues/716)
## [1.4.1] - 2018-09-30 ## 1.4.1 - 2018-09-30
### Fixed ### Fixed
@ -303,7 +326,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fix warning when reading xlsx without styles [#631](https://github.com/PHPOffice/PhpSpreadsheet/pull/631) - Fix warning when reading xlsx without styles [#631](https://github.com/PHPOffice/PhpSpreadsheet/pull/631)
- Fix broken sample links on windows due to $baseDir having backslash [#653](https://github.com/PHPOffice/PhpSpreadsheet/pull/653) - Fix broken sample links on windows due to $baseDir having backslash [#653](https://github.com/PHPOffice/PhpSpreadsheet/pull/653)
## [1.4.0] - 2018-08-06 ## 1.4.0 - 2018-08-06
### Added ### Added
@ -367,13 +390,13 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Migration tool keep variables containing $PHPExcel untouched [#598](https://github.com/PHPOffice/PhpSpreadsheet/issues/598) - Migration tool keep variables containing $PHPExcel untouched [#598](https://github.com/PHPOffice/PhpSpreadsheet/issues/598)
- Rowspans/colspans were incorrect when adding worksheet using loadIntoExisting [#619](https://github.com/PHPOffice/PhpSpreadsheet/issues/619) - Rowspans/colspans were incorrect when adding worksheet using loadIntoExisting [#619](https://github.com/PHPOffice/PhpSpreadsheet/issues/619)
## [1.3.1] - 2018-06-12 ## 1.3.1 - 2018-06-12
### Fixed ### Fixed
- Ranges across Z and AA columns incorrectly threw an exception [#545](https://github.com/PHPOffice/PhpSpreadsheet/issues/545) - Ranges across Z and AA columns incorrectly threw an exception [#545](https://github.com/PHPOffice/PhpSpreadsheet/issues/545)
## [1.3.0] - 2018-06-10 ## 1.3.0 - 2018-06-10
### Added ### Added
@ -392,13 +415,13 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fixed parsing of conditionals in COUNTIF functions [#526](https://github.com/PHPOffice/PhpSpreadsheet/issues/526) - Fixed parsing of conditionals in COUNTIF functions [#526](https://github.com/PHPOffice/PhpSpreadsheet/issues/526)
- Corruption errors for saved Xlsx docs with frozen panes [#532](https://github.com/PHPOffice/PhpSpreadsheet/issues/532) - Corruption errors for saved Xlsx docs with frozen panes [#532](https://github.com/PHPOffice/PhpSpreadsheet/issues/532)
## [1.2.1] - 2018-04-10 ## 1.2.1 - 2018-04-10
### Fixed ### Fixed
- Plain text and richtext mixed in same cell can be read [#442](https://github.com/PHPOffice/PhpSpreadsheet/issues/442) - Plain text and richtext mixed in same cell can be read [#442](https://github.com/PHPOffice/PhpSpreadsheet/issues/442)
## [1.2.0] - 2018-03-04 ## 1.2.0 - 2018-03-04
### Added ### Added
@ -416,7 +439,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Select correct cell when calling freezePane [#389](https://github.com/PHPOffice/PhpSpreadsheet/issues/389) - Select correct cell when calling freezePane [#389](https://github.com/PHPOffice/PhpSpreadsheet/issues/389)
- `setStrikethrough()` did not set the font [#403](https://github.com/PHPOffice/PhpSpreadsheet/issues/403) - `setStrikethrough()` did not set the font [#403](https://github.com/PHPOffice/PhpSpreadsheet/issues/403)
## [1.1.0] - 2018-01-28 ## 1.1.0 - 2018-01-28
### Added ### Added
@ -434,7 +457,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Support XML file without styles [#331](https://github.com/PHPOffice/PhpSpreadsheet/pull/331) - Support XML file without styles [#331](https://github.com/PHPOffice/PhpSpreadsheet/pull/331)
- Cell coordinates which are already a range cause an exception [#319](https://github.com/PHPOffice/PhpSpreadsheet/issues/319) - Cell coordinates which are already a range cause an exception [#319](https://github.com/PHPOffice/PhpSpreadsheet/issues/319)
## [1.0.0] - 2017-12-25 ## 1.0.0 - 2017-12-25
### Added ### Added
@ -453,7 +476,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Constant `TYPE_DOUGHTNUTCHART` is now `TYPE_DOUGHNUTCHART`. - Constant `TYPE_DOUGHTNUTCHART` is now `TYPE_DOUGHNUTCHART`.
## [1.0.0-beta2] - 2017-11-26 ## 1.0.0-beta2 - 2017-11-26
### Added ### Added
@ -491,7 +514,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- `PhpSpreadsheet\Style` => `PhpSpreadsheet\Style\Style` - `PhpSpreadsheet\Style` => `PhpSpreadsheet\Style\Style`
- `PhpSpreadsheet\Worksheet` => `PhpSpreadsheet\Worksheet\Worksheet` - `PhpSpreadsheet\Worksheet` => `PhpSpreadsheet\Worksheet\Worksheet`
## [1.0.0-beta] - 2017-08-17 ## 1.0.0-beta - 2017-08-17
### Added ### Added

View File

@ -57,7 +57,8 @@
"markbaker/complex": "^1.4", "markbaker/complex": "^1.4",
"markbaker/matrix": "^1.2", "markbaker/matrix": "^1.2",
"psr/simple-cache": "^1.0", "psr/simple-cache": "^1.0",
"guzzlehttp/guzzle": "^7.0" "psr/http-client": "^1.0",
"psr/http-factory": "^1.0"
}, },
"require-dev": { "require-dev": {
"dompdf/dompdf": "^0.8.5", "dompdf/dompdf": "^0.8.5",

312
composer.lock generated
View File

@ -4,211 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "b7ea4dea7ce2e1c2299029fe978d2173", "content-hash": "931b86c12c78e665f1766ea922f95e0b",
"packages": [ "packages": [
{
"name": "guzzlehttp/guzzle",
"version": "7.0.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/2d9d3c186a6637a43193e66b097c50e4451eaab2",
"reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.6.1",
"php": "^7.2.5",
"psr/http-client": "^1.0"
},
"provide": {
"psr/http-client-implementation": "1.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.0",
"ext-curl": "*",
"php-http/client-integration-tests": "dev-phpunit8",
"phpunit/phpunit": "^8.5.5",
"psr/log": "^1.1"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "7.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://sagikazarmark.hu"
}
],
"description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"psr-18",
"psr-7",
"rest",
"web service"
],
"time": "2020-06-27T10:33:25+00:00"
},
{
"name": "guzzlehttp/promises",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"shasum": ""
},
"require": {
"php": ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"time": "2016-12-20T10:07:11+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "1.6.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "239400de7a173fe9901b9ac7c06497751f00727a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a",
"reference": "239400de7a173fe9901b9ac7c06497751f00727a",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0",
"ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"ext-zlib": "*",
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
},
"suggest": {
"zendframework/zend-httphandlerrunner": "Emit PSR-7 responses"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
],
"time": "2019-07-01T23:21:34+00:00"
},
{ {
"name": "maennchen/zipstream-php", "name": "maennchen/zipstream-php",
"version": "2.1.0", "version": "2.1.0",
@ -482,20 +279,20 @@
}, },
{ {
"name": "psr/http-client", "name": "psr/http-client",
"version": "1.0.0", "version": "1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/http-client.git", "url": "https://github.com/php-fig/http-client.git",
"reference": "496a823ef742b632934724bf769560c2a5c7c44e" "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/http-client/zipball/496a823ef742b632934724bf769560c2a5c7c44e", "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
"reference": "496a823ef742b632934724bf769560c2a5c7c44e", "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.0", "php": "^7.0 || ^8.0",
"psr/http-message": "^1.0" "psr/http-message": "^1.0"
}, },
"type": "library", "type": "library",
@ -527,7 +324,59 @@
"psr", "psr",
"psr-18" "psr-18"
], ],
"time": "2018-10-30T23:29:13+00:00" "time": "2020-06-29T06:28:15+00:00"
},
{
"name": "psr/http-factory",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
"shasum": ""
},
"require": {
"php": ">=7.0.0",
"psr/http-message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"time": "2019-04-30T12:38:16+00:00"
}, },
{ {
"name": "psr/http-message", "name": "psr/http-message",
@ -627,46 +476,6 @@
], ],
"time": "2017-10-23T01:57:42+00:00" "time": "2017-10-23T01:57:42+00:00"
}, },
{
"name": "ralouphie/getallheaders",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
"reference": "120b605dfeb996808c31b6477290a714d356e822"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
"reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^5 || ^6.5"
},
"type": "library",
"autoload": {
"files": [
"src/getallheaders.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders.",
"time": "2019-03-08T08:55:37+00:00"
},
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.17.1", "version": "v1.17.1",
@ -4382,5 +4191,6 @@
"ext-zip": "*", "ext-zip": "*",
"ext-zlib": "*" "ext-zlib": "*"
}, },
"platform-dev": [] "platform-dev": [],
"plugin-api-version": "1.1.0"
} }

View File

@ -43,3 +43,20 @@ More details of the features available once a locale has been set,
including a list of the languages and locales currently supported, can including a list of the languages and locales currently supported, can
be found in [Locale Settings for be found in [Locale Settings for
Formulae](./recipes.md#locale-settings-for-formulae). Formulae](./recipes.md#locale-settings-for-formulae).
## HTTP client
In order to use the `WEBSERVICE` function in formulae, you must configure an
HTTP client. Assuming you chose Guzzle 7, this can be done like:
```php
use GuzzleHttp\Client;
use Http\Factory\Guzzle\RequestFactory;
use PhpOffice\PhpSpreadsheet\Settings;
$client = new Client();
$requestFactory = new RequestFactory();
Settings::setHttpClient($client, $requestFactory);
```

View File

@ -2,7 +2,6 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
use GuzzleHttp\Psr7\Request;
use PhpOffice\PhpSpreadsheet\Settings; use PhpOffice\PhpSpreadsheet\Settings;
use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientExceptionInterface;
@ -31,7 +30,8 @@ class Web
// Get results from the the webservice // Get results from the the webservice
$client = Settings::getHttpClient(); $client = Settings::getHttpClient();
$request = new Request('GET', $url); $requestFactory = Settings::getRequestFactory();
$request = $requestFactory->createRequest('GET', $url);
try { try {
$response = $client->sendRequest($request); $response = $client->sendRequest($request);
@ -43,7 +43,7 @@ class Web
return Functions::VALUE(); // cURL error return Functions::VALUE(); // cURL error
} }
$output = (string) $response->getBody(); $output = $response->getBody()->getContents();
if (strlen($output) > 32767) { if (strlen($output) > 32767) {
return Functions::VALUE(); // Output not a string or too long return Functions::VALUE(); // Output not a string or too long
} }

View File

@ -682,7 +682,26 @@ class Html extends BaseReader
return; return;
} }
$cellStyle = $sheet->getStyle($column . $row); if (isset($attributeArray['rowspan'], $attributeArray['colspan'])) {
$columnTo = $column;
for ($i = 0; $i < (int) $attributeArray['colspan'] - 1; ++$i) {
++$columnTo;
}
$range = $column . $row . ':' . $columnTo . ($row + (int) $attributeArray['rowspan'] - 1);
$cellStyle = $sheet->getStyle($range);
} elseif (isset($attributeArray['rowspan'])) {
$range = $column . $row . ':' . $column . ($row + (int) $attributeArray['rowspan'] - 1);
$cellStyle = $sheet->getStyle($range);
} elseif (isset($attributeArray['colspan'])) {
$columnTo = $column;
for ($i = 0; $i < (int) $attributeArray['colspan'] - 1; ++$i) {
++$columnTo;
}
$range = $column . $row . ':' . $columnTo . $row;
$cellStyle = $sheet->getStyle($range);
} else {
$cellStyle = $sheet->getStyle($column . $row);
}
// add color styles (background & text) from dom element,currently support : td & th, using ONLY inline css style with RGB color // add color styles (background & text) from dom element,currently support : td & th, using ONLY inline css style with RGB color
$styles = explode(';', $attributeArray['style']); $styles = explode(';', $attributeArray['style']);

View File

@ -2,11 +2,11 @@
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
use GuzzleHttp\Client;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Chart\Renderer\IRenderer; use PhpOffice\PhpSpreadsheet\Chart\Renderer\IRenderer;
use PhpOffice\PhpSpreadsheet\Collection\Memory; use PhpOffice\PhpSpreadsheet\Collection\Memory;
use Psr\Http\Client\ClientInterface; use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheInterface;
class Settings class Settings
@ -47,9 +47,14 @@ class Settings
/** /**
* The HTTP client implementation to be used for network request. * The HTTP client implementation to be used for network request.
* *
* @var ClientInterface * @var null|ClientInterface
*/ */
private static $client; private static $httpClient;
/**
* @var null|RequestFactoryInterface
*/
private static $requestFactory;
/** /**
* Set the locale code to use for formula translations and any special formatting. * Set the locale code to use for formula translations and any special formatting.
@ -169,9 +174,19 @@ class Settings
/** /**
* Set the HTTP client implementation to be used for network request. * Set the HTTP client implementation to be used for network request.
*/ */
public static function setHttpClient(ClientInterface $httpClient): void public static function setHttpClient(ClientInterface $httpClient, RequestFactoryInterface $requestFactory): void
{ {
self::$client = $httpClient; self::$httpClient = $httpClient;
self::$requestFactory = $requestFactory;
}
/**
* Unset the HTTP client configuration.
*/
public static function unsetHttpClient(): void
{
self::$httpClient = null;
self::$requestFactory = null;
} }
/** /**
@ -179,10 +194,25 @@ class Settings
*/ */
public static function getHttpClient(): ClientInterface public static function getHttpClient(): ClientInterface
{ {
if (!self::$client) { self::assertHttpClient();
self::$client = new Client();
}
return self::$client; return self::$httpClient;
}
/**
* Get the HTTP request factory.
*/
public static function getRequestFactory(): RequestFactoryInterface
{
self::assertHttpClient();
return self::$requestFactory;
}
private static function assertHttpClient(): void
{
if (!self::$httpClient || !self::$requestFactory) {
throw new Exception('HTTP client must be configured via Settings::setHttpClient() to be able to use WEBSERVICE function.');
}
} }
} }

View File

@ -9,15 +9,23 @@ use PHPUnit\Framework\TestCase;
class CalculationTest extends TestCase class CalculationTest extends TestCase
{ {
private $compatibilityMode;
private $locale;
protected function setUp(): void protected function setUp(): void
{ {
$this->compatibilityMode = Functions::getCompatibilityMode();
$calculation = Calculation::getInstance();
$this->locale = $calculation->getLocale();
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
} }
protected function tearDown(): void protected function tearDown(): void
{ {
Functions::setCompatibilityMode($this->compatibilityMode);
$calculation = Calculation::getInstance(); $calculation = Calculation::getInstance();
$calculation->setLocale('en_us'); $calculation->setLocale($this->locale);
} }
/** /**

View File

@ -9,13 +9,29 @@ use PHPUnit\Framework\TestCase;
class DayTest extends TestCase class DayTest extends TestCase
{ {
private $compatibilityMode;
private $returnDateType;
private $excelCalendar;
protected function setUp(): void protected function setUp(): void
{ {
$this->compatibilityMode = Functions::getCompatibilityMode();
$this->returnDateType = Functions::getReturnDateType();
$this->excelCalendar = Date::getExcelCalendar();
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
} }
protected function tearDown(): void
{
Functions::setCompatibilityMode($this->compatibilityMode);
Functions::setReturnDateType($this->returnDateType);
Date::setExcelCalendar($this->excelCalendar);
}
/** /**
* @dataProvider providerDAY * @dataProvider providerDAY
* *

View File

@ -8,11 +8,19 @@ use PHPUnit\Framework\TestCase;
class CountTest extends TestCase class CountTest extends TestCase
{ {
private $compatibilityMode;
protected function setUp(): void protected function setUp(): void
{ {
$this->compatibilityMode = Functions::getCompatibilityMode();
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
} }
protected function tearDown(): void
{
Functions::setCompatibilityMode($this->compatibilityMode);
}
/** /**
* @dataProvider providerBasicCOUNT * @dataProvider providerBasicCOUNT
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class CharTest extends TestCase class CharTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerCHAR * @dataProvider providerCHAR
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class CleanTest extends TestCase class CleanTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerCLEAN * @dataProvider providerCLEAN
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class CodeTest extends TestCase class CodeTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerCODE * @dataProvider providerCODE
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class ConcatenateTest extends TestCase class ConcatenateTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerCONCATENATE * @dataProvider providerCONCATENATE
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class DollarTest extends TestCase class DollarTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerDOLLAR * @dataProvider providerDOLLAR
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class ExactTest extends TestCase class ExactTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerEXACT * @dataProvider providerEXACT
* *
@ -33,10 +15,6 @@ class ExactTest extends TestCase
*/ */
public function testEXACT($expectedResult, ...$args): void public function testEXACT($expectedResult, ...$args): void
{ {
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(' ');
StringHelper::setCurrencyCode('$');
$result = TextData::EXACT(...$args); $result = TextData::EXACT(...$args);
self::assertSame($expectedResult, $result); self::assertSame($expectedResult, $result);
} }

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class FindTest extends TestCase class FindTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerFIND * @dataProvider providerFIND
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class FixedTest extends TestCase class FixedTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerFIXED * @dataProvider providerFIXED
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class LeftTest extends TestCase class LeftTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerLEFT * @dataProvider providerLEFT
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class LenTest extends TestCase class LenTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerLEN * @dataProvider providerLEN
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class LowerTest extends TestCase class LowerTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerLOWER * @dataProvider providerLOWER
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class MidTest extends TestCase class MidTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerMID * @dataProvider providerMID
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class NumberValueTest extends TestCase class NumberValueTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerNUMBERVALUE * @dataProvider providerNUMBERVALUE
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class ProperTest extends TestCase class ProperTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerPROPER * @dataProvider providerPROPER
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class ReplaceTest extends TestCase class ReplaceTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerREPLACE * @dataProvider providerREPLACE
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class RightTest extends TestCase class RightTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerRIGHT * @dataProvider providerRIGHT
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class SearchTest extends TestCase class SearchTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerSEARCH * @dataProvider providerSEARCH
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class SubstituteTest extends TestCase class SubstituteTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerSUBSTITUTE * @dataProvider providerSUBSTITUTE
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class TTest extends TestCase class TTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerT * @dataProvider providerT
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class TextJoinTest extends TestCase class TextJoinTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerTEXTJOIN * @dataProvider providerTEXTJOIN
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class TextTest extends TestCase class TextTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerTEXT * @dataProvider providerTEXT
* *
@ -32,11 +14,6 @@ class TextTest extends TestCase
*/ */
public function testTEXT($expectedResult, ...$args): void public function testTEXT($expectedResult, ...$args): void
{ {
// Enforce decimal and thousands separator values to UK/US, and currency code to USD
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
$result = TextData::TEXTFORMAT(...$args); $result = TextData::TEXTFORMAT(...$args);
self::assertEquals($expectedResult, $result); self::assertEquals($expectedResult, $result);
} }

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class TrimTest extends TestCase class TrimTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerTRIM * @dataProvider providerTRIM
* *

View File

@ -2,29 +2,11 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class UpperTest extends TestCase class UpperTest extends TestCase
{ {
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
protected function tearDown(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/** /**
* @dataProvider providerUPPER * @dataProvider providerUPPER
* *

View File

@ -2,27 +2,30 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class ValueTest extends TestCase class ValueTest extends TestCase
{ {
private $currencyCode;
private $decimalSeparator;
private $thousandsSeparator;
protected function setUp(): void protected function setUp(): void
{ {
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->currencyCode = StringHelper::getCurrencyCode();
StringHelper::setDecimalSeparator('.'); $this->decimalSeparator = StringHelper::getDecimalSeparator();
StringHelper::setThousandsSeparator(','); $this->thousandsSeparator = StringHelper::getThousandsSeparator();
StringHelper::setCurrencyCode('$');
} }
protected function tearDown(): void protected function tearDown(): void
{ {
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setCurrencyCode($this->currencyCode);
StringHelper::setDecimalSeparator('.'); StringHelper::setDecimalSeparator($this->decimalSeparator);
StringHelper::setThousandsSeparator(','); StringHelper::setThousandsSeparator($this->thousandsSeparator);
StringHelper::setCurrencyCode('$');
} }
/** /**

View File

@ -2,47 +2,46 @@
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Web; namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Web;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\Web; use PhpOffice\PhpSpreadsheet\Calculation\Web;
use PhpOffice\PhpSpreadsheet\Settings; use PhpOffice\PhpSpreadsheet\Settings;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
class WebServiceTest extends TestCase class WebServiceTest extends TestCase
{ {
protected static $client; protected function tearDown(): void
public static function setUpBeforeClass(): void
{ {
// Prevent URL requests being sent out Settings::unsetHttpClient();
$mock = new MockHandler([
new ClientException('This is not a valid URL', new Request('GET', 'test'), new Response()),
new ConnectException('This is a 404 error', new Request('GET', 'test')),
new Response('200', [], str_repeat('a', 40000)),
new Response('200', [], 'This is a test'),
]);
$handlerStack = HandlerStack::create($mock);
self::$client = new Client(['handler' => $handlerStack]);
}
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
} }
/** /**
* @dataProvider providerWEBSERVICE * @dataProvider providerWEBSERVICE
*/ */
public function testWEBSERVICE(string $expectedResult, string $url): void public function testWEBSERVICE(string $expectedResult, string $url, ?array $responseData): void
{ {
Settings::setHttpClient(self::$client); if ($responseData) {
$body = $this->createMock(StreamInterface::class);
$body->expects(self::atMost(1))->method('getContents')->willReturn($responseData[1]);
$response = $this->createMock(ResponseInterface::class);
$response->expects(self::once())->method('getStatusCode')->willReturn($responseData[0]);
$response->expects(self::atMost(1))->method('getBody')->willReturn($body);
$client = $this->createMock(ClientInterface::class);
$client->expects(self::once())->method('sendRequest')->willReturn($response);
$request = $this->createMock(RequestInterface::class);
$requestFactory = $this->createMock(RequestFactoryInterface::class);
$requestFactory->expects(self::atMost(1))->method('createRequest')->willReturn($request);
Settings::setHttpClient($client, $requestFactory);
}
$result = Web::WEBSERVICE($url); $result = Web::WEBSERVICE($url);
self::assertEquals($expectedResult, $result); self::assertEquals($expectedResult, $result);
} }
@ -51,4 +50,28 @@ class WebServiceTest extends TestCase
{ {
return require 'tests/data/Calculation/Web/WEBSERVICE.php'; return require 'tests/data/Calculation/Web/WEBSERVICE.php';
} }
public function testWEBSERVICEReturnErrorWhenClientThrows(): void
{
$exception = $this->createMock(\Psr\Http\Client\ClientExceptionInterface::class);
$client = $this->createMock(ClientInterface::class);
$client->expects(self::once())->method('sendRequest')->willThrowException($exception);
$request = $this->createMock(RequestInterface::class);
$requestFactory = $this->createMock(RequestFactoryInterface::class);
$requestFactory->expects(self::atMost(1))->method('createRequest')->willReturn($request);
Settings::setHttpClient($client, $requestFactory);
$result = Web::WEBSERVICE('https://example.com');
self::assertEquals('#VALUE!', $result);
}
public function testWEBSERVICEThrowsIfNotClientConfigured(): void
{
$this->expectExceptionMessage('HTTP client must be configured via Settings::setHttpClient() to be able to use WEBSERVICE function.');
Web::WEBSERVICE('https://example.com');
}
} }

View File

@ -10,16 +10,22 @@ use PHPUnit\Framework\TestCase;
class FunctionsTest extends TestCase class FunctionsTest extends TestCase
{ {
private $compatibilityMode;
private $returnDate;
protected function setUp(): void protected function setUp(): void
{ {
$this->compatibilityMode = Functions::getCompatibilityMode();
$this->returnDate = Functions::getReturnDateType();
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
} }
protected function tearDown(): void protected function tearDown(): void
{ {
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setCompatibilityMode($this->compatibilityMode);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); Functions::setReturnDateType($this->returnDate);
} }
public function testCompatibilityMode(): void public function testCompatibilityMode(): void

View File

@ -13,6 +13,26 @@ use PHPUnit\Framework\TestCase;
class AdvancedValueBinderTest extends TestCase class AdvancedValueBinderTest extends TestCase
{ {
private $currencyCode;
private $decimalSeparator;
private $thousandsSeparator;
protected function setUp(): void
{
$this->currencyCode = StringHelper::getCurrencyCode();
$this->decimalSeparator = StringHelper::getDecimalSeparator();
$this->thousandsSeparator = StringHelper::getThousandsSeparator();
}
protected function tearDown(): void
{
StringHelper::setCurrencyCode($this->currencyCode);
StringHelper::setDecimalSeparator($this->decimalSeparator);
StringHelper::setThousandsSeparator($this->thousandsSeparator);
}
public function provider() public function provider()
{ {
$currencyUSD = NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; $currencyUSD = NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;

View File

@ -424,4 +424,35 @@ class HtmlTest extends TestCase
self::assertEquals(10, $style->getAlignment()->getIndent()); self::assertEquals(10, $style->getAlignment()->getIndent());
unlink($filename); unlink($filename);
} }
public function testBorderWithRowspanAndColspan(): void
{
$html = '<table>
<tr>
<td style="border: 1px solid black;">NOT SPANNED</td>
<td rowspan="2" colspan="2" style="border: 1px solid black;">SPANNED</td>
</tr>
<tr>
<td style="border: 1px solid black;">NOT SPANNED</td>
</tr>
</table>';
$reader = new Html();
$spreadsheet = $reader->loadFromString($html);
$firstSheet = $spreadsheet->getSheet(0);
$style = $firstSheet->getStyle('B1:C2');
$borders = $style->getBorders();
$totalBorders = [
$borders->getTop(),
$borders->getLeft(),
$borders->getBottom(),
$borders->getRight(),
];
foreach ($totalBorders as $border) {
self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle());
}
}
} }

View File

@ -95,4 +95,21 @@ class ReferenceHelperTest extends TestCase
self::assertEquals($columnExpectedResult[$key], $value); self::assertEquals($columnExpectedResult[$key], $value);
} }
} }
/**
* @dataProvider providerFormulaUpdates
*/
public function testUpdateFormula(string $formula, int $insertRows, int $insertColumns, string $worksheet, string $expectedResult): void
{
$referenceHelper = ReferenceHelper::getInstance();
$result = $referenceHelper->updateFormulaReferences($formula, 'A1', $insertRows, $insertColumns, $worksheet);
self::assertSame($expectedResult, $result);
}
public function providerFormulaUpdates(): array
{
return require 'tests/data/ReferenceHelperFormulaUpdates.php';
}
} }

View File

@ -7,14 +7,30 @@ use PHPUnit\Framework\TestCase;
class StringHelperTest extends TestCase class StringHelperTest extends TestCase
{ {
private $currencyCode;
private $decimalSeparator;
private $thousandsSeparator;
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->currencyCode = StringHelper::getCurrencyCode();
$this->decimalSeparator = StringHelper::getDecimalSeparator();
$this->thousandsSeparator = StringHelper::getThousandsSeparator();
// Reset Currency Code // Reset Currency Code
StringHelper::setCurrencyCode(null); StringHelper::setCurrencyCode(null);
} }
protected function tearDown(): void
{
StringHelper::setCurrencyCode($this->currencyCode);
StringHelper::setDecimalSeparator($this->decimalSeparator);
StringHelper::setThousandsSeparator($this->thousandsSeparator);
}
public function testGetIsIconvEnabled(): void public function testGetIsIconvEnabled(): void
{ {
$result = StringHelper::getIsIconvEnabled(); $result = StringHelper::getIsIconvEnabled();

View File

@ -8,12 +8,28 @@ use PHPUnit\Framework\TestCase;
class NumberFormatTest extends TestCase class NumberFormatTest extends TestCase
{ {
private $currencyCode;
private $decimalSeparator;
private $thousandsSeparator;
protected function setUp(): void protected function setUp(): void
{ {
$this->currencyCode = StringHelper::getCurrencyCode();
$this->decimalSeparator = StringHelper::getDecimalSeparator();
$this->thousandsSeparator = StringHelper::getThousandsSeparator();
StringHelper::setDecimalSeparator('.'); StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(','); StringHelper::setThousandsSeparator(',');
} }
protected function tearDown(): void
{
StringHelper::setCurrencyCode($this->currencyCode);
StringHelper::setDecimalSeparator($this->decimalSeparator);
StringHelper::setThousandsSeparator($this->thousandsSeparator);
}
/** /**
* @dataProvider providerNumberFormat * @dataProvider providerNumberFormat
* *

View File

@ -10,12 +10,16 @@ use PhpOffice\PhpSpreadsheetTests\Functional;
class HtmlNumberFormatTest extends Functional\AbstractFunctional class HtmlNumberFormatTest extends Functional\AbstractFunctional
{ {
private $currency;
private $decsep; private $decsep;
private $thosep; private $thosep;
protected function setUp(): void protected function setUp(): void
{ {
$this->currency = StringHelper::getCurrencyCode();
StringHelper::setCurrencyCode('$');
$this->decsep = StringHelper::getDecimalSeparator(); $this->decsep = StringHelper::getDecimalSeparator();
StringHelper::setDecimalSeparator('.'); StringHelper::setDecimalSeparator('.');
$this->thosep = StringHelper::getThousandsSeparator(); $this->thosep = StringHelper::getThousandsSeparator();
@ -24,6 +28,7 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional
protected function tearDown(): void protected function tearDown(): void
{ {
StringHelper::setCurrencyCode($this->currency);
StringHelper::setDecimalSeparator($this->decsep); StringHelper::setDecimalSeparator($this->decsep);
StringHelper::setThousandsSeparator($this->thosep); StringHelper::setThousandsSeparator($this->thosep);
} }

View File

@ -4,25 +4,27 @@ return [
[ [
'#VALUE!', '#VALUE!',
'http://www.thisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolor.com', 'http://www.thisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolorthisurlisfartoolongLoremipsumdolorsitametconsecteturadipiscingelitAliquamimperdietmetusurnasedaliquampurusdapibusefficiturQuisqueatullamcorpermaurisacmattisanteDonecsagittisauguenullaegeinterduurnapharetrautQuisquealectusvelnisivolutpatpharetraSuspendisseconvallisvulputateblanditClassaptenttacitisociosquadlitoratorquentperconubianostraperinceptoshimenaeosProinjustdiampulvinaracjustoauctorimperdietsuscipitestEtiamacmaximusmassasitametvulputatedolor.com',
null,
], ],
[ [
'#VALUE!', '#VALUE!',
'ftp://www.bla.com', 'ftp://www.bla.com',
], null,
[
'#VALUE!',
'http://notevenanurl',
], ],
[ [
'#VALUE!', '#VALUE!',
'http://www.example1.com', 'http://www.example1.com',
['404', 'not found'],
], ],
[ [
'#VALUE!', '#VALUE!',
'http://www.example2.com', 'http://www.example2.com',
['200', str_repeat('a', 40000)],
], ],
[ [
'This is a test', 'This is a test',
'http://www.example3.com', 'http://www.example3.com',
['200', 'This is a test'],
], ],
]; ];

View File

@ -0,0 +1,74 @@
<?php
return [
[
'=SUM(C3:E5)',
-2,
-2,
'2020',
'=SUM(A1:C3)',
],
[
'=SUM(2020!C3:E5,2019!C3:E5)',
-2,
-2,
'2020',
'=SUM(2020!A1:C3,2019!C3:E5)',
],
[
'=SUM(2020!3:5,2019!3:5)',
-2,
-2,
'2020',
'=SUM(2020!1:3,2019!3:5)',
],
[
'=SUM(2020!C:E,2019!C:E)',
-2,
-2,
'2020',
'=SUM(2020!A:C,2019!C:E)',
],
[
"=IF('2020'!\$B1=\"\",\"-\",(('2020'!\$B1/'2019'!\$B1)-1))",
2,
2,
'2019',
"=IF('2020'!\$B1=\"\",\"-\",(('2020'!\$B1/'2019'!\$B3)-1))",
],
[
"=IF('2020'!B$1=\"\",\"-\",(('2020'!B$1/'2019'!B$1)-1))",
2,
2,
'2019',
"=IF('2020'!B\$1=\"\",\"-\",(('2020'!B\$1/'2019'!D\$1)-1))",
],
[
"=IF('2020'!Z$1=\"\",\"-\",(('2020'!Z$1/'2019'!Z$1)-1))",
2,
2,
'2019',
"=IF('2020'!Z\$1=\"\",\"-\",(('2020'!Z\$1/'2019'!AB\$1)-1))",
],
[
"=IF('2020'!\$B1=\"\",\"-\",(('2020'!\$B1/'2019'!\$B1)-1))",
2,
2,
'2020',
"=IF('2020'!\$B3=\"\",\"-\",(('2020'!\$B3/'2019'!\$B1)-1))",
],
[
"=IF('2020'!B$1=\"\",\"-\",(('2020'!B$1/'2019'!B$1)-1))",
2,
2,
'2020',
"=IF('2020'!D\$1=\"\",\"-\",(('2020'!D\$1/'2019'!B\$1)-1))",
],
[
"=IF('2020'!Z$1=\"\",\"-\",(('2020'!Z$1/'2019'!Z$1)-1))",
2,
2,
'2020',
"=IF('2020'!AB\$1=\"\",\"-\",(('2020'!AB\$1/'2019'!Z\$1)-1))",
],
];