public static function PHPExcel_Calculation_Statistical::COUNTIF in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php \PHPExcel_Calculation_Statistical::COUNTIF()
* COUNTIF * * Counts the number of cells that contain numbers within the list of arguments * * Excel Function: * COUNTIF(value1[,value2[, ...]],condition) * * @access public * @category Statistical Functions *
Parameters
mixed $arg,... Data values: * @param string $condition The criteria that defines which cells will be counted. * @return int
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Statistical.php, line 1263
Class
- PHPExcel_Calculation_Statistical
- PHPExcel_Calculation_Statistical
Code
public static function COUNTIF($aArgs, $condition) {
// Return value
$returnValue = 0;
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
// Loop through arguments
foreach ($aArgs as $arg) {
if (!is_numeric($arg)) {
$arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg));
}
$testCondition = '=' . $arg . $condition;
if (PHPExcel_Calculation::getInstance()
->_calculateFormulaValue($testCondition)) {
// Is it a value within our criteria
++$returnValue;
}
}
// Return
return $returnValue;
}