4
$file = $request->file('excel');
$reader = Excel::load($file->getRealPath())->get();

The following error appears:

Call to undefined method Maatwebsite\Excel\Facades\Excel::load()

I am using Maatwebsite 3 in laravel 5.7

  • to get load or to get excel data as array you can refer [this question](https://stackoverflow.com/q/54902966/2815635) – Niklesh Raut Feb 28 '19 at 12:28

3 Answers3

3

The load method has been removed as quoted in the las post, however it has been already implemented in 3.1 version.

Excel::load() is removed and replaced by Excel::import($yourImport)

Checkout this link

Personally, I ended it up using Excel::toColletion($file) though.

3

^3.0 versions of maatwebsite/excel does not support loads. Delete the config/excel.php file first .

Downgrade the maatwebsite/excel version by changing your composer.json "maatwebsite/excel": "^3.1", to "maatwebsite/excel": "~2.1.0" perform composer update.

And if you get an error "Undefined class constant 'XLSX' in 2.1 version",this is what you have to do .

delete the config/excel.php before downgrading

then perform composer update.

Mahdi Bashirpour
  • 17,147
  • 12
  • 117
  • 144
Aravind
  • 191
  • 2
  • 10
2

The load method has been removed in version 3.0 (may be re-added in 3.1). Please refer the upgrade guide

ALL Laravel Excel 2.* methods are deprecated and will not be able to use in 3.0 .

  1. Excel::load() is removed and will not be re-added until 3.1
  2. Excel::create() is removed and replaced by Excel::download/Excel::store($yourExport)
  3. v3.0 provides no convenience methods for styling, you are encouraged to use PhpSpreadsheets native methods.
Paras
  • 9,258
  • 31
  • 55