mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2025-02-06 09:49:24 +03:00
Double quote support for SUMIF() condition
SUMIF() condition can have double quote, such as '=SUMIF(A2:A4,">""",B2:B4)'. This formula purpose is to compare the character double quote ("). In our previous patch (commit f1a1f525) we wrongly assumed that PHPExcel_Calculation_MathTrig::SUMIF() expected the condition to escaped ('>""'), but this is actually not the case in real use of PHPExcel, so the unit tests were modified accordingly to use non-escaped condition ('>"').
This commit is contained in:
parent
496b76e70a
commit
a0da3e32ec
@ -316,7 +316,12 @@ class PHPExcel_Calculation_Functions {
|
|||||||
} else {
|
} else {
|
||||||
preg_match('/([<>=]+)(.*)/',$condition,$matches);
|
preg_match('/([<>=]+)(.*)/',$condition,$matches);
|
||||||
list(,$operator,$operand) = $matches;
|
list(,$operator,$operand) = $matches;
|
||||||
if (!is_numeric($operand)) { $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); }
|
|
||||||
|
if (!is_numeric($operand)) {
|
||||||
|
$operand = str_replace('"', '""', $operand);
|
||||||
|
$operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand));
|
||||||
|
}
|
||||||
|
|
||||||
return $operator.$operand;
|
return $operator.$operand;
|
||||||
}
|
}
|
||||||
} // function _ifCondition()
|
} // function _ifCondition()
|
||||||
|
@ -521,7 +521,7 @@ class MathTrigTest extends PHPUnit_Framework_TestCase
|
|||||||
array('"text with quotes"'),
|
array('"text with quotes"'),
|
||||||
array(2),
|
array(2),
|
||||||
),
|
),
|
||||||
'=""text with quotes""',
|
'="text with quotes"',
|
||||||
array(
|
array(
|
||||||
array(10),
|
array(10),
|
||||||
array(100),
|
array(100),
|
||||||
@ -533,13 +533,25 @@ class MathTrigTest extends PHPUnit_Framework_TestCase
|
|||||||
array('"text with quotes"'),
|
array('"text with quotes"'),
|
||||||
array(''),
|
array(''),
|
||||||
),
|
),
|
||||||
'>""', // Compare to the single characater " (double quote)
|
'>"', // Compare to the single characater " (double quote)
|
||||||
array(
|
array(
|
||||||
array(10),
|
array(10),
|
||||||
array(100),
|
array(100),
|
||||||
),
|
),
|
||||||
10
|
10
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array(''),
|
||||||
|
array('anything'),
|
||||||
|
),
|
||||||
|
'>"', // Compare to the single characater " (double quote)
|
||||||
|
array(
|
||||||
|
array(10),
|
||||||
|
array(100),
|
||||||
|
),
|
||||||
|
100
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user