Support numeric condition in SUMIF, SUMIFS, AVERAGEIF, COUNTIF, MAXIF and MINIF

Fixes #683
Fixes #701
This commit is contained in:
Sreten Ilić 2018-10-02 14:51:51 +02:00 committed by Adrien Crivelli
parent 90bb4df777
commit ed6a3a0148
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
3 changed files with 31 additions and 2 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Fixed
- Support numeric condition in SUMIF, SUMIFS, AVERAGEIF, COUNTIF, MAXIF and MINIF [#683](https://github.com/PHPOffice/PhpSpreadsheet/issues/683)
## [1.5.0] - 2018-10-21
### Added

View File

@ -267,7 +267,7 @@ class Functions
public static function ifCondition($condition)
{
$condition = self::flattenSingleValue($condition);
if (!isset($condition[0])) {
if (!isset($condition[0]) && !is_numeric($condition)) {
$condition = '=""';
}
if (!in_array($condition[0], ['>', '<', '='])) {

View File

@ -70,5 +70,28 @@ return [
[10],
],
],
[
100,
[
['0'],
['some text'],
],
0, // Compare integer with string
[
[100],
[1],
],
],
[
100,
[
[0],
['some text'],
],
0, // Compare integer with integer
[
[100],
[1],
],
],
];