Exemplo n.º 1
0
 /**
  * SUBTOTAL
  *
  * Returns a subtotal in a list or database.
  *
  * @param	int		the number 1 to 11 that specifies which function to
  *					use in calculating subtotals within a list.
  * @param	array of mixed		Data Series
  * @return	float
  */
 public static function SUBTOTAL()
 {
     $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
     // Calculate
     $subtotal = array_shift($aArgs);
     if (is_numeric($subtotal) && !is_string($subtotal)) {
         switch ($subtotal) {
             case 1:
                 return PHPExcel_Calculation_Statistical::AVERAGE($aArgs);
                 break;
             case 2:
                 return PHPExcel_Calculation_Statistical::COUNT($aArgs);
                 break;
             case 3:
                 return PHPExcel_Calculation_Statistical::COUNTA($aArgs);
                 break;
             case 4:
                 return PHPExcel_Calculation_Statistical::MAX($aArgs);
                 break;
             case 5:
                 return PHPExcel_Calculation_Statistical::MIN($aArgs);
                 break;
             case 6:
                 return self::PRODUCT($aArgs);
                 break;
             case 7:
                 return PHPExcel_Calculation_Statistical::STDEV($aArgs);
                 break;
             case 8:
                 return PHPExcel_Calculation_Statistical::STDEVP($aArgs);
                 break;
             case 9:
                 return self::SUM($aArgs);
                 break;
             case 10:
                 return PHPExcel_Calculation_Statistical::VARFunc($aArgs);
                 break;
             case 11:
                 return PHPExcel_Calculation_Statistical::VARP($aArgs);
                 break;
         }
     }
     return PHPExcel_Calculation_Functions::VALUE();
 }
Exemplo n.º 2
0
 /**
  * DAVERAGE
  *
  * Averages the values in a column of a list or database that match conditions you specify.
  *
  * Excel Function:
  *        DAVERAGE(database,field,criteria)
  *
  * @access    public
  * @category Database Functions
  * @param    mixed[] $database The range of cells that makes up the list or database.
  *                                        A database is a list of related data in which rows of related
  *                                        information are records, and columns of data are fields. The
  *                                        first row of the list contains labels for each column.
  * @param    string|integer $field Indicates which column is used in the function. Enter the
  *                                        column label enclosed between double quotation marks, such as
  *                                        "Age" or "Yield," or a number (without quotation marks) that
  *                                        represents the position of the column within the list: 1 for
  *                                        the first column, 2 for the second column, and so on.
  * @param    mixed[] $criteria The range of cells that contains the conditions you specify.
  *                                        You can use any range for the criteria argument, as long as it
  *                                        includes at least one column label and at least one cell below
  *                                        the column label in which you specify a condition for the
  *                                        column.
  * @return    float
  *
  */
 public static function DAVERAGE($database, $field, $criteria)
 {
     $field = self::__fieldExtract($database, $field);
     if (is_null($field)) {
         return NULL;
     }
     //	reduce the database to a set of rows that match all the criteria
     $database = self::__filter($database, $criteria);
     //	extract an array of values for the requested column
     $colData = array();
     foreach ($database as $row) {
         $colData[] = $row[$field];
     }
     // Return
     return PHPExcel_Calculation_Statistical::AVERAGE($colData);
 }
Exemplo n.º 3
0
 /**
  * DAVERAGE
  *
  * Averages the values in a column of a list or database that match conditions you specify.
  *
  * Excel Function:
  *        DAVERAGE(database,field,criteria)
  *
  * @access    public
  * @category Database Functions
  * @param mixed[] $database The range of cells that makes up the list or database.
  *                                        A database is a list of related data in which rows of related
  *                                        information are records, and columns of data are fields. The
  *                                        first row of the list contains labels for each column.
  * @param string|integer $field Indicates which column is used in the function. Enter the
  *                                        column label enclosed between double quotation marks, such as
  *                                        "Age" or "Yield," or a number (without quotation marks) that
  *                                        represents the position of the column within the list: 1 for
  *                                        the first column, 2 for the second column, and so on.
  * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  *                                        You can use any range for the criteria argument, as long as it
  *                                        includes at least one column label and at least one cell below
  *                                        the column label in which you specify a condition for the
  *                                        column.
  * @return float
  *
  */
 public static function DAVERAGE($database, $field, $criteria)
 {
     $field = self::fieldExtract($database, $field);
     if (is_null($field)) {
         return null;
     }
     // Return
     return PHPExcel_Calculation_Statistical::AVERAGE(self::getFilteredColumn($database, $field, $criteria));
 }