__destroy methods for Excel and Worksheet objects

This commit is contained in:
Mark Baker 2013-02-13 09:01:36 +00:00
parent 4e8dea7883
commit 245a1dc832
2 changed files with 20 additions and 1 deletions

View File

@ -133,6 +133,7 @@ class PHPExcel
*
*/
public function disconnectWorksheets() {
$worksheet = NULL;
foreach($this->_workSheetCollection as $k => &$worksheet) {
$worksheet->disconnectCells();
$this->_workSheetCollection[$k] = null;
@ -141,6 +142,14 @@ class PHPExcel
$this->_workSheetCollection = array();
}
/**
* Code to execute when this worksheet is unset()
*
*/
function __destruct() {
$this->disconnectWorksheets();
}
/**
* Get properties
*

View File

@ -379,13 +379,23 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function disconnectCells()
{
$this->_cellCollection->unsetWorksheetCells();
$this->_cellCollection = null;
$this->_cellCollection = NULL;
// detach ourself from the workbook, so that it can then delete this worksheet successfully
$this->_parent = null;
}
/**
* Code to execute when this worksheet is unset()
*
*/
function __destruct() {
if ($this->_cellCollection !== NULL) {
$this->disconnectCells();
}
}
/**
* Return the cache controller for the cell collection
*
* @return PHPExcel_CachedObjectStorage_xxx