Introducing Laravel Nova Excel 🚀

At Maatwebsite we love Laravel! Of course we couldn’t wait to get our hands on Laravel Nova! We can tell you… the wait was worth it! Considering our primary open source focus is Laravel Excel, we couldn’t stay behind and now introduce you Laravel Nova Excel.

🚀 5 Minute quick start

Laravel Nova Excel integrates Laravel Nova resources and Laravel Excel seamlessly. Integration is as easy as adding one class to your list of resource actions!

💡 Installing Laravel Excel Nova

Before integrating this package, make sure you have Laravel Nova installed. Then install maatwebsite/laravel-nova-excel via composer. This will download the package and Laravel-Excel.

composer require maatwebsite/laravel-nova-excel

💪 Supercharging your resource

Go to your Nova resource. As example we’ll use the app/Nova/User.php. Add Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel action to your actions() list.

<?php

namespace App\Nova;

use Illuminate\Http\Request;
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;

class User extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = 'App\\User';

// Other default resource methods

/**
* Get the actions available for the resource.
*
* @param \Illuminate\Http\Request $request
*
* @return array
*/
public function actions(Request $request)
{
return [
new DownloadExcel(),
];
}
}

🔥 Download it!

Go to your resource in your Nova admin panel, select all or some users and click “Download Excel”.

📄 Check your users.xlsx

In your downloads folder you will find your users.xlsx! The name of the file is auto-generated based on the plural form of the resource name. But of course this is fully configurable!

public function actions(Request $request)
{
return [
(new DownloadExcel())->withFilename('users-2018.xlsx'),
];
}

Prefer your customer to choose the filename themselves? No problem! Use the askForFilename method to prompt a question after clicking “Download Excel”.

public function actions(Request $request)
{
return [
(new DownloadExcel())->askForFilename(),
];
}

🔧 Customizing your exports

As Laravel Nova Excel delegates all the heavy-lifting to Laravel Excel, it’s also possible to customize your entire export.

You can read more about it in our dedicated documentation: https://laravel-excel.maatwebsite.nl/nova/1.0/getting-started/


Do you need help with integrating Laravel (Nova) Excel or do you need help building a Laravel application? We are there to help you on a commercial basis. Contact us via info@maatwebsite.nl or via phone +31 (0)10 744 9312 to discuss the possibilities.


Written by Patrick Brouwers