hero

Laravel Excel

Supercharged Excel exports and imports in Laravel

Read documentation →

💪 Export to Excel.

Supercharge your Laravel collections or Blade views and export them directly to an Excel or CSV document. Exporting has never been so easy.

🚀 Supercharged exports.

Export queries with automatic chunking for better performance. For even more superpowers, exports can also be queued.

🔥 Supercharged imports.

Import workbooks and worksheets to Eloquent models with chunk reading and batch inserts! You can also queue every chunk of a file! Your entire import will happen in the background.

💡 Install the package via composer.

composer require maatwebsite/excel
1

💪 Create an export and import class.

php artisan make:export UsersExport --model=App\\User
php artisan make:import UsersImport --model=App\\User
1
2

🔥 Download your export and import your file.

<?php 

use App\Exports\UsersExport;
use App\Imports\UsersImport;
use Maatwebsite\Excel\Facades\Excel;
use App\Http\Controllers\Controller;

class UsersController extends Controller 
{
    public function export() 
    {
        return Excel::download(new UsersExport, 'users.xlsx');
    }
    
    public function import() 
    {
        return Excel::import(new UsersImport, 'users.xlsx');
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19