@@ 2240-2264 (lines=25) @@ | ||
2237 | * @param string $condition The criteria that defines which cells will be checked. |
|
2238 | * @return float |
|
2239 | */ |
|
2240 | public static function MAXIF($aArgs, $condition, $sumArgs = []) |
|
2241 | { |
|
2242 | $returnValue = null; |
|
2243 | ||
2244 | $aArgs = Functions::flattenArray($aArgs); |
|
2245 | $sumArgs = Functions::flattenArray($sumArgs); |
|
2246 | if (empty($sumArgs)) { |
|
2247 | $sumArgs = $aArgs; |
|
2248 | } |
|
2249 | $condition = Functions::ifCondition($condition); |
|
2250 | // Loop through arguments |
|
2251 | foreach ($aArgs as $key => $arg) { |
|
2252 | if (!is_numeric($arg)) { |
|
2253 | $arg = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); |
|
2254 | } |
|
2255 | $testCondition = '=' . $arg . $condition; |
|
2256 | if (\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
|
2257 | if ((is_null($returnValue)) || ($arg > $returnValue)) { |
|
2258 | $returnValue = $arg; |
|
2259 | } |
|
2260 | } |
|
2261 | } |
|
2262 | ||
2263 | return $returnValue; |
|
2264 | } |
|
2265 | ||
2266 | /** |
|
2267 | * MEDIAN |
|
@@ 2394-2418 (lines=25) @@ | ||
2391 | * @param string $condition The criteria that defines which cells will be checked. |
|
2392 | * @return float |
|
2393 | */ |
|
2394 | public static function MINIF($aArgs, $condition, $sumArgs = []) |
|
2395 | { |
|
2396 | $returnValue = null; |
|
2397 | ||
2398 | $aArgs = Functions::flattenArray($aArgs); |
|
2399 | $sumArgs = Functions::flattenArray($sumArgs); |
|
2400 | if (empty($sumArgs)) { |
|
2401 | $sumArgs = $aArgs; |
|
2402 | } |
|
2403 | $condition = Functions::ifCondition($condition); |
|
2404 | // Loop through arguments |
|
2405 | foreach ($aArgs as $key => $arg) { |
|
2406 | if (!is_numeric($arg)) { |
|
2407 | $arg = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); |
|
2408 | } |
|
2409 | $testCondition = '=' . $arg . $condition; |
|
2410 | if (\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
|
2411 | if ((is_null($returnValue)) || ($arg < $returnValue)) { |
|
2412 | $returnValue = $arg; |
|
2413 | } |
|
2414 | } |
|
2415 | } |
|
2416 | ||
2417 | return $returnValue; |
|
2418 | } |
|
2419 | ||
2420 | // |
|
2421 | // Special variant of array_count_values that isn't limited to strings and integers, |