调用未定义的方法Maatwebsite \ Excel \ Excel :: load() [英] Call to undefined method Maatwebsite\Excel\Excel::load()
本文介绍了调用未定义的方法Maatwebsite \ Excel \ Excel :: load()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用maatwebsite 3.0导入Excel文件(.xlsx).如何解决此错误
I'm trying to import excel file (.xlsx) using maatwebsite 3.0. How to fix This error
调用未定义的方法Maatwebsite \ Excel \ Excel :: load()
Call to undefined method Maatwebsite\Excel\Excel::load()
我的控制器
public function importsave(Request $request)
{
if($request->hasFile('excel'))
{
$path = $request->file('excel')->getRealPath();
$data= Excel::load($path, function($reader) {})->get();
if(!empty($data) && $data->count())
{
foreach($data->toArray() as $key=>$value)
{
if(!empty($value))
{
Employee::insert($value);
}
}
}
}
}
推荐答案
该软件包的版本 3.0 尚不能处理导入.此功能的发布日期未知.请参阅此帖子以了解更多详细信息: https://medium.com/@maatwebsite/laravel-excel-lessons-learned-7fee2812551
Version 3.0 of that package doesn't handle imports yet. Release date for this feature is unknown. See this post for more details: https://medium.com/@maatwebsite/laravel-excel-lessons-learned-7fee2812551
我建议您切换到版本2.* .
这篇关于调用未定义的方法Maatwebsite \ Excel \ Excel :: load()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文