Minor performance/memory tweaks to the Excel2007 Writer

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@65356 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2010-12-15 17:19:30 +00:00
parent ad3d9dc853
commit f71aeebd30
3 changed files with 21 additions and 12 deletions

View File

@ -140,7 +140,9 @@ class PHPExcel_Cell
$this->_parent = $pSheet;
// Set datatype?
if ($pDataType !== NULL) {
if ($pDataType !== null) {
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
$this->_dataType = $pDataType;
} else {
if (!self::getValueBinder()->bindValue($this, $pValue)) {
@ -624,8 +626,7 @@ class PHPExcel_Cell
// Extract range
if (strpos($pRange, ':') === false) {
$rangeA = $pRange;
$rangeB = $pRange;
$rangeA = $rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
}

View File

@ -54,7 +54,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
*
* @var PHPExcel_Writer_Excel2007_WriterPart[]
*/
private $_writerParts;
private $_writerParts = array();
/**
* Private PHPExcel
@ -68,7 +68,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
*
* @var string[]
*/
private $_stringTable;
private $_stringTable = array();
/**
* Private unique PHPExcel_Style_Conditional HashTable
@ -124,7 +124,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
*
* @var string
*/
private $_diskCachingDirectory;
private $_diskCachingDirectory = './';
/**
* Create a new PHPExcel_Writer_Excel2007
@ -136,9 +136,6 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
// Assign PHPExcel
$this->setPHPExcel($pPHPExcel);
// Set up disk caching location
$this->_diskCachingDirectory = './';
$writerPartsArray = array( 'stringtable' => 'PHPExcel_Writer_Excel2007_StringTable',
'contenttypes' => 'PHPExcel_Writer_Excel2007_ContentTypes',
'docprops' => 'PHPExcel_Writer_Excel2007_DocProps',
@ -154,8 +151,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
// Initialise writer parts
// and Assign their parent IWriters
foreach ($writerPartsArray as $writer => $class) {
$this->_writerParts[$writer] = new $class();
$this->_writerParts[$writer]->setParentWriter($this);
$this->_writerParts[$writer] = new $class($this);
}
$hashTablesArray = array( '_stylesConditionalHashTable', '_fillHashTable', '_fontHashTable',
@ -163,7 +159,6 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
);
// Set HashTable variables
$this->_stringTable = array();
foreach ($hashTablesArray as $tableName) {
$this->$tableName = new PHPExcel_HashTable();
}

View File

@ -65,4 +65,17 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart
throw new Exception("No parent PHPExcel_Writer_IWriter assigned.");
}
}
/**
* Set parent IWriter object
*
* @param PHPExcel_Writer_IWriter $pWriter
* @throws Exception
*/
public function __construct(PHPExcel_Writer_IWriter $pWriter = null) {
if (!is_null($pWriter)) {
$this->_parentWriter = $pWriter;
}
}
}