Laravel Excel Export-类型错误:传递给Maatwebsite \ Excel \ Excel :: download()的参数2必须为字符串类型

时间:2019-11-13 17:40:20

标签: php excel laravel

在我的 StudentController 上:

//data collection
$all_students= Student::with('Customer')->where('std', $name)->get();

//create a new array
$student_array[] = array();

//loop and set array indexes
foreach ($all_studentsas $student)
        {
            $student_array[] = array(
                'description' => $student['description'],
                'cost'       => $student['cost']
            );
        }

return Excel::download('Student_Data', function ($excel) {

                    $excel->setTitle('Student Data');
                    $excel->sheet('Student_Data', function ($sheet) {
                        $sheet->fromArray($student_array);
                    });
                })->download('xls');

我尝试了很多solutions,但无法解决此问题

  

类型错误:参数2传递给Maatwebsite \ Excel \ Excel :: download()   必须是字符串类型,给定对象,在   C:\ xampp \ htdocs \ project \ vendor \ laravel \ framework \ src \ Illuminate \ Support \ Facades \ Facade.php   在第221行

有人可以指出我在这里做错了什么,我应该怎么做才能解决此问题?

0 个答案:

没有答案