private function PHPExcel_Calculation::_executeNumericBinaryOperation in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php \PHPExcel_Calculation::_executeNumericBinaryOperation()
1 call to PHPExcel_Calculation::_executeNumericBinaryOperation()
- PHPExcel_Calculation::_processTokenStack in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php
File
- vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php, line 3661
Class
- PHPExcel_Calculation
- PHPExcel_Calculation (Multiton)
Code
private function _executeNumericBinaryOperation($cellID, $operand1, $operand2, $operation, $matrixFunction, &$stack) {
if (!$this
->_validateBinaryOperand($cellID, $operand1, $stack)) {
return FALSE;
}
if (!$this
->_validateBinaryOperand($cellID, $operand2, $stack)) {
return FALSE;
}
if (is_array($operand1) || is_array($operand2)) {
self::_checkMatrixOperands($operand1, $operand2, 2);
try {
$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
$matrixResult = $matrix
->{$matrixFunction}($operand2);
$result = $matrixResult
->getArray();
} catch (PHPExcel_Exception $ex) {
$this->_debugLog
->writeDebugLog('JAMA Matrix Exception: ', $ex
->getMessage());
$result = '#VALUE!';
}
}
else {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE && (is_string($operand1) && !is_numeric($operand1) && strlen($operand1) > 0 || is_string($operand2) && !is_numeric($operand2) && strlen($operand2) > 0)) {
$result = PHPExcel_Calculation_Functions::VALUE();
}
else {
switch ($operation) {
case '+':
$result = $operand1 + $operand2;
break;
case '-':
$result = $operand1 - $operand2;
break;
case '*':
$result = $operand1 * $operand2;
break;
case '/':
if ($operand2 == 0) {
$stack
->push('Value', '#DIV/0!');
$this->_debugLog
->writeDebugLog('Evaluation Result is ', $this
->_showTypeDetails('#DIV/0!'));
return FALSE;
}
else {
$result = $operand1 / $operand2;
}
break;
case '^':
$result = pow($operand1, $operand2);
break;
}
}
}
$this->_debugLog
->writeDebugLog('Evaluation Result is ', $this
->_showTypeDetails($result));
$stack
->push('Value', $result);
return TRUE;
}