Excel Export with Date Column

Hello, I am trying to use the Actions to export data to Excel (CSV). The function works great except when including a DateTime column. When I include any DateTime column in the export, it returns a blank export. I've also tried to use the formatStateUsing() function to ensure it's converting to a string, with no luck. I've looked through the docs and don't see any information specific to Date or DateTime fields when exporting to Excel. Has anyone else run into this issue and know how to solve? Or is this a known field type that can't be exported and I'm just not seeing that?
class MailchimpExport extends Exporter
{
protected static ?string $model = EventAttendance::class;

/**
* Export columns.
*/
public static function getColumns(): array
{
return [
ExportColumn::make('attendee_email')
->label('Email Address'),
ExportColumn::make('attendee_name_first')
->label('First Name'),
ExportColumn::make('attendee_name_last')
->label('Last Name'),
ExportColumn::make('attendee_company')
->label('Company'),
ExportColumn::make('attendee_title')
->label('Title'),
ExportColumn::make('get_profession.title')
->label('Profession'),
ExportColumn::make('pronouns')
->label('What are your pronouns?'),
ExportColumn::make('event.chapters')
->label('What groups are you interested in hearing about?')
->formatStateUsing(function ($state): ?string {
return implode('; ', $state->pluck('title')->toArray());
}),
ExportColumn::make('eventbrite_order_timestamp')
->label('Test')
->formatStateUsing(function ($state): ?string {
return $state->toISOString();
}),
];
}
class MailchimpExport extends Exporter
{
protected static ?string $model = EventAttendance::class;

/**
* Export columns.
*/
public static function getColumns(): array
{
return [
ExportColumn::make('attendee_email')
->label('Email Address'),
ExportColumn::make('attendee_name_first')
->label('First Name'),
ExportColumn::make('attendee_name_last')
->label('Last Name'),
ExportColumn::make('attendee_company')
->label('Company'),
ExportColumn::make('attendee_title')
->label('Title'),
ExportColumn::make('get_profession.title')
->label('Profession'),
ExportColumn::make('pronouns')
->label('What are your pronouns?'),
ExportColumn::make('event.chapters')
->label('What groups are you interested in hearing about?')
->formatStateUsing(function ($state): ?string {
return implode('; ', $state->pluck('title')->toArray());
}),
ExportColumn::make('eventbrite_order_timestamp')
->label('Test')
->formatStateUsing(function ($state): ?string {
return $state->toISOString();
}),
];
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server