|
@@ -0,0 +1,89 @@
|
|
|
+<?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 BanzuiExcelExport 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:K')->setWidth(20);
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+}
|