基于javaweb+mysql的springboot教务管理系统(java+thymeleaf+html+spring+springboot+layui+maven)

基于javaweb+mysql的springboot教务管理系统(java+thymeleaf+html+spring+springboot+layui+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot教务管理系统(java+thymeleaf+html+spring+springboot+layui+maven)

一、项目简述

功能包括: 三角色教师 管理员,学生教务管理系统,包括院系管理,课题综合管理,信息管理,以及差旅管理,学生选题等等。

二、项目运行 环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

JSP +Spring + SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等

        return Msg.sqlChange(collegeService.delCollege(institute));
    }
    @PutMapping("/college")
    @ResponseBody
    public Msg updateCollege(@RequestBody @Validated Institute institute){
        return Msg.sqlChange(collegeService.updateCollege(institute.getId(),institute.getInstituteName()));
    }
    @PostMapping("/college")
    @ResponseBody
    public Msg addeCollege(@RequestBody @Validated Institute institute){
        return Msg.sqlChange(collegeService.addCollege(institute.getInstituteName()));
    }

    /**
     *  子管理员 管理
     */

    @GetMapping("/AdminManagement")
    public String subadmin(){
        return "admin/AdminManagement";
    }

    @GetMapping("/admin")
    @ResponseBody
    public Msg getAdmins(
            @RequestParam(required = false) Long offset
    ){

        return Msg.success().add("admins",adminService.selectAdmins(offset));
    }
    @PostMapping("/admin")
    @ResponseBody
    public Msg addAdmin(
            @RequestBody @Validated Admin admin
    ){
        return Msg.sqlChange(adminService.addAdmin(admin));
    }
    @DeleteMapping("/admin")
    @ResponseBody
    public Msg delAdmin(
            @RequestBody Admin admin
    ){
        return Msg.sqlChange(adminService.delAdmin(admin));
    }
        EasyExcel.write(response.getOutputStream())
                // 这里放入动态头
                .head(TeacherExcelUtil.head()).sheet("模板")
                // table的时候 传入class 并且设置needHead =false
                .table().head(TeacherExcel.class)
                .needHead(Boolean.FALSE)
                .doWrite(teacherExcels);//写入空数据
    }

    /**
     * 学生导入
     *
     * @param excelFile
     * @param id_institute
     */
    @Override
    public Msg studentExcelImport(MultipartFile excelFile, long id_institute) throws IOException {
        System.out.println(1);
        if(excelFile==null)
        {
            throw new MyException("文件上传失败");
        }
        String name = excelFile.getOriginalFilename();
        LOGGER.info("Excel文件名{}",name);
        if(
                name.indexOf("xlsx")<0 &&
                        name.indexOf("xls")<0
        ){
            System.out.println(2);
            throw new MyException("文件格式有问题!");
        }
        //使用easyExcel
        //给监听器初始化
        studentExcelUtil.init();
        studentExcelUtil.setId_institute(id_institute);

        long start = System.currentTimeMillis();
        //excel读取
        EasyExcel.read(excelFile.getInputStream(), StudentExcel.class, studentExcelUtil).sheet().doRead();
        LOGGER.info("用时:{}",System.currentTimeMillis()-start);

        //如果 出现异常 则显示导入多少教师,和没导入的教师message

        return projectMapper.select_project(institute_id, null, null);
    }

    @Override
    public List<Static_student> select_studentXT_all(Long section_id, String section_name, Long specialty_id, String specialty_name, Long class_id, String class_name) {
        List<Static_student> static_students = studentMapper.select_studentXT_all(section_id, section_name, specialty_id, specialty_name, class_id, class_name);
        if (static_students != null && static_students.size() > 0) {
            for (int i = 0; i < static_students.size(); i++) {
                List<Subjectselected> projectselecteds = select_Projectselected(static_students.get(i).getId(), null);
                if (projectselecteds != null && projectselecteds.size() > 0) {
                    static_students.get(i).setStuselectFlag("" + projectselecteds.get(0).getStuselectFlag());
                    static_students.get(i).setProjectname(projectselecteds.get(0).getProject_name());
                    static_students.get(i).setTeachernames(projectselecteds.get(0).getProject_teachers());
                } else {
                    static_students.get(i).setProjectname("未选题");
                    static_students.get(i).setTeachernames("");
                }
            }
        }
        return static_students;
    }

    @Override
    public List<Class> select_class(Long institute_id, Long section_id, Long specialty_id, Long class_id, String class_name) {
        return classMapper.select_class(institute_id, section_id, specialty_id, class_id, class_name);
    }

    // 专业方向的增删改查
    @Override
    public int add_specialty(Long section_id, String specialty_name) {
        List<Specialty> specialties = select_specialty(null, null, null, specialty_name);
        if (specialties == null || specialties.size() == 0) {
            Specialty specialty = new Specialty();
            specialty.setIdSection(section_id);
            specialty.setSpecialtyName(specialty_name);
            return specialtyMapper.insert(specialty);
        }
        return 0;
    }

    @Override
    public int delete_student(Long student_id) {
        return studentMapper.deleteByPrimaryKey(student_id);
    }
        //获取获奖情况
        String winAward = debriefing.getWinaward();
        aa = winAward.split("/");

        region = new CellRangeAddress(index, index + aa.length - 1, (short) 0, (short) 0);
        sheet.addMergedRegion(region);
        fun8(region, sheet, workBook);

        //填充获奖情况
        for (int j = 0; j < aa.length; index++, j++) {
            row = sheet.createRow(index);
            cell = row.createCell(1);
            cell.setCellValue(j + 1);
            cell.setCellStyle(style3);
            cell = row.createCell(0);
            cell.setCellValue("获奖情况");
            cell.setCellStyle(style3);
            region = new CellRangeAddress(index, index, (short) 2, (short) 6);
            sheet.addMergedRegion(region);
            fun8(region, sheet, workBook);
            cell = row.createCell(2);
            cell.setCellValue(aa[j]);
            cell.setCellStyle(style3);
            row.setHeightInPoints(30);

        }

        String summary = debriefing.getSummary();
        row = sheet.createRow(index);
        cell = row.createCell(0);
        cell.setCellValue("工作亮点小结(不超过100字)");
        cell.setCellStyle(style3);
        region = new CellRangeAddress(index, index, (short) 1, (short) 6);
        sheet.addMergedRegion(region);
        fun8(region, sheet, workBook);
        cell = row.createCell(1);
        cell.setCellValue(summary);
        cell.setCellStyle(style3);
        row.setHeightInPoints(150);

        response.setCharacterEncoding("utf-8");
        response.setContentType("application/msexcel");
        OutputStream output = response.getOutputStream();
        String outputName = teacher.getInstituteName() + year + term + "学期述职表";
        String encodeFilename = URLEncoder.encode(outputName, StandardCharsets.UTF_8.toString());

        response.setHeader("Content-disposition", "attachment; filename=" + encodeFilename + ".xlsx");

