I use this library to export data from collection to excel file. By default I et columns names as namesd of table fields.
How to replace names of colums on own?
I have own abstract class:
abstract class Excel
{
abstract public function export();
public function download()
{
$this->file = \Excel::create($this->filename, function ($excel) {
$excel->sheet($this->sheetname, function ($sheet) {
$sheet->fromArray($this->data->toArray());
});
})->store($this->typefile, $this->path_save);
}
}
My excel file:
<?php
namespace App\Library;
use App\Library\Excel;
use App\DistributorContacts;
use App\PersonalityTraits;
use App\Helpers\Helper;
use Maatwebsite\Excel\Concerns\WithHeadings;
class ExcelConclusions extends Excel implements WithHeadings
{
public $type = "_conclusions";
public function headings(): array
{
return ["your", "headings", "here"];
}
public function export()
{}
}