49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
|
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
|
use phpDocumentor\Reflection\Types\Object_;
|
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use App\Models\User;
|
|
use App\Models\FeedbackHistory;
|
|
|
|
class LiveLogDataV2 implements FromCollection,WithHeadings
|
|
{
|
|
private $data;
|
|
|
|
public function __construct($data)
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'直播id',
|
|
'红娘昵称',
|
|
'直播次数',
|
|
'直播开始时间',
|
|
'直播结束时间',
|
|
'总时长{单位、秒}',
|
|
];
|
|
}
|
|
//设置列格式
|
|
public function columnFormats(): array
|
|
{
|
|
return [
|
|
'A' => NumberFormat::FORMAT_TEXT,
|
|
];
|
|
}
|
|
public function collection()
|
|
{
|
|
return collect($this->data);
|
|
}
|
|
|
|
}
|
|
|