Maatwebsite Excel for Laravel



我以前做过同样的事情,但是面对这段代码的错误:

Excel::create('churros_contact', function($excel){
        $excel->sheet('contact', function($sheet){
            $sheet->fromModel(Contact::all());
        });
})->export('xlsx');

它说:

ZipArchive::close((: 创建临时文件失败: 没有这样的文件或目录

在哪里可以修改目录设置?至于权限,我已经设置好了,所以应该是其他问题。.我可能错过了什么配置?

如果我更改为XLS,它不会给我错误,但它也不会下载。

 public function csvOrderstatus($id)  
{
    $result = DB::table('order')->where('id',$id)->first();  // the data you want to download as csv
    $csv = (array)$result;  // stored the data in a array
    return Excel::create('csvfile', function ($excel) use ($csv) {
        $excel->sheet('mySheet', function ($sheet) use ($csv) {
            $sheet->fromArray($csv);
        });
    })->download('xls');
}

这对我有用。希望这对您有所帮助。

最新更新