Fixed parsing of conditionals in COUNTIF functions
Conditional operators in the selection parameter of COUNTIF functions were not being parsed properly, causing evaluations of formulae with such functions to sometimes fail. Fixes #526 Closes #528
This commit is contained in:
parent
ed2185417e
commit
e3fb160f5f
|
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
- Xlsx reader do not read rows and columns filtered out in readFilter at all - [#370](https://github.com/PHPOffice/PhpSpreadsheet/issues/370)
|
- Xlsx reader do not read rows and columns filtered out in readFilter at all - [#370](https://github.com/PHPOffice/PhpSpreadsheet/issues/370)
|
||||||
- Make newer Excel versions properly recalculate formulas on document open - [#456](https://github.com/PHPOffice/PhpSpreadsheet/issues/456)
|
- Make newer Excel versions properly recalculate formulas on document open - [#456](https://github.com/PHPOffice/PhpSpreadsheet/issues/456)
|
||||||
- `Coordinate::extractAllCellReferencesInRange()` throws an exception for an invalid range – [#519](https://github.com/PHPOffice/PhpSpreadsheet/issues/519)
|
- `Coordinate::extractAllCellReferencesInRange()` throws an exception for an invalid range – [#519](https://github.com/PHPOffice/PhpSpreadsheet/issues/519)
|
||||||
|
- Fixed parsing of conditionals in COUNTIF functions - [#526](https://github.com/PHPOffice/PhpSpreadsheet/issues/526)
|
||||||
|
|
||||||
## [1.2.1] - 2018-04-10
|
## [1.2.1] - 2018-04-10
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ class Functions
|
||||||
|
|
||||||
return '=' . $condition;
|
return '=' . $condition;
|
||||||
}
|
}
|
||||||
preg_match('/([<>=]+)(.*)/', $condition, $matches);
|
preg_match('/(=|<[>=]?|>=?)(.*)/', $condition, $matches);
|
||||||
list(, $operator, $operand) = $matches;
|
list(, $operator, $operand) = $matches;
|
||||||
|
|
||||||
if (!is_numeric($operand)) {
|
if (!is_numeric($operand)) {
|
||||||
|
|
|
@ -307,4 +307,20 @@ class FunctionsTest extends TestCase
|
||||||
{
|
{
|
||||||
return require 'data/Calculation/Functions/ISFORMULA.php';
|
return require 'data/Calculation/Functions/ISFORMULA.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerIfCondition
|
||||||
|
*
|
||||||
|
* @param mixed $expectedResult
|
||||||
|
*/
|
||||||
|
public function testIfCondition($expectedResult, ...$args)
|
||||||
|
{
|
||||||
|
$result = Functions::ifCondition(...$args);
|
||||||
|
self::assertEquals($expectedResult, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function providerIfCondition()
|
||||||
|
{
|
||||||
|
return require 'data/Calculation/Functions/IF_CONDITION.php';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'<"A"',
|
||||||
|
'<A',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'>"A"',
|
||||||
|
'>A',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'<="A"',
|
||||||
|
'<=A',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'>"A"',
|
||||||
|
'>A',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'>="A"',
|
||||||
|
'>=A',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'<>"A"',
|
||||||
|
'<>A',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'<"<A"',
|
||||||
|
'<<A',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'<>"< PLEASE SELECT >"',
|
||||||
|
'<>< Please Select >',
|
||||||
|
],
|
||||||
|
];
|
Loading…
Reference in New Issue