Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

XLSX Writer file not closed properly #190

Closed
SauloARS opened this issue Mar 23, 2016 · 1 comment
Closed

XLSX Writer file not closed properly #190

SauloARS opened this issue Mar 23, 2016 · 1 comment

Comments

@SauloARS
Copy link

Hi,

Reporting a bug: after using $writer->close(); the file is not being released.
My Code:

$writer = WriterFactory::create(Type::XLSX);
$writer->openToFile($filename);
(...)
$writer->close();
(...)
unlink($filename);

Unlink returns an error (Permission Denied). Using windows cmd del also doesn't work.
The file can be deleted after the php process finishes.

My fix was to add one line to the close() function, in Box\Spout\Writer\AbstractWriter.php

public function close()
{
    $this->closeWriter();
    $this->isWriterOpened = false;
    fclose($this->filePointer); // Added this line
}
@adrilo
Copy link
Collaborator

adrilo commented Mar 23, 2016

Good catch!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants