Call to undefined method MaatwebsiteExcelExcel::load()(调用未定义的方法 MaatwebsiteExcelExcel::load())
问题描述
我正在尝试使用 maatwebsite 3.0 导入 excel 文件 (.xlsx).如何修复此错误
I'm trying to import excel file (.xlsx) using maatwebsite 3.0. How to fix This error
调用未定义的方法 MaatwebsiteExcelExcel::load()
Call to undefined method MaatwebsiteExcelExcel::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.*.
否则你想继续所有 Laravel Excel 2.* 方法均已弃用,无法在 3.0 中使用.
Else you want to continue further ALL Laravel Excel 2.* methods are deprecated and will not be able to use in 3.0 .
Excel::load() is removed and replaced by Excel::import($yourImport)
Excel::create() is removed and replaced by Excel::download/Excel::store($yourExport)
Excel::create()->string('xlsx') is removed an replaced by Excel::raw($yourExport, Excel::XLSX)
3.0 没有提供方便的样式方法,鼓励您使用 PhpSpreadsheets 原生方法.
3.0 provides no convenience methods for styling, you are encouraged to use PhpSpreadsheets native methods.
这篇关于调用未定义的方法 MaatwebsiteExcelExcel::load()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:调用未定义的方法 MaatwebsiteExcelExcel::load()


- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01