stationModel = $stationModel; } /** * 设置头部 * * @time 2020年09月08日 * @return string[] */ public function headers(): array { // TODO: Implement headers() method. return [ '省份', '市区', '县区', '基站名称', '基站Mac', '基站简码', '基站型号', '安装照片', '安装地址', 'SIM卡序列号', '在线时间','安装时间' ]; } /** * 处理数据 * * @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 [ 'province_name', 'city_name', 'district_name', 'station_name', 'station_mac', 'station_code', 'station_model', 'install_photo', 'address', 'sim_serial_number', '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, 'K' => 20, 'L' => 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; } }