Fixed Functions->ifCondition for allowing <> and empty condition

In cells with formulas containing conditions like `=IFSUM(A1:A3;"";B1:B3)`
to sum cells from range A1:A3 with empty value in range B1:B3, the function
`Functions::ifCondition()` create in this case the code `=""""` instead of
`=""`, so it didn't work.

Closes #1206
This commit is contained in:
Jorge Casas 2019-10-15 13:11:43 +02:00 committed by Adrien Crivelli
parent b20f5c1d11
commit 156ab360fe
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
3 changed files with 11 additions and 2 deletions

View File

@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Keep big integer as integer instead of lossely casting to float [#874](https://github.com/PHPOffice/PhpSpreadsheet/pull/874) - Keep big integer as integer instead of lossely casting to float [#874](https://github.com/PHPOffice/PhpSpreadsheet/pull/874)
- Fix branch pruning handling of non boolean conditions [#1167](https://github.com/PHPOffice/PhpSpreadsheet/pull/1167) - Fix branch pruning handling of non boolean conditions [#1167](https://github.com/PHPOffice/PhpSpreadsheet/pull/1167)
- Fix ODS Reader when no DC namespace are defined [#1182](https://github.com/PHPOffice/PhpSpreadsheet/pull/1182) - Fix ODS Reader when no DC namespace are defined [#1182](https://github.com/PHPOffice/PhpSpreadsheet/pull/1182)
- Fixed Functions->ifCondition for allowing <> and empty condition [#1206](https://github.com/PHPOffice/PhpSpreadsheet/pull/1206)
## [1.9.0] - 2019-08-17 ## [1.9.0] - 2019-08-17

View File

@ -278,7 +278,7 @@ class Functions
$condition = Calculation::wrapResult(strtoupper($condition)); $condition = Calculation::wrapResult(strtoupper($condition));
} }
return '=' . $condition; return str_replace('""""', '""', '=' . $condition);
} }
preg_match('/(=|<[>=]?|>=?)(.*)/', $condition, $matches); preg_match('/(=|<[>=]?|>=?)(.*)/', $condition, $matches);
[, $operator, $operand] = $matches; [, $operator, $operand] = $matches;
@ -290,7 +290,7 @@ class Functions
$operand = Calculation::wrapResult(strtoupper($operand)); $operand = Calculation::wrapResult(strtoupper($operand));
} }
return $operator . $operand; return str_replace('""""', '""', $operator . $operand);
} }
/** /**

View File

@ -33,4 +33,12 @@ return [
'<>"< PLEASE SELECT >"', '<>"< PLEASE SELECT >"',
'<>< Please Select >', '<>< Please Select >',
], ],
[
'<>""',
'<>',
],
[
'=""',
'""',
],
]; ];