传递给 Maatwebsite\Excel\Excel::download() 的参数 2 必须是字符串类型,给定的对象,在 C:\xampp\htdocs\student_route\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade 中调用第 237 行的 .php
public function excel_report()
{
$student_data = DB::table('student_details')->get()->toArray();
$student_array[] = array('Name', 'Address', 'Roll No', 'Class');
foreach($student_data as $student)
{
$student_array[] = array(
'Student Name' => $student->st_name,
'Address' => $student->address,
'Roll No' => $student->roll_no,
'Class' => $student->st_class
);
}
Excel::download('Student_Data', function($excel) use ($student_array){
$excel->setTitle('Student Datas');
$excel->sheet('Student_Datass', function($sheet) use ($student_array){
$sheet->fromArray($student_array, null, 'A1', false, false);
});
})->download('xlsx');
}
我收到错误参数 2 传递给 Maatwebsite\Excel\Excel::download() must be of the type string, object given.不知道问题出在哪里。任何人请检查。我正在使用 Laravel 5.8