Skip to content

Commit

Permalink
Merge pull request #134 from lukasinko/strip-html-labels
Browse files Browse the repository at this point in the history
Strip tags from HTML labels
  • Loading branch information
alperenersoy authored Sep 21, 2024
2 parents f633035 + 0089a20 commit 883636a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/FilamentExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\HtmlString;
use Spatie\SimpleExcel\SimpleExcelWriter;
use Symfony\Component\HttpFoundation\StreamedResponse;

Expand Down Expand Up @@ -130,7 +131,7 @@ public function download(): StreamedResponse
}

return response()->streamDownload(function () {
$headers = $this->getAllColumns()->map(fn ($column) => $column->getLabel())->toArray();
$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()
Expand Down

0 comments on commit 883636a

Please sign in to comment.