@@ 2266-2290 (lines=25) @@ | ||
2263 | * @param string $condition The criteria that defines which cells will be checked. |
|
2264 | * @return float |
|
2265 | */ |
|
2266 | public static function MAXIF($aArgs, $condition, $sumArgs = array()) |
|
2267 | { |
|
2268 | $returnValue = null; |
|
2269 | ||
2270 | $aArgs = Functions::flattenArray($aArgs); |
|
2271 | $sumArgs = Functions::flattenArray($sumArgs); |
|
2272 | if (empty($sumArgs)) { |
|
2273 | $sumArgs = $aArgs; |
|
2274 | } |
|
2275 | $condition = Functions::ifCondition($condition); |
|
2276 | // Loop through arguments |
|
2277 | foreach ($aArgs as $key => $arg) { |
|
2278 | if (!is_numeric($arg)) { |
|
2279 | $arg = \PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); |
|
2280 | } |
|
2281 | $testCondition = '='.$arg.$condition; |
|
2282 | if (\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
|
2283 | if ((is_null($returnValue)) || ($arg > $returnValue)) { |
|
2284 | $returnValue = $arg; |
|
2285 | } |
|
2286 | } |
|
2287 | } |
|
2288 | ||
2289 | return $returnValue; |
|
2290 | } |
|
2291 | ||
2292 | /** |
|
2293 | * MEDIAN |
|
@@ 2425-2449 (lines=25) @@ | ||
2422 | * @param string $condition The criteria that defines which cells will be checked. |
|
2423 | * @return float |
|
2424 | */ |
|
2425 | public static function MINIF($aArgs, $condition, $sumArgs = array()) |
|
2426 | { |
|
2427 | $returnValue = null; |
|
2428 | ||
2429 | $aArgs = Functions::flattenArray($aArgs); |
|
2430 | $sumArgs = Functions::flattenArray($sumArgs); |
|
2431 | if (empty($sumArgs)) { |
|
2432 | $sumArgs = $aArgs; |
|
2433 | } |
|
2434 | $condition = Functions::ifCondition($condition); |
|
2435 | // Loop through arguments |
|
2436 | foreach ($aArgs as $key => $arg) { |
|
2437 | if (!is_numeric($arg)) { |
|
2438 | $arg = \PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); |
|
2439 | } |
|
2440 | $testCondition = '='.$arg.$condition; |
|
2441 | if (\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
|
2442 | if ((is_null($returnValue)) || ($arg < $returnValue)) { |
|
2443 | $returnValue = $arg; |
|
2444 | } |
|
2445 | } |
|
2446 | } |
|
2447 | ||
2448 | return $returnValue; |
|
2449 | } |
|
2450 | ||
2451 | ||
2452 | // |