Laravel-Excel — P2: Importing Multiple Sheets Basics
Excel sheets will automatically be imported with Laravel-Excel. Sheets 1
through N
will be handled the exact same way as sheet 0
. We can specify how multiple sheets are handled, and we will in this article.
Importing Multiple Sheets with the Same Format
We’ll use our user mock data from the previous article and create a couple of excel sheets to store the user data. We now have user_data_1
and user_data_2
sheets. Each sheet stores the exact same type of data, both with headers (first_name
, last_name
, email
, password
) and 19 rows of user data. The MOCK_DATA.xlsx
file is placed in our public
directory.
We’ll create our importer with our laravel-excel command:
php artisan make:import MultiSheetSingleFormatImport --model=User