Skip to content

Commit

Permalink
[fixes #132] Don't treat headers as regular rows (so style can be app…
Browse files Browse the repository at this point in the history
…lied to the header) in case of XLS
  • Loading branch information
llowinge authored and alperen ersoy committed Sep 21, 2024
1 parent 883636a commit 8dfb1b1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/FilamentExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ public function download(): StreamedResponse
return response()->streamDownload(function () {
$headers = $this->getAllColumns()->map(fn ($column) => ($column->getLabel() instanceof HtmlString ? strip_tags($column->getLabel()) : $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()}");
}
Expand Down

0 comments on commit 8dfb1b1

Please sign in to comment.