【发布时间】:2022-01-14 08:54:01
【问题描述】:
我使用this library 将数据从集合导出到 excel 文件。默认情况下,我将列名称设置为表字段的名称。
如何自行替换列名?
我有自己的抽象类:
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);
}
}
我的excel文件:
<?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()
{}
}
【问题讨论】:
-
这是一个文档齐全的软件包,您阅读过它的文档吗?
-
没有关于那个的部分,我试过了
标签: laravel laravel-excel