diff --git a/src/PhpSpreadsheet/Worksheet/Table.php b/src/PhpSpreadsheet/Worksheet/Table.php index 1bc8dff45f..af70024fba 100644 --- a/src/PhpSpreadsheet/Worksheet/Table.php +++ b/src/PhpSpreadsheet/Worksheet/Table.php @@ -92,6 +92,14 @@ public function __construct($range = '', string $name = '') $this->setName($name); } + /** + * Code to execute when this table is unset(). + */ + public function __destruct() + { + $this->workSheet = null; + } + /** * Get Table name. */ diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 008b5c7bf0..a904c8f62b 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -444,7 +444,7 @@ public function __destruct() $this->disconnectCells(); $this->rowDimensions = []; - //$this->removeTableCollection(); // problem with phpunit10 + $this->tableCollection = new ArrayObject(); } /**