How to skip first row when importing file
you can implement the StartingRow
use Maatwebsite\Excel\Concerns\WithStartRow;
class VotersImport implements ToModel, WithStartRow
{
/**
* @return int
*/
public function startRow(): int
{
return 2;
}
}
Another option would be to use HeadingRow https://docs.laravel-excel.com/3.1/imports/heading-row.html
Add this code before load the Excel file. it works for me.
config(['excel.import.startRow' => your_number_of_row_to_skip]);
Ex:
$path = $request->file('select_file')->getRealPath();
config(['excel.import.startRow' => 4]);
$data = Excel::load($path)->get();