//                String time = sdf.format(teacher.getParticipationdate());
                System.out.println(teacher.getParticipationdate());
                put("date", teacher.getParticipationdate());
                put("administrativeDuty", teacher.getAdministrativeduty());
                put("technicalPosition", teacher.getTechnicalposition());
                put("politicalStatus", teacher.getPoliticalstatus());
                put("year", assessment.getYear());
                put("personalSummary", assessment.getPersonalsummary());

            }
        };

        File path = new File(ResourceUtils.getURL("target").getPath());
        String wordPath = path.getAbsolutePath() + "\\classes\\static\\model\\";
        String modelName = "ndkh.docx";

        XWPFTemplate template = XWPFTemplate.compile(wordPath + modelName)
                .render(datas);

        try {
            BufferedOutputStream out = new BufferedOutputStream(output);
            template.write(out);
            out.flush();
            out.close();
            template.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    //下载年度述职表
    @GetMapping("/down_year_debriefing")
    public void fun7(Long year, HttpSession httpSession, HttpServletResponse response) throws IOException {
        Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");

        //查询指定年份的年度述职信息
        DebriefingYearWithBLOBs debriefingYear = teacherService.selectYearDebriefingInfo(teacher.getId(), year);

        // 新建工作簿对象

/**
 * 统一异常处理器
 */

@ControllerAdvice
//@ResponseBody
public class WebExceptionHandler {

    @Autowired
    HttpServletResponse response;

    private static final Logger log = LoggerFactory.getLogger(WebExceptionHandler.class);

    @ResponseBody
    @ExceptionHandler
    public Msg methodArgumentNotValidException(MethodArgumentNotValidException exception){
        BindingResult result = exception.getBindingResult();
        String errorMsg = "";
        int index= 1;
        for(FieldError e: result.getFieldErrors())
        {
            errorMsg += index++ +"."+ e.getDefaultMessage()+"<br>";
        }

        return Msg.error(errorMsg);
    }

    /**
     * 登录超时
     * @param e
     * @throws IOException
     */
    @ResponseBody
    @ExceptionHandler
    public String LoginTimeOutException(LoginTimeoutException e) throws IOException {
//        response.sendError(404);
//        response.sendRedirect("404");
        return "登录超时 或 没有登录";
    }
            student.setIdClass(null);
        }
        if (student.getName().equals(Tstudent.getName())) {
            student.setName(null);
        }
        if (student.getGender().equals(Tstudent.getGender())) {
            student.setGender(null);
        }
        if (student.getGender() == null && student.getName() == null && student.getIdClass() == null && student.getStunum() == null) {

        } else {
            student.setId(Tstudent.getId());
            count = indexService.updateBymodifyinfo(student);
            student = indexService.selectByid(Tstudent.getId());
            model.addAttribute("student", student);
        }
        if (count > 0) {
            request.getSession().setAttribute("student",student);
            request.getSession().setAttribute("modifyFlag",1);
            return "200";
        } else {
            request.getSession().setAttribute("modifyFlag",0);
            return "201";
        }
    }*/

    /**
     *   跳转页面(修改密码)
     */
    @RequestMapping("/changepsw")
    public String changepsw() {
        return "student/changepsw";
    }

    /**
     * 200修改成功
     * 201对不起密码错误
     * 202对不起输入框为空
     * 203新密码不一致
     * 204修改失败
     */
    @RequestMapping(value = "/changepassword", method = RequestMethod.PUT)
    @ResponseBody
    private static final Logger LOGGER = LoggerFactory.getLogger(StaticController.class);

    @Autowired
    StaticService staticService;

    @Autowired
    TeacherService teacherService;

    @Autowired
    SectionService sectionService;

    @Autowired
    SubjectService subjectService;

    @GetMapping("/upload_work_page")
    public String uploadWork() {
        return "teacher/workapproval/upload";
    }

    @GetMapping("/texaminePage")
    public String examine() {
        return "teacher/texamine";
    }

    //查询出差类型
    @GetMapping("/work_type")
    @ResponseBody
    public Msg fun1() {
        List<Workapprovaltype> list = staticService.selectAllWorkApprovalType();
        return Msg.success().add("workInfo", list);
    }

    //提交出差申请
    @PostMapping("/upload_work")
    @ResponseBody
    public Msg fun2(String idType, String worktitle, String beginDate, String endDate, String location,
                    String member, HttpSession httpSession) throws ParseException {
        //获取教师信息
        Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");

        //字符串转换为时间
        Date currentTime = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date start = sdf.parse(beginDate);
    //下载年度述职表
    @GetMapping("/down_year_debriefing")
    public void fun7(Long year, HttpSession httpSession, HttpServletResponse response) throws IOException {
        Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");

        //查询指定年份的年度述职信息
        DebriefingYearWithBLOBs debriefingYear = teacherService.selectYearDebriefingInfo(teacher.getId(), year);

        // 新建工作簿对象
        XSSFWorkbook workBook = new XSSFWorkbook();
        // 创建sheet对象
        XSSFSheet sheet = workBook.createSheet("Sheet1");

        sheet.setColumnWidth(0, 15 * 256);//设置第1列宽

        sheet.setColumnWidth(6, 24 * 256);//设置第1列宽

        //创建行,头标题
        XSSFRow row = sheet.createRow(0);
        CellRangeAddress region = new CellRangeAddress(0, 0, (short) 0, (short) 6);  //合并单元格,
        sheet.addMergedRegion(region);
        //合并单元格边框
        fun8(region, sheet, workBook);

        row.createCell(0).setCellValue("信息工程学院" + year + "年度述职表");
        row.setHeightInPoints(40); //设置行高

        //设置头部单元格样式
        XSSFCellStyle style1 = workBook.createCellStyle();
        XSSFFont f = workBook.createFont();
        f.setFontHeightInPoints((short) 18);//字号
        f.setFontName("仿宋_GB2312");//设置字体
        f.setBold(true);//加粗
        style1.setFont(f);
        style1.setAlignment(HorizontalAlignment.CENTER);//左右居中
        style1.setVerticalAlignment(VerticalAlignment.CENTER);//上下居中
        style1.setBorderBottom(BorderStyle.THIN);//下边框
        style1.setBorderBottom(BorderStyle.THIN);//下边框
        style1.setBorderLeft(BorderStyle.THIN);//左边框
        style1.setBorderTop(BorderStyle.THIN);//上边框
        style1.setBorderRight(BorderStyle.THIN);//右边框
        row = sheet.getRow(0);
        XSSFCell cell = row.getCell(0);
        cell.setCellStyle(style1); //获取指定行并赋值样式

            if (user.getRole().equals("sadmin")) {
                //检查方法上 是否有注解的 Role.SADMIN 或者 Role.ADMIN 权限 , 没有则检查类上有没有 如果符合要求则放行
                if (HandlerUitl.checkAuthority(handler, new Role[]{Role.SADMIN, Role.ADMIN})) {
                    request.setAttribute("user", user);
                    return true;
                }
            }
            if (user.getRole().equals("admin")) {
                if (HandlerUitl.checkAuthority(handler, new Role[]{Role.ADMIN})) {
                    request.setAttribute("user", user);
                    return true;
                }else {
                    response.sendRedirect(contextPath + "/login");
                }
            }

            if (user.getRole().equals("teacher")) {
                if (HandlerUitl.checkAuthority(handler, new Role[]{Role.TEACHER})) {

                    return true;
                } else {
                    response.sendRedirect(contextPath + "/login");
                }
            }

            if (user.getRole().equals("student")) {
                if (HandlerUitl.checkAuthority(handler, new Role[]{Role.STUDENT})) {

                    return true;
                } else {

                    response.sendRedirect(contextPath + "/student/login");
                }
            }
        }else {
            response.sendRedirect(contextPath + "/login");
        }

        return false;
    }
}
package com.hngy.educationaladministration.controller;

    @Autowired
    AdminService adminService;

    @Autowired
    AdminMapper adminMapper;

    @Autowired
    CollegeService collegeService;

    @Autowired
    SectionService sectionService;

    @Autowired
    SpecialtyService specialtyService;

    @Autowired
    ClassService classService;

    @Autowired
    TeacherService teacherService;

    @Autowired
    StudentService studentService;

    @Autowired
    SubjectService subjectService;

    @Autowired
    ExcelService excelService;

    @Autowired
    SubjectRelationStudentMapper subjectRelationStudentMapper;

    @Autowired
    HttpServletRequest request;

    @Autowired
    HttpServletResponse response;

    @Autowired
    HttpSession session;

    @ModelAttribute("id_institute")
    public long getRoleInfo() {
        User user = (User) request.getAttribute("user");
//        LOGGER.info("USER:{}",user);
        if (user != null) {
            if (user.getRole().equals("admin")) {
                Institute institute = collegeService.selectCollege(adminMapper.selectByPrimaryKey(user.getId()).getIdInstitute());
                return institute.getId();
            }
    int delete_class(Long class_id);

    int update_class(Long class_id, Long specialty_id, String class_name);

    List<Class> select_class(Long institute_id, Long section_id, Long specialty_id, Long class_id, String class_name);// 根据学院id 或者 教研室id  或者 专业方向_id 查询所有班级

    // 根据学院生成 以专业为前提 课题一览表
    List<Project> select_project(Long institute_id, Long section_id, String section_name);

    // 根据 综合条件 ,专业生成 学生选题一览表;
    List<Static_student> select_studentXT_all(Long section_id, String section_name, Long specialty_id, String specialty_name, Long class_id, String class_name);

    // 学院的增删改查
//    int add_institute(String institute_name);
//
//    int delete_institute(Long institute_id);
//
//    int update_institute(Long institute_id, String institute_name);

    List<Institute> select_institute(Long institute_id, String institute_name);

    // 专业方向的增删改查
    int add_specialty(Long section_id, String specialty_name);

    int delete_specialty(Long specialty_id);

    int update_specialty(Long specialty_id, Long section_id, String specialty_name);

    List<Specialty> select_specialty(Long institute_id, Long section_id, Long specialty_id, String specialty_name); // 根据学院id 或者 教研室id 查所有专业方向

}

package com.hngy.educationaladministration.config;


    @Autowired
    SpecialtyService specialtyService;

    @Autowired
    ClassService classService;

    @Autowired
    TeacherService teacherService;

    @Autowired
    StudentService studentService;

    @Autowired
    SubjectService subjectService;

    @Autowired
    ExcelService excelService;

    @Autowired
    SubjectRelationStudentMapper subjectRelationStudentMapper;

    @Autowired
    HttpServletRequest request;

    @Autowired
    HttpServletResponse response;

    @Autowired
    HttpSession session;

    @ModelAttribute("id_institute")
    public long getRoleInfo() {
        User user = (User) request.getAttribute("user");
//        LOGGER.info("USER:{}",user);
        if (user != null) {
            if (user.getRole().equals("admin")) {
                Institute institute = collegeService.selectCollege(adminMapper.selectByPrimaryKey(user.getId()).getIdInstitute());
                return institute.getId();
            }
            if (user.getRole().equals("sadmin")) {
                return -1;
            }
            return 0;
        } else {
            return 0;
        }
    }

//   admin index page   子管首页
        response.sendRedirect("/error/404");
    }

}
package com.hngy.educationaladministration.interceptor;

