如何预先格式化Laravel Excel上的单元格

我正在使用包maatwebsite.com/excel从我的应用程序导出xls文件。 我想预先格式化单元格的date。 可能吗?

我已经格式化数据到目前为止,但我希望单元格会预先格式化为date (其默认单元格格式是general )。 我如何在PHPLaravel 4实现这个Laravel 4

你试过这个吗?

 $sheet->setColumnFormat(array( 'A' => 'yyyy-mm-dd' )); 

从文档: http : //www.maatwebsite.nl/laravel-excel/docs/export#format

不同的date格式可以在这里find: http : //www.maatwebsite.nl/laravel-excel/docs/reference-guide#formatting

列格式

要告诉Excel如何解释某些列,可以使用 – > setColumnFormat($ array)。

 Column formatting To tell Excel how it should interpret certain columns, you can use ->setColumnFormat($array). // Format column as percentage $sheet->setColumnFormat(array( 'C' => '0%' )); // Format a range with eg leading zeros $sheet->setColumnFormat(array( 'A2:K2' => '0000' )); // Set multiple column formats $sheet->setColumnFormat(array( 'B' => '0', 'D' => '0.00', 'F' => '@', 'F' => 'yyyy-mm-dd', )); 

参考: http : //www.maatwebsite.nl/laravel-excel/docs/reference-guide#sheet-properties