I can't seem to get the full header row, when using MaatWebsite Excel with Laravel.
My file is as follows...
Row 1 data | Test11 | Test1
Row 2 data | Test22 | Test2
Row 3 data | Test33 | Test3
If I do this...
$tempFile = Excel::selectSheetsByIndex(0)->load(storage_path().$tempFile, function($reader){
$reader->setHeaderRow(1);
$results = $reader->get()->toArray();
});
$results becomes...
Row 2 data | Test22 | Test2
Row 3 data | Test33 | Test3
If I do this setHeaderRow(0)
though...you would think Id get the same thing, but including the first row. But I dont.
$tempFile = Excel::selectSheetsByIndex(0)->load(storage_path().$tempFile, function($reader){
$reader->setHeaderRow(0);
$results = $reader->get()->toArray();
});
$results becomes...
Test1
Test2
Test3
So the problem is if I start reading on the second row, I get all the data from all columns, EXCEPT the first row.
But if I start reading on the first row, I get all the rows, but only get the last column.
What's going on here?
I solved this by simply adding...
config(['excel.import.heading'=>false]);
before all my Excel:: code.