public class LoginInterceptor extends HandlerInterceptorAdapter {

    private static final Logger log = LoggerFactory.getLogger(WebExceptionHandler.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        String url = request.getRequestURI();
//        log.info(request.getMethod()+" 请求URL:"+url);

        //从Token中解析User信息
        User user = TokenUtil.verifyToken(request);

        String contextPath = request.getContextPath();
        //user 为空则 表示 Token 不存在
        if (user != null) {
            if (user.getRole().equals("sadmin")) {
                //检查方法上 是否有注解的 Role.SADMIN 或者 Role.ADMIN 权限 , 没有则检查类上有没有 如果符合要求则放行
                if (HandlerUitl.checkAuthority(handler, new Role[]{Role.SADMIN, Role.ADMIN})) {
                    request.setAttribute("user", user);
                    return true;
                }
            }
            if (user.getRole().equals("admin")) {
                if (HandlerUitl.checkAuthority(handler, new Role[]{Role.ADMIN})) {
                    request.setAttribute("user", user);
public class LoginController {

    private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);

    @Autowired
    AdminService adminService;

    @GetMapping("/cs")
    public String cs() {
        return "cs";
    }

    @GetMapping("/login")
    public String login() {
        return "login";
    }

    @PostMapping("/login")
    @ResponseBody
    public Msg login(String name, String pwd, HttpSession httpSession) {
        name = name.trim();
//        LOGGER.info("{}--{}",name,pwd);
        return adminService.login(name, pwd, httpSession);

    }
}
package com.hngy.educationaladministration.service;

public interface ExcelService {

    /**
     * 教师导入
     */

   Msg teacherExcelImport(MultipartFile excelFile,long id_institute) throws IOException;
            return user;
        } catch ( TokenExpiredException e){
//            e.printStackTrace();
            throw new LoginTimeoutException("登录超时");
        } catch (JWTVerificationException exception ){
//                    exception.printStackTrace();
        }

        return null;
    }
}
package com.hngy.educationaladministration.service;

public interface AdminService {

    Msg login(String name, String pwd , HttpSession httpSession);

    Admin selectByName(String name);

    Sadmin selectSadminByName(String name);

    int updatePwdByUserName(String name,String pwd);

    List selectAdmins(Long offset);

    /**
     *  ----------

                    .example().or()
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andStunumEqualTo(keyWord)) // 根据学号查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 按指定专业的班级查询
                            criteria -> criteria.andIdEqualTo(0L))

                    .example()
                    .when(offset!=-1 && offset != 0,criteria -> criteria.page(offset-1, 10));// 查询第offest-1页数据(每页10条);
        }

        return studentExample.newAndCreateCriteria()
                .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andNameEqualTo(keyWord)) //根据姓名
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 查询的学生只能在当前的学院的班级下
                            criteria -> criteria.andIdEqualTo(0L))

                .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andUsernameEqualTo(keyWord)) //根据登录名查询
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 查询的学生只能在当前的学院的班级下
                            criteria -> criteria.andIdEqualTo(0L))

                .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andStunumEqualTo(keyWord)) // 根据学号查询
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                        criteria -> criteria.andIdClassIn(classesIDs),// 查询的学生只能在当前的学院的班级下
                        criteria -> criteria.andIdEqualTo(0L))

                .example()
                .when(offset!=-1 && offset != 0,criteria -> criteria.page(offset-1, 10));// 查询第offest-1页数据(每页10条);
    }

    public void check(StudentWithBLOBs student ,Long id_institute) throws MyException {
        //懒得写
    }

    public void updateselectnumAdd(String project_name) {
        Long id = studentMapper.select_projectID(project_name);
        int listsize = (int)request.getSession().getAttribute("listsize");
        synchronized (this){
            studentMapper.updateNumAdd(id,listsize);
        }
        为单元格添加背景样式
//        for (int i = 1; i < projects.size() + 3; i++) { //需要6行表格
//            Row row = sheet.createRow(i); //创建行
//            for (int j = 0; j < 7; j++) {//需要6列
//                row.createCell(j).setCellStyle(style);
//            }
//        }
//        //合并单元格
//        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));//合并单元格,cellRangAddress四个参数,第一个起始行,第二终止行,第三个起始列,第四个终止列
//        sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
//        sheet.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
//        sheet.addMergedRegion(new CellRangeAddress(1, 2, 2, 2));
//        sheet.addMergedRegion(new CellRangeAddress(1, 1, 3, 5));
//        sheet.addMergedRegion(new CellRangeAddress(1, 2, 6, 6));
//        //设置标题栏
//        XSSFRow row = sheet.createRow(0); //获取第一行
//        row.createCell(0).setCellStyle(style1);
//        if (Idinstitute != null) {
//            row.getCell(0).setCellValue("湖南工业职业技术学院 " + institutes.get(0).getInstituteName() + " 毕业设计课题汇总表"); //在第一行中创建一个单元格并赋值
//        } else {
//            row.getCell(0).setCellValue("湖南工业职业技术学院全院毕业设计课题汇总表");
//        }
//        XSSFRow row1 = sheet.getRow(1); //获取第二行,为每一列添加字段
//        row1.getCell(0).setCellValue("序号");
//        row1.getCell(1).setCellValue("专业");
//        row1.getCell(2).setCellValue("指导老师");
//        row1.getCell(3).setCellValue("课   题");
//        row1.getCell(6).setCellValue("报选人数");
//        XSSFRow row2 = sheet.getRow(2); //获取第三行
//        row2.getCell(3).setCellValue("课题名称");
//        row2.getCell(4).setCellValue("课题类型");
//        row2.getCell(5).setCellValue("课题来源");
//
//        int hang = 3;
//        //导入数据
//        for (int j = 0; j < projects.size(); j++, hang++) {
//            XSSFRow rowxx = sheet.getRow(hang);
//            rowxx.getCell(0).setCellValue(hang - 2);
//            rowxx.getCell(1).setCellValue(projects.get(j).getSection_name());
//            rowxx.getCell(2).setCellValue(projects.get(j).getTeachernames());
//            rowxx.getCell(3).setCellValue(projects.get(j).getProjectname());
//            rowxx.getCell(4).setCellValue(projects.get(j).getTypeName());
//            rowxx.getCell(5).setCellValue(projects.get(j).getSourceName());
//            rowxx.getCell(6).setCellValue(" " + projects.get(j).getSelectcount());
//        }
//
//        // 自动列宽
//        sheet.setDefaultRowHeight((short) (2 * 256));

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值