Minor performance tweaks
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@62816 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
66f0fb12d8
commit
e3b15694c0
|
@ -627,20 +627,17 @@ 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
|
'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
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($lookup[$pString]))
|
|
||||||
return $lookup[$pString];
|
|
||||||
|
|
||||||
// Convert to uppercase
|
// Convert to uppercase
|
||||||
$pString = strtoupper($pString);
|
$pString = strtoupper($pString);
|
||||||
|
|
||||||
$strLen = strlen($pString);
|
$strLen = strlen($pString);
|
||||||
// Convert column to integer
|
// Convert column to integer
|
||||||
if ($strLen == 1) {
|
if ($strLen == 1) {
|
||||||
return (ord($pString{0}) - 64);
|
return $lookup[$pString];
|
||||||
} elseif ($strLen == 2) {
|
} elseif ($strLen == 2) {
|
||||||
return $result = ((1 + (ord($pString{0}) - 65)) * 26) + (ord($pString{1}) - 64);
|
return $lookup[$pString{0}] * 26 + $lookup[$pString{1}];
|
||||||
} elseif ($strLen == 3) {
|
} elseif ($strLen == 3) {
|
||||||
return ((1 + (ord($pString{0}) - 65)) * 676) + ((1 + (ord($pString{1}) - 65)) * 26) + (ord($pString{2}) - 64);
|
return $lookup[$pString{0}] * 676 + $lookup[$pString{1}] * 26 + $lookup[$pString{2}];
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Column string index can not be " . ($strLen != 0 ? "longer than 3 characters" : "empty") . ".");
|
throw new Exception("Column string index can not be " . ($strLen != 0 ? "longer than 3 characters" : "empty") . ".");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue