Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在laravel 5.3中导出表格时,使用“时间”分隔日期;maatwebsite/excel“文件:&引用;“2.1”;_Php_Mysql_Excel_Eloquent_Laravel 5.3 - Fatal编程技术网

Php 在laravel 5.3中导出表格时,使用“时间”分隔日期;maatwebsite/excel“文件:&引用;“2.1”;

Php 在laravel 5.3中导出表格时,使用“时间”分隔日期;maatwebsite/excel“文件:&引用;“2.1”;,php,mysql,excel,eloquent,laravel-5.3,Php,Mysql,Excel,Eloquent,Laravel 5.3,当我将数据从表格导出到excel文件时,在日期部分,我将以以下格式获取日期加时间: 2016-09-02 00:00:00 但我希望date部分仅显示如下所示的日期,例如: 2016-09-02 没有时间 下面是我将表格数据导出到excel工作表的代码 public function export_records(){ $date = Carbon::today()->toDateString(); $nc24_export = nc24form_model::whe

当我将数据从表格导出到excel文件时,在日期部分,我将以以下格式获取日期加时间:

2016-09-02 00:00:00
但我希望date部分仅显示如下所示的日期,例如:

2016-09-02
没有时间

下面是我将表格数据导出到excel工作表的代码

public function export_records(){
    $date = Carbon::today()->toDateString();

    $nc24_export = nc24form_model::where('created_at', '>=', Carbon::now()->subDays(7))->get();
    Excel::create('Weekly Report' . $date , function($excel) use($nc24_export){
        $excel->sheet('sheet 1', function($sheet) use($nc24_export){
            $sheet->fromArray($nc24_export);

        });
    })->export('xlsx');

}
试试看

试试看

$sheet->setColumnFormat(['A'=>'@']);