Are you using Maatwebsite\Excel\Facades\Excel ?
Problem in export option using maatwebsite/laravel
Guys I have installed the package maatwebsite for my project to make an export to excel and pdf. My laravel version is 5.6 After installing I used these coding for my project
controller
public function downloadExcel($type)
{
$data = Sales_details::get()->toArray();
return Excel::load($data, function($excel) use ($data) {
$excel->sheet('mySheet', function($sheet) use ($data)
{
$sheet->fromArray($data);
});
})->download($type);
}
But when I click the button it shows an error
Call to undefined method Maatwebsite\Excel\Excel::load()
I refferd in net and found that it is version problem maatwebsite version 2 only supports load() function Maatwebsite version 3 supports store() function.
So I changed load() to store() now it show the error
Type error: Argument 2 passed to Maatwebsite\Excel\Excel::store() must be of the type string, object given, called in D:\XAMPP\htdocs\Laravel\milkfarm\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 221
Whats the mistake kindly suggest. Is the sytax I right else where can I get the new version syntax for Maatwebsite version 3
kindly suggest any related videos or links please
@version is the only reason for this problem..
So better use "maatwebsite/excel": "~2.1.0" version
if we simply give
composer require maatwebsite/excel
it download the latest version 3
so directly give it
"maatwebsite/excel": "~2.1.0"
like this in your composer.json and update the composer.json file
there may some other solution. but i rectified and solved my problem is by doing like this
Please or to participate in this conversation.