diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index 74a8ecba..c136eb64 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -474,8 +474,15 @@ class Index extends Base ->only([ 'kaoshi'=>'1', 'banji'=>array(), + 'school', + 'ruxuenian' ],'POST'); + // 获取要下载成绩的学校和年级信息 + $school = new \app\system\model\School; + $schoolname = $school->where('id',$list['school'])->value('jiancheng'); + $nianji = nianjiList(); + // 实例化验证模型 $validate = new \app\chengji\validate\Cjdownload; @@ -515,6 +522,8 @@ class Index extends Base ]) ->find(); + $tabletitle =$ks->title.' '.$schoolname.' '.$nianji[$list['ruxuenian']].' '.'学生成绩详细列表'; + $colname = excelLieming(); @@ -522,8 +531,10 @@ class Index extends Base $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet; $sheet = $spreadsheet->getActiveSheet(); + + // 设置表头信息 - $sheet->setCellValue('A1', $ks->title.'学生成绩列表'); + $sheet->setCellValue('A1', $tabletitle); $sheet->setCellValue('A2', '序号'); $sheet->setCellValue('B2', '班级'); $sheet->setCellValue('C2', '姓名'); @@ -590,7 +601,7 @@ class Index extends Base // 保存文件 - $filename = $ks->title.'学生成绩列表'.date('ymdHis').'.xlsx'; + $filename = $tabletitle.date('ymdHis').'.xlsx'; header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0'); diff --git a/application/chengji/controller/Tongji.php b/application/chengji/controller/Tongji.php index c3937666..c8c12afd 100644 --- a/application/chengji/controller/Tongji.php +++ b/application/chengji/controller/Tongji.php @@ -237,7 +237,7 @@ class Tongji extends Base // 获取参考学科 $ks = new \app\kaoshi\model\Kaoshi; $ksinfo = $ks->where('id',$src['kaoshi']) - ->field('id') + ->field('id,title') ->with([ 'ksSubject'=>function($query){ $query->field('kaoshiid,subjectid,manfen') @@ -250,6 +250,11 @@ class Tongji extends Base ->find(); $xk = $ksinfo->ks_subject; + // 获取要下载成绩的学校和年级信息 + $school = new \app\system\model\School; + $schoolname = $school->where('id',$src['school'])->value('jiancheng'); + $tabletitle = $ksinfo->title.' '.$schoolname.' '.$src['nianji'].'各班级成绩汇总'; + // 创建表格 $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -263,7 +268,7 @@ class Tongji extends Base // 设置表头信息 $sheet->mergeCells('A1:'.$colname[$colcnt].'1'); - $sheet->setCellValue('A1', '各班级学生成绩列表'); + $sheet->setCellValue('A1', $tabletitle); $sheet->mergeCells('A3:A4'); $sheet->setCellValue('A3', '序号'); $sheet->mergeCells('B3:B4'); @@ -302,7 +307,7 @@ class Tongji extends Base } // 保存文件 - $filename = '各班级成绩汇总'.date('ymdHis').'.xlsx'; + $filename = $tabletitle.date('ymdHis').'.xlsx'; header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0'); @@ -519,7 +524,7 @@ class Tongji extends Base // 获取参考学科 $ks = new \app\kaoshi\model\Kaoshi; $ksinfo = $ks->where('id',$src['kaoshi']) - ->field('id') + ->field('id,title') ->with([ 'ksSubject'=>function($query){ $query->field('kaoshiid,subjectid,manfen') @@ -532,6 +537,9 @@ class Tongji extends Base ->find(); $xk = $ksinfo->ks_subject; + // 获取要下载成绩的学校和年级信息 + $tabletitle = $ksinfo->title.' '.$src['nianji'].'各学校成绩汇总'; + // 创建表格 $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -545,7 +553,7 @@ class Tongji extends Base // 设置表头信息 $sheet->mergeCells('A1:'.$colname[$colcnt].'1'); - $sheet->setCellValue('A1', '各班级学生成绩列表'); + $sheet->setCellValue('A1', $tabletitle); $sheet->mergeCells('A3:A4'); $sheet->setCellValue('A3', '序号'); $sheet->mergeCells('B3:B4'); @@ -584,7 +592,7 @@ class Tongji extends Base } // 保存文件 - $filename = '各学校'.$src['nianji'].'年级成绩汇总'.date('ymdHis').'.xlsx'; + $filename = $tabletitle.date('ymdHis').'.xlsx'; header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0');