Category: Laravel

Are you looking for import and export Excel files in Laravel? In the real world, sometimes we want to export records from the application.

In this article, we study exporting and importing Excel files in your Laravel application.

public function export() { return (new FastExcel(User::all()))->download('users.xlsx', function ($user) { return [ 'Name' => $user->name, 'Email' => $user->email, ]; }); }

public function import(Request $request) { $users = (new FastExcel)->import($request->file('users'), function ($line) { return User::create([ 'name' => $line['Name'], 'email' => $line['Email']]); }); return redirect('excel')->with(['success' => "Users imported successfully."]); }
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners