Form View - Column stores only the string value(Customizing the column data type Like: Date) #3714
-
While exporting data to excel using form view, can not set the column data type as date. However, an extra single quote starter is being exported with the data. How to solve this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Following |
Beta Was this translation helpful? Give feedback.
-
First of all you need to convert your date format to Excel with - \PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel() function then you can use laravel column columnFormats() method. code : \PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel(\Carbon\Carbon::parse($item->joining_date)) to convert date at table td column. To conver date format at formView approach - |
Beta Was this translation helpful? Give feedback.
-
Thank you so much @ziadulh it worked like magic... |
Beta Was this translation helpful? Give feedback.
First of all you need to convert your date format to Excel with - \PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel() function then you can use laravel column columnFormats() method.
code :
\PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel(\Carbon\Carbon::parse($item->joining_date)) to convert date at table td column.
To conver date format at formView approach -
public function columnFormats(): array
{
return [
'A' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}