stationModel = $stationModel; } /** * 设置头部 * * @time 2020年09月08日 * @return string[] */ public function headers(): array { // TODO: Implement headers() method. return [ '部门','名称','Mac','简码','基站状态','在线时间', '开局时间','入库时间','开局员工','安装地址','备注' ]; } /** * 处理数据 * * @time 2020年09月08日 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @return \think\Collection */ public function sheets() { $list = $this->stationModel->getStationExportList(); foreach ($list as &$val) { $val->mac ="\t".$val->mac."\t"; $val->shortmac ="\t".$val->shortmac."\t"; if($val->open_status){ $val->use_state = '已开局'; }else{ $val->use_state = '未开局'; } } return $list; } public function keys(): array { // TODO: Implement keys() method. return [ 'depart_name','name','mac','shortcode','use_state','online_time','open_time','created_at','open_user_name','address','remark' ]; } /** * 设置开始行 * * @time 2020年09月08日 * @return int */ public function setRow() { return 2; } /** * 设置标题 * * @time 2020年09月08日 * @return array */ public function setTitle() { return [ 'A1:I1', '导出基站设备', Alignment::HORIZONTAL_CENTER ]; } /** * 设置宽度 * * @time 2020年09月08日 * @return array */ public function setWidth() { return [ 'A' => 20, 'B' => 20, 'C' => 20, 'D' => 20, 'E' => 20, 'F' => 20, 'G' => 20, 'H' => 20, 'I' => 20, 'J' => 30, 'K' => 20, ]; } public function getWorksheet($sheet) { // $sheet->getStyle('B')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT); // $sheet->getColumnDimension('B')->setAutoSize(true); // $sheet->getColumnDimension('C')->setAutoSize(true); // $sheet->getColumnDimension('D')->setAutoSize(true); // $sheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true); // $sheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true); return $sheet; } }