Menu

Multiple Sheets Excel Export in Laravel
🖼️

Multiple Sheets Excel Export in Laravel

DEV Community·Rafli Zocky·6 months ago
#LDMT00Bd
#excel#php#laravel#webdev#class
Reading 0:00
15s threshold

This example uses the maatwebsite/excel package.

composer require maatwebsite/excel:^3.1

Enter fullscreen mode

Exit fullscreen mode

1. Route

Route :: get ( '/export-excel' , [ App\Http\Controllers\MyController :: class , 'excel' ]) -> name ( 'export-excel' );

Enter fullscreen mode

Exit fullscreen mode

2. Simple View

Date input and a button that triggers the download.

<div class= "mb-4 form-group col-lg-4" > <label class= "form-label" > Start Date </label> <input type= "text" name= "start_date" id= "start_date" class= "form-control" required > </div> <div class= "mb-4 form-group col-lg-4" > <label class= "form-label" > End Date </label> <input type= "text" name= "end_date" id= "end_date" class= "form-control" required > </div>

<button type= "button" class= "btn btn-primary exportExcel" > Excel </button>

$(document).on('click', '.exportExcel', function() { var start = $('#start_date').val(); var end = $('#end_date').val();

window.location.href = {{ route('export-excel') }}?start=${start}…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.