diff --git a/Classes/PHPExcel/Calculation.php b/Classes/PHPExcel/Calculation.php
index 16b7ac52..d493fdd2 100644
--- a/Classes/PHPExcel/Calculation.php
+++ b/Classes/PHPExcel/Calculation.php
@@ -2042,7 +2042,7 @@ class PHPExcel_Calculation {
*/
public static function _unwrapResult($value) {
if (is_string($value)) {
- if ((strlen($value) > 0) && ($value{0} == '"') && (substr($value,-1) == '"')) {
+ if ((isset($value{0})) && ($value{0} == '"') && (substr($value,-1) == '"')) {
return substr($value,1,-1);
}
// Convert numeric errors to NaN error
@@ -2150,10 +2150,9 @@ class PHPExcel_Calculation {
// Basic validation that this is indeed a formula
// We return an empty array if not
$formula = trim($formula);
- if ((strlen($formula) == 0) || ($formula{0} != '=')) return array();
+ if ((!isset($formula{0})) || ($formula{0} != '=')) return array();
$formula = trim(substr($formula,1));
- $formulaLength = strlen($formula);
- if ($formulaLength < 1) return array();
+ if (!isset($formula{0})) return array();
// Parse the formula and return the token stack
return $this->_parseFormula($formula);
@@ -2208,7 +2207,7 @@ class PHPExcel_Calculation {
$formula = trim($formula);
if ($formula{0} != '=') return self::_wrapResult($formula);
$formula = trim(substr($formula,1));
- if (strlen($formula) < 1) return self::_wrapResult($formula);
+ if (!isset($formula{0})) return self::_wrapResult($formula);
$wsTitle = "\x00Wrk";
if (!is_null($pCell)) {
@@ -3280,9 +3279,9 @@ class PHPExcel_Calculation {
$stack->push('Value',$token);
// if the token is a named range, push the named range name onto the stack
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $token, $matches)) {
- echo 'Token is a named range
';
+// echo 'Token is a named range
';
$namedRange = $matches[6];
- echo 'Named Range is '.$namedRange.'
';
+// echo 'Named Range is '.$namedRange.'
';
$this->_writeDebug('Evaluating Named Range '.$namedRange);
$cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellParent : null), false);
$pCell->attach($pCellParent);
diff --git a/Classes/PHPExcel/Cell.php b/Classes/PHPExcel/Cell.php
index 835cc8ef..00be5427 100644
--- a/Classes/PHPExcel/Cell.php
+++ b/Classes/PHPExcel/Cell.php
@@ -635,17 +635,18 @@ class PHPExcel_Cell
'n' => 14, 'o' => 15, 'p' => 16, 'q' => 17, 'r' => 18, 's' => 19, 't' => 20, 'u' => 21, 'v' => 22, 'w' => 23, 'x' => 24, 'y' => 25, 'z' => 26
);
- $strLen = strlen($pString);
- // Convert column to integer
- if ($strLen == 1) {
- return $_columnLookup[$pString];
- } elseif ($strLen == 2) {
- return $_columnLookup[$pString[0]] * 26 + $_columnLookup[$pString[1]];
- } elseif ($strLen == 3) {
- return $_columnLookup[$pString[0]] * 676 + $_columnLookup[$pString[1]] * 26 + $_columnLookup[$pString[2]];
- } else {
- throw new Exception("Column string index can not be " . ($strLen != 0 ? "longer than 3 characters" : "empty") . ".");
+ // We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString
+ // for improved performance
+ if (isset($pString[0])) {
+ if (!isset($pString[1])) {
+ return $_columnLookup[$pString];
+ } elseif(!isset($pString[2])) {
+ return $_columnLookup[$pString[0]] * 26 + $_columnLookup[$pString[1]];
+ } elseif(!isset($pString[3])) {
+ return $_columnLookup[$pString[0]] * 676 + $_columnLookup[$pString[1]] * 26 + $_columnLookup[$pString[2]];
+ }
}
+ throw new Exception("Column string index can not be " . ((isset($pString[0])) ? "longer than 3 characters" : "empty") . ".");
}
/**