Exporting Bookmarks as CSV or PDF using Filament Admin Panel

Earlier we have created the Bookmark Application using Filament Admin Panel, now in this blog we will see how we can export the bookmarks.

Now to create the export functionality in Filament Admin Panel we need to find the export plugin from Plugins link in menu.

If we search the export in plugins we get the results, in this we will choose the following plugin. Here is the link of the same https://filamentphp.com/plugins/alperenersoy-export

Export Plugin(Filament Admin Panel)

Now we need to add this plugin in Bookmarks page to do so we need to install the plugin first.

composer require alperenersoy/filament-export

This command will install the filament export plugin into our application.Now we need to configure the plugin.

We need to add the following line in `/resources/app.css` file.

@import '../../vendor/alperenersoy/filament-export/resources/css/filament-export.css';

And add following code in `/resources/app.js` file.

import '../../vendor/alperenersoy/filament-export/resources/js/filament-export.js';

Now we need to run our development server by using following command.

npm run dev

After running the development server we will add the following code in table bulk actions as shown in below .

->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
                FilamentExportBulkAction::make('export'),//added this line
            
            ]);

And don’t forget to add the namespace for the same as shown in below.

use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;

Once all the changes done in resource file we can check in the browser to use export functionality.

Export Menu

Now we can see the export functionality is added in bulk actions. If we click on the export link below window will open and we need to choose from XLSX, CSV or PDF.

Export XLSX/CSV/PDF

In this window we can select/deselect the column to show/hide in excel/pdf. We can also see the preview of it by clicking on Preview button as shown in below screen.

Export Preview

In this way we have successfully added the export functionality by using plugin.