Laravel Excel how to use second row as collection attributes

3.2k views Asked by At

I am using Maatwebsite's Laravel-Excel package. I want to import an Excel file, have laravel-excel ignore the first row, and use the second row as the collection attributes (table columns).

Without resorting to "import by config", is this possible?

It seems something like this has not yet been implemented. I haven't dug into the source code for laravel-excel as it's a bit daunting to me, but is there some hard-coded value I could change so it starts at row 1 (instead of 0) and uses that one for the attribute names?

1

There are 1 answers

0
Patrick Delos Santos On

You can use this reference .

https://github.com/Maatwebsite/Laravel-Excel/issues/458

Set Config::set('excel.import.startRow', $headerRowNumber); in Config/excel file

Then use Config in your controller.