正在显示
1 个修改的文件
包含
30 行增加
和
29 行删除
@@ -107,7 +107,7 @@ class Dashboard extends Backend | @@ -107,7 +107,7 @@ class Dashboard extends Backend | ||
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | - //自定义导出 | 110 | + |
111 | public function exportDayInner() | 111 | public function exportDayInner() |
112 | { | 112 | { |
113 | //月 起止时间戳 | 113 | //月 起止时间戳 |
@@ -139,42 +139,43 @@ class Dashboard extends Backend | @@ -139,42 +139,43 @@ class Dashboard extends Backend | ||
139 | $data[$k]['WRound'] = $WRound . '%'; | 139 | $data[$k]['WRound'] = $WRound . '%'; |
140 | } | 140 | } |
141 | } | 141 | } |
142 | - $table = ''; | ||
143 | - $table .= "<table> | ||
144 | - <thead> | ||
145 | - <tr> | ||
146 | - <th class='name'>站点</th> | ||
147 | - <th class='name'>报修单数量</th> | ||
148 | - <th class='name'>报修完成率</th> | ||
149 | - <th class='name'>报修未完成率</th> | ||
150 | - <th class='name'>故障设备名称</th> | ||
151 | - </tr> | ||
152 | - </thead> | ||
153 | - <tbody>"; | ||
154 | - foreach ($data as $v) { | ||
155 | - $table .= "<tr> | ||
156 | - <td class='name'>{$v['zhandian_name']}</td> | ||
157 | - <td class='name'>{$v['baoxiu_num']}</td> | ||
158 | - <td class='name'>{$v['Round']}</td> | ||
159 | - <td class='name'>{$v['WRound']}</td> | ||
160 | - <td class='name'>{$v['BaoXiuStr']}</td> | ||
161 | - </tr>"; | 142 | + $filename = "用户测评数据"; |
143 | + vendor('PHPExcel.PHPExcel'); | ||
144 | + $objPHPExcel = new \PHPExcel(); | ||
145 | + //设置保存版本格式 | ||
146 | + $objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel); | ||
147 | + //设置表头 | ||
148 | + $objPHPExcel->getActiveSheet()->setCellValue('A1', '站点'); | ||
149 | + $objPHPExcel->getActiveSheet()->setCellValue('B1', '报修单数量'); | ||
150 | + $objPHPExcel->getActiveSheet()->setCellValue('C1', '报修完成率'); | ||
151 | + $objPHPExcel->getActiveSheet()->setCellValue('D1', '报修未完成率'); | ||
152 | + $objPHPExcel->getActiveSheet()->setCellValue('E1', '故障设备名称'); | ||
153 | + | ||
154 | + //改变此处设置的长度数值 | ||
155 | + $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10); | ||
156 | + $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12); | ||
157 | + //输出表格 | ||
158 | + foreach ($data as $key => &$val) { | ||
159 | + $count = Db::name('applet_answer')->where(['uid' => $val['id'], 'isdelete' => 0])->count(); | ||
160 | + $i = $key + 2;//表格是从2开始的 | ||
161 | + if ($count >= 1) { | ||
162 | + $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $val['zhandian_name']); | ||
163 | + $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $val['baoxiu_num']); | ||
164 | + $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $val['Round']); | ||
165 | + $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $val['WRound']); | ||
166 | + $objPHPExcel->getActiveSheet()->setCellValue('E' . $i, $val['BaoXiuStr']); | ||
167 | + } | ||
162 | } | 168 | } |
163 | - $table .= "</tbody> | ||
164 | - </table>"; | ||
165 | - //通过header头控制输出excel表格 | ||
166 | - $write = new \PHPExcel_Writer_Excel5($table); | ||
167 | header("Pragma: public"); | 169 | header("Pragma: public"); |
168 | header("Expires: 0"); | 170 | header("Expires: 0"); |
169 | header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); | 171 | header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); |
170 | header("Content-Type:application/force-download"); | 172 | header("Content-Type:application/force-download"); |
171 | header("Content-Type:application/vnd.ms-execl"); | 173 | header("Content-Type:application/vnd.ms-execl"); |
172 | header("Content-Type:application/octet-stream"); | 174 | header("Content-Type:application/octet-stream"); |
173 | - header("Content-Type:application/download");; | ||
174 | - header('Content-Disposition:attachment;filename="入库明细表.xls"'); | 175 | + header("Content-Type:application/download"); |
176 | + header('Content-Disposition:attachment;filename=' . $filename . '.xls'); | ||
175 | header("Content-Transfer-Encoding:binary"); | 177 | header("Content-Transfer-Encoding:binary"); |
176 | -// echo $table; | ||
177 | - $write->save('php://output'); | 178 | + $objWriter->save('php://output'); |
178 | } | 179 | } |
179 | 180 | ||
180 | } | 181 | } |
-
请 注册 或 登录 后发表评论