diff --git a/src/FilamentExport.php b/src/FilamentExport.php index 2899b5c..822f245 100644 --- a/src/FilamentExport.php +++ b/src/FilamentExport.php @@ -132,14 +132,15 @@ public function download(): StreamedResponse return response()->streamDownload(function () { $headers = $this->getAllColumns()->map(fn ($column) => $column->getLabel())->toArray(); - $stream = SimpleExcelWriter::streamDownload("{$this->getFileName()}.{$this->getFormat()}", $this->getFormat(), delimiter: $this->getCsvDelimiter()) - ->noHeaderRow() - ->addRows($this->getRows()->prepend($headers)); + $stream = SimpleExcelWriter::streamDownload("{$this->getFileName()}.{$this->getFormat()}", $this->getFormat(), delimiter: $this->getCsvDelimiter()); if ($modifyExcel = $this->getModifyExcelWriter()) { $stream = $modifyExcel($stream); } + $stream->addHeader($headers); + $stream->addRows($this->getRows()); + $stream->close(); }, "{$this->getFileName()}.{$this->getFormat()}"); }