Skip to content

Commit

Permalink
Check if we can clear the output buffer before cleaning (fixes #4090
Browse files Browse the repository at this point in the history
…#4901)
  • Loading branch information
patrickbrouwers authored Feb 20, 2024
1 parent c35a38e commit 33f9732
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Excel.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ public function __construct(
public function download($export, string $fileName, string $writerType = null, array $headers = [])
{
// Clear output buffer to prevent stuff being prepended to the Excel output.
ob_end_clean();
ob_start();
if ( ob_get_length() > 0 ) {
ob_end_clean();
ob_start();
}

return response()->download(
$this->export($export, $fileName, $writerType)->getLocalPath(),
Expand Down

0 comments on commit 33f9732

Please sign in to comment.