mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-30 01:06:03 +03:00
Performance tweaks (particularly affecting the Excel5 Writer)
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@63320 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
8c3ce4f938
commit
3aa1142b5f
@ -98,9 +98,7 @@ class PHPExcel_CachedObjectStorage_CacheBase {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function updateCacheData(PHPExcel_Cell $cell) {
|
public function updateCacheData(PHPExcel_Cell $cell) {
|
||||||
$pCoord = $cell->getCoordinate();
|
return $this->addCacheData($cell->getCoordinate(),$cell);
|
||||||
|
|
||||||
return $this->addCacheData($pCoord,$cell);
|
|
||||||
} // function updateCacheData()
|
} // function updateCacheData()
|
||||||
|
|
||||||
|
|
||||||
|
@ -2335,10 +2335,7 @@ class PHPExcel_Calculation {
|
|||||||
$matrixRows = count($matrix);
|
$matrixRows = count($matrix);
|
||||||
$matrixColumns = 0;
|
$matrixColumns = 0;
|
||||||
foreach($matrix as $rowKey => $rowValue) {
|
foreach($matrix as $rowKey => $rowValue) {
|
||||||
$colCount = count($rowValue);
|
$matrixColumns = max(count($rowValue),$matrixColumns);
|
||||||
if ($colCount > $matrixColumns) {
|
|
||||||
$matrixColumns = $colCount;
|
|
||||||
}
|
|
||||||
if (!is_array($rowValue)) {
|
if (!is_array($rowValue)) {
|
||||||
$matrix[$rowKey] = array($rowValue);
|
$matrix[$rowKey] = array($rowValue);
|
||||||
} else {
|
} else {
|
||||||
@ -2678,11 +2675,11 @@ class PHPExcel_Calculation {
|
|||||||
// }
|
// }
|
||||||
$output[] = $d; // Dump the argument count on the output
|
$output[] = $d; // Dump the argument count on the output
|
||||||
$output[] = $stack->pop(); // Pop the function and push onto the output
|
$output[] = $stack->pop(); // Pop the function and push onto the output
|
||||||
if (array_key_exists($functionName, self::$_controlFunctions)) {
|
if (isset(self::$_controlFunctions[$functionName])) {
|
||||||
// echo 'Built-in function '.$functionName.'<br />';
|
// echo 'Built-in function '.$functionName.'<br />';
|
||||||
$expectedArgumentCount = self::$_controlFunctions[$functionName]['argumentCount'];
|
$expectedArgumentCount = self::$_controlFunctions[$functionName]['argumentCount'];
|
||||||
$functionCall = self::$_controlFunctions[$functionName]['functionCall'];
|
$functionCall = self::$_controlFunctions[$functionName]['functionCall'];
|
||||||
} elseif (array_key_exists($functionName, self::$_PHPExcelFunctions)) {
|
} elseif (isset(self::$_PHPExcelFunctions[$functionName])) {
|
||||||
// echo 'PHPExcel function '.$functionName.'<br />';
|
// echo 'PHPExcel function '.$functionName.'<br />';
|
||||||
$expectedArgumentCount = self::$_PHPExcelFunctions[$functionName]['argumentCount'];
|
$expectedArgumentCount = self::$_PHPExcelFunctions[$functionName]['argumentCount'];
|
||||||
$functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
|
$functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
|
||||||
@ -2773,7 +2770,7 @@ class PHPExcel_Calculation {
|
|||||||
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
|
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
|
||||||
$val = preg_replace('/\s/','',$val);
|
$val = preg_replace('/\s/','',$val);
|
||||||
// echo 'Element '.$val.' is a Function<br />';
|
// echo 'Element '.$val.' is a Function<br />';
|
||||||
if (array_key_exists(strtoupper($matches[1]), self::$_PHPExcelFunctions) || array_key_exists(strtoupper($matches[1]), self::$_controlFunctions)) { // it's a func
|
if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) { // it's a function
|
||||||
$stack->push('Function', strtoupper($val));
|
$stack->push('Function', strtoupper($val));
|
||||||
$ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch);
|
$ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch);
|
||||||
if ($ax) {
|
if ($ax) {
|
||||||
@ -2855,7 +2852,7 @@ class PHPExcel_Calculation {
|
|||||||
// echo 'Casting '.$val.' to integer<br />';
|
// echo 'Casting '.$val.' to integer<br />';
|
||||||
$val = (integer) $val;
|
$val = (integer) $val;
|
||||||
}
|
}
|
||||||
} elseif (array_key_exists(trim(strtoupper($val)), self::$_ExcelConstants)) {
|
} elseif (isset(self::$_ExcelConstants[trim(strtoupper($val))])) {
|
||||||
$excelConstant = trim(strtoupper($val));
|
$excelConstant = trim(strtoupper($val));
|
||||||
// echo 'Element '.$excelConstant.' is an Excel Constant<br />';
|
// echo 'Element '.$excelConstant.' is an Excel Constant<br />';
|
||||||
$val = self::$_ExcelConstants[$excelConstant];
|
$val = self::$_ExcelConstants[$excelConstant];
|
||||||
@ -3189,12 +3186,12 @@ class PHPExcel_Calculation {
|
|||||||
if ($functionName != 'MKMATRIX') {
|
if ($functionName != 'MKMATRIX') {
|
||||||
$this->_writeDebug('Evaluating Function '.self::_localeFunc($functionName).'() with '.(($argCount == 0) ? 'no' : $argCount).' argument'.(($argCount == 1) ? '' : 's'));
|
$this->_writeDebug('Evaluating Function '.self::_localeFunc($functionName).'() with '.(($argCount == 0) ? 'no' : $argCount).' argument'.(($argCount == 1) ? '' : 's'));
|
||||||
}
|
}
|
||||||
if ((array_key_exists($functionName, self::$_PHPExcelFunctions)) || (array_key_exists($functionName, self::$_controlFunctions))) { // function
|
if ((isset(self::$_PHPExcelFunctions[$functionName])) || (isset(self::$_controlFunctions[$functionName]))) { // function
|
||||||
if (array_key_exists($functionName, self::$_PHPExcelFunctions)) {
|
if (isset(self::$_PHPExcelFunctions[$functionName])) {
|
||||||
$functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
|
$functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
|
||||||
$passByReference = isset(self::$_PHPExcelFunctions[$functionName]['passByReference']);
|
$passByReference = isset(self::$_PHPExcelFunctions[$functionName]['passByReference']);
|
||||||
$passCellReference = isset(self::$_PHPExcelFunctions[$functionName]['passCellReference']);
|
$passCellReference = isset(self::$_PHPExcelFunctions[$functionName]['passCellReference']);
|
||||||
} elseif (array_key_exists($functionName, self::$_controlFunctions)) {
|
} elseif (isset(self::$_controlFunctions[$functionName])) {
|
||||||
$functionCall = self::$_controlFunctions[$functionName]['functionCall'];
|
$functionCall = self::$_controlFunctions[$functionName]['functionCall'];
|
||||||
$passByReference = isset(self::$_controlFunctions[$functionName]['passByReference']);
|
$passByReference = isset(self::$_controlFunctions[$functionName]['passByReference']);
|
||||||
$passCellReference = isset(self::$_controlFunctions[$functionName]['passCellReference']);
|
$passCellReference = isset(self::$_controlFunctions[$functionName]['passCellReference']);
|
||||||
@ -3278,7 +3275,7 @@ class PHPExcel_Calculation {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// if the token is a number, boolean, string or an Excel error, push it onto the stack
|
// if the token is a number, boolean, string or an Excel error, push it onto the stack
|
||||||
if (array_key_exists(strtoupper($token), self::$_ExcelConstants)) {
|
if (isset(self::$_ExcelConstants[strtoupper($token)])) {
|
||||||
$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]);
|
||||||
@ -3521,7 +3518,7 @@ class PHPExcel_Calculation {
|
|||||||
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
|
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
|
||||||
$pRange = $pSheet->getTitle().'!'.$pRange;
|
$pRange = $pSheet->getTitle().'!'.$pRange;
|
||||||
if (count($aReferences) == 1) {
|
if (count($aReferences) == 1) {
|
||||||
list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
|
list($currentCol,$currentRow) = sscanf($aReferences[0],'%[A-Z]%d');
|
||||||
if ($pSheet->cellExists($aReferences[0])) {
|
if ($pSheet->cellExists($aReferences[0])) {
|
||||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
|
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
|
||||||
} else {
|
} else {
|
||||||
@ -3531,7 +3528,7 @@ class PHPExcel_Calculation {
|
|||||||
// Extract cell data
|
// Extract cell data
|
||||||
foreach ($aReferences as $reference) {
|
foreach ($aReferences as $reference) {
|
||||||
// Extract range
|
// Extract range
|
||||||
list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference);
|
list($currentCol,$currentRow) = sscanf($reference,'%[A-Z]%d');
|
||||||
|
|
||||||
if ($pSheet->cellExists($reference)) {
|
if ($pSheet->cellExists($reference)) {
|
||||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
|
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
|
||||||
|
@ -484,8 +484,8 @@ class PHPExcel_Cell
|
|||||||
} else if ($pCoordinateString == '') {
|
} else if ($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)) {
|
} else if (preg_match("/([$]?[A-Z]+)([$]?\d+)/", $pCoordinateString, $matches)) {
|
||||||
list(, $column, $row) = $matches;
|
array_shift($matches);
|
||||||
return array($column, $row);
|
return $matches;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Invalid cell coordinate.');
|
throw new Exception('Invalid cell coordinate.');
|
||||||
}
|
}
|
||||||
@ -518,7 +518,8 @@ class PHPExcel_Cell
|
|||||||
public static function splitRange($pRange = 'A1:A1')
|
public static function splitRange($pRange = 'A1:A1')
|
||||||
{
|
{
|
||||||
$exploded = explode(',', $pRange);
|
$exploded = explode(',', $pRange);
|
||||||
for ($i = 0; $i < count($exploded); ++$i) {
|
$counter = count($exploded);
|
||||||
|
for ($i = 0; $i < $counter; ++$i) {
|
||||||
$exploded[$i] = explode(':', $exploded[$i]);
|
$exploded[$i] = explode(':', $exploded[$i]);
|
||||||
}
|
}
|
||||||
return $exploded;
|
return $exploded;
|
||||||
@ -540,7 +541,8 @@ class PHPExcel_Cell
|
|||||||
|
|
||||||
// Build range
|
// Build range
|
||||||
$imploded = array();
|
$imploded = array();
|
||||||
for ($i = 0; $i < count($pRange); ++$i) {
|
$counter = count($pRange);
|
||||||
|
for ($i = 0; $i < $counter; ++$i) {
|
||||||
$pRange[$i] = implode(':', $pRange[$i]);
|
$pRange[$i] = implode(':', $pRange[$i]);
|
||||||
}
|
}
|
||||||
$imploded = implode(',', $pRange);
|
$imploded = implode(',', $pRange);
|
||||||
@ -622,22 +624,24 @@ class PHPExcel_Cell
|
|||||||
*/
|
*/
|
||||||
public static function columnIndexFromString($pString = 'A')
|
public static function columnIndexFromString($pString = 'A')
|
||||||
{
|
{
|
||||||
static $lookup = array(
|
// It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord()
|
||||||
|
// and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant
|
||||||
|
// memory overhead either
|
||||||
|
static $_columnLookup = array(
|
||||||
'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13,
|
'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13,
|
||||||
'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,
|
||||||
|
'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7, 'h' => 8, 'i' => 9, 'j' => 10, 'k' => 11, 'l' => 12, 'm' => 13,
|
||||||
|
'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
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert to uppercase
|
|
||||||
$pString = strtoupper($pString);
|
|
||||||
|
|
||||||
$strLen = strlen($pString);
|
$strLen = strlen($pString);
|
||||||
// Convert column to integer
|
// Convert column to integer
|
||||||
if ($strLen == 1) {
|
if ($strLen == 1) {
|
||||||
return $lookup[$pString];
|
return $_columnLookup[$pString];
|
||||||
} elseif ($strLen == 2) {
|
} elseif ($strLen == 2) {
|
||||||
return $lookup[$pString{0}] * 26 + $lookup[$pString{1}];
|
return $_columnLookup[$pString[0]] * 26 + $_columnLookup[$pString[1]];
|
||||||
} elseif ($strLen == 3) {
|
} elseif ($strLen == 3) {
|
||||||
return $lookup[$pString{0}] * 676 + $lookup[$pString{1}] * 26 + $lookup[$pString{2}];
|
return $_columnLookup[$pString[0]] * 676 + $_columnLookup[$pString[1]] * 26 + $_columnLookup[$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") . ".");
|
||||||
}
|
}
|
||||||
@ -654,8 +658,7 @@ class PHPExcel_Cell
|
|||||||
// Determine column string
|
// Determine column string
|
||||||
if ($pColumnIndex < 26) {
|
if ($pColumnIndex < 26) {
|
||||||
return chr(65 + $pColumnIndex);
|
return chr(65 + $pColumnIndex);
|
||||||
}
|
} elseif ($pColumnIndex < 702) {
|
||||||
if ($pColumnIndex < 702) {
|
|
||||||
return chr(64 + ($pColumnIndex / 26)).chr(65 + $pColumnIndex % 26);
|
return chr(64 + ($pColumnIndex / 26)).chr(65 + $pColumnIndex % 26);
|
||||||
}
|
}
|
||||||
return chr(64 + (($pColumnIndex - 26) / 676)).chr(65 + ((($pColumnIndex - 26) % 676) / 26)).chr(65 + $pColumnIndex % 26);
|
return chr(64 + (($pColumnIndex - 26) / 676)).chr(65 + ((($pColumnIndex - 26) % 676) / 26)).chr(65 + $pColumnIndex % 26);
|
||||||
@ -672,60 +675,41 @@ class PHPExcel_Cell
|
|||||||
$returnValue = array();
|
$returnValue = array();
|
||||||
|
|
||||||
// Explode spaces
|
// Explode spaces
|
||||||
$aExplodeSpaces = explode(' ', str_replace('$', '', strtoupper($pRange)));
|
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
|
||||||
foreach ($aExplodeSpaces as $explodedSpaces) {
|
foreach ($cellBlocks as $cellBlock) {
|
||||||
// Single cell?
|
// Single cell?
|
||||||
if (strpos($explodedSpaces,':') === false && strpos($explodedSpaces,',') === false) {
|
if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) {
|
||||||
$col = 'A';
|
$returnValue[] = $cellBlock;
|
||||||
$row = 1;
|
|
||||||
list($col, $row) = PHPExcel_Cell::coordinateFromString($explodedSpaces);
|
|
||||||
|
|
||||||
if (strlen($col) <= 2) {
|
|
||||||
$returnValue[] = $explodedSpaces;
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Range...
|
// Range...
|
||||||
$range = PHPExcel_Cell::splitRange($explodedSpaces);
|
$ranges = PHPExcel_Cell::splitRange($cellBlock);
|
||||||
for ($i = 0; $i < count($range); ++$i) {
|
foreach($ranges as $range) {
|
||||||
// Single cell?
|
// Single cell?
|
||||||
if (count($range[$i]) == 1) {
|
if (count($range) == 1) {
|
||||||
$col = 'A';
|
$returnValue[] = $range[0];
|
||||||
$row = 1;
|
continue;
|
||||||
list($col, $row) = PHPExcel_Cell::coordinateFromString($range[$i]);
|
|
||||||
|
|
||||||
if (strlen($col) <= 2) {
|
|
||||||
$returnValue[] = $explodedSpaces;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Range...
|
// Range...
|
||||||
$rangeStart = $rangeEnd = '';
|
list($rangeStart, $rangeEnd) = $range;
|
||||||
$startingCol = $startingRow = $endingCol = $endingRow = 0;
|
list($startCol, $startRow) = sscanf($rangeStart,'%[A-Z]%d');
|
||||||
|
list($endCol, $endRow) = sscanf($rangeEnd,'%[A-Z]%d');
|
||||||
list($rangeStart, $rangeEnd) = $range[$i];
|
$endCol++;
|
||||||
list($startingCol, $startingRow) = PHPExcel_Cell::coordinateFromString($rangeStart);
|
|
||||||
list($endingCol, $endingRow) = PHPExcel_Cell::coordinateFromString($rangeEnd);
|
|
||||||
|
|
||||||
// Conversions...
|
|
||||||
$startingCol = PHPExcel_Cell::columnIndexFromString($startingCol);
|
|
||||||
$endingCol = PHPExcel_Cell::columnIndexFromString($endingCol);
|
|
||||||
|
|
||||||
// Current data
|
// Current data
|
||||||
$currentCol = --$startingCol;
|
$currentCol = $startCol;
|
||||||
$currentRow = $startingRow;
|
$currentRow = $startRow;
|
||||||
|
|
||||||
// Loop cells
|
// Loop cells
|
||||||
while ($currentCol < $endingCol) {
|
while ($currentCol != $endCol) {
|
||||||
$loopColumn = PHPExcel_Cell::stringFromColumnIndex($currentCol);
|
while ($currentRow <= $endRow) {
|
||||||
while ($currentRow <= $endingRow) {
|
$returnValue[] = $currentCol.$currentRow;
|
||||||
$returnValue[] = $loopColumn.$currentRow;
|
|
||||||
++$currentRow;
|
++$currentRow;
|
||||||
}
|
}
|
||||||
++$currentCol;
|
++$currentCol;
|
||||||
$currentRow = $startingRow;
|
$currentRow = $startRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1278,7 +1278,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
|||||||
private function _readDefault()
|
private function _readDefault()
|
||||||
{
|
{
|
||||||
$length = $this->_GetInt2d($this->_data, $this->_pos + 2);
|
$length = $this->_GetInt2d($this->_data, $this->_pos + 2);
|
||||||
$recordData = substr($this->_data, $this->_pos + 4, $length);
|
// $recordData = substr($this->_data, $this->_pos + 4, $length);
|
||||||
|
|
||||||
// move stream pointer to next record
|
// move stream pointer to next record
|
||||||
$this->_pos += 4 + $length;
|
$this->_pos += 4 + $length;
|
||||||
@ -1337,7 +1337,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
|||||||
private function _readFilepass()
|
private function _readFilepass()
|
||||||
{
|
{
|
||||||
$length = $this->_GetInt2d($this->_data, $this->_pos + 2);
|
$length = $this->_GetInt2d($this->_data, $this->_pos + 2);
|
||||||
$recordData = substr($this->_data, $this->_pos + 4, $length);
|
// $recordData = substr($this->_data, $this->_pos + 4, $length);
|
||||||
|
|
||||||
// move stream pointer to next record
|
// move stream pointer to next record
|
||||||
$this->_pos += 4 + $length;
|
$this->_pos += 4 + $length;
|
||||||
@ -5869,7 +5869,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
|||||||
$b = ord($rgb{2});
|
$b = ord($rgb{2});
|
||||||
|
|
||||||
// HEX notation, e.g. 'FF00FC'
|
// HEX notation, e.g. 'FF00FC'
|
||||||
$rgb = sprintf('%02X', $r) . sprintf('%02X', $g) . sprintf('%02X', $b);
|
$rgb = sprintf('%02X%02X%02X', $r, $g, $b);
|
||||||
|
|
||||||
return array('rgb' => $rgb);
|
return array('rgb' => $rgb);
|
||||||
}
|
}
|
||||||
@ -6021,17 +6021,17 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
|||||||
$rknumhigh = $this->_GetInt4d($data, 4);
|
$rknumhigh = $this->_GetInt4d($data, 4);
|
||||||
$rknumlow = $this->_GetInt4d($data, 0);
|
$rknumlow = $this->_GetInt4d($data, 0);
|
||||||
$sign = ($rknumhigh & 0x80000000) >> 31;
|
$sign = ($rknumhigh & 0x80000000) >> 31;
|
||||||
$exp = ($rknumhigh & 0x7ff00000) >> 20;
|
$exp = (($rknumhigh & 0x7ff00000) >> 20) - 1023;
|
||||||
$mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
|
$mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
|
||||||
$mantissalow1 = ($rknumlow & 0x80000000) >> 31;
|
$mantissalow1 = ($rknumlow & 0x80000000) >> 31;
|
||||||
$mantissalow2 = ($rknumlow & 0x7fffffff);
|
$mantissalow2 = ($rknumlow & 0x7fffffff);
|
||||||
$value = $mantissa / pow( 2 , (20 - ($exp - 1023)));
|
$value = $mantissa / pow( 2 , (20 - $exp));
|
||||||
|
|
||||||
if ($mantissalow1 != 0) {
|
if ($mantissalow1 != 0) {
|
||||||
$value += 1 / pow (2 , (21 - ($exp - 1023)));
|
$value += 1 / pow (2 , (21 - $exp));
|
||||||
}
|
}
|
||||||
|
|
||||||
$value += $mantissalow2 / pow (2 , (52 - ($exp - 1023)));
|
$value += $mantissalow2 / pow (2 , (52 - $exp));
|
||||||
if ($sign) {
|
if ($sign) {
|
||||||
$value = -1 * $value;
|
$value = -1 * $value;
|
||||||
}
|
}
|
||||||
@ -6078,9 +6078,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
|||||||
$string = $this->_uncompressByteString($string);
|
$string = $this->_uncompressByteString($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', 'UTF-16LE');
|
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', 'UTF-16LE');
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6092,7 +6090,8 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
|||||||
private function _uncompressByteString($string)
|
private function _uncompressByteString($string)
|
||||||
{
|
{
|
||||||
$uncompressedString = '';
|
$uncompressedString = '';
|
||||||
for ($i = 0; $i < strlen($string); ++$i) {
|
$strLen = strlen($string);
|
||||||
|
for ($i = 0; $i < $strLen; ++$i) {
|
||||||
$uncompressedString .= $string[$i] . "\0";
|
$uncompressedString .= $string[$i] . "\0";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6107,8 +6106,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
|||||||
*/
|
*/
|
||||||
private function _decodeCodepage($string)
|
private function _decodeCodepage($string)
|
||||||
{
|
{
|
||||||
$result = PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $this->_codepage);
|
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $this->_codepage);
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6157,17 +6155,17 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
|||||||
{
|
{
|
||||||
if ($color <= 0x07 || $color >= 0x40) {
|
if ($color <= 0x07 || $color >= 0x40) {
|
||||||
// special built-in color
|
// special built-in color
|
||||||
$color = $this->_mapBuiltInColor($color);
|
return $this->_mapBuiltInColor($color);
|
||||||
} else if (isset($this->_palette) && isset($this->_palette[$color - 8])) {
|
} else if (isset($this->_palette) && isset($this->_palette[$color - 8])) {
|
||||||
// palette color, color index 0x08 maps to pallete index 0
|
// palette color, color index 0x08 maps to pallete index 0
|
||||||
$color = $this->_palette[$color - 8];
|
return $this->_palette[$color - 8];
|
||||||
} else {
|
} else {
|
||||||
// default color table
|
// default color table
|
||||||
if ($this->_version == self::XLS_BIFF8) {
|
if ($this->_version == self::XLS_BIFF8) {
|
||||||
$color = $this->_mapColor($color);
|
return $this->_mapColor($color);
|
||||||
} else {
|
} else {
|
||||||
// BIFF5
|
// BIFF5
|
||||||
$color = $this->_mapColorBIFF5($color);
|
return $this->_mapColorBIFF5($color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,14 +169,12 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
|||||||
$selectedCell = $this->getActiveCell(); // e.g. 'A1'
|
$selectedCell = $this->getActiveCell(); // e.g. 'A1'
|
||||||
|
|
||||||
if ($activeSheet->cellExists($selectedCell)) {
|
if ($activeSheet->cellExists($selectedCell)) {
|
||||||
$cell = $activeSheet->getCell($selectedCell);
|
$xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex();
|
||||||
$xfIndex = $cell->getXfIndex();
|
|
||||||
} else {
|
} else {
|
||||||
$xfIndex = 0;
|
$xfIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$activeStyle = $this->_parent->getCellXfByIndex($xfIndex);
|
return $this->_parent->getCellXfByIndex($xfIndex);
|
||||||
return $activeStyle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -270,8 +268,6 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
|||||||
$pRange = strtoupper($pRange);
|
$pRange = strtoupper($pRange);
|
||||||
|
|
||||||
// Is it a cell range or a single cell?
|
// Is it a cell range or a single cell?
|
||||||
$rangeA = '';
|
|
||||||
$rangeB = '';
|
|
||||||
if (strpos($pRange, ':') === false) {
|
if (strpos($pRange, ':') === false) {
|
||||||
$rangeA = $pRange;
|
$rangeA = $pRange;
|
||||||
$rangeB = $pRange;
|
$rangeB = $pRange;
|
||||||
|
@ -393,7 +393,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
|||||||
self::fillBuiltInFormatCodes();
|
self::fillBuiltInFormatCodes();
|
||||||
|
|
||||||
// Lookup format code
|
// Lookup format code
|
||||||
if (array_key_exists($pIndex, self::$_builtInFormats)) {
|
if (isset(self::$_builtInFormats[$pIndex])) {
|
||||||
return self::$_builtInFormats[$pIndex];
|
return self::$_builtInFormats[$pIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,7 +412,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
|||||||
self::fillBuiltInFormatCodes();
|
self::fillBuiltInFormatCodes();
|
||||||
|
|
||||||
// Lookup format code
|
// Lookup format code
|
||||||
if (array_key_exists($formatCode, self::$_flippedBuiltInFormats)) {
|
if (isset(self::$_flippedBuiltInFormats[$formatCode])) {
|
||||||
return self::$_flippedBuiltInFormats[$formatCode];
|
return self::$_flippedBuiltInFormats[$formatCode];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,8 +957,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
|
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
|
||||||
$this->_cachedHighestColumn = $aCoordinates[0];
|
$this->_cachedHighestColumn = $aCoordinates[0];
|
||||||
|
|
||||||
if ($this->_cachedHighestRow < $aCoordinates[1])
|
$this->_cachedHighestRow = max($this->_cachedHighestRow,$aCoordinates[1]);
|
||||||
$this->_cachedHighestRow = $aCoordinates[1];
|
|
||||||
|
|
||||||
// Cell needs appropriate xfIndex
|
// Cell needs appropriate xfIndex
|
||||||
$rowDimensions = $this->getRowDimensions();
|
$rowDimensions = $this->getRowDimensions();
|
||||||
@ -998,8 +997,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
|
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
|
||||||
$this->_cachedHighestColumn = $columnLetter;
|
$this->_cachedHighestColumn = $columnLetter;
|
||||||
|
|
||||||
if ($this->_cachedHighestRow < $pRow)
|
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
||||||
$this->_cachedHighestRow = $pRow;
|
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
}
|
}
|
||||||
@ -1081,8 +1079,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
if (!isset($this->_rowDimensions[$pRow])) {
|
if (!isset($this->_rowDimensions[$pRow])) {
|
||||||
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
|
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
|
||||||
|
|
||||||
if ($this->_cachedHighestRow < $pRow)
|
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
||||||
$this->_cachedHighestRow = $pRow;
|
|
||||||
}
|
}
|
||||||
return $this->_rowDimensions[$pRow];
|
return $this->_rowDimensions[$pRow];
|
||||||
}
|
}
|
||||||
@ -2194,29 +2191,19 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// Find cells that can be cleaned
|
// Find cells that can be cleaned
|
||||||
foreach ($this->_cellCollection->getCellList() as $coord) {
|
foreach ($this->_cellCollection->getCellList() as $coord) {
|
||||||
list($col,$row) = sscanf($coord,'%[A-Z]%d');
|
list($col,$row) = sscanf($coord,'%[A-Z]%d');
|
||||||
$column = PHPExcel_Cell::columnIndexFromString($col);
|
|
||||||
|
|
||||||
// Determine highest column and row
|
// Determine highest column and row
|
||||||
if ($highestColumn < $column) {
|
$highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($col));
|
||||||
$highestColumn = $column;
|
$highestRow = max($highestRow,$row);
|
||||||
}
|
|
||||||
if ($row > $highestRow) {
|
|
||||||
$highestRow = $row;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through column dimensions
|
// Loop through column dimensions
|
||||||
foreach ($this->_columnDimensions as $dimension) {
|
foreach ($this->_columnDimensions as $dimension) {
|
||||||
if ($highestColumn < PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())) {
|
$highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
|
||||||
$highestColumn = PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through row dimensions
|
// Loop through row dimensions
|
||||||
foreach ($this->_rowDimensions as $dimension) {
|
foreach ($this->_rowDimensions as $dimension) {
|
||||||
if ($highestRow < $dimension->getRowIndex()) {
|
$highestRow = max($highestRow,$dimension->getRowIndex());
|
||||||
$highestRow = $dimension->getRowIndex();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache values
|
// Cache values
|
||||||
|
@ -395,9 +395,8 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
|||||||
|
|
||||||
case 1: // GIF, not supported by BIFF8, we convert to PNG
|
case 1: // GIF, not supported by BIFF8, we convert to PNG
|
||||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
||||||
$imageResource = imagecreatefromgif($filename);
|
|
||||||
ob_start();
|
ob_start();
|
||||||
imagepng($imageResource);
|
imagepng(imagecreatefromgif($filename));
|
||||||
$blipData = ob_get_contents();
|
$blipData = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
break;
|
break;
|
||||||
@ -414,9 +413,8 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
|||||||
|
|
||||||
case 6: // Windows DIB (BMP), we convert to PNG
|
case 6: // Windows DIB (BMP), we convert to PNG
|
||||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
||||||
$imageResource = PHPExcel_Shared_Drawing::imagecreatefrombmp($filename);
|
|
||||||
ob_start();
|
ob_start();
|
||||||
imagepng($imageResource);
|
imagepng(PHPExcel_Shared_Drawing::imagecreatefrombmp($filename));
|
||||||
$blipData = ob_get_contents();
|
$blipData = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
break;
|
break;
|
||||||
|
@ -148,7 +148,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
|
|||||||
if (strlen($data) - 4 > $this->_limit) {
|
if (strlen($data) - 4 > $this->_limit) {
|
||||||
$data = $this->_addContinue($data);
|
$data = $this->_addContinue($data);
|
||||||
}
|
}
|
||||||
$this->_data = $this->_data.$data;
|
$this->_data .= $data;
|
||||||
$this->_datasize += strlen($data);
|
$this->_datasize += strlen($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,7 +1055,7 @@ class PHPExcel_Writer_Excel5_Parser
|
|||||||
$col = 0;
|
$col = 0;
|
||||||
$col_ref_length = strlen($col_ref);
|
$col_ref_length = strlen($col_ref);
|
||||||
for ($i = 0; $i < $col_ref_length; ++$i) {
|
for ($i = 0; $i < $col_ref_length; ++$i) {
|
||||||
$col += (ord($col_ref{$i}) - ord('A') + 1) * pow(26, $expn);
|
$col += (ord($col_ref{$i}) - 64) * pow(26, $expn);
|
||||||
--$expn;
|
--$expn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1125,27 +1125,20 @@ class PHPExcel_Writer_Excel5_Parser
|
|||||||
{
|
{
|
||||||
switch($token) {
|
switch($token) {
|
||||||
case "+":
|
case "+":
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "-":
|
case "-":
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "*":
|
case "*":
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "/":
|
case "/":
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "(":
|
case "(":
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case ")":
|
case ")":
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case ",":
|
case ",":
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case ";":
|
case ";":
|
||||||
|
case ">=":
|
||||||
|
case "<=":
|
||||||
|
case "=":
|
||||||
|
case "<>":
|
||||||
|
case "^":
|
||||||
|
case "&":
|
||||||
|
case "%":
|
||||||
return $token;
|
return $token;
|
||||||
break;
|
break;
|
||||||
case ">":
|
case ">":
|
||||||
@ -1161,27 +1154,6 @@ class PHPExcel_Writer_Excel5_Parser
|
|||||||
}
|
}
|
||||||
return $token;
|
return $token;
|
||||||
break;
|
break;
|
||||||
case ">=":
|
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "<=":
|
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "=":
|
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "<>":
|
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "^":
|
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "&":
|
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
case "%":
|
|
||||||
return $token;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// if it's a reference A1 or $A$1 or $A1 or A$1
|
// if it's a reference A1 or $A$1 or $A1 or A$1
|
||||||
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
|
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
|
||||||
|
@ -242,25 +242,29 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||||||
$this->_outline_on = 1;
|
$this->_outline_on = 1;
|
||||||
|
|
||||||
// calculate values for DIMENSIONS record
|
// calculate values for DIMENSIONS record
|
||||||
$this->_firstRowIndex = 0;
|
$_firstRowIndex = 0;
|
||||||
$this->_lastRowIndex = -1;
|
$_lastRowIndex = -1;
|
||||||
$this->_firstColumnIndex = 0;
|
$_firstColumnIndex = 0;
|
||||||
$this->_lastColumnIndex = -1;
|
$_lastColumnIndex = -1;
|
||||||
|
|
||||||
foreach ($this->_phpSheet->getCellCollection(false) as $cellID) {
|
foreach ($this->_phpSheet->getCellCollection(false) as $cellID) {
|
||||||
list($col,$row) = sscanf($cellID,'%[A-Z]%d');
|
list($col,$row) = sscanf($cellID,'%[A-Z]%d');
|
||||||
$column = PHPExcel_Cell::columnIndexFromString($col) - 1;
|
$column = PHPExcel_Cell::columnIndexFromString($col) - 1;
|
||||||
|
|
||||||
// Don't break Excel!
|
// Don't break Excel!
|
||||||
if ($row + 1 > 65536 or $column + 1 > 256) {
|
if ($row >= 65536 or $column >= 256) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_firstRowIndex = min($this->_firstRowIndex, $row);
|
$_firstRowIndex = min($_firstRowIndex, $row);
|
||||||
$this->_lastRowIndex = max($this->_lastRowIndex, $row);
|
$_lastRowIndex = max($_lastRowIndex, $row);
|
||||||
$this->_firstColumnIndex = min($this->_firstColumnIndex, $column);
|
$_firstColumnIndex = min($_firstColumnIndex, $column);
|
||||||
$this->_lastColumnIndex = max($this->_lastColumnIndex, $column);
|
$_lastColumnIndex = max($_lastColumnIndex, $column);
|
||||||
}
|
}
|
||||||
|
$this->_firstRowIndex = $_firstRowIndex;
|
||||||
|
$this->_lastRowIndex = $_lastRowIndex;
|
||||||
|
$this->_firstColumnIndex = $_firstColumnIndex;
|
||||||
|
$this->_lastColumnIndex = $_lastColumnIndex;
|
||||||
|
|
||||||
$this->_countCellStyleXfs = count($phpSheet->getParent()->getCellStyleXfCollection());
|
$this->_countCellStyleXfs = count($phpSheet->getParent()->getCellStyleXfCollection());
|
||||||
}
|
}
|
||||||
@ -529,14 +533,12 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||||||
$firstCellCoordinates = PHPExcel_Cell::coordinateFromString($firstCell); // e.g. array(0, 1)
|
$firstCellCoordinates = PHPExcel_Cell::coordinateFromString($firstCell); // e.g. array(0, 1)
|
||||||
$lastCellCoordinates = PHPExcel_Cell::coordinateFromString($lastCell); // e.g. array(1, 6)
|
$lastCellCoordinates = PHPExcel_Cell::coordinateFromString($lastCell); // e.g. array(1, 6)
|
||||||
|
|
||||||
$data = pack('vvvv',
|
return(pack('vvvv',
|
||||||
$firstCellCoordinates[1] - 1,
|
$firstCellCoordinates[1] - 1,
|
||||||
$lastCellCoordinates[1] - 1,
|
$lastCellCoordinates[1] - 1,
|
||||||
PHPExcel_Cell::columnIndexFromString($firstCellCoordinates[0]) - 1,
|
PHPExcel_Cell::columnIndexFromString($firstCellCoordinates[0]) - 1,
|
||||||
PHPExcel_Cell::columnIndexFromString($lastCellCoordinates[0]) - 1
|
PHPExcel_Cell::columnIndexFromString($lastCellCoordinates[0]) - 1
|
||||||
);
|
));
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -852,8 +854,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||||||
$unknown = 0x0000; // Must be zero
|
$unknown = 0x0000; // Must be zero
|
||||||
|
|
||||||
// Strip the '=' or '@' sign at the beginning of the formula string
|
// Strip the '=' or '@' sign at the beginning of the formula string
|
||||||
if (preg_match("/^=/", $formula)) {
|
if ($formula{0} == '=') {
|
||||||
$formula = preg_replace("/(^=)/", "", $formula);
|
$formula = substr($formula,1);
|
||||||
} else {
|
} else {
|
||||||
// Error handling
|
// Error handling
|
||||||
$this->_writeString($row, $col, 'Unrecognised character for formula');
|
$this->_writeString($row, $col, 'Unrecognised character for formula');
|
||||||
|
Loading…
Reference in New Issue
Block a user