I am using the Laravel Excel library and I have been reading the documentation but it does not say anything to read the excel from a certain row number, that is, I have the first 6 lines of the excel with information and the "title" of each column is not until row 7, as I indicated to the function that the "indexes" are there?
public function excel($id){
$bankFiles = FicheroBanco::find($id);
$url = $bankFiles->url;
Excel::selectSheetsByIndex(0)->load($url, function ($sheet){
//$sheet->noHeading();
$sheet->each(function ($row){
$mov = new Transaccion();
$mov->cuenta = $row->cuenta;
$mov->divisa = $row->divisa;
$mov->titular = $row->titular;
$mov->fecha = $row->fecha;
$mov->concepto = $row->concepto;
$mov->valor = $row->valor;
$mov->importe = $row->importe;
$mov->saldo = $row->saldo;
$mov->observaciones = $row->observaciones;
$mov->extra = $row->extra;
$mov->save();
});
});
return view('bank.excel');
}
I've seen that I can use the - > take (); to catch the first x lines of a document or the - > skip (); to skip the first x lines. The problem is that the first line of the excel file is a merged cell of 7 columns I can not use the titles of line 6, since it mounts the unstructured array.
EDIT: By default it can be configured from within the excel.php configuration file in the 'startRow' = > 1 but the thing is that I can not take any kind of information from the fields before that line either. The thing is that I need the info of some fields of the first 6 lines, but I need to indicate that the headings start on line 6. Any ideas?
I have read in the documentation that you can use the - > byConfig (); parameter but as indicated only if you do not use headings.
Would someone know how to do it?
I need to insert into the database the fields before the "headings", for each row of subsequent data.
EDITO: I've been doing tests and although I did two different functions one without using headings and the other one, having changed the startRow parameter of the configuration, both one and another load me from the same row. I do not know how to indicate one to load one row and the other to load from the beginning. Can you?
The above code works perfectly for me if I put 'startRow' = > 6 , on the other hand if I use noheadings (with startrow 6) I can not access previous rows of the excel file.
I can not modify the structure of the excel since I have to stick to it.
I leave the documentation - > link