diff --git a/src/Spout/Writer/ODS/Internal/Worksheet.php b/src/Spout/Writer/ODS/Internal/Worksheet.php index 3a65726..f0544f0 100644 --- a/src/Spout/Writer/ODS/Internal/Worksheet.php +++ b/src/Spout/Writer/ODS/Internal/Worksheet.php @@ -218,6 +218,10 @@ class Worksheet implements WorksheetInterface */ public function close() { + if (!is_resource($this->sheetFilePointer)) { + return; + } + fclose($this->sheetFilePointer); } } diff --git a/src/Spout/Writer/XLSX/Helper/SharedStringsHelper.php b/src/Spout/Writer/XLSX/Helper/SharedStringsHelper.php index a17493a..9d9639d 100644 --- a/src/Spout/Writer/XLSX/Helper/SharedStringsHelper.php +++ b/src/Spout/Writer/XLSX/Helper/SharedStringsHelper.php @@ -88,6 +88,10 @@ EOD; */ public function close() { + if (!is_resource($this->sharedStringsFilePointer)) { + return; + } + fwrite($this->sharedStringsFilePointer, ''); // Replace the default strings count with the actual number of shared strings in the file header diff --git a/src/Spout/Writer/XLSX/Internal/Worksheet.php b/src/Spout/Writer/XLSX/Internal/Worksheet.php index 3ffd97b..af3fbc4 100644 --- a/src/Spout/Writer/XLSX/Internal/Worksheet.php +++ b/src/Spout/Writer/XLSX/Internal/Worksheet.php @@ -178,6 +178,10 @@ EOD; */ public function close() { + if (!is_resource($this->sheetFilePointer)) { + return; + } + fwrite($this->sheetFilePointer, ''); fwrite($this->sheetFilePointer, ''); fclose($this->sheetFilePointer);