<?php require_once '../service/StudentInfoService.class.php'; require_once '../phpbean/StudentInfo.class.php'; require_once '../service/NationService.class.php'; $nationService = new NationService(); $zkzh = $_GET['zkzh']; $studentInfoService = new StudentInfoService(); $studentInfo = $studentInfoService->GetStudentInfo($zkzh); /*使用 JSON数据格式返回*/ header('Content-type: text/json;charset=utf-8'); echo "{zkzh:\"" . $studentInfo->getZkzh() . "\""; echo ",name:\"" . $studentInfo->getName() . "\""; echo ",sex:\"" . $studentInfo->getSex() . "\""; echo ",kslb:\"" . $studentInfo->getKslb() . "\""; echo ",zzmm:\"" . $studentInfo->getZzmm() . "\""; echo ",nation:\"" . $nationService->GetNation($studentInfo->getNation())->getNationName() . "\""; echo ",byxx:\"" . $studentInfo->getByxx() . "\""; echo ",hkszd:\"" . $studentInfo->getHkszd() . "\""; echo ",address:\"" . $studentInfo->getAddress() . "\""; echo ",telephone:\"" . $studentInfo->getTelephone() . "\""; echo ",zcxx:\"" . $studentInfo->getZcxx() . "\""; echo ",cardNumber:\"" . $studentInfo->getCardNumber() . "\""; echo ",xjh:\"" . $studentInfo->getXjh() . "\""; echo ",gysznj:\"" . $studentInfo->getGysznj() . "\""; echo ",gesznj:\"" . $studentInfo->getGesznj() . "\""; echo ",gssznj:\"" . $studentInfo->getGssznj() . "\""; echo ",memo:\"" . $studentInfo->getMemo() . "\""; echo ",photo:\"" . $studentInfo->getPhoto() . "\""; echo "}";
//$objWriter->save($FileName); //选中保存路径 $outputFileName = iconv('UTF-8', 'gb2312', '民族信息记录.xls'); ob_end_clean(); //清除缓冲区,避免乱码 header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename=' . $outputFileName); header('Cache-Control: max-age=0'); //$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); } else { if ($action == "update") { //说明用户希望执行更新民族信息信息 $array_nation = $_POST["nation"]; $nation = $nationService->GetNation($array_nation['nationId']); $nation->setNationId($array_nation['nationId']); $nation->setNationName($array_nation['nationName']); //完成修改->数据库 $res = $nationService->UpdateNation($nation); if ($res != 0) { header("Location: /ok.php"); exit; } else { //失败 header("Location: /error.php"); exit; } } else { if ($action == "del") { //这时我们知道要删除民族信息信息
<?php require_once '../service/NationService.class.php'; require_once '../phpbean/Nation.class.php'; $nationId = $_GET['nationId']; $nationService = new NationService(); $nation = $nationService->GetNation($nationId); /*使用 JSON数据格式返回*/ header('Content-type: text/json;charset=utf-8'); echo "{nationId:" . $nation->getNationId(); echo ",nationName:\"" . $nation->getNationName() . "\""; echo "}";
$cardNumber = !empty($_POST['cardNumber']) ? $_POST['cardNumber'] : ""; $xjh = !empty($_POST['xjh']) ? $_POST['xjh'] : ""; //创建StudentInfoService实例 $studentInfoService = new StudentInfoService(); $studentInfoArray = $studentInfoService->QueryPrintStudentInfoInfo($zkzh, $name, $kslb, $nation, $byxx, $hkszd, $address, $telephone, $cardNumber, $xjh); for ($i = 0; $i < count($studentInfoArray); $i++) { $objPHPExcel->getActiveSheet()->getRowDimension($i + 3)->setRowHeight(50); $studentInfo = $studentInfoArray[$i]; $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 3), $studentInfo['zkzh']); $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 3), $studentInfo['name']); $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 3), $studentInfo['sex']); $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 3), $studentInfo['kslb']); $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 3), $studentInfo['zzmm']); require_once '../service/NationService.class.php'; $nationService = new NationService(); $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 3), $nationService->GetNation($studentInfo['nation'])->getnationName()); $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 3), $studentInfo['byxx']); $objPHPExcel->getActiveSheet()->setCellValue('H' . ($i + 3), $studentInfo['hkszd']); $objPHPExcel->getActiveSheet()->setCellValue('I' . ($i + 3), $studentInfo['address']); $objPHPExcel->getActiveSheet()->setCellValue('J' . ($i + 3), $studentInfo['telephone']); $objPHPExcel->getActiveSheet()->setCellValue('K' . ($i + 3), $studentInfo['zcxx']); $objPHPExcel->getActiveSheet()->setCellValueExplicit('L' . ($i + 3), $studentInfo['cardNumber'], PHPExcel_Cell_DataType::TYPE_STRING); $objPHPExcel->getActiveSheet()->setCellValue('M' . ($i + 3), $studentInfo['xjh']); $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setName('photo'); $objDrawing->setDescription('photo'); $objDrawing->setPath('..' . $studentInfo['photo']); $objDrawing->setResizeProportional(false); //取消按原图像缩放 $objDrawing->setHeight(68); $objDrawing->setWidth(85);