123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace App\Exports;
- use App\Models\User;
- use Illuminate\Support\Facades\Log;
- use Maatwebsite\Excel\Concerns\FromCollection;
- use Maatwebsite\Excel\Concerns\WithEvents;
- use Maatwebsite\Excel\Concerns\WithHeadings;
- use Maatwebsite\Excel\Concerns\WithTitle;
- use Maatwebsite\Excel\Events\AfterSheet;
- class NeikuExcelExport implements FromCollection, WithHeadings, WithEvents
- {
- protected $data;
- public function __construct($data){
- $this->data = $data;
- }
- public function collection()
- {
- return $this->data;
- }
- public function headings(): array
- {
- return['进货月份',
- '进货人(批发商)昵称',
- '进货人(批发商)手机号',
- '精装版(盒)',
- '简约版(件)',
- '高腰版(件)',
- '青春版(件)',
- '袜子(件)',
- '进货金额',
- '补助接收者昵称',
- '补助接收者手机号',
- '类型',
- '补助/盒或件',
- '补助金额'
- ];
- }
- public function setRowHeight(array $rouHeight)
- {
- $this->RowHeight=$rouHeight;
- }
- public function registerEvents(): array
- {
- return [
- AfterSheet::class => function(AfterSheet $event) {
- // 合并单元格,从 A1 到 C1
- $sheet = $event->sheet;
- // $sheet->mergeCells('A1:C1');
- // $sheet->setCellValue('A1','进货人信息');
- // 设置字体加粗、居中等样式
- // $sheet->getStyle('A1')->getFont()->setBold(true);
- // $sheet->getStyle('A1')->getAlignment()->setHorizontal('center');
- //
- //// $sheet->mergeCells('D1:I1');
- //// $sheet->setCellValue('D1','进货数量及金额');
- //
- // // 设置字体加粗、居中等样式
- // $sheet->getStyle('D1')->getFont()->setBold(true);
- // $sheet->getStyle('D1')->getAlignment()->setHorizontal('center');
- //
- //// $sheet->mergeCells('J1:L1');
- //// $sheet->setCellValue('J1','拿补助的人信息');
- //
- //
- // // 设置字体加粗、居中等样式
- // $sheet->getStyle('J1')->getFont()->setBold(true);
- // $sheet->getStyle('J1')->getAlignment()->setHorizontal('center');
- //
- //// $sheet->mergeCells('M1:N1');
- //// $sheet->setCellValue('M1','补助明细及金额');
- //
- // $sheet->getStyle('M1')->getFont()->setBold(true);
- // $sheet->getStyle('M1')->getAlignment()->setHorizontal('center');
- //
- // $sheet->getColumnDimension('B')->setWidth(20);
- // $sheet->getColumnDimension('K')->setWidth(20);
- // $sheet->setHeight=20;
- $sheet->getStyle('A:N')->getAlignment()->setHorizontal('center');
- $sheet->getColumnDimension('A')->setWidth(20);
- $sheet->getColumnDimension('B')->setWidth(20);
- $sheet->getColumnDimension('C')->setWidth(20);
- $sheet->getColumnDimension('D')->setWidth(20);
- $sheet->getColumnDimension('E')->setWidth(20);
- $sheet->getColumnDimension('F')->setWidth(20);
- $sheet->getColumnDimension('G')->setWidth(20);
- $sheet->getColumnDimension('H')->setWidth(20);
- $sheet->getColumnDimension('I')->setWidth(20);
- $sheet->getColumnDimension('J')->setWidth(20);
- $sheet->getColumnDimension('K')->setWidth(20);
- $sheet->getColumnDimension('L')->setWidth(20);
- $sheet->getColumnDimension('M')->setWidth(20);
- $sheet->getColumnDimension('N')->setWidth(20);
- },
- ];
- }
- }
|