You are here

public static function PHPExcel_Calculation_Engineering::IMSUM in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php \PHPExcel_Calculation_Engineering::IMSUM()

* IMSUM * * Returns the sum of two or more complex numbers in x + yi or x + yj text format. * * Excel Function: * IMSUM(complexNumber[,complexNumber[,...]]) * *

Parameters

string $complexNumber,... Series of complex numbers to add: * @return string

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php, line 2116

Class

PHPExcel_Calculation_Engineering
PHPExcel_Calculation_Engineering

Code

public static function IMSUM() {

  // Return value
  $returnValue = self::_parseComplex('0');
  $activeSuffix = '';

  // Loop through the arguments
  $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
  foreach ($aArgs as $arg) {
    $parsedComplex = self::_parseComplex($arg);
    if ($activeSuffix == '') {
      $activeSuffix = $parsedComplex['suffix'];
    }
    elseif ($parsedComplex['suffix'] != '' && $activeSuffix != $parsedComplex['suffix']) {
      return PHPExcel_Calculation_Functions::VALUE();
    }
    $returnValue['real'] += $parsedComplex['real'];
    $returnValue['imaginary'] += $parsedComplex['imaginary'];
  }
  if ($returnValue['imaginary'] == 0.0) {
    $activeSuffix = '';
  }
  return self::COMPLEX($returnValue['real'], $returnValue['imaginary'], $activeSuffix);
}