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->getExportList(); // var_dump($list); foreach ($list as &$val) { // $val->student_no ="\t".$val->student_no."\t"; // $val->passive_rfid ="\t".$val->passive_rfid."\t"; // $val->active_rfid ="\t".$val->active_rfid."\t"; // $val->parent_phone ="\t".$val->parent_phone."\t"; } return $list; } public function keys(): array { // TODO: Implement keys() method. return [ 'school_name', 'building_name', 'floor_name', 'room_no', 'station_name', 'station_mac', 'station_code','install_photo','online_time','created_at' ]; } /** * 设置开始行 * * @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' => 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; } }