Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GodziLaravel's avatar

How to set date type when make an excel export using Laravel Excel?

Hello.

First I'm using maatwebsite/excel version 3.1.

Laravel 8.

I'm wondering if it's possible to set the column type to date when I export.

            return Excel::download(
                new  RoExport(
                    collect($resultArray)
                        ->sortBy(
                            ['employee_fullname']
                        )->toArray(),
                    $request->exportType),
                'file_name.xls');

Here the dd($resultArray) result :

array:49 [▼
  0 => {#1685 ▼
    +"employee_fullname": "aaa bbbb"
    +"user_id": 1161
    +"plannings_to_month": "December 2022"
    +"project": "Excellence en fiabilité"
    +"is_funded": "Is not funded"
    +"total_working_days": "22.00000000000000000000"
    +"possible_working_days": 22
    +"percentage": 100.0
  

My question is : plannings_to_month attribute is the date value but I'm wondering I should change it in the controller or if there is a way in maatwebsite/excel to set the column type ?

Thanks

0 likes
1 reply

Please or to participate in this conversation.