正在显示
1 个修改的文件
包含
2 行增加
和
100 行删除
@@ -163,6 +163,7 @@ class Dashboard extends Backend | @@ -163,6 +163,7 @@ class Dashboard extends Backend | ||
163 | $table .= "</tbody> | 163 | $table .= "</tbody> |
164 | </table>"; | 164 | </table>"; |
165 | //通过header头控制输出excel表格 | 165 | //通过header头控制输出excel表格 |
166 | + $write = new \PHPExcel_Writer_Excel5($table); | ||
166 | header("Pragma: public"); | 167 | header("Pragma: public"); |
167 | header("Expires: 0"); | 168 | header("Expires: 0"); |
168 | header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); | 169 | header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); |
@@ -172,107 +173,8 @@ class Dashboard extends Backend | @@ -172,107 +173,8 @@ class Dashboard extends Backend | ||
172 | header("Content-Type:application/download");; | 173 | header("Content-Type:application/download");; |
173 | header('Content-Disposition:attachment;filename="入库明细表.xls"'); | 174 | header('Content-Disposition:attachment;filename="入库明细表.xls"'); |
174 | header("Content-Transfer-Encoding:binary"); | 175 | header("Content-Transfer-Encoding:binary"); |
175 | - $objPHPExcel = new \PHPExcel(); | ||
176 | - //设置保存版本格式 | ||
177 | - $objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel); | ||
178 | - $objWriter->save('php://output'); | ||
179 | // echo $table; | 176 | // echo $table; |
177 | + $write->save('php://output'); | ||
180 | } | 178 | } |
181 | 179 | ||
182 | - | ||
183 | - | ||
184 | - | ||
185 | - public function out(){ | ||
186 | - | ||
187 | - $result = Db::name('applet_user')->field('id,name,mobile,colleges')->order('id desc')->select(); | ||
188 | - | ||
189 | - $filename = "用户测评数据"; | ||
190 | - vendor('PHPExcel.PHPExcel'); | ||
191 | - $objPHPExcel = new \PHPExcel(); | ||
192 | - //设置保存版本格式 | ||
193 | - $objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel); | ||
194 | - | ||
195 | - //设置表头 | ||
196 | - $objPHPExcel->getActiveSheet()->setCellValue('A1','id'); | ||
197 | - $objPHPExcel->getActiveSheet()->setCellValue('B1','姓名'); | ||
198 | - $objPHPExcel->getActiveSheet()->setCellValue('C1','手机'); | ||
199 | - $objPHPExcel->getActiveSheet()->setCellValue('D1','意向院校'); | ||
200 | - $objPHPExcel->getActiveSheet()->setCellValue('E1','测评分值'); | ||
201 | - $objPHPExcel->getActiveSheet()->setCellValue('F1','学历背景得分'); | ||
202 | - $objPHPExcel->getActiveSheet()->setCellValue('G1','企业背景得分'); | ||
203 | - $objPHPExcel->getActiveSheet()->setCellValue('H1','收入水平得分'); | ||
204 | - $objPHPExcel->getActiveSheet()->setCellValue('I1','发展潜力得分'); | ||
205 | - $objPHPExcel->getActiveSheet()->setCellValue('J1','管理经验得分'); | ||
206 | - $objPHPExcel->getActiveSheet()->setCellValue('K1','英语水平得分'); | ||
207 | - $objPHPExcel->getActiveSheet()->setCellValue('L1','背景优势'); | ||
208 | - $objPHPExcel->getActiveSheet()->setCellValue('M1','背景劣势'); | ||
209 | - $objPHPExcel->getActiveSheet()->setCellValue('N1','匹配院校'); | ||
210 | - | ||
211 | - //改变此处设置的长度数值 | ||
212 | - $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10); | ||
213 | - $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12); | ||
214 | - //输出表格 | ||
215 | - $str = '用户未进行测评'; | ||
216 | - foreach ($result as $key => &$val) { | ||
217 | - | ||
218 | - $count = Db::name('applet_answer')->where(['uid'=>$val['id'],'isdelete'=>0])->count(); | ||
219 | - $i=$key+2;//表格是从2开始的 | ||
220 | - if ($count>=1){ | ||
221 | - | ||
222 | - $row = SubjectService::getResult($val['id'],'');//score--1学历背景 2企业背景 3收入水平 4发展潜力 5管理经验 6英语水平 | ||
223 | - | ||
224 | - //优势 | ||
225 | - $advan = $row['advan'] ? implode('、',$row['advan']) : '暂无优势'; | ||
226 | - | ||
227 | - $inferi = $row['inferi'] ? implode('、',$row['inferi']) : '暂无劣势'; | ||
228 | - | ||
229 | - $colllist = $row['colllist'] ? implode('、',array_column($row['colllist'],'title')) : '无匹配院校'; | ||
230 | - | ||
231 | - //$score = Db::name('applet_answer')->where(['uid'=>$val['id'],'isdelete'=>0])->sum('score'); | ||
232 | - | ||
233 | - //dump($row);exit(); | ||
234 | - $objPHPExcel->getActiveSheet()->setCellValue('A'.$i,$val['id']); | ||
235 | - $objPHPExcel->getActiveSheet()->setCellValue('B'.$i,$val['name']); | ||
236 | - $objPHPExcel->getActiveSheet()->setCellValue('C'.$i,$val['mobile']); | ||
237 | - $objPHPExcel->getActiveSheet()->setCellValue('D'.$i,$val['colleges']); | ||
238 | - $objPHPExcel->getActiveSheet()->setCellValue('E'.$i,$row['totalscore']); | ||
239 | - $objPHPExcel->getActiveSheet()->setCellValue('F'.$i,$row['score'][0]); | ||
240 | - $objPHPExcel->getActiveSheet()->setCellValue('G'.$i,$row['score'][1]); | ||
241 | - $objPHPExcel->getActiveSheet()->setCellValue('H'.$i,$row['score'][2]); | ||
242 | - $objPHPExcel->getActiveSheet()->setCellValue('I'.$i,$row['score'][3]); | ||
243 | - $objPHPExcel->getActiveSheet()->setCellValue('J'.$i,$row['score'][4]); | ||
244 | - $objPHPExcel->getActiveSheet()->setCellValue('K'.$i,$row['score'][5]); | ||
245 | - $objPHPExcel->getActiveSheet()->setCellValue('L'.$i,$advan); | ||
246 | - $objPHPExcel->getActiveSheet()->setCellValue('M'.$i,$inferi); | ||
247 | - $objPHPExcel->getActiveSheet()->setCellValue('N'.$i,$colllist); | ||
248 | - } | ||
249 | - else{ | ||
250 | - $objPHPExcel->getActiveSheet()->setCellValue('A'.$i,$val['id']); | ||
251 | - $objPHPExcel->getActiveSheet()->setCellValue('B'.$i,$val['name']); | ||
252 | - $objPHPExcel->getActiveSheet()->setCellValue('C'.$i,$val['mobile']); | ||
253 | - $objPHPExcel->getActiveSheet()->setCellValue('D'.$i,$val['colleges']); | ||
254 | - $objPHPExcel->getActiveSheet()->setCellValue('E'.$i,$str); | ||
255 | - $objPHPExcel->getActiveSheet()->setCellValue('F'.$i,$str); | ||
256 | - $objPHPExcel->getActiveSheet()->setCellValue('G'.$i,$str); | ||
257 | - $objPHPExcel->getActiveSheet()->setCellValue('H'.$i,$str); | ||
258 | - $objPHPExcel->getActiveSheet()->setCellValue('I'.$i,$str); | ||
259 | - $objPHPExcel->getActiveSheet()->setCellValue('J'.$i,$str); | ||
260 | - $objPHPExcel->getActiveSheet()->setCellValue('K'.$i,$str); | ||
261 | - $objPHPExcel->getActiveSheet()->setCellValue('L'.$i,$str); | ||
262 | - $objPHPExcel->getActiveSheet()->setCellValue('M'.$i,$str); | ||
263 | - $objPHPExcel->getActiveSheet()->setCellValue('N'.$i,$str); | ||
264 | - } | ||
265 | - | ||
266 | - } | ||
267 | - header("Pragma: public"); | ||
268 | - header("Expires: 0"); | ||
269 | - header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); | ||
270 | - header("Content-Type:application/force-download"); | ||
271 | - header("Content-Type:application/vnd.ms-execl"); | ||
272 | - header("Content-Type:application/octet-stream"); | ||
273 | - header("Content-Type:application/download"); | ||
274 | - header('Content-Disposition:attachment;filename='.$filename.'.xls'); | ||
275 | - header("Content-Transfer-Encoding:binary"); | ||
276 | - $objWriter->save('php://output'); | ||
277 | - } | ||
278 | } | 180 | } |
-
请 注册 或 登录 后发表评论