如果任何/所有工作表都是 FromView,则多张工作表不起作用
`
类 FormatReportExport 实现了 WithMultipleSheets、Responsable
{
使用可出口;
protected $reports;
protected $summary;
public function __construct($summary, $reports)
{
$this->summary = $summary;
$this->reports = $reports;
}
public function sheets(): array
{
$sheets = [];
$sheets[] = new ReportSummaryExport($this->summary);
$sheets[] = new ReportExport($this->reports);
return $sheets;
}
}
`
`
类 ReportSummaryExport 实现 FromCollection、WithTitle
{
受保护的 $summary;
public function __construct($summary)
{
$this->summary = $summary;
}
public function collection()
{
return User::get();
}
/**
* <strong i="34">@return</strong> string
*/
public function title(): string
{
return 'Summary';
}
}`
`类 ReportExport 实现了 FromView、WithTitle
{
受保护的 $reports;
public function __construct($reports)
{
$this->reports = $reports;
}
public function view(): View
{
return view('export.report.list', [
'title' => $this->title(),
'reports' => $this->reports
]);
}
/**
* <strong i="41">@return</strong> string
*/
public function title(): string
{
return 'Checklists';
}
}`
list.blade.php
`@extends('layouts.export', ['title' => $title])
@section('内容')
创建日期 |
{{ $report['created_at'] }} |
@endsection`
预期行为:
基于视图的具有多个工作表的 Excel 文件。
实际行为:
感谢您提交门票。 我们将在有可用资源时尽快获取它(如我们的支持指南 (https://laravel-excel.maatwebsite.nl/docs/3.0/getting-started/support) 中所述)。
很可能会被 #1590 解决
最有用的评论
https://github.com/Maatwebsite/Laravel-Excel/releases/tag/3.0.2