Merge pull request #199 from box/check_valid_resource_on_close

Check file handle is valid before manipulating it
This commit is contained in:
Adrien Loison 2016-04-12 11:03:15 -07:00
commit e9cd7a397e
3 changed files with 12 additions and 0 deletions

View File

@ -218,6 +218,10 @@ class Worksheet implements WorksheetInterface
*/
public function close()
{
if (!is_resource($this->sheetFilePointer)) {
return;
}
fclose($this->sheetFilePointer);
}
}

View File

@ -88,6 +88,10 @@ EOD;
*/
public function close()
{
if (!is_resource($this->sharedStringsFilePointer)) {
return;
}
fwrite($this->sharedStringsFilePointer, '</sst>');
// Replace the default strings count with the actual number of shared strings in the file header

View File

@ -178,6 +178,10 @@ EOD;
*/
public function close()
{
if (!is_resource($this->sheetFilePointer)) {
return;
}
fwrite($this->sheetFilePointer, '</sheetData>');
fwrite($this->sheetFilePointer, '</worksheet>');
fclose($this->sheetFilePointer);