Home > Back-end >  How to generate an Excel file based on MYSQL columns using Laravel
How to generate an Excel file based on MYSQL columns using Laravel

Time:10-13

I want to generate an Excel template based on the column of a MySQL database. I want the worksheets to be the columns of the Excel file.

How can I achieve that. I am using Laravel

CodePudding user response:

You can use Maatwebsite

It's an excellent package to use excel sheets in Laravel. Go through it's documentation

CodePudding user response:

You should look for a library that does that for you on Packagist.

For example, with maatwebsite/excel, here is a summary of the quick start guide:

  1. Create an exporter (automatically as shown or manually as in the doc)
php artisan make:export UsersExport --model=User
  1. Call it where you need it:
Excel::download(new UsersExport, 'users.xlsx');
  1. Look for users.xlsx in /downloads
  • Related