Я экспортирую Excel, используя Laravel Excel 3.1 от Maatwebsite .Я хочу сопоставить его с 2 заголовками и отобразить его один под другим
Я использую WithHeadings, WithMapping, FromArray Я получаю записи, только формат, который нуждается в исправлении
<?php
namespace App\Exports;
use Modules\Program\Entities\Program;
use Modules\report\Entities\report;
use DB;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithMapping;
class reportPerDaySheet implements FromArray, WithTitle, WithHeadings, ShouldAutoSize, WithMapping
{
private $year;
private $day;
private $month;
public function __construct(int $year, int $month, int $day)
{
$this->year = $year;
$this->day = $day;
$this->month = $month;
}
public function array():array
{
$reportOut = DB::table('reports')->join('programs','programs.program_id','=','reports.program_id')->whereMonth('report_dateofreport', $this->month)->whereday('report_dateofreport', $this->day)->get()->toArray();
return $reportOut;
}
public function map($reportOut):array
{
return [
[
$reportOut->program_programname,
$reportOut->program_projectlead,
$reportOut->program_dse,
$reportOut->program_extserviceprovider,
$reportOut->program_programid,
$reportOut->program_datatype,
],
[
$reportOut->report_id,
$reportOut->report_date,
$reportOut->report_url,
$reportOut->report_username,
$reportOut->report_reportertype,
$reportOut->report_productname,
$reportOut->report_verbatim,
$reportOut->report_priority,
$reportOut->report_aeraised,
]
];
}
public function title(): string
{
return $this->day .' '. date("F", mktime(0,0,0,$this->month,1)) .' '. $this->year;
}
public function headings(): array
{
return[
[
'Program Name',
'Project Lead',
'DS&E Contact',
'Name of external service provider',
'Prepared By',
'External Service Provider Contact Information',
'Time Period Covered',
'Program ID',
'Date of Report',
'Data Type',
'Signature'
],
[
'Id',
'Date of report',
'Date',
'URL',
'Username',
'Reporter Type',
'Product Name',
'Verbatim',
'Priority',
'AE Raised',
'User',
'Date From',
'Date Till',
'Record Created At',
'Record Updated At'
]
];
}
}
Токовый выход:
Требуемый выход: