id, // To format as a true Excel date, pass a native PHP DateTime object or an Excel timestamp // \PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel($row->created_at), $row->created_at?->format('Y-m-d H:i'), // $row->amount, ]; } /** * Apply Excel formatting to specific columns (Dates, Currency, Percentages). */ public function columnFormats(): array { return [ // Example: Format Column B as a true Date // 'B' => NumberFormat::FORMAT_DATE_YYYYMMDD, // Example: Format Column C as Currency // 'C' => NumberFormat::FORMAT_CURRENCY_USD_SIMPLE, ]; } /** * Apply visual styling to specific rows or columns. */ public function styles(Worksheet $sheet) { return [ // Make the first row (the headings) bold 1 => ['font' => ['bold' => true]], ]; } }