love_php/app/Exports/UserCoinExport.php

41 lines
930 B
PHP
Raw Normal View History

2026-04-02 09:20:51 +08:00
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
class UserCoinExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
{
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);
}
}