【发布时间】:2018-10-23 21:45:49
【问题描述】:
我正在使用 Laravel 5.4,我想将记录导出到 excel 文件,但出现此错误
传递给 Illuminate\Database\Eloquent\Builder::create() 的参数 1 必须是数组类型,给定字符串,在 C:\xampp\htdocs\www\vendor\laravel\framework\src\Illuminate\ 中调用Database\Eloquent\Model.php 在第 1332 行并已定义
这是我的代码:
$export = Student::all();
Excel::create('Export Excel',function($excel) use($export){
$excel->sheet('Sheet 1', function($sheet) use($export){
$sheet->fromArray($export);
});
})->download('xlsx');
$export = Student::all();
Excel::create('Export Excel',function($excel) use($export){
$excel->sheet('Sheet 1', function($sheet) use($export){
$sheet->fromArray($export);
});
})->download('xlsx');
【问题讨论】:
-
第 1332 行代码的内容是什么?