@alcinos You should pass a date object that the package recommends.
Use the WithMapping implementation and pass the package's Date object to the sheet:
Use PhpOffice\PhpSpreadsheet\Shared\Date;
class TestExport implements FromQuery, WithHeadings, ShouldAutoSize, WithStyles, WithColumnFormatting, WithMapping
{
use Exportable;
// ...
public function map($row): array
{
return [
Date::dateTimeToExcel($row->datnum),
];
}
public function columnFormats(): array {
return [
'A' => NumberFormat::FORMAT_DATE_DDMMYYYY
];
}
// ...
}
You'll likely find the above a satisfactory solution, as you may find yourself needing to use mapping more times than not. Unless you're lucky and can get away with directly dumping from your database, but in my experience, almost every time I'll need to resort to mapping for some kind of conditional logic.