Fix – Call to undefined method maatwebsite\excel\excel::create()

If you are getting call to undefined method maatwebsite\excel\excel::create() error, this article will help you fix the issue. If you are getting the above error…

The post Fix – Call to undefined method maatwebsite\excel\excel::create() appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Deven

If you are getting call to undefined method maatwebsite\excel\excel::create() error, this article will help you fix the issue.

If you are getting the above error while trying to add providers and aliases like in the code example below:

"php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "maatwebsite/excel": "^3.1",
        "predis/predis": "^1.1",
        "uxweb/sweet-alert": "^2.0"
Controller:

use Excel;

    public function export_list()
    {
      Excel::create('Export data', function($excel) {

      $excel->sheet('Sheet', function($sheet) {
      $data = User::where('city','ygn')->get();

       $sheet->fromArray($data);
      });
    })->download('xls');
    }

it can be easily fixed by using Excel::download() or Excel::store(). since  ::create has been removed in the latest release.

please note that ALL Laravel Excel 2.* methods are deprecated and will not be able to use in 3.0. Consider the example below:

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)

The post Fix – Call to undefined method maatwebsite\excel\excel::create() appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Deven


Print Share Comment Cite Upload Translate Updates
APA

Deven | Sciencx (2021-02-26T15:20:08+00:00) Fix – Call to undefined method maatwebsite\excel\excel::create(). Retrieved from https://www.scien.cx/2021/02/26/fix-call-to-undefined-method-maatwebsiteexcelexcelcreate/

MLA
" » Fix – Call to undefined method maatwebsite\excel\excel::create()." Deven | Sciencx - Friday February 26, 2021, https://www.scien.cx/2021/02/26/fix-call-to-undefined-method-maatwebsiteexcelexcelcreate/
HARVARD
Deven | Sciencx Friday February 26, 2021 » Fix – Call to undefined method maatwebsite\excel\excel::create()., viewed ,<https://www.scien.cx/2021/02/26/fix-call-to-undefined-method-maatwebsiteexcelexcelcreate/>
VANCOUVER
Deven | Sciencx - » Fix – Call to undefined method maatwebsite\excel\excel::create(). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/26/fix-call-to-undefined-method-maatwebsiteexcelexcelcreate/
CHICAGO
" » Fix – Call to undefined method maatwebsite\excel\excel::create()." Deven | Sciencx - Accessed . https://www.scien.cx/2021/02/26/fix-call-to-undefined-method-maatwebsiteexcelexcelcreate/
IEEE
" » Fix – Call to undefined method maatwebsite\excel\excel::create()." Deven | Sciencx [Online]. Available: https://www.scien.cx/2021/02/26/fix-call-to-undefined-method-maatwebsiteexcelexcelcreate/. [Accessed: ]
rf:citation
» Fix – Call to undefined method maatwebsite\excel\excel::create() | Deven | Sciencx | https://www.scien.cx/2021/02/26/fix-call-to-undefined-method-maatwebsiteexcelexcelcreate/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.