Laravel-excel: Starting at Row X

Created on 14 Mar 2019  路  8Comments  路  Source: Maatwebsite/Laravel-Excel

Versions

  • PHP version: 7.3
  • Laravel version: 5.8
  • Package version: 3.1.7

Description

I'm using a custom view to export my rows, the view has 2 heading rows, as defined like this
in the thead.
<thead> <tr> <th colspan="8"> Blackfisk </th> </tr> <tr> <th>unique_number</th> <th>name</th> <th>remarks</th> <th>price</th> <th>payment_qty</th> <th>payment_unit</th> <th>in_europe_sku</th> <th>in_supplier_sku</th> </tr> </thead>
Now when I'm trying to re-import this file, even without doing any editing, I get validation errors, while the input is there. In my Import file, I don't see any settings to specify at what row it has to start importing? I have WithHeadingRow set, but that's only 1 row, right?

more information needed

Most helpful comment

Use Maatwebsite\Excel\Concerns\WithStartRow and set the start row by:

public function startRow() {
return n;
}.

All 8 comments

Could you please elaborate and have a look at the formatting of your issue / include some code?
I'm not sure whether WithHeadingRow is applicable for exports, since it's not listed on the Export concerns.

In our example for using views, we don't mention any other concerns, so could you try removing withHeadingRow from your export class?

Thanks for the response Glenn, I'm just wondering, during an import, since the first 2, or 3 rows will contain irrelevant information, how can I specify for an import, at what row the data starts?

Use Maatwebsite\Excel\Concerns\WithStartRow and set the start row by:

public function startRow() {
return n;
}.

You can view our import concerns here.

We don't have documentation for all of them, but of course, Pull Requests are always welcome. You can use the {{Help us improve this page!}} link at the bottom of each page.

I will close this issue, please feel free to re-open if you need any further help.

Just a note to say that startRow starts from 1

Hi,
for import, Is it possible to use WithStartRow together with WithMappedCells?
My first row is the header of the sheet and I want to remap the first row.

In summary the solution is:

public function startCell(): string
{
return 'B2';
}

Hi,
for import, Is it possible to use WithStartRow together with WithMappedCells?
My first row is the header of the sheet and I want to remap the first row.

it's possible, use in FirstSheetImport or SecondSheetImport

Was this page helpful?
0 / 5 - 0 ratings