We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export Class which implements WithMapping interface has map($row) function to manipulate rows.
WithMapping
map($row)
I needed to use index, but I couldn't get index data from it.
How about passing index parameter to map()?
Make those lines https://github.com/Maatwebsite/Laravel-Excel/blob/90977aa13e687f7a11eda97a5037267919cfd1f0/src/Sheet.php#L530-L538
into this (just adding $index is enough!)
$index
$rows = (new Collection($rows))->flatMap(function ($row, $index) use ($sheetExport) { if ($sheetExport instanceof WithMapping) { $row = $sheetExport->map($row, $index); } return ArrayHelper::ensureMultipleRows( static::mapArraybleRow($row) ); })->toArray();
Also https://github.com/Maatwebsite/Laravel-Excel/blob/90977aa13e687f7a11eda97a5037267919cfd1f0/src/Sheet.php#L310-L322
into
foreach ($this->worksheet->getRowIterator($startRow, $endRow) as $index => $row) { $row = (new Row($row, $headingRow))->toArray($nullValue, $calculateFormulas, $formatData); if ($import instanceof WithMapping) { $row = $import->map($row, $index); } $rows[] = $row; if ($import instanceof WithProgressBar) { $import->getConsoleOutput()->progressAdvance(); } }
Also https://github.com/Maatwebsite/Laravel-Excel/blob/90977aa13e687f7a11eda97a5037267919cfd1f0/src/Concerns/WithMapping.php#L7-L12
/** * @param mixed $row * @param int $index * * @return array */ public function map($row, $index): array;
The text was updated successfully, but these errors were encountered:
That would be a breaking change, so that won't be possible. The next release will have a RemembersRowNumber that will help you with this situation.
RemembersRowNumber
Sorry, something went wrong.
Is this functionality already on version 3?
+1. Is this feature added in v3? A simple workaround is here though.
No branches or pull requests
Prerequisites
Versions
Description
Export Class which implements
WithMapping
interface hasmap($row)
function to manipulate rows.I needed to use index, but I couldn't get index data from it.
How about passing index parameter to map()?
Example
Make those lines
https://github.com/Maatwebsite/Laravel-Excel/blob/90977aa13e687f7a11eda97a5037267919cfd1f0/src/Sheet.php#L530-L538
into this (just adding
$index
is enough!)Also
https://github.com/Maatwebsite/Laravel-Excel/blob/90977aa13e687f7a11eda97a5037267919cfd1f0/src/Sheet.php#L310-L322
into
Also
https://github.com/Maatwebsite/Laravel-Excel/blob/90977aa13e687f7a11eda97a5037267919cfd1f0/src/Concerns/WithMapping.php#L7-L12
into
Additional Information
The text was updated successfully, but these errors were encountered: