【发布时间】:2019-10-09 01:24:35
【问题描述】:
我正在使用 Laravel Excel 3.1 版来生成 CSV/XLS 等。 我必须自定义我的 csv 或 xls 以使自定义页脚和页眉跨越列。
它应该看起来像所附的屏幕截图。
另外,我想将导出的文件存储到存储位置,但无法正常工作。
而我做的代码是:
class ReportExport implements FromArray, WithHeadings
{
protected $results;
public function __construct(array $results, array $headings, array $fileAttributes)
{
$this->results = $results;
$this->headings = $headings;
$this->file_attributes = $fileAttributes;
}
/**
* @return array
*/
public function array(): array
{
return $this->results;
}
/**
* @return array
*/
public function headings(): array
{
return $this->headings;
}
public function registerEvents(): array
{
return [
// Handle by a closure.
BeforeExport::class => function(BeforeExport $event) {
$event->writer->getProperties()->setTitle('Patrick');
},
];
}
}
如下调用i:
Excel::store(["1","2"],"xyz.xlsx");
如何将这些额外的行添加到导出的结果中。
【问题讨论】:
标签: php laravel laravel-excel