Any additional information, configuration or data that might be necessary to reproduce the issue.
I am using Laravel version 5.5 and Laravel-Excel 3.1
I am trying to format my excel file according to my specifications using an array.
I am using the 'map' method included and it is working fine. It is below
`public function map($ticketsData): array
{
$row = [
$ticketsData->id,
$ticketsData->date,
$ticketsData->status,
$ticketsData->total,
$ticketsData->discount,
$ticketsData->paid,
];
return $row;
}`
I want to move to next row in this function to output nested array data, but I cannot seem to do so. How can it be done
Can you elaborate on it please?
Not sure I really understand what you want to do, but the map() function can return multiple rows.
public function map($ticketsData): array
{
$row1 = [
$ticketsData->id,
$ticketsData->date,
$ticketsData->status,
$ticketsData->total,
$ticketsData->discount,
$ticketsData->paid,
];
$row2 = [
//... more data
];
return [
$row1,
$row2,
];
}
Not sure I really understand what you want to do, but the map() function can return multiple rows.
public function map($ticketsData): array { $row1 = [ $ticketsData->id, $ticketsData->date, $ticketsData->status, $ticketsData->total, $ticketsData->discount, $ticketsData->paid, ]; $row2 = [ //... more data ]; return [ $row1, $row2, ]; }
This is exactly what I requested and worked like a charm. Thanks, you managed to solve the problem despite me not being clear in explaining it.
This should be somewhere in the docs.
Thanks again!
@abid1208 Glad you managed to solve your problem. Feel free to PR an update to the docs! :)
Also don't forget to send us a postcard! (https://docs.laravel-excel.com/3.1/getting-started/license.html#postcardware) :)
Most helpful comment
Not sure I really understand what you want to do, but the map() function can return multiple rows.