You are here

public static function PHPExcel_Calculation_MathTrig::SUMPRODUCT in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php \PHPExcel_Calculation_MathTrig::SUMPRODUCT()

* SUMPRODUCT * * Excel Function: * SUMPRODUCT(value1[,value2[, ...]]) * * @access public * @category Mathematical and Trigonometric Functions *

Parameters

mixed $arg,... Data values: * @return float

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php, line 1198

Class

PHPExcel_Calculation_MathTrig
PHPExcel_Calculation_MathTrig

Code

public static function SUMPRODUCT() {
  $arrayList = func_get_args();
  $wrkArray = PHPExcel_Calculation_Functions::flattenArray(array_shift($arrayList));
  $wrkCellCount = count($wrkArray);
  for ($i = 0; $i < $wrkCellCount; ++$i) {
    if (!is_numeric($wrkArray[$i]) || is_string($wrkArray[$i])) {
      $wrkArray[$i] = 0;
    }
  }
  foreach ($arrayList as $matrixData) {
    $array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData);
    $count = count($array2);
    if ($wrkCellCount != $count) {
      return PHPExcel_Calculation_Functions::VALUE();
    }
    foreach ($array2 as $i => $val) {
      if (!is_numeric($val) || is_string($val)) {
        $val = 0;
      }
      $wrkArray[$i] *= $val;
    }
  }
  return array_sum($wrkArray);
}