This plugin is a wrapper for Maatwebsite/Laravel-Excel package. It adds convenient tools to import/export excel files.
The complete documentation can be found at: http://www.maatwebsite.nl/laravel-excel/docs
use Vdomah\Excel\Classes\Excel;
Excel::excel()->load(base_path() . '/storage/app/media/file.xlsx', function($reader) {
dd($reader);
});
To start importing a file, you can use ->load($filename). The callback is optional.
Excel::load('file.xls', function($reader) {
// Getting all results
$results = $reader->get();
// ->all() is a wrapper for ->get() and will work the same
$results = $reader->all();
});
Sheets, rows and cells are collections, this means after doing a ->get() you can use all default collection methods.
// E.g. group the results
$reader->get()->groupBy('firstname');
Getting the first sheet or row
To get the first sheet or row, you can utilise ->first().
$reader->first();