df
This commit is contained in:
parent
2a7a881f85
commit
40edb8f161
|
|
@ -2548,7 +2548,7 @@ class PHPExcel_Calculation
|
||||||
public static function unwrapResult($value)
|
public static function unwrapResult($value)
|
||||||
{
|
{
|
||||||
if (is_string($value)) {
|
if (is_string($value)) {
|
||||||
if ((isset($value{0})) && ($value{0} == '"') && (substr($value, -1) == '"')) {
|
if ((isset($value[0])) && ($value[0] == '"') && (substr($value, -1) == '"')) {
|
||||||
return substr($value, 1, -1);
|
return substr($value, 1, -1);
|
||||||
}
|
}
|
||||||
// Convert numeric errors to NaN error
|
// Convert numeric errors to NaN error
|
||||||
|
|
@ -2669,11 +2669,11 @@ class PHPExcel_Calculation
|
||||||
// Basic validation that this is indeed a formula
|
// Basic validation that this is indeed a formula
|
||||||
// We return an empty array if not
|
// We return an empty array if not
|
||||||
$formula = trim($formula);
|
$formula = trim($formula);
|
||||||
if ((!isset($formula{0})) || ($formula{0} != '=')) {
|
if ((!isset($formula[0])) || ($formula[0] != '=')) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$formula = ltrim(substr($formula, 1));
|
$formula = ltrim(substr($formula, 1));
|
||||||
if (!isset($formula{0})) {
|
if (!isset($formula[0])) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2761,11 +2761,11 @@ class PHPExcel_Calculation
|
||||||
// Basic validation that this is indeed a formula
|
// Basic validation that this is indeed a formula
|
||||||
// We simply return the cell value if not
|
// We simply return the cell value if not
|
||||||
$formula = trim($formula);
|
$formula = trim($formula);
|
||||||
if ($formula{0} != '=') {
|
if ($formula[0] != '=') {
|
||||||
return self::wrapResult($formula);
|
return self::wrapResult($formula);
|
||||||
}
|
}
|
||||||
$formula = ltrim(substr($formula, 1));
|
$formula = ltrim(substr($formula, 1));
|
||||||
if (!isset($formula{0})) {
|
if (!isset($formula[0])) {
|
||||||
return self::wrapResult($formula);
|
return self::wrapResult($formula);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2777,7 +2777,7 @@ class PHPExcel_Calculation
|
||||||
return $cellValue;
|
return $cellValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($wsTitle{0} !== "\x00") && ($this->cyclicReferenceStack->onStack($wsCellReference))) {
|
if (($wsTitle[0] !== "\x00") && ($this->cyclicReferenceStack->onStack($wsCellReference))) {
|
||||||
if ($this->cyclicFormulaCount <= 0) {
|
if ($this->cyclicFormulaCount <= 0) {
|
||||||
$this->cyclicFormulaCell = '';
|
$this->cyclicFormulaCell = '';
|
||||||
return $this->raiseFormulaError('Cyclic Reference in Formula');
|
return $this->raiseFormulaError('Cyclic Reference in Formula');
|
||||||
|
|
@ -3031,7 +3031,7 @@ class PHPExcel_Calculation
|
||||||
} else {
|
} else {
|
||||||
if ($value == '') {
|
if ($value == '') {
|
||||||
return 'an empty string';
|
return 'an empty string';
|
||||||
} elseif ($value{0} == '#') {
|
} elseif ($value[0] == '#') {
|
||||||
return 'a '.$value.' error';
|
return 'a '.$value.' error';
|
||||||
} else {
|
} else {
|
||||||
$typeString = 'a string';
|
$typeString = 'a string';
|
||||||
|
|
@ -3163,10 +3163,10 @@ class PHPExcel_Calculation
|
||||||
// Loop through the formula extracting each operator and operand in turn
|
// Loop through the formula extracting each operator and operand in turn
|
||||||
while (true) {
|
while (true) {
|
||||||
//echo 'Assessing Expression '.substr($formula, $index), PHP_EOL;
|
//echo 'Assessing Expression '.substr($formula, $index), PHP_EOL;
|
||||||
$opCharacter = $formula{$index}; // Get the first character of the value at the current index position
|
$opCharacter = $formula[$index]; // Get the first character of the value at the current index position
|
||||||
//echo 'Initial character of expression block is '.$opCharacter, PHP_EOL;
|
//echo 'Initial character of expression block is '.$opCharacter, PHP_EOL;
|
||||||
if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula{$index+1}]))) {
|
if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula[$index+1]]))) {
|
||||||
$opCharacter .= $formula{++$index};
|
$opCharacter .= $formula[++$index+1];
|
||||||
//echo 'Initial character of expression block is comparison operator '.$opCharacter.PHP_EOL;
|
//echo 'Initial character of expression block is comparison operator '.$opCharacter.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3454,11 +3454,11 @@ class PHPExcel_Calculation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ignore white space
|
// Ignore white space
|
||||||
while (($formula{$index} == "\n") || ($formula{$index} == "\r")) {
|
while (($formula[$index] == "\n") || ($formula[$index] == "\r")) {
|
||||||
++$index;
|
++$index;
|
||||||
}
|
}
|
||||||
if ($formula{$index} == ' ') {
|
if ($formula[$index] == ' ') {
|
||||||
while ($formula{$index} == ' ') {
|
while ($formula[$index] == ' ') {
|
||||||
++$index;
|
++$index;
|
||||||
}
|
}
|
||||||
// If we're expecting an operator, but only have a space between the previous and next operands (and both are
|
// If we're expecting an operator, but only have a space between the previous and next operands (and both are
|
||||||
|
|
@ -3888,7 +3888,7 @@ class PHPExcel_Calculation
|
||||||
// echo 'Token is a PHPExcel constant: '.$excelConstant.'<br />';
|
// echo 'Token is a PHPExcel constant: '.$excelConstant.'<br />';
|
||||||
$stack->push('Constant Value', self::$excelConstants[$excelConstant]);
|
$stack->push('Constant Value', self::$excelConstants[$excelConstant]);
|
||||||
$this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->showTypeDetails(self::$excelConstants[$excelConstant]));
|
$this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->showTypeDetails(self::$excelConstants[$excelConstant]));
|
||||||
} elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
|
} elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token[0] == '"') || ($token[0] == '#')) {
|
||||||
// echo 'Token is a number, boolean, string, null or an Excel error<br />';
|
// echo 'Token is a number, boolean, string, null or an Excel error<br />';
|
||||||
$stack->push('Value', $token);
|
$stack->push('Value', $token);
|
||||||
// if the token is a named range, push the named range name onto the stack
|
// if the token is a named range, push the named range name onto the stack
|
||||||
|
|
@ -3933,13 +3933,13 @@ class PHPExcel_Calculation
|
||||||
if (is_string($operand)) {
|
if (is_string($operand)) {
|
||||||
// We only need special validations for the operand if it is a string
|
// We only need special validations for the operand if it is a string
|
||||||
// Start by stripping off the quotation marks we use to identify true excel string values internally
|
// Start by stripping off the quotation marks we use to identify true excel string values internally
|
||||||
if ($operand > '' && $operand{0} == '"') {
|
if ($operand > '' && $operand[0] == '"') {
|
||||||
$operand = self::unwrapResult($operand);
|
$operand = self::unwrapResult($operand);
|
||||||
}
|
}
|
||||||
// If the string is a numeric value, we treat it as a numeric, so no further testing
|
// If the string is a numeric value, we treat it as a numeric, so no further testing
|
||||||
if (!is_numeric($operand)) {
|
if (!is_numeric($operand)) {
|
||||||
// If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations
|
// If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations
|
||||||
if ($operand > '' && $operand{0} == '#') {
|
if ($operand > '' && $operand[0] == '#') {
|
||||||
$stack->push('Value', $operand);
|
$stack->push('Value', $operand);
|
||||||
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($operand));
|
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($operand));
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -3995,10 +3995,10 @@ class PHPExcel_Calculation
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple validate the two operands if they are string values
|
// Simple validate the two operands if they are string values
|
||||||
if (is_string($operand1) && $operand1 > '' && $operand1{0} == '"') {
|
if (is_string($operand1) && $operand1 > '' && $operand1[0] == '"') {
|
||||||
$operand1 = self::unwrapResult($operand1);
|
$operand1 = self::unwrapResult($operand1);
|
||||||
}
|
}
|
||||||
if (is_string($operand2) && $operand2 > '' && $operand2{0} == '"') {
|
if (is_string($operand2) && $operand2 > '' && $operand2[0] == '"') {
|
||||||
$operand2 = self::unwrapResult($operand2);
|
$operand2 = self::unwrapResult($operand2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user