mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-26 07:16:03 +03:00
Merge pull request #228 from PowerKiKi/patch-sumif
Double quote support for SUMIF()
This commit is contained in:
commit
8d51b6e90a
@ -1164,7 +1164,11 @@ class PHPExcel_Calculation_MathTrig {
|
|||||||
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
|
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
|
||||||
// Loop through arguments
|
// Loop through arguments
|
||||||
foreach ($aArgs as $key => $arg) {
|
foreach ($aArgs as $key => $arg) {
|
||||||
if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
|
if (!is_numeric($arg)) {
|
||||||
|
$arg = str_replace('"', '""', $arg);
|
||||||
|
$arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg));
|
||||||
|
}
|
||||||
|
|
||||||
$testCondition = '='.$arg.$condition;
|
$testCondition = '='.$arg.$condition;
|
||||||
if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
|
if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
|
||||||
// Is it a value within our criteria
|
// Is it a value within our criteria
|
||||||
|
@ -481,4 +481,66 @@ class MathTrigTest extends PHPUnit_Framework_TestCase
|
|||||||
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SQRTPI.data');
|
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SQRTPI.data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerSUMIF
|
||||||
|
*/
|
||||||
|
public function testSUMIF()
|
||||||
|
{
|
||||||
|
$args = func_get_args();
|
||||||
|
$expectedResult = array_pop($args);
|
||||||
|
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig', 'SUMIF'), $args);
|
||||||
|
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function providerSUMIF()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array(1),
|
||||||
|
array(5),
|
||||||
|
array(10),
|
||||||
|
),
|
||||||
|
'>=5',
|
||||||
|
15,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array('text'),
|
||||||
|
array(2),
|
||||||
|
),
|
||||||
|
'=text',
|
||||||
|
array(
|
||||||
|
array(10),
|
||||||
|
array(100),
|
||||||
|
),
|
||||||
|
10,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array('"text with quotes"'),
|
||||||
|
array(2),
|
||||||
|
),
|
||||||
|
'=""text with quotes""',
|
||||||
|
array(
|
||||||
|
array(10),
|
||||||
|
array(100),
|
||||||
|
),
|
||||||
|
10,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array('"text with quotes"'),
|
||||||
|
array(''),
|
||||||
|
),
|
||||||
|
'>""', // Compare to the single characater " (double quote)
|
||||||
|
array(
|
||||||
|
array(10),
|
||||||
|
array(100),
|
||||||
|
),
|
||||||
|
10
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user