Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.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
在Laravel中导出到Excel时出现“不应静态调用非静态方法”错误_Excel_Laravel - Fatal编程技术网

在Laravel中导出到Excel时出现“不应静态调用非静态方法”错误

在Laravel中导出到Excel时出现“不应静态调用非静态方法”错误,excel,laravel,Excel,Laravel,网站: 出口控制器: Route::get('/export', 'ExportController@export'); 用户导出: public function export() { return Excel::download(new UserExport, 'users.xlsx'); } 应用程序: use Illuminate\Http\Request; use Maatwebsite\Excel\Excel; public function collection()

网站:

出口控制器:

Route::get('/export', 'ExportController@export');
用户导出:

public function export() {
    return Excel::download(new UserExport, 'users.xlsx');
}
应用程序:

use Illuminate\Http\Request;
use Maatwebsite\Excel\Excel;

public function collection() {
    return User::all();
}
获取此错误:

不应静态调用非静态方法Maatwebsite\Excel\Excel::download


我做错了什么?

将导出方法更改为此,我希望它能工作

'Excel' => Maatwebsite\Excel\Facades\Excel::class,
Maatwebsite\Excel\ExcelServiceProvider::class, (provider)

未测试

它不起作用。ArgumentCounter函数Maatwebsite\Excel\Excel::\uu构造的参数太少,0在第14行和第4行的E:\Xampp\htdocs\Projects\laravel\happyoutles\app\Http\Controllers\ExportController.php中传递expected@Don您可以访问Maatwebsite\Excel\Excel.php文件吗?每当我在代码编辑器vscode中键入Excel时,它会自动检测到Maatwebsite\Excel\Excel而不是Maatwebsite\Excel\Facades\Excel版本maatwebsite/excel:^3.1
public function export(){
    $export = new Excel();
    return $export->download(new UserExport, 'users.xlsx');
}