mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-23 05:46:06 +03:00
Minor performance tweak
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@63742 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
9c9657a2e2
commit
012348ac4a
@ -2317,11 +2317,9 @@ class PHPExcel_Calculation {
|
|||||||
if ($resize == 2) {
|
if ($resize == 2) {
|
||||||
// Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger
|
// Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger
|
||||||
self::_resizeMatricesExtend($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
|
self::_resizeMatricesExtend($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
|
||||||
// self::_resizeMatricesExtend($operand1,$operand2);
|
|
||||||
} elseif ($resize == 1) {
|
} elseif ($resize == 1) {
|
||||||
// Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller
|
// Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller
|
||||||
self::_resizeMatricesShrink($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
|
self::_resizeMatricesShrink($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
|
||||||
// self::_resizeMatricesShrink($operand1,$operand2);
|
|
||||||
}
|
}
|
||||||
} // function _checkMatrixOperands()
|
} // function _checkMatrixOperands()
|
||||||
|
|
||||||
@ -2355,10 +2353,6 @@ class PHPExcel_Calculation {
|
|||||||
* @param mixed &$matrix2 Second matrix operand
|
* @param mixed &$matrix2 Second matrix operand
|
||||||
*/
|
*/
|
||||||
private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
|
private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
|
||||||
// private static function _resizeMatricesShrink(&$matrix1,&$matrix2) {
|
|
||||||
// list($matrix1Rows,$matrix1Columns) = self::_getMatrixDimensions($matrix1);
|
|
||||||
// list($matrix2Rows,$matrix2Columns) = self::_getMatrixDimensions($matrix2);
|
|
||||||
|
|
||||||
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
|
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
|
||||||
if ($matrix2Columns < $matrix1Columns) {
|
if ($matrix2Columns < $matrix1Columns) {
|
||||||
for ($i = 0; $i < $matrix1Rows; ++$i) {
|
for ($i = 0; $i < $matrix1Rows; ++$i) {
|
||||||
@ -2398,10 +2392,6 @@ class PHPExcel_Calculation {
|
|||||||
* @param mixed &$matrix2 Second matrix operand
|
* @param mixed &$matrix2 Second matrix operand
|
||||||
*/
|
*/
|
||||||
private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
|
private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
|
||||||
// private static function _resizeMatricesExtend(&$matrix1,&$matrix2) {
|
|
||||||
// list($matrix1Rows,$matrix1Columns) = self::_getMatrixDimensions($matrix1);
|
|
||||||
// list($matrix2Rows,$matrix2Columns) = self::_getMatrixDimensions($matrix2);
|
|
||||||
|
|
||||||
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
|
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
|
||||||
if ($matrix2Columns < $matrix1Columns) {
|
if ($matrix2Columns < $matrix1Columns) {
|
||||||
for ($i = 0; $i < $matrix2Rows; ++$i) {
|
for ($i = 0; $i < $matrix2Rows; ++$i) {
|
||||||
|
@ -140,7 +140,7 @@ class PHPExcel_Cell
|
|||||||
$this->_parent = $pSheet;
|
$this->_parent = $pSheet;
|
||||||
|
|
||||||
// Set datatype?
|
// Set datatype?
|
||||||
if (!is_null($pDataType)) {
|
if ($pDataType !== NULL) {
|
||||||
$this->_dataType = $pDataType;
|
$this->_dataType = $pDataType;
|
||||||
} else {
|
} else {
|
||||||
if (!self::getValueBinder()->bindValue($this, $pValue)) {
|
if (!self::getValueBinder()->bindValue($this, $pValue)) {
|
||||||
@ -280,10 +280,10 @@ class PHPExcel_Cell
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($this->_value)) {
|
// if (is_null($this->_value)) {
|
||||||
// echo 'Cell '.$this->getCoordinate().' has no value, formula or otherwise<br />';
|
// echo 'Cell '.$this->getCoordinate().' has no value, formula or otherwise<br />';
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
|
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
|
||||||
return $this->_value;
|
return $this->_value;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
|
|||||||
*/
|
*/
|
||||||
public function save($pFilename = null)
|
public function save($pFilename = null)
|
||||||
{
|
{
|
||||||
if (!is_null($this->_spreadSheet)) {
|
if ($this->_spreadSheet !== NULL) {
|
||||||
// garbage collect
|
// garbage collect
|
||||||
$this->_spreadSheet->garbageCollect();
|
$this->_spreadSheet->garbageCollect();
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
|
|||||||
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
|
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
|
||||||
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
|
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
|
||||||
$customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet);
|
$customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet);
|
||||||
if (!is_null($customPropertiesPart)) {
|
if ($customPropertiesPart !== NULL) {
|
||||||
$objZip->addFromString('docProps/custom.xml', $customPropertiesPart);
|
$objZip->addFromString('docProps/custom.xml', $customPropertiesPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function getPHPExcel() {
|
public function getPHPExcel() {
|
||||||
if (!is_null($this->_spreadSheet)) {
|
if ($this->_spreadSheet !== NULL) {
|
||||||
return $this->_spreadSheet;
|
return $this->_spreadSheet;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("No PHPExcel assigned.");
|
throw new Exception("No PHPExcel assigned.");
|
||||||
@ -503,7 +503,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
|
|||||||
public function setUseDiskCaching($pValue = false, $pDirectory = null) {
|
public function setUseDiskCaching($pValue = false, $pDirectory = null) {
|
||||||
$this->_useDiskCaching = $pValue;
|
$this->_useDiskCaching = $pValue;
|
||||||
|
|
||||||
if (!is_null($pDirectory)) {
|
if ($pDirectory !== NULL) {
|
||||||
if (is_dir($pDirectory)) {
|
if (is_dir($pDirectory)) {
|
||||||
$this->_diskCachingDirectory = $pDirectory;
|
$this->_diskCachingDirectory = $pDirectory;
|
||||||
} else {
|
} else {
|
||||||
|
@ -934,12 +934,11 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
|
|||||||
*/
|
*/
|
||||||
private function _writeCell(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pCellAddress = null, $pStringTable = null, $pFlippedStringTable = null)
|
private function _writeCell(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pCellAddress = null, $pStringTable = null, $pFlippedStringTable = null)
|
||||||
{
|
{
|
||||||
$pCell = $pSheet->getCell($pCellAddress);
|
|
||||||
|
|
||||||
if (is_array($pStringTable) && is_array($pFlippedStringTable)) {
|
if (is_array($pStringTable) && is_array($pFlippedStringTable)) {
|
||||||
// Cell
|
// Cell
|
||||||
|
$pCell = $pSheet->getCell($pCellAddress);
|
||||||
$objWriter->startElement('c');
|
$objWriter->startElement('c');
|
||||||
$objWriter->writeAttribute('r', $pCell->getCoordinate());
|
$objWriter->writeAttribute('r', $pCellAddress);
|
||||||
|
|
||||||
// Sheet styles
|
// Sheet styles
|
||||||
if ($pCell->getXfIndex() != '') {
|
if ($pCell->getXfIndex() != '') {
|
||||||
@ -947,18 +946,15 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If cell value is supplied, write cell value
|
// If cell value is supplied, write cell value
|
||||||
if (is_object($pCell->getValue()) || $pCell->getValue() !== '') {
|
$cellValue = $pCell->getValue();
|
||||||
|
if (is_object($cellValue) || $cellValue !== '') {
|
||||||
// Map type
|
// Map type
|
||||||
$mappedType = $pCell->getDataType();
|
$mappedType = $pCell->getDataType();
|
||||||
|
|
||||||
// Write data type depending on its type
|
// Write data type depending on its type
|
||||||
switch (strtolower($mappedType)) {
|
switch (strtolower($mappedType)) {
|
||||||
case 'inlinestr': // Inline string
|
case 'inlinestr': // Inline string
|
||||||
$objWriter->writeAttribute('t', $mappedType);
|
|
||||||
break;
|
|
||||||
case 's': // String
|
case 's': // String
|
||||||
$objWriter->writeAttribute('t', $mappedType);
|
|
||||||
break;
|
|
||||||
case 'b': // Boolean
|
case 'b': // Boolean
|
||||||
$objWriter->writeAttribute('t', $mappedType);
|
$objWriter->writeAttribute('t', $mappedType);
|
||||||
break;
|
break;
|
||||||
@ -967,7 +963,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
|
|||||||
if ($this->getParentWriter()->getPreCalculateFormulas()) {
|
if ($this->getParentWriter()->getPreCalculateFormulas()) {
|
||||||
$calculatedValue = $pCell->getCalculatedValue();
|
$calculatedValue = $pCell->getCalculatedValue();
|
||||||
} else {
|
} else {
|
||||||
$calculatedValue = $pCell->getValue();
|
$calculatedValue = $cellValue;
|
||||||
}
|
}
|
||||||
if (is_string($calculatedValue)) {
|
if (is_string($calculatedValue)) {
|
||||||
$objWriter->writeAttribute('t', 'str');
|
$objWriter->writeAttribute('t', 'str');
|
||||||
@ -980,22 +976,22 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
|
|||||||
// Write data depending on its type
|
// Write data depending on its type
|
||||||
switch (strtolower($mappedType)) {
|
switch (strtolower($mappedType)) {
|
||||||
case 'inlinestr': // Inline string
|
case 'inlinestr': // Inline string
|
||||||
if (! $pCell->getValue() instanceof PHPExcel_RichText) {
|
if (! $cellValue instanceof PHPExcel_RichText) {
|
||||||
$objWriter->writeElement('t', PHPExcel_Shared_String::ControlCharacterPHP2OOXML( htmlspecialchars($pCell->getValue()) ) );
|
$objWriter->writeElement('t', PHPExcel_Shared_String::ControlCharacterPHP2OOXML( htmlspecialchars($cellValue) ) );
|
||||||
} else if ($pCell->getValue() instanceof PHPExcel_RichText) {
|
} else if ($cellValue instanceof PHPExcel_RichText) {
|
||||||
$objWriter->startElement('is');
|
$objWriter->startElement('is');
|
||||||
$this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $pCell->getValue());
|
$this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 's': // String
|
case 's': // String
|
||||||
if (! $pCell->getValue() instanceof PHPExcel_RichText) {
|
if (! $cellValue instanceof PHPExcel_RichText) {
|
||||||
if (isset($pFlippedStringTable[$pCell->getValue()])) {
|
if (isset($pFlippedStringTable[$cellValue])) {
|
||||||
$objWriter->writeElement('v', $pFlippedStringTable[$pCell->getValue()]);
|
$objWriter->writeElement('v', $pFlippedStringTable[$cellValue]);
|
||||||
}
|
}
|
||||||
} else if ($pCell->getValue() instanceof PHPExcel_RichText) {
|
} else if ($cellValue instanceof PHPExcel_RichText) {
|
||||||
$objWriter->writeElement('v', $pFlippedStringTable[$pCell->getValue()->getHashCode()]);
|
$objWriter->writeElement('v', $pFlippedStringTable[$cellValue->getHashCode()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1004,20 +1000,19 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
|
|||||||
if($attributes['t'] == 'array') {
|
if($attributes['t'] == 'array') {
|
||||||
$objWriter->startElement('f');
|
$objWriter->startElement('f');
|
||||||
$objWriter->writeAttribute('t', 'array');
|
$objWriter->writeAttribute('t', 'array');
|
||||||
$objWriter->writeAttribute('ref', $pCell->getCoordinate());
|
$objWriter->writeAttribute('ref', $pCellAddress);
|
||||||
$objWriter->writeAttribute('aca', '1');
|
$objWriter->writeAttribute('aca', '1');
|
||||||
$objWriter->writeAttribute('ca', '1');
|
$objWriter->writeAttribute('ca', '1');
|
||||||
$objWriter->text(substr($pCell->getValue(), 1));
|
$objWriter->text(substr($cellValue, 1));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
} else {
|
} else {
|
||||||
$objWriter->writeElement('f', substr($pCell->getValue(), 1));
|
$objWriter->writeElement('f', substr($cellValue, 1));
|
||||||
}
|
}
|
||||||
if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
|
if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
|
||||||
if ($this->getParentWriter()->getPreCalculateFormulas()) {
|
if ($this->getParentWriter()->getPreCalculateFormulas()) {
|
||||||
$calculatedValue = $pCell->getCalculatedValue();
|
$calculatedValue = $pCell->getCalculatedValue();
|
||||||
if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') {
|
if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') {
|
||||||
$v = PHPExcel_Shared_String::FormatNumber($calculatedValue);
|
$objWriter->writeElement('v', PHPExcel_Shared_String::FormatNumber($calculatedValue));
|
||||||
$objWriter->writeElement('v', $v);
|
|
||||||
} else {
|
} else {
|
||||||
$objWriter->writeElement('v', '0');
|
$objWriter->writeElement('v', '0');
|
||||||
}
|
}
|
||||||
@ -1028,18 +1023,17 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
|
|||||||
break;
|
break;
|
||||||
case 'n': // Numeric
|
case 'n': // Numeric
|
||||||
// force point as decimal separator in case current locale uses comma
|
// force point as decimal separator in case current locale uses comma
|
||||||
$v = str_replace(',', '.', $pCell->getValue());
|
$objWriter->writeElement('v', str_replace(',', '.', $cellValue));
|
||||||
$objWriter->writeElement('v', $v);
|
|
||||||
break;
|
break;
|
||||||
case 'b': // Boolean
|
case 'b': // Boolean
|
||||||
$objWriter->writeElement('v', ($pCell->getValue() ? '1' : '0'));
|
$objWriter->writeElement('v', ($cellValue ? '1' : '0'));
|
||||||
break;
|
break;
|
||||||
case 'e': // Error
|
case 'e': // Error
|
||||||
if (substr($pCell->getValue(), 0, 1) == '=') {
|
if (substr($cellValue, 0, 1) == '=') {
|
||||||
$objWriter->writeElement('f', substr($pCell->getValue(), 1));
|
$objWriter->writeElement('f', substr($cellValue, 1));
|
||||||
$objWriter->writeElement('v', substr($pCell->getValue(), 1));
|
$objWriter->writeElement('v', substr($cellValue, 1));
|
||||||
} else {
|
} else {
|
||||||
$objWriter->writeElement('v', $pCell->getValue());
|
$objWriter->writeElement('v', $cellValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user