Here, i will show you cell maatwebsite in laravel. This tutorial will give you simple example of laravel export with headings row maatwebsite 3. i would like to share with you laravel excel header. step by step explain laravel excel export headers. Alright, let’s dive into the steps.
I will simple show you how you can set specific header on your export excel file using maatwebsite/excel composer package. If you want to import export from scratch then you can follow this tutorial: Import Export CSV File in Laravel 5.8.
So, let's see bellow example how it is done. just follow bellow file:
app/Exports/ServiceExport.php
<?php
namespace App\Exports;
use App\Service;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
class ServiceExport implements FromCollection, WithHeadings
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return Service::all();
}
public function headings(): array
{
return [
'Code',
'Description',
'Pos',
'Mod A',
'Mod B',
'Charge',
];
}
}
I hope it can help you...