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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners