# How to export data to excel in Laravel 8


![Export Laravel Excel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whzmfut4kqf1rg88v0e3.png)

## Export Data to Excel Files in Laravel 8

Today I am Going To Explain to you how you can Export Excel  Files in Laravel 8.

I am going to use [Tech-Admin Panel](https://techtoolindia.hashnode.dev/how-to-create-admin-panel-in-laravel-8) for this.

For Exporting an excel file I am using [Laravel Excel](https://laravel-excel.com/).

You can read about 
[Laravel Import From CSV/ Excel Files Here!](https://techtoolindia.hashnode.dev/how-to-import-excel-csv-files-into-laravel-8)

## Step 1 - Installation
To Install the [Laravel Excel](https://laravel-excel.com/) Package via composer run command below.
```php
composer require maatwebsite/excel
```

Next to export config file you need run command below.
```php
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config
```

## Step 2 - Create an Exports Class inside `app/Exports`

Create Exports Class by using artisan command

```php
php artisan make:export UsersExport --model=User
```

## Step 3 - Handle Export To Excel Function
```php
public function export() 
{
   return Excel::download(new UsersExport, 'users.xlsx');
}
```

You can watch the explanation video for more clarity.

%[https://www.youtube.com/watch?v=_tRwyCCQ9dQ]

Thank You for Reading

In case of any query related to LARAVEL.

Reach Out To me.
[Twitter](https://twitter.com/techtoolindia)
[Instagram](https://www.instagram.com/techtoolindia/)
[YouTube](https://www.youtube.com/channel/UCOy6o08Yn9DtXMKqxhD9ivA)
