I want to export an excel sheet with "xslx" extension and make custom header Name, Iso for Countries that I have used this plugin for it laravel-countries
The export class app/Exports/GeoExport.php
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithMapping;
use Webpatser\Countries\Countries;
class GeoExport implements FromQuery, WithHeadingRow, WithMapping
{
use Exportable;
/**
* @return array
*/
public function headings(): array
{
return [
'Name',
'ISO'
];
}
public function map($countries) : array
{
return [
$countries->name,
$countries->iso_3166_2
];
}
public function query()
{
return Countries::query()->select(['name','iso_3166_2']);
}
}
The export method in my controller exportGeoCountryList
public function exportGeoCountryList()
{
return (new GeoExport)->download('geo_countries.xlsx');
}
Expected behavior:

Actual behavior:

All steps depend on the documentation in this link
As noted in the documentation link you shared, the concern is WithHeadings. WithHeadingRow is the concern used for Imports.
Thanks a lot I didn't see that there is difference between WithHeadings and WithHeadingRow 馃檲
Most helpful comment
As noted in the documentation link you shared, the concern is
WithHeadings.WithHeadingRowis the concern used for Imports.