# Heading row
# Adding a heading row
A heading row can easily be added by adding the WithHeadings
concern. The heading row will be added
as very first row of the file.
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithHeadings;
class InvoicesExport implements FromQuery, WithHeadings
public function headings(): array
{
return [
'#',
'Date',
];
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# Multiple rows
It is possible to return multiple heading rows. These will be added as the first x rows. Example:
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithHeadings;
class InvoicesExport implements FromQuery, WithHeadings
public function headings(): array
{
return [
['#', 'date'],
['Amount', 'Status'],
];
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
This would result in the following export:
"#","date"
"amount","status"
1
2
2