Exporting as PDF does't save with correct .pdf extension #220

Closed
opened 2025-02-20 10:26:59 +00:00 by jimiero · 2 comments
jimiero commented 2025-02-20 10:26:59 +00:00 (Migrated from github.com)

Hello,

When i try to export as pdf it returns the file with .dompdf extension instead of .pdf

This is the code i'm using

ExcelExport::make()->withWriterType(\Maatwebsite\Excel\Excel::DOMPDF)->label('PDF')->fromTable()->withFilename(class_basename(get_class(($this)))),

@pxlrbt any idea how I can make it to save as .pdf ?

Hello, When i try to export as pdf it returns the file with .dompdf extension instead of .pdf This is the code i'm using ```php ExcelExport::make()->withWriterType(\Maatwebsite\Excel\Excel::DOMPDF)->label('PDF')->fromTable()->withFilename(class_basename(get_class(($this)))), ``` @pxlrbt any idea how I can make it to save as .pdf ?
jimiero commented 2025-02-20 11:04:46 +00:00 (Migrated from github.com)

My bad, i've did it wrong the naming on ->withFilename

using

->withFilename(class_basename(get_class($this)) . '.pdf')

does the job

My bad, i've did it wrong the naming on ->withFilename using ```php ->withFilename(class_basename(get_class($this)) . '.pdf') ``` does the job
pxlrbt commented 2025-02-20 12:11:27 +00:00 (Migrated from github.com)

It's because of the getDefaultExtension() logic:

return $this->getWriterType() ? strtolower($this->getWriterType()) : 'xlsx';

But as you figured out, you can work around this by adding an extension yourself.

It's because of the `getDefaultExtension()` logic: `return $this->getWriterType() ? strtolower($this->getWriterType()) : 'xlsx';` But as you figured out, you can work around this by adding an extension yourself.
Sign in to join this conversation.
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
pxlrbt/filament-excel#220
No description provided.