|
@@ -68,24 +68,50 @@ class JjhcController extends WebBaseController
|
|
|
// }
|
|
|
|
|
|
|
|
|
- for ($room = 1;$room <= 52; $room++){
|
|
|
- $word = new TemplateProcessor(base_path() . "/public/cunwu.docx");
|
|
|
- $word->setValue('room', $room);
|
|
|
- if($room<10){
|
|
|
- $room = sprintf('%02s', $room);
|
|
|
- }
|
|
|
- $list = DB::table("recruit_ticket")->leftJoin("recruit_appoint_info","recruit_ticket.appoint_id",'=','recruit_appoint_info.id')->where("recruit_ticket.ex_start",'2022-05-17 08:00:00')->where('recruit_ticket.ex_room',$room)->orderBy('ex_seat','ASC')->get()->toArray();
|
|
|
- $rows = count($list);//总行数
|
|
|
- $word->cloneRow('id', $rows);//复制行
|
|
|
- for ($i = 0; $i < $rows; $i++) {
|
|
|
- $word->setValue("id#" . ($i + 1), $i + 1);//替换变量
|
|
|
- $word->setValue("realname#" . ($i + 1), $list[$i]->realname);
|
|
|
- $word->setValue("ex_number#" . ($i + 1), $list[$i]->ex_number);
|
|
|
- $word->setValue("ex_seat#" . ($i + 1), $list[$i]->ex_seat);
|
|
|
- }
|
|
|
- $word->saveAs(base_path() ."/public/excel/cunwu{$room}.docx");//另存为
|
|
|
- }
|
|
|
+// for ($room = 1;$room <= 52; $room++){
|
|
|
+// $word = new TemplateProcessor(base_path() . "/public/cunwu.docx");
|
|
|
+// $word->setValue('room', $room);
|
|
|
+// if($room<10){
|
|
|
+// $room = sprintf('%02s', $room);
|
|
|
+// }
|
|
|
+// $list = DB::table("recruit_ticket")->leftJoin("recruit_appoint_info","recruit_ticket.appoint_id",'=','recruit_appoint_info.id')->where("recruit_ticket.ex_start",'2022-05-17 08:00:00')->where('recruit_ticket.ex_room',$room)->orderBy('ex_seat','ASC')->get()->toArray();
|
|
|
+// $rows = count($list);//总行数
|
|
|
+// $word->cloneRow('id', $rows);//复制行
|
|
|
+// for ($i = 0; $i < $rows; $i++) {
|
|
|
+// $word->setValue("id#" . ($i + 1), $i + 1);//替换变量
|
|
|
+// $word->setValue("realname#" . ($i + 1), $list[$i]->realname);
|
|
|
+// $word->setValue("ex_number#" . ($i + 1), $list[$i]->ex_number);
|
|
|
+// $word->setValue("ex_seat#" . ($i + 1), $list[$i]->ex_seat);
|
|
|
+// }
|
|
|
+// $word->saveAs(base_path() ."/public/excel/cunwu{$room}.docx");//另存为
|
|
|
+// }
|
|
|
|
|
|
+ $spreadsheet = new Spreadsheet();
|
|
|
+ $sheet = $spreadsheet->getActiveSheet();
|
|
|
+ $header = ['姓名','准考证'];
|
|
|
+ foreach ($header as $key => $value) {
|
|
|
+ $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
|
|
|
+ }
|
|
|
+ $row = 2;
|
|
|
+ $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
|
|
|
+ $list = DB::table("recruit_ticket")->leftJoin("recruit_appoint_info","recruit_ticket.appoint_id",'=','recruit_appoint_info.id')->where("recruit_appoint_info.recruit_id",'16')->orderBy('ex_room','ASC')->orderBy('ex_seat','ASC')->get()->toArray();
|
|
|
+ foreach ($list as $k => $v){
|
|
|
+ $sheet->setCellValueByColumnAndRow('1',$row, $v->realname);
|
|
|
+ $sheet->setCellValueExplicitByColumnAndRow('2',$row, $v->ex_number,DataType::TYPE_STRING);
|
|
|
+ $row++;
|
|
|
+ }
|
|
|
+ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
|
+ header('Content-Disposition: attachment;filename="'.time().'.xlsx"');
|
|
|
+ header('Cache-Control: max-age=0');
|
|
|
+ // If you're serving to IE 9, then the following may be needed
|
|
|
+ header('Cache-Control: max-age=1');
|
|
|
+ // If you're serving to IE over SSL, then the following may be needed
|
|
|
+ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
|
|
+ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
|
|
|
+ header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
|
|
+ header('Pragma: public'); // HTTP/1.0
|
|
|
+ $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
|
|
+ $writer->save('php://output');
|
|
|
|
|
|
echo "success";
|
|
|
|