mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-26 15:26:03 +03:00
Minor performance tweak
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@63609 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
b16083246e
commit
3bd1ef536d
@ -1910,9 +1910,9 @@ class PHPExcel_Calculation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) {
|
private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) {
|
||||||
$inBraces = False;
|
|
||||||
// Convert any Excel function names to the required language
|
// Convert any Excel function names to the required language
|
||||||
if (self::$_localeLanguage !== 'en_us') {
|
if (self::$_localeLanguage !== 'en_us') {
|
||||||
|
$inBraces = False;
|
||||||
// If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
|
// If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
|
||||||
if (strpos($formula,'"') !== false) {
|
if (strpos($formula,'"') !== false) {
|
||||||
// So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
|
// So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
|
||||||
@ -2211,7 +2211,7 @@ class PHPExcel_Calculation {
|
|||||||
$formulaLength = strlen($formula);
|
$formulaLength = strlen($formula);
|
||||||
if ($formulaLength < 1) return self::_wrapResult($formula);
|
if ($formulaLength < 1) return self::_wrapResult($formula);
|
||||||
|
|
||||||
$wsTitle = 'Wrk';
|
$wsTitle = 0x00.'Wrk';
|
||||||
if (!is_null($pCell)) {
|
if (!is_null($pCell)) {
|
||||||
$pCellParent = $pCell->getParent();
|
$pCellParent = $pCell->getParent();
|
||||||
if (!is_null($pCellParent)) {
|
if (!is_null($pCellParent)) {
|
||||||
@ -2248,7 +2248,7 @@ class PHPExcel_Calculation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((in_array($wsTitle.'!'.$cellID,$this->debugLogStack)) && ($wsTitle != 'Wrk')) {
|
if ((in_array($wsTitle.'!'.$cellID,$this->debugLogStack)) && ($wsTitle != 0x00.'Wrk')) {
|
||||||
if ($this->cyclicFormulaCount <= 0) {
|
if ($this->cyclicFormulaCount <= 0) {
|
||||||
return $this->_raiseFormulaError('Cyclic Reference in Formula');
|
return $this->_raiseFormulaError('Cyclic Reference in Formula');
|
||||||
} elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) &&
|
} elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) &&
|
||||||
@ -2441,28 +2441,29 @@ class PHPExcel_Calculation {
|
|||||||
* @param mixed $value First matrix operand
|
* @param mixed $value First matrix operand
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private static function _showValue($value) {
|
private function _showValue($value) {
|
||||||
$testArray = PHPExcel_Calculation_Functions::flattenArray($value);
|
if ($this->writeDebugLog) {
|
||||||
if (count($testArray) == 1) {
|
$testArray = PHPExcel_Calculation_Functions::flattenArray($value);
|
||||||
$value = array_pop($testArray);
|
if (count($testArray) == 1) {
|
||||||
}
|
$value = array_pop($testArray);
|
||||||
|
|
||||||
if (is_array($value)) {
|
|
||||||
$returnMatrix = array();
|
|
||||||
$pad = $rpad = ', ';
|
|
||||||
foreach($value as $row) {
|
|
||||||
if (is_array($row)) {
|
|
||||||
$returnMatrix[] = implode($pad,$row);
|
|
||||||
$rpad = '; ';
|
|
||||||
} else {
|
|
||||||
$returnMatrix[] = $row;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return '{ '.implode($rpad,$returnMatrix).' }';
|
|
||||||
} elseif(is_bool($value)) {
|
|
||||||
return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (is_array($value)) {
|
||||||
|
$returnMatrix = array();
|
||||||
|
$pad = $rpad = ', ';
|
||||||
|
foreach($value as $row) {
|
||||||
|
if (is_array($row)) {
|
||||||
|
$returnMatrix[] = implode($pad,$row);
|
||||||
|
$rpad = '; ';
|
||||||
|
} else {
|
||||||
|
$returnMatrix[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '{ '.implode($rpad,$returnMatrix).' }';
|
||||||
|
} elseif(is_bool($value)) {
|
||||||
|
return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
|
||||||
|
}
|
||||||
|
}
|
||||||
return $value;
|
return $value;
|
||||||
} // function _showValue()
|
} // function _showValue()
|
||||||
|
|
||||||
@ -2473,32 +2474,34 @@ class PHPExcel_Calculation {
|
|||||||
* @param mixed $value First matrix operand
|
* @param mixed $value First matrix operand
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private static function _showTypeDetails($value) {
|
private function _showTypeDetails($value) {
|
||||||
$testArray = PHPExcel_Calculation_Functions::flattenArray($value);
|
if ($this->writeDebugLog) {
|
||||||
if (count($testArray) == 1) {
|
$testArray = PHPExcel_Calculation_Functions::flattenArray($value);
|
||||||
$value = array_pop($testArray);
|
if (count($testArray) == 1) {
|
||||||
}
|
$value = array_pop($testArray);
|
||||||
|
|
||||||
if (is_null($value)) {
|
|
||||||
return 'a null value';
|
|
||||||
} elseif (is_float($value)) {
|
|
||||||
$typeString = 'a floating point number';
|
|
||||||
} elseif(is_int($value)) {
|
|
||||||
$typeString = 'an integer number';
|
|
||||||
} elseif(is_bool($value)) {
|
|
||||||
$typeString = 'a boolean';
|
|
||||||
} elseif(is_array($value)) {
|
|
||||||
$typeString = 'a matrix';
|
|
||||||
} else {
|
|
||||||
if ($value == '') {
|
|
||||||
return 'an empty string';
|
|
||||||
} elseif ($value{0} == '#') {
|
|
||||||
return 'a '.$value.' error';
|
|
||||||
} else {
|
|
||||||
$typeString = 'a string';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_null($value)) {
|
||||||
|
return 'a null value';
|
||||||
|
} elseif (is_float($value)) {
|
||||||
|
$typeString = 'a floating point number';
|
||||||
|
} elseif(is_int($value)) {
|
||||||
|
$typeString = 'an integer number';
|
||||||
|
} elseif(is_bool($value)) {
|
||||||
|
$typeString = 'a boolean';
|
||||||
|
} elseif(is_array($value)) {
|
||||||
|
$typeString = 'a matrix';
|
||||||
|
} else {
|
||||||
|
if ($value == '') {
|
||||||
|
return 'an empty string';
|
||||||
|
} elseif ($value{0} == '#') {
|
||||||
|
return 'a '.$value.' error';
|
||||||
|
} else {
|
||||||
|
$typeString = 'a string';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $typeString.' with a value of '.$this->_showValue($value);
|
||||||
}
|
}
|
||||||
return $typeString.' with a value of '.self::_showValue($value);
|
|
||||||
} // function _showTypeDetails()
|
} // function _showTypeDetails()
|
||||||
|
|
||||||
|
|
||||||
@ -2950,9 +2953,9 @@ class PHPExcel_Calculation {
|
|||||||
$operand1 = $operand1Data['value'];
|
$operand1 = $operand1Data['value'];
|
||||||
$operand2 = $operand2Data['value'];
|
$operand2 = $operand2Data['value'];
|
||||||
if ($token == ':') {
|
if ($token == ':') {
|
||||||
$this->_writeDebug('Evaluating Range '.self::_showValue($operand1Data['reference']).$token.self::_showValue($operand2Data['reference']));
|
$this->_writeDebug('Evaluating Range '.$this->_showValue($operand1Data['reference']).$token.$this->_showValue($operand2Data['reference']));
|
||||||
} else {
|
} else {
|
||||||
$this->_writeDebug('Evaluating '.self::_showValue($operand1).' '.$token.' '.self::_showValue($operand2));
|
$this->_writeDebug('Evaluating '.$this->_showValue($operand1).' '.$token.' '.$this->_showValue($operand2));
|
||||||
}
|
}
|
||||||
// Process the operation in the appropriate manner
|
// Process the operation in the appropriate manner
|
||||||
switch ($token) {
|
switch ($token) {
|
||||||
@ -3058,7 +3061,7 @@ class PHPExcel_Calculation {
|
|||||||
} else {
|
} else {
|
||||||
$result = '"'.str_replace('""','"',self::_unwrapResult($operand1,'"').self::_unwrapResult($operand2,'"')).'"';
|
$result = '"'.str_replace('""','"',self::_unwrapResult($operand1,'"').self::_unwrapResult($operand2,'"')).'"';
|
||||||
}
|
}
|
||||||
$this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
|
$this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result));
|
||||||
$stack->push('Value',$result);
|
$stack->push('Value',$result);
|
||||||
break;
|
break;
|
||||||
case '|' : // Intersect
|
case '|' : // Intersect
|
||||||
@ -3072,7 +3075,7 @@ class PHPExcel_Calculation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
|
$cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
|
||||||
$this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($cellIntersect));
|
$this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($cellIntersect));
|
||||||
$stack->push('Value',$cellIntersect,$cellRef);
|
$stack->push('Value',$cellIntersect,$cellRef);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3084,11 +3087,11 @@ class PHPExcel_Calculation {
|
|||||||
$arg = $arg['value'];
|
$arg = $arg['value'];
|
||||||
if ($token === '~') {
|
if ($token === '~') {
|
||||||
// echo 'Token is a negation operator<br />';
|
// echo 'Token is a negation operator<br />';
|
||||||
$this->_writeDebug('Evaluating Negation of '.self::_showValue($arg));
|
$this->_writeDebug('Evaluating Negation of '.$this->_showValue($arg));
|
||||||
$multiplier = -1;
|
$multiplier = -1;
|
||||||
} else {
|
} else {
|
||||||
// echo 'Token is a percentile operator<br />';
|
// echo 'Token is a percentile operator<br />';
|
||||||
$this->_writeDebug('Evaluating Percentile of '.self::_showValue($arg));
|
$this->_writeDebug('Evaluating Percentile of '.$this->_showValue($arg));
|
||||||
$multiplier = 0.01;
|
$multiplier = 0.01;
|
||||||
}
|
}
|
||||||
if (is_array($arg)) {
|
if (is_array($arg)) {
|
||||||
@ -3101,7 +3104,7 @@ class PHPExcel_Calculation {
|
|||||||
$this->_writeDebug('JAMA Matrix Exception: '.$ex->getMessage());
|
$this->_writeDebug('JAMA Matrix Exception: '.$ex->getMessage());
|
||||||
$result = '#VALUE!';
|
$result = '#VALUE!';
|
||||||
}
|
}
|
||||||
$this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
|
$this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result));
|
||||||
$stack->push('Value',$result);
|
$stack->push('Value',$result);
|
||||||
} else {
|
} else {
|
||||||
$this->_executeNumericBinaryOperation($cellID,$multiplier,$arg,'*','arrayTimesEquals',$stack);
|
$this->_executeNumericBinaryOperation($cellID,$multiplier,$arg,'*','arrayTimesEquals',$stack);
|
||||||
@ -3126,7 +3129,7 @@ class PHPExcel_Calculation {
|
|||||||
} else {
|
} else {
|
||||||
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
||||||
}
|
}
|
||||||
$this->_writeDebug('Evaluation Result for cells '.$cellRef.' in worksheet '.$matches[2].' is '.self::_showTypeDetails($cellValue));
|
$this->_writeDebug('Evaluation Result for cells '.$cellRef.' in worksheet '.$matches[2].' is '.$this->_showTypeDetails($cellValue));
|
||||||
// $cellRef = $matches[2].'!'.$cellRef;
|
// $cellRef = $matches[2].'!'.$cellRef;
|
||||||
} else {
|
} else {
|
||||||
// echo '$cellRef='.$cellRef.' in current worksheet<br />';
|
// echo '$cellRef='.$cellRef.' in current worksheet<br />';
|
||||||
@ -3136,7 +3139,7 @@ class PHPExcel_Calculation {
|
|||||||
} else {
|
} else {
|
||||||
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
||||||
}
|
}
|
||||||
$this->_writeDebug('Evaluation Result for cells '.$cellRef.' is '.self::_showTypeDetails($cellValue));
|
$this->_writeDebug('Evaluation Result for cells '.$cellRef.' is '.$this->_showTypeDetails($cellValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -3160,7 +3163,7 @@ class PHPExcel_Calculation {
|
|||||||
} else {
|
} else {
|
||||||
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
||||||
}
|
}
|
||||||
$this->_writeDebug('Evaluation Result for cell '.$cellRef.' in worksheet '.$matches[2].' is '.self::_showTypeDetails($cellValue));
|
$this->_writeDebug('Evaluation Result for cell '.$cellRef.' in worksheet '.$matches[2].' is '.$this->_showTypeDetails($cellValue));
|
||||||
// $cellRef = $matches[2].'!'.$cellRef;
|
// $cellRef = $matches[2].'!'.$cellRef;
|
||||||
} else {
|
} else {
|
||||||
// echo '$cellRef='.$cellRef.' in current worksheet<br />';
|
// echo '$cellRef='.$cellRef.' in current worksheet<br />';
|
||||||
@ -3171,7 +3174,7 @@ class PHPExcel_Calculation {
|
|||||||
} else {
|
} else {
|
||||||
$cellValue = NULL;
|
$cellValue = NULL;
|
||||||
}
|
}
|
||||||
$this->_writeDebug('Evaluation Result for cell '.$cellRef.' is '.self::_showTypeDetails($cellValue));
|
$this->_writeDebug('Evaluation Result for cell '.$cellRef.' is '.$this->_showTypeDetails($cellValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3207,21 +3210,21 @@ class PHPExcel_Calculation {
|
|||||||
(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) {
|
(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) {
|
||||||
if (is_null($arg['reference'])) {
|
if (is_null($arg['reference'])) {
|
||||||
$args[] = $cellID;
|
$args[] = $cellID;
|
||||||
if ($functionName != 'MKMATRIX') { $argArrayVals[] = self::_showValue($cellID); }
|
if ($functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($cellID); }
|
||||||
} else {
|
} else {
|
||||||
$args[] = $arg['reference'];
|
$args[] = $arg['reference'];
|
||||||
if ($functionName != 'MKMATRIX') { $argArrayVals[] = self::_showValue($arg['reference']); }
|
if ($functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($arg['reference']); }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$args[] = self::_unwrapResult($arg['value']);
|
$args[] = self::_unwrapResult($arg['value']);
|
||||||
if ($functionName != 'MKMATRIX') { $argArrayVals[] = self::_showValue($arg['value']); }
|
if ($functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($arg['value']); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Reverse the order of the arguments
|
// Reverse the order of the arguments
|
||||||
krsort($args);
|
krsort($args);
|
||||||
if (($passByReference) && ($argCount == 0)) {
|
if (($passByReference) && ($argCount == 0)) {
|
||||||
$args[] = $cellID;
|
$args[] = $cellID;
|
||||||
$argArrayVals[] = self::_showValue($cellID);
|
$argArrayVals[] = $this->_showValue($cellID);
|
||||||
}
|
}
|
||||||
// echo 'Arguments are: ';
|
// echo 'Arguments are: ';
|
||||||
// print_r($args);
|
// print_r($args);
|
||||||
@ -3233,22 +3236,22 @@ class PHPExcel_Calculation {
|
|||||||
// Process each argument in turn, building the return value as an array
|
// Process each argument in turn, building the return value as an array
|
||||||
// if (($argCount == 1) && (is_array($args[1])) && ($functionName != 'MKMATRIX')) {
|
// if (($argCount == 1) && (is_array($args[1])) && ($functionName != 'MKMATRIX')) {
|
||||||
// $operand1 = $args[1];
|
// $operand1 = $args[1];
|
||||||
// $this->_writeDebug('Argument is a matrix: '.self::_showValue($operand1));
|
// $this->_writeDebug('Argument is a matrix: '.$this->_showValue($operand1));
|
||||||
// $result = array();
|
// $result = array();
|
||||||
// $row = 0;
|
// $row = 0;
|
||||||
// foreach($operand1 as $args) {
|
// foreach($operand1 as $args) {
|
||||||
// if (is_array($args)) {
|
// if (is_array($args)) {
|
||||||
// foreach($args as $arg) {
|
// foreach($args as $arg) {
|
||||||
// $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.self::_showValue($arg).' )');
|
// $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.$this->_showValue($arg).' )');
|
||||||
// $r = call_user_func_array($functionCall,$arg);
|
// $r = call_user_func_array($functionCall,$arg);
|
||||||
// $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.self::_showTypeDetails($r));
|
// $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.$this->_showTypeDetails($r));
|
||||||
// $result[$row][] = $r;
|
// $result[$row][] = $r;
|
||||||
// }
|
// }
|
||||||
// ++$row;
|
// ++$row;
|
||||||
// } else {
|
// } else {
|
||||||
// $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.self::_showValue($args).' )');
|
// $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.$this->_showValue($args).' )');
|
||||||
// $r = call_user_func_array($functionCall,$args);
|
// $r = call_user_func_array($functionCall,$args);
|
||||||
// $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.self::_showTypeDetails($r));
|
// $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.$this->_showTypeDetails($r));
|
||||||
// $result[] = $r;
|
// $result[] = $r;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
@ -3268,7 +3271,7 @@ class PHPExcel_Calculation {
|
|||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
if ($functionName != 'MKMATRIX') {
|
if ($functionName != 'MKMATRIX') {
|
||||||
$this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.self::_showTypeDetails($result));
|
$this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.$this->_showTypeDetails($result));
|
||||||
}
|
}
|
||||||
$stack->push('Value',self::_wrapResult($result));
|
$stack->push('Value',self::_wrapResult($result));
|
||||||
}
|
}
|
||||||
@ -3279,7 +3282,7 @@ class PHPExcel_Calculation {
|
|||||||
$excelConstant = strtoupper($token);
|
$excelConstant = strtoupper($token);
|
||||||
// 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->_writeDebug('Evaluating Constant '.$excelConstant.' as '.self::_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
|
$this->_writeDebug('Evaluating Constant '.$excelConstant.' as '.$this->_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
|
||||||
} elseif ((is_numeric($token)) || (is_bool($token)) || (is_null($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
|
} elseif ((is_numeric($token)) || (is_bool($token)) || (is_null($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);
|
||||||
@ -3291,7 +3294,7 @@ class PHPExcel_Calculation {
|
|||||||
$this->_writeDebug('Evaluating Named Range '.$namedRange);
|
$this->_writeDebug('Evaluating Named Range '.$namedRange);
|
||||||
$cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellParent : null), false);
|
$cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellParent : null), false);
|
||||||
$pCell->attach($pCellParent);
|
$pCell->attach($pCellParent);
|
||||||
$this->_writeDebug('Evaluation Result for named range '.$namedRange.' is '.self::_showTypeDetails($cellValue));
|
$this->_writeDebug('Evaluation Result for named range '.$namedRange.' is '.$this->_showTypeDetails($cellValue));
|
||||||
$stack->push('Named Range',$cellValue,$namedRange);
|
$stack->push('Named Range',$cellValue,$namedRange);
|
||||||
} else {
|
} else {
|
||||||
return $this->_raiseFormulaError("undefined variable '$token'");
|
return $this->_raiseFormulaError("undefined variable '$token'");
|
||||||
@ -3321,12 +3324,12 @@ class PHPExcel_Calculation {
|
|||||||
// 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->_writeDebug('Evaluation Result is '.self::_showTypeDetails($operand));
|
$this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($operand));
|
||||||
return false;
|
return false;
|
||||||
} elseif (!PHPExcel_Shared_String::convertToNumberIfFraction($operand)) {
|
} elseif (!PHPExcel_Shared_String::convertToNumberIfFraction($operand)) {
|
||||||
// If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations
|
// If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations
|
||||||
$stack->push('Value', '#VALUE!');
|
$stack->push('Value', '#VALUE!');
|
||||||
$this->_writeDebug('Evaluation Result is a '.self::_showTypeDetails('#VALUE!'));
|
$this->_writeDebug('Evaluation Result is a '.$this->_showTypeDetails('#VALUE!'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3343,14 +3346,14 @@ class PHPExcel_Calculation {
|
|||||||
$result = array();
|
$result = array();
|
||||||
if ((is_array($operand1)) && (!is_array($operand2))) {
|
if ((is_array($operand1)) && (!is_array($operand2))) {
|
||||||
foreach($operand1 as $x => $operandData) {
|
foreach($operand1 as $x => $operandData) {
|
||||||
$this->_writeDebug('Evaluating '.self::_showValue($operandData).' '.$operation.' '.self::_showValue($operand2));
|
$this->_writeDebug('Evaluating '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2));
|
||||||
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack);
|
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack);
|
||||||
$r = $stack->pop();
|
$r = $stack->pop();
|
||||||
$result[$x] = $r['value'];
|
$result[$x] = $r['value'];
|
||||||
}
|
}
|
||||||
} elseif ((!is_array($operand1)) && (is_array($operand2))) {
|
} elseif ((!is_array($operand1)) && (is_array($operand2))) {
|
||||||
foreach($operand2 as $x => $operandData) {
|
foreach($operand2 as $x => $operandData) {
|
||||||
$this->_writeDebug('Evaluating '.self::_showValue($operand1).' '.$operation.' '.self::_showValue($operandData));
|
$this->_writeDebug('Evaluating '.$this->_showValue($operand1).' '.$operation.' '.$this->_showValue($operandData));
|
||||||
$this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack);
|
$this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack);
|
||||||
$r = $stack->pop();
|
$r = $stack->pop();
|
||||||
$result[$x] = $r['value'];
|
$result[$x] = $r['value'];
|
||||||
@ -3358,14 +3361,14 @@ class PHPExcel_Calculation {
|
|||||||
} else {
|
} else {
|
||||||
if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); }
|
if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); }
|
||||||
foreach($operand1 as $x => $operandData) {
|
foreach($operand1 as $x => $operandData) {
|
||||||
$this->_writeDebug('Evaluating '.self::_showValue($operandData).' '.$operation.' '.self::_showValue($operand2[$x]));
|
$this->_writeDebug('Evaluating '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x]));
|
||||||
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,True);
|
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,True);
|
||||||
$r = $stack->pop();
|
$r = $stack->pop();
|
||||||
$result[$x] = $r['value'];
|
$result[$x] = $r['value'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Log the result details
|
// Log the result details
|
||||||
$this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
|
$this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result));
|
||||||
// And push the result onto the stack
|
// And push the result onto the stack
|
||||||
$stack->push('Array',$result);
|
$stack->push('Array',$result);
|
||||||
return true;
|
return true;
|
||||||
@ -3404,7 +3407,7 @@ class PHPExcel_Calculation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log the result details
|
// Log the result details
|
||||||
$this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
|
$this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result));
|
||||||
// And push the result onto the stack
|
// And push the result onto the stack
|
||||||
$stack->push('Value',$result);
|
$stack->push('Value',$result);
|
||||||
return true;
|
return true;
|
||||||
@ -3452,7 +3455,7 @@ class PHPExcel_Calculation {
|
|||||||
if ($operand2 == 0) {
|
if ($operand2 == 0) {
|
||||||
// Trap for Divide by Zero error
|
// Trap for Divide by Zero error
|
||||||
$stack->push('Value','#DIV/0!');
|
$stack->push('Value','#DIV/0!');
|
||||||
$this->_writeDebug('Evaluation Result is '.self::_showTypeDetails('#DIV/0!'));
|
$this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails('#DIV/0!'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$result = $operand1/$operand2;
|
$result = $operand1/$operand2;
|
||||||
@ -3466,7 +3469,7 @@ class PHPExcel_Calculation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log the result details
|
// Log the result details
|
||||||
$this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
|
$this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result));
|
||||||
// And push the result onto the stack
|
// And push the result onto the stack
|
||||||
$stack->push('Value',$result);
|
$stack->push('Value',$result);
|
||||||
return true;
|
return true;
|
||||||
|
@ -479,13 +479,12 @@ class PHPExcel_Cell
|
|||||||
*/
|
*/
|
||||||
public static function coordinateFromString($pCoordinateString = 'A1')
|
public static function coordinateFromString($pCoordinateString = 'A1')
|
||||||
{
|
{
|
||||||
if (strpos($pCoordinateString,':') !== false) {
|
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,5})$/", $pCoordinateString, $matches)) {
|
||||||
|
return array($matches[1],$matches[2]);
|
||||||
|
} elseif ((strpos($pCoordinateString,':') !== false) || (strpos($pCoordinateString,',') !== false)) {
|
||||||
throw new Exception('Cell coordinate string can not be a range of cells.');
|
throw new Exception('Cell coordinate string can not be a range of cells.');
|
||||||
} else if ($pCoordinateString == '') {
|
} elseif ($pCoordinateString == '') {
|
||||||
throw new Exception('Cell coordinate can not be zero-length string.');
|
throw new Exception('Cell coordinate can not be zero-length string.');
|
||||||
} else if (preg_match("/([$]?[A-Z]+)([$]?\d+)/", $pCoordinateString, $matches)) {
|
|
||||||
array_shift($matches);
|
|
||||||
return $matches;
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Invalid cell coordinate.');
|
throw new Exception('Invalid cell coordinate.');
|
||||||
}
|
}
|
||||||
@ -503,6 +502,8 @@ class PHPExcel_Cell
|
|||||||
if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) {
|
if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) {
|
||||||
// Create absolute coordinate
|
// Create absolute coordinate
|
||||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($pCoordinateString);
|
list($column, $row) = PHPExcel_Cell::coordinateFromString($pCoordinateString);
|
||||||
|
if ($column[0] == '$') $column = substr($column,1);
|
||||||
|
if ($row[0] == '$') $row = substr($row,1);
|
||||||
return '$' . $column . '$' . $row;
|
return '$' . $column . '$' . $row;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Coordinate string should not be a cell range.");
|
throw new Exception("Coordinate string should not be a cell range.");
|
||||||
|
@ -199,10 +199,10 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
*/
|
*/
|
||||||
private function _mapVAlign($vAlign) {
|
private function _mapVAlign($vAlign) {
|
||||||
switch ($vAlign) {
|
switch ($vAlign) {
|
||||||
case PHPExcel_Style_Alignment::VERTICAL_BOTTOM: return 'bottom';
|
case PHPExcel_Style_Alignment::VERTICAL_BOTTOM: return 'bottom';
|
||||||
case PHPExcel_Style_Alignment::VERTICAL_TOP: return 'top';
|
case PHPExcel_Style_Alignment::VERTICAL_TOP: return 'top';
|
||||||
case PHPExcel_Style_Alignment::VERTICAL_CENTER:
|
case PHPExcel_Style_Alignment::VERTICAL_CENTER:
|
||||||
case PHPExcel_Style_Alignment::VERTICAL_JUSTIFY: return 'middle';
|
case PHPExcel_Style_Alignment::VERTICAL_JUSTIFY: return 'middle';
|
||||||
default: return 'baseline';
|
default: return 'baseline';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,11 +214,12 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
*/
|
*/
|
||||||
private function _mapHAlign($hAlign) {
|
private function _mapHAlign($hAlign) {
|
||||||
switch ($hAlign) {
|
switch ($hAlign) {
|
||||||
case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL: return false;
|
case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL: return false;
|
||||||
case PHPExcel_Style_Alignment::HORIZONTAL_LEFT: return 'left';
|
case PHPExcel_Style_Alignment::HORIZONTAL_LEFT: return 'left';
|
||||||
case PHPExcel_Style_Alignment::HORIZONTAL_RIGHT: return 'right';
|
case PHPExcel_Style_Alignment::HORIZONTAL_RIGHT: return 'right';
|
||||||
case PHPExcel_Style_Alignment::HORIZONTAL_CENTER: return 'center';
|
case PHPExcel_Style_Alignment::HORIZONTAL_CENTER:
|
||||||
case PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY: return 'justify';
|
case PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS: return 'center';
|
||||||
|
case PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY: return 'justify';
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,11 +229,20 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
*/
|
*/
|
||||||
private function _mapBorderStyle($borderStyle) {
|
private function _mapBorderStyle($borderStyle) {
|
||||||
switch ($borderStyle) {
|
switch ($borderStyle) {
|
||||||
case PHPExcel_Style_Border::BORDER_NONE: return '0px';
|
case PHPExcel_Style_Border::BORDER_NONE: return '0px';
|
||||||
case PHPExcel_Style_Border::BORDER_DASHED: return '1px dashed';
|
case PHPExcel_Style_Border::BORDER_DASHDOT: return '1px dashed';
|
||||||
case PHPExcel_Style_Border::BORDER_DOTTED: return '1px dotted';
|
case PHPExcel_Style_Border::BORDER_DASHDOTDOT: return '1px dotted';
|
||||||
case PHPExcel_Style_Border::BORDER_DOUBLE: return '3px double';
|
case PHPExcel_Style_Border::BORDER_DASHED: return '1px dashed';
|
||||||
case PHPExcel_Style_Border::BORDER_THICK: return '2px solid';
|
case PHPExcel_Style_Border::BORDER_DOTTED: return '1px dotted';
|
||||||
|
case PHPExcel_Style_Border::BORDER_DOUBLE: return '3px double';
|
||||||
|
case PHPExcel_Style_Border::BORDER_HAIR: return '1px solid';
|
||||||
|
case PHPExcel_Style_Border::BORDER_MEDIUM: return '2px solid';
|
||||||
|
case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT: return '2px dashed';
|
||||||
|
case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT: return '2px dotted';
|
||||||
|
case PHPExcel_Style_Border::BORDER_MEDIUMDASHED: return '2px dashed';
|
||||||
|
case PHPExcel_Style_Border::BORDER_SLANTDASHDOT: return '2px dashed';
|
||||||
|
case PHPExcel_Style_Border::BORDER_THICK: return '3px solid';
|
||||||
|
case PHPExcel_Style_Border::BORDER_THIN return '1px solid';
|
||||||
default: return '1px solid'; // map others to thin
|
default: return '1px solid'; // map others to thin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user