Skip to content

Commit 245a1dc

Browse files
author
Mark Baker
committed
__destroy methods for Excel and Worksheet objects
1 parent 4e8dea7 commit 245a1dc

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Classes/PHPExcel.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function __construct()
133133
*
134134
*/
135135
public function disconnectWorksheets() {
136+
$worksheet = NULL;
136137
foreach($this->_workSheetCollection as $k => &$worksheet) {
137138
$worksheet->disconnectCells();
138139
$this->_workSheetCollection[$k] = null;
@@ -141,6 +142,14 @@ public function disconnectWorksheets() {
141142
$this->_workSheetCollection = array();
142143
}
143144

145+
/**
146+
* Code to execute when this worksheet is unset()
147+
*
148+
*/
149+
function __destruct() {
150+
$this->disconnectWorksheets();
151+
}
152+
144153
/**
145154
* Get properties
146155
*

Classes/PHPExcel/Worksheet.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,23 @@ public function __construct(PHPExcel $pParent = null, $pTitle = 'Worksheet')
379379
public function disconnectCells()
380380
{
381381
$this->_cellCollection->unsetWorksheetCells();
382-
$this->_cellCollection = null;
382+
$this->_cellCollection = NULL;
383383

384384
// detach ourself from the workbook, so that it can then delete this worksheet successfully
385385
$this->_parent = null;
386386
}
387387

388388
/**
389+
* Code to execute when this worksheet is unset()
390+
*
391+
*/
392+
function __destruct() {
393+
if ($this->_cellCollection !== NULL) {
394+
$this->disconnectCells();
395+
}
396+
}
397+
398+
/**
389399
* Return the cache controller for the cell collection
390400
*
391401
* @return PHPExcel_CachedObjectStorage_xxx

0 commit comments

Comments
 (0)