Check file handle is valid before manipulating it
This fixes issues when something went wrong on reader/writer init and the developer wants to close the reader/writer. The file handle may not be defined so we need to add a check for it, before actually using it.
This commit is contained in:
parent
71a6f6a937
commit
8bb42ebc23
@ -218,6 +218,10 @@ class Worksheet implements WorksheetInterface
|
|||||||
*/
|
*/
|
||||||
public function close()
|
public function close()
|
||||||
{
|
{
|
||||||
|
if (!is_resource($this->sheetFilePointer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fclose($this->sheetFilePointer);
|
fclose($this->sheetFilePointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,10 @@ EOD;
|
|||||||
*/
|
*/
|
||||||
public function close()
|
public function close()
|
||||||
{
|
{
|
||||||
|
if (!is_resource($this->sharedStringsFilePointer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fwrite($this->sharedStringsFilePointer, '</sst>');
|
fwrite($this->sharedStringsFilePointer, '</sst>');
|
||||||
|
|
||||||
// Replace the default strings count with the actual number of shared strings in the file header
|
// Replace the default strings count with the actual number of shared strings in the file header
|
||||||
|
@ -178,6 +178,10 @@ EOD;
|
|||||||
*/
|
*/
|
||||||
public function close()
|
public function close()
|
||||||
{
|
{
|
||||||
|
if (!is_resource($this->sheetFilePointer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fwrite($this->sheetFilePointer, '</sheetData>');
|
fwrite($this->sheetFilePointer, '</sheetData>');
|
||||||
fwrite($this->sheetFilePointer, '</worksheet>');
|
fwrite($this->sheetFilePointer, '</worksheet>');
|
||||||
fclose($this->sheetFilePointer);
|
fclose($this->sheetFilePointer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user