In this lesson, we will use Laravel Excel package to export selected products into CSV, XLSX, and PDF.
Let's start by adding three buttons, which will trigger the export() method in the Livewire component.
resources/views/livewire/products-list.blade.php:
<div class="mb-4"> <div class="mb-4"> <a class="inline-flex items-center px-4 py-2 text-xs font-semibold tracking-widest text-white uppercase bg-gray-800 rounded-md border border-transparent hover:bg-gray-700"> Create Product </a> </div> <button type="button" wire:click="deleteConfirm('deleteSelected')" wire:loading.attr="disabled" @disabled(! $this->selectedCount) class="px-4 py-2 mr-5 text-xs text-red-500 uppercase bg-red-200 rounded-md border border-transparent hover:text-red-700 hover:bg-red-300 disabled:opacity-50 disabled:cursor-not-allowed"> Delete Selected </button> <x-primary-button wire:click="export('csv')">CSV</x-primary-button> <x-primary-button wire:click="export('xlsx')">XLSX</x-primary-button> <x-primary-button wire:click="export('pdf')">PDF</x-primary-button> </div>

Next, we need to install the Laravel Excel package and create Export...
Hey Povilas, I try to export with every method but data need to be selected. if not selected the export file is empy. How to export all data withoud be selected? Can you add a button to select everthing on the page? Can you show production quantity? For example I want to click a button/select to show 100 or 50 or 1000 products. At least can you create that as components on livewire kit?
A few ideas for the future, thanks. For now I'm waiting for Livewire 3 and then will create more content about Livewire, and refresh the old ones.
Can you add dark mode switcher, infinity loading on livewire kit? On bulk delete add the select all checkbox. Its great features. I start using the livewire and the livewire kit is very helpful. I love livewire kit and I wait the new version with livewire 3.
We'll see about new components for Livewire Kit when Livewire 3 is released, thanks for the ideas.
@prpanto dark mode switcher shouldn't be made with Livewire. You should use Alpine.js for that.
Hello, I don't know if it is the best solution, but to export all without select any register I did this
And it's worked like a charm!