& symbol exported as & #18

Closed
opened 2026-01-16 13:50:25 +01:00 by RealZone22 · 1 comment
RealZone22 commented 2026-01-16 13:50:25 +01:00 (Migrated from git.cyanfox.de)

Fix:

    protected function export($data, $type)
    {
        $filename = config('pengutables.export_filename', 'export_'.now()->format('Ymd_Hi'));
        $exportColumns = collect($this->columns())->filter(fn ($column) => $column->hideInExport)->values()->toArray();

        $headers = collect($exportColumns)->map(fn ($column) => $column->label)->toArray();
        $rows = $data->map(function ($item) use ($exportColumns) {
            return collect($exportColumns)->map(function ($column) use ($item) {
                $value = $column->getValue($item);

                return html_entity_decode(strip_tags($value), ENT_QUOTES | ENT_HTML5, 'UTF-8');
            })->toArray();
        })->toArray();

        if (str_starts_with($type, 'csv')) {
            return $this->streamCsv($filename, $headers, $rows);
        }

        return $this->streamExcel($filename, $headers, $rows);
    }
Fix: ```php protected function export($data, $type) { $filename = config('pengutables.export_filename', 'export_'.now()->format('Ymd_Hi')); $exportColumns = collect($this->columns())->filter(fn ($column) => $column->hideInExport)->values()->toArray(); $headers = collect($exportColumns)->map(fn ($column) => $column->label)->toArray(); $rows = $data->map(function ($item) use ($exportColumns) { return collect($exportColumns)->map(function ($column) use ($item) { $value = $column->getValue($item); return html_entity_decode(strip_tags($value), ENT_QUOTES | ENT_HTML5, 'UTF-8'); })->toArray(); })->toArray(); if (str_starts_with($type, 'csv')) { return $this->streamCsv($filename, $headers, $rows); } return $this->streamExcel($filename, $headers, $rows); } ```
RealZone22 commented 2026-01-17 20:43:53 +01:00 (Migrated from git.cyanfox.de)

mentioned in merge request !19

mentioned in merge request !19
RealZone22 (Migrated from git.cyanfox.de) closed this issue 2026-01-17 20:46:11 +01:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
RealZone22/PenguTables#18
No description provided.