mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-22 21:36:05 +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
|
||||
*/
|
||||
public function updateCacheData(PHPExcel_Cell $cell) {
|
||||
$pCoord = $cell->getCoordinate();
|
||||
|
||||
return $this->addCacheData($pCoord,$cell);
|
||||
return $this->addCacheData($cell->getCoordinate(),$cell);
|
||||
} // function updateCacheData()
|
||||
|
||||
|
||||
|
@ -2335,10 +2335,7 @@ class PHPExcel_Calculation {
|
||||
$matrixRows = count($matrix);
|
||||
$matrixColumns = 0;
|
||||
foreach($matrix as $rowKey => $rowValue) {
|
||||
$colCount = count($rowValue);
|
||||
if ($colCount > $matrixColumns) {
|
||||
$matrixColumns = $colCount;
|
||||
}
|
||||
$matrixColumns = max(count($rowValue),$matrixColumns);
|
||||
if (!is_array($rowValue)) {
|
||||
$matrix[$rowKey] = array($rowValue);
|
||||
} else {
|
||||
@ -2678,11 +2675,11 @@ class PHPExcel_Calculation {
|
||||
// }
|
||||
$output[] = $d; // Dump the argument count on 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 />';
|
||||
$expectedArgumentCount = self::$_controlFunctions[$functionName]['argumentCount'];
|
||||
$functionCall = self::$_controlFunctions[$functionName]['functionCall'];
|
||||
} elseif (array_key_exists($functionName, self::$_PHPExcelFunctions)) {
|
||||
} elseif (isset(self::$_PHPExcelFunctions[$functionName])) {
|
||||
// echo 'PHPExcel function '.$functionName.'<br />';
|
||||
$expectedArgumentCount = self::$_PHPExcelFunctions[$functionName]['argumentCount'];
|
||||
$functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
|
||||
@ -2773,7 +2770,7 @@ class PHPExcel_Calculation {
|
||||
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
|
||||
$val = preg_replace('/\s/','',$val);
|
||||
// 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));
|
||||
$ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch);
|
||||
if ($ax) {
|
||||
@ -2855,7 +2852,7 @@ class PHPExcel_Calculation {
|
||||
// echo 'Casting '.$val.' to integer<br />';
|
||||
$val = (integer) $val;
|
||||
}
|
||||
} elseif (array_key_exists(trim(strtoupper($val)), self::$_ExcelConstants)) {
|
||||
} elseif (isset(self::$_ExcelConstants[trim(strtoupper($val))])) {
|
||||
$excelConstant = trim(strtoupper($val));
|
||||
// echo 'Element '.$excelConstant.' is an Excel Constant<br />';
|
||||
$val = self::$_ExcelConstants[$excelConstant];
|
||||
@ -3189,12 +3186,12 @@ class PHPExcel_Calculation {
|
||||
if ($functionName != 'MKMATRIX') {
|
||||
$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 (array_key_exists($functionName, self::$_PHPExcelFunctions)) {
|
||||
if ((isset(self::$_PHPExcelFunctions[$functionName])) || (isset(self::$_controlFunctions[$functionName]))) { // function
|
||||
if (isset(self::$_PHPExcelFunctions[$functionName])) {
|
||||
$functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
|
||||
$passByReference = isset(self::$_PHPExcelFunctions[$functionName]['passByReference']);
|
||||
$passCellReference = isset(self::$_PHPExcelFunctions[$functionName]['passCellReference']);
|
||||
} elseif (array_key_exists($functionName, self::$_controlFunctions)) {
|
||||
} elseif (isset(self::$_controlFunctions[$functionName])) {
|
||||
$functionCall = self::$_controlFunctions[$functionName]['functionCall'];
|
||||
$passByReference = isset(self::$_controlFunctions[$functionName]['passByReference']);
|
||||
$passCellReference = isset(self::$_controlFunctions[$functionName]['passCellReference']);
|
||||
@ -3278,7 +3275,7 @@ class PHPExcel_Calculation {
|
||||
|
||||
} else {
|
||||
// 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);
|
||||
// echo 'Token is a PHPExcel constant: '.$excelConstant.'<br />';
|
||||
$stack->push('Constant Value',self::$_ExcelConstants[$excelConstant]);
|
||||
@ -3521,7 +3518,7 @@ class PHPExcel_Calculation {
|
||||
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
|
||||
$pRange = $pSheet->getTitle().'!'.$pRange;
|
||||
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])) {
|
||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
|
||||
} else {
|
||||
@ -3531,7 +3528,7 @@ class PHPExcel_Calculation {
|
||||
// Extract cell data
|
||||
foreach ($aReferences as $reference) {
|
||||
// Extract range
|
||||
list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference);
|
||||
list($currentCol,$currentRow) = sscanf($reference,'%[A-Z]%d');
|
||||
|
||||
if ($pSheet->cellExists($reference)) {
|
||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
|
||||
|
@ -484,8 +484,8 @@ class PHPExcel_Cell
|
||||
} else if ($pCoordinateString == '') {
|
||||
throw new Exception('Cell coordinate can not be zero-length string.');
|
||||
} else if (preg_match("/([$]?[A-Z]+)([$]?\d+)/", $pCoordinateString, $matches)) {
|
||||
list(, $column, $row) = $matches;
|
||||
return array($column, $row);
|
||||
array_shift($matches);
|
||||
return $matches;
|
||||
} else {
|
||||
throw new Exception('Invalid cell coordinate.');
|
||||
}
|
||||
@ -518,7 +518,8 @@ class PHPExcel_Cell
|
||||
public static function splitRange($pRange = 'A1:A1')
|
||||
{
|
||||
$exploded = explode(',', $pRange);
|
||||
for ($i = 0; $i < count($exploded); ++$i) {
|
||||
$counter = count($exploded);
|
||||
for ($i = 0; $i < $counter; ++$i) {
|
||||
$exploded[$i] = explode(':', $exploded[$i]);
|
||||
}
|
||||
return $exploded;
|
||||
@ -540,7 +541,8 @@ class PHPExcel_Cell
|
||||
|
||||
// Build range
|
||||
$imploded = array();
|
||||
for ($i = 0; $i < count($pRange); ++$i) {
|
||||
$counter = count($pRange);
|
||||
for ($i = 0; $i < $counter; ++$i) {
|
||||
$pRange[$i] = implode(':', $pRange[$i]);
|
||||
}
|
||||
$imploded = implode(',', $pRange);
|
||||
@ -622,22 +624,24 @@ class PHPExcel_Cell
|
||||
*/
|
||||
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,
|
||||
'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);
|
||||
// Convert column to integer
|
||||
if ($strLen == 1) {
|
||||
return $lookup[$pString];
|
||||
return $_columnLookup[$pString];
|
||||
} elseif ($strLen == 2) {
|
||||
return $lookup[$pString{0}] * 26 + $lookup[$pString{1}];
|
||||
return $_columnLookup[$pString[0]] * 26 + $_columnLookup[$pString[1]];
|
||||
} 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 {
|
||||
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
|
||||
if ($pColumnIndex < 26) {
|
||||
return chr(65 + $pColumnIndex);
|
||||
}
|
||||
if ($pColumnIndex < 702) {
|
||||
} elseif ($pColumnIndex < 702) {
|
||||
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);
|
||||
@ -672,60 +675,41 @@ class PHPExcel_Cell
|
||||
$returnValue = array();
|
||||
|
||||
// Explode spaces
|
||||
$aExplodeSpaces = explode(' ', str_replace('$', '', strtoupper($pRange)));
|
||||
foreach ($aExplodeSpaces as $explodedSpaces) {
|
||||
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
|
||||
foreach ($cellBlocks as $cellBlock) {
|
||||
// Single cell?
|
||||
if (strpos($explodedSpaces,':') === false && strpos($explodedSpaces,',') === false) {
|
||||
$col = 'A';
|
||||
$row = 1;
|
||||
list($col, $row) = PHPExcel_Cell::coordinateFromString($explodedSpaces);
|
||||
|
||||
if (strlen($col) <= 2) {
|
||||
$returnValue[] = $explodedSpaces;
|
||||
}
|
||||
|
||||
if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) {
|
||||
$returnValue[] = $cellBlock;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Range...
|
||||
$range = PHPExcel_Cell::splitRange($explodedSpaces);
|
||||
for ($i = 0; $i < count($range); ++$i) {
|
||||
$ranges = PHPExcel_Cell::splitRange($cellBlock);
|
||||
foreach($ranges as $range) {
|
||||
// Single cell?
|
||||
if (count($range[$i]) == 1) {
|
||||
$col = 'A';
|
||||
$row = 1;
|
||||
list($col, $row) = PHPExcel_Cell::coordinateFromString($range[$i]);
|
||||
|
||||
if (strlen($col) <= 2) {
|
||||
$returnValue[] = $explodedSpaces;
|
||||
}
|
||||
if (count($range) == 1) {
|
||||
$returnValue[] = $range[0];
|
||||
continue;
|
||||
}
|
||||
|
||||
// Range...
|
||||
$rangeStart = $rangeEnd = '';
|
||||
$startingCol = $startingRow = $endingCol = $endingRow = 0;
|
||||
|
||||
list($rangeStart, $rangeEnd) = $range[$i];
|
||||
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);
|
||||
list($rangeStart, $rangeEnd) = $range;
|
||||
list($startCol, $startRow) = sscanf($rangeStart,'%[A-Z]%d');
|
||||
list($endCol, $endRow) = sscanf($rangeEnd,'%[A-Z]%d');
|
||||
$endCol++;
|
||||
|
||||
// Current data
|
||||
$currentCol = --$startingCol;
|
||||
$currentRow = $startingRow;
|
||||
$currentCol = $startCol;
|
||||
$currentRow = $startRow;
|
||||
|
||||
// Loop cells
|
||||
while ($currentCol < $endingCol) {
|
||||
$loopColumn = PHPExcel_Cell::stringFromColumnIndex($currentCol);
|
||||
while ($currentRow <= $endingRow) {
|
||||
$returnValue[] = $loopColumn.$currentRow;
|
||||
while ($currentCol != $endCol) {
|
||||
while ($currentRow <= $endRow) {
|
||||
$returnValue[] = $currentCol.$currentRow;
|
||||
++$currentRow;
|
||||
}
|
||||
++$currentCol;
|
||||
$currentRow = $startingRow;
|
||||
$currentRow = $startRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1278,7 +1278,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||
private function _readDefault()
|
||||
{
|
||||
$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
|
||||
$this->_pos += 4 + $length;
|
||||
@ -1337,7 +1337,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||
private function _readFilepass()
|
||||
{
|
||||
$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
|
||||
$this->_pos += 4 + $length;
|
||||
@ -5869,7 +5869,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||
$b = ord($rgb{2});
|
||||
|
||||
// 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);
|
||||
}
|
||||
@ -6021,17 +6021,17 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||
$rknumhigh = $this->_GetInt4d($data, 4);
|
||||
$rknumlow = $this->_GetInt4d($data, 0);
|
||||
$sign = ($rknumhigh & 0x80000000) >> 31;
|
||||
$exp = ($rknumhigh & 0x7ff00000) >> 20;
|
||||
$exp = (($rknumhigh & 0x7ff00000) >> 20) - 1023;
|
||||
$mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
|
||||
$mantissalow1 = ($rknumlow & 0x80000000) >> 31;
|
||||
$mantissalow2 = ($rknumlow & 0x7fffffff);
|
||||
$value = $mantissa / pow( 2 , (20 - ($exp - 1023)));
|
||||
$value = $mantissa / pow( 2 , (20 - $exp));
|
||||
|
||||
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) {
|
||||
$value = -1 * $value;
|
||||
}
|
||||
@ -6078,9 +6078,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||
$string = $this->_uncompressByteString($string);
|
||||
}
|
||||
|
||||
$result = PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', 'UTF-16LE');
|
||||
|
||||
return $result;
|
||||
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', 'UTF-16LE');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -6092,7 +6090,8 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||
private function _uncompressByteString($string)
|
||||
{
|
||||
$uncompressedString = '';
|
||||
for ($i = 0; $i < strlen($string); ++$i) {
|
||||
$strLen = strlen($string);
|
||||
for ($i = 0; $i < $strLen; ++$i) {
|
||||
$uncompressedString .= $string[$i] . "\0";
|
||||
}
|
||||
|
||||
@ -6107,8 +6106,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||
*/
|
||||
private function _decodeCodepage($string)
|
||||
{
|
||||
$result = PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $this->_codepage);
|
||||
return $result;
|
||||
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $this->_codepage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -6157,17 +6155,17 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||
{
|
||||
if ($color <= 0x07 || $color >= 0x40) {
|
||||
// special built-in color
|
||||
$color = $this->_mapBuiltInColor($color);
|
||||
return $this->_mapBuiltInColor($color);
|
||||
} else if (isset($this->_palette) && isset($this->_palette[$color - 8])) {
|
||||
// palette color, color index 0x08 maps to pallete index 0
|
||||
$color = $this->_palette[$color - 8];
|
||||
return $this->_palette[$color - 8];
|
||||
} else {
|
||||
// default color table
|
||||
if ($this->_version == self::XLS_BIFF8) {
|
||||
$color = $this->_mapColor($color);
|
||||
return $this->_mapColor($color);
|
||||
} else {
|
||||
// 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'
|
||||
|
||||
if ($activeSheet->cellExists($selectedCell)) {
|
||||
$cell = $activeSheet->getCell($selectedCell);
|
||||
$xfIndex = $cell->getXfIndex();
|
||||
$xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex();
|
||||
} else {
|
||||
$xfIndex = 0;
|
||||
}
|
||||
|
||||
$activeStyle = $this->_parent->getCellXfByIndex($xfIndex);
|
||||
return $activeStyle;
|
||||
return $this->_parent->getCellXfByIndex($xfIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,8 +268,6 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
$pRange = strtoupper($pRange);
|
||||
|
||||
// Is it a cell range or a single cell?
|
||||
$rangeA = '';
|
||||
$rangeB = '';
|
||||
if (strpos($pRange, ':') === false) {
|
||||
$rangeA = $pRange;
|
||||
$rangeB = $pRange;
|
||||
|
@ -393,7 +393,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
self::fillBuiltInFormatCodes();
|
||||
|
||||
// Lookup format code
|
||||
if (array_key_exists($pIndex, self::$_builtInFormats)) {
|
||||
if (isset(self::$_builtInFormats[$pIndex])) {
|
||||
return self::$_builtInFormats[$pIndex];
|
||||
}
|
||||
|
||||
@ -412,7 +412,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
self::fillBuiltInFormatCodes();
|
||||
|
||||
// Lookup format code
|
||||
if (array_key_exists($formatCode, self::$_flippedBuiltInFormats)) {
|
||||
if (isset(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]))
|
||||
$this->_cachedHighestColumn = $aCoordinates[0];
|
||||
|
||||
if ($this->_cachedHighestRow < $aCoordinates[1])
|
||||
$this->_cachedHighestRow = $aCoordinates[1];
|
||||
$this->_cachedHighestRow = max($this->_cachedHighestRow,$aCoordinates[1]);
|
||||
|
||||
// Cell needs appropriate xfIndex
|
||||
$rowDimensions = $this->getRowDimensions();
|
||||
@ -998,8 +997,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
|
||||
$this->_cachedHighestColumn = $columnLetter;
|
||||
|
||||
if ($this->_cachedHighestRow < $pRow)
|
||||
$this->_cachedHighestRow = $pRow;
|
||||
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
||||
|
||||
return $cell;
|
||||
}
|
||||
@ -1081,8 +1079,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
if (!isset($this->_rowDimensions[$pRow])) {
|
||||
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
|
||||
|
||||
if ($this->_cachedHighestRow < $pRow)
|
||||
$this->_cachedHighestRow = $pRow;
|
||||
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
||||
}
|
||||
return $this->_rowDimensions[$pRow];
|
||||
}
|
||||
@ -2194,29 +2191,19 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
// Find cells that can be cleaned
|
||||
foreach ($this->_cellCollection->getCellList() as $coord) {
|
||||
list($col,$row) = sscanf($coord,'%[A-Z]%d');
|
||||
$column = PHPExcel_Cell::columnIndexFromString($col);
|
||||
|
||||
// Determine highest column and row
|
||||
if ($highestColumn < $column) {
|
||||
$highestColumn = $column;
|
||||
}
|
||||
if ($row > $highestRow) {
|
||||
$highestRow = $row;
|
||||
}
|
||||
$highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($col));
|
||||
$highestRow = max($highestRow,$row);
|
||||
}
|
||||
|
||||
// Loop through column dimensions
|
||||
foreach ($this->_columnDimensions as $dimension) {
|
||||
if ($highestColumn < PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())) {
|
||||
$highestColumn = PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex());
|
||||
}
|
||||
$highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
|
||||
}
|
||||
|
||||
// Loop through row dimensions
|
||||
foreach ($this->_rowDimensions as $dimension) {
|
||||
if ($highestRow < $dimension->getRowIndex()) {
|
||||
$highestRow = $dimension->getRowIndex();
|
||||
}
|
||||
$highestRow = max($highestRow,$dimension->getRowIndex());
|
||||
}
|
||||
|
||||
// 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
|
||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
||||
$imageResource = imagecreatefromgif($filename);
|
||||
ob_start();
|
||||
imagepng($imageResource);
|
||||
imagepng(imagecreatefromgif($filename));
|
||||
$blipData = ob_get_contents();
|
||||
ob_end_clean();
|
||||
break;
|
||||
@ -414,9 +413,8 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
||||
|
||||
case 6: // Windows DIB (BMP), we convert to PNG
|
||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
||||
$imageResource = PHPExcel_Shared_Drawing::imagecreatefrombmp($filename);
|
||||
ob_start();
|
||||
imagepng($imageResource);
|
||||
imagepng(PHPExcel_Shared_Drawing::imagecreatefrombmp($filename));
|
||||
$blipData = ob_get_contents();
|
||||
ob_end_clean();
|
||||
break;
|
||||
|
@ -32,7 +32,7 @@
|
||||
// * The majority of this is _NOT_ my code. I simply ported it from the
|
||||
// * PERL Spreadsheet::WriteExcel module.
|
||||
// *
|
||||
// * The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
// * The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
// * <jmcnamara@cpan.org>
|
||||
// *
|
||||
// * I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
@ -148,8 +148,8 @@ class PHPExcel_Writer_Excel5_BIFFwriter
|
||||
if (strlen($data) - 4 > $this->_limit) {
|
||||
$data = $this->_addContinue($data);
|
||||
}
|
||||
$this->_data = $this->_data.$data;
|
||||
$this->_datasize += strlen($data);
|
||||
$this->_data .= $data;
|
||||
$this->_datasize += strlen($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +164,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
|
||||
$data = $this->_addContinue($data);
|
||||
}
|
||||
$this->_datasize += strlen($data);
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$length = 0x0010;
|
||||
|
||||
// by inspection of real files, MS Office Excel 2007 writes the following
|
||||
// by inspection of real files, MS Office Excel 2007 writes the following
|
||||
$unknown = pack("VV", 0x000100D1, 0x00000406);
|
||||
|
||||
$build = 0x0DBB;
|
||||
|
@ -1055,7 +1055,7 @@ class PHPExcel_Writer_Excel5_Parser
|
||||
$col = 0;
|
||||
$col_ref_length = strlen($col_ref);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1125,27 +1125,20 @@ class PHPExcel_Writer_Excel5_Parser
|
||||
{
|
||||
switch($token) {
|
||||
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;
|
||||
case ";":
|
||||
case ">=":
|
||||
case "<=":
|
||||
case "=":
|
||||
case "<>":
|
||||
case "^":
|
||||
case "&":
|
||||
case "%":
|
||||
return $token;
|
||||
break;
|
||||
case ">":
|
||||
@ -1161,27 +1154,6 @@ class PHPExcel_Writer_Excel5_Parser
|
||||
}
|
||||
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;
|
||||
case "%":
|
||||
return $token;
|
||||
break;
|
||||
default:
|
||||
// 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
|
||||
|
@ -242,25 +242,29 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
||||
$this->_outline_on = 1;
|
||||
|
||||
// calculate values for DIMENSIONS record
|
||||
$this->_firstRowIndex = 0;
|
||||
$this->_lastRowIndex = -1;
|
||||
$this->_firstColumnIndex = 0;
|
||||
$this->_lastColumnIndex = -1;
|
||||
$_firstRowIndex = 0;
|
||||
$_lastRowIndex = -1;
|
||||
$_firstColumnIndex = 0;
|
||||
$_lastColumnIndex = -1;
|
||||
|
||||
foreach ($this->_phpSheet->getCellCollection(false) as $cellID) {
|
||||
list($col,$row) = sscanf($cellID,'%[A-Z]%d');
|
||||
$column = PHPExcel_Cell::columnIndexFromString($col) - 1;
|
||||
|
||||
// Don't break Excel!
|
||||
if ($row + 1 > 65536 or $column + 1 > 256) {
|
||||
if ($row >= 65536 or $column >= 256) {
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_firstRowIndex = min($this->_firstRowIndex, $row);
|
||||
$this->_lastRowIndex = max($this->_lastRowIndex, $row);
|
||||
$this->_firstColumnIndex = min($this->_firstColumnIndex, $column);
|
||||
$this->_lastColumnIndex = max($this->_lastColumnIndex, $column);
|
||||
$_firstRowIndex = min($_firstRowIndex, $row);
|
||||
$_lastRowIndex = max($_lastRowIndex, $row);
|
||||
$_firstColumnIndex = min($_firstColumnIndex, $column);
|
||||
$_lastColumnIndex = max($_lastColumnIndex, $column);
|
||||
}
|
||||
$this->_firstRowIndex = $_firstRowIndex;
|
||||
$this->_lastRowIndex = $_lastRowIndex;
|
||||
$this->_firstColumnIndex = $_firstColumnIndex;
|
||||
$this->_lastColumnIndex = $_lastColumnIndex;
|
||||
|
||||
$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)
|
||||
$lastCellCoordinates = PHPExcel_Cell::coordinateFromString($lastCell); // e.g. array(1, 6)
|
||||
|
||||
$data = pack('vvvv',
|
||||
return(pack('vvvv',
|
||||
$firstCellCoordinates[1] - 1,
|
||||
$lastCellCoordinates[1] - 1,
|
||||
PHPExcel_Cell::columnIndexFromString($firstCellCoordinates[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
|
||||
|
||||
// Strip the '=' or '@' sign at the beginning of the formula string
|
||||
if (preg_match("/^=/", $formula)) {
|
||||
$formula = preg_replace("/(^=)/", "", $formula);
|
||||
if ($formula{0} == '=') {
|
||||
$formula = substr($formula,1);
|
||||
} else {
|
||||
// Error handling
|
||||
$this->_writeString($row, $col, 'Unrecognised character for formula');
|
||||
|
Loading…
Reference in New Issue
Block a user