Fix IF implementation to comply with Excel behavior

Closes #1165
This commit is contained in:
Fräntz Miccoli 2019-09-22 22:56:19 +02:00 committed by Adrien Crivelli
parent 86bb4f9356
commit 445cc18e39
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
3 changed files with 11 additions and 0 deletions

View File

@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Fixed
- IF implementation properly handles the value `#N/A` [#1165](https://github.com/PHPOffice/PhpSpreadsheet/pull/1165)
- Formula Parser: Wrong line count for stuff like "MyOtherSheet!A:D" [#1215](https://github.com/PHPOffice/PhpSpreadsheet/issues/1215)
- Call garbage collector after removing a column to prevent stale cached values
- Trying to remove a column that doesn't exist deletes the latest column

View File

@ -266,6 +266,10 @@ class Logical
*/
public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
{
if (Functions::isError($condition)) {
return $condition;
}
$condition = ($condition === null) ? true : (bool) Functions::flattenSingleValue($condition);
$returnIfTrue = ($returnIfTrue === null) ? 0 : Functions::flattenSingleValue($returnIfTrue);
$returnIfFalse = ($returnIfFalse === null) ? false : Functions::flattenSingleValue($returnIfFalse);

View File

@ -34,4 +34,10 @@ return [
'ABC',
'XYZ',
],
[
'#N/A',
'#N/A',
'ABC',
'XYZ',
],
];