@@ 2200-2223 (lines=24) @@ | ||
2197 | * @param string $condition The criteria that defines which cells will be checked. |
|
2198 | * @return float |
|
2199 | */ |
|
2200 | public static function MAXIF($aArgs,$condition,$sumArgs = array()) { |
|
2201 | // Return value |
|
2202 | $returnValue = null; |
|
2203 | ||
2204 | $aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs); |
|
2205 | $sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs); |
|
2206 | if (empty($sumArgs)) { |
|
2207 | $sumArgs = $aArgs; |
|
2208 | } |
|
2209 | $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); |
|
2210 | // Loop through arguments |
|
2211 | foreach ($aArgs as $key => $arg) { |
|
2212 | if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2213 | $testCondition = '='.$arg.$condition; |
|
2214 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
|
2215 | if ((is_null($returnValue)) || ($arg > $returnValue)) { |
|
2216 | $returnValue = $arg; |
|
2217 | } |
|
2218 | } |
|
2219 | } |
|
2220 | ||
2221 | // Return |
|
2222 | return $returnValue; |
|
2223 | } // function MAXIF() |
|
2224 | ||
2225 | ||
2226 | /** |
|
@@ 2362-2385 (lines=24) @@ | ||
2359 | * @param string $condition The criteria that defines which cells will be checked. |
|
2360 | * @return float |
|
2361 | */ |
|
2362 | public static function MINIF($aArgs,$condition,$sumArgs = array()) { |
|
2363 | // Return value |
|
2364 | $returnValue = null; |
|
2365 | ||
2366 | $aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs); |
|
2367 | $sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs); |
|
2368 | if (empty($sumArgs)) { |
|
2369 | $sumArgs = $aArgs; |
|
2370 | } |
|
2371 | $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); |
|
2372 | // Loop through arguments |
|
2373 | foreach ($aArgs as $key => $arg) { |
|
2374 | if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2375 | $testCondition = '='.$arg.$condition; |
|
2376 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
|
2377 | if ((is_null($returnValue)) || ($arg < $returnValue)) { |
|
2378 | $returnValue = $arg; |
|
2379 | } |
|
2380 | } |
|
2381 | } |
|
2382 | ||
2383 | // Return |
|
2384 | return $returnValue; |
|
2385 | } // function MINIF() |
|
2386 | ||
2387 | ||
2388 | // |