ΠΠ΅ΡΠΊΠΎΠ»ΡΠΊΠΎ Π»ΠΈΡΡΠΎΠ² Π½Π΅ ΡΠ°Π±ΠΎΡΠ°ΡΡ, Π΅ΡΠ»ΠΈ ΠΊΠ°ΠΊΠΈΠ΅-Π»ΠΈΠ±ΠΎ / Π²ΡΠ΅ Π»ΠΈΡΡΡ - FromView
`
ΠΊΠ»Π°ΡΡ FormatReportExport ΡΠ΅Π°Π»ΠΈΠ·ΡΠ΅Ρ WithMultipleSheets, Responsable
{
ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Exportable;
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
{
Π·Π°ΡΠΈΡΠ΅Π½Π½Π°Ρ ΡΠ²ΠΎΠ΄ΠΊΠ° $;
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';
}
} `
`class ReportExport ΡΠ΅Π°Π»ΠΈΠ·ΡΠ΅Ρ FromView, WithTitle
{
Π·Π°ΡΠΈΡΠ΅Π½Π½ΡΠ΅ ΠΎΡΡΠ΅ΡΡ $;
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 ('layout.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