Excel双重文件下载做法结合上面的方法
作者:互联网
@Override
public String downloadTeachClassTemplate() {
HSSFWorkbook work = null;
List<KeyValueBean> headList = new ArrayList<KeyValueBean>();
String[] headerList = new String[]{"课程编号!","课程名称","班级名称!","教师工号!","教师名称","理论周学时","实训周学时","实训场地","连排节数!"};
String[] explainList = new String[]{"说明:必填,填入系统中已经存在的课程编号",
"说明:选填,该列可以不填,导入表格时以课程号为准",
"说明:必填,填入系统中存在的班级名称,多个班级间以“,”分隔(例:班1,班2)",
"说明:必填,填入系统为教工用户分配的系统工号",
"说明:选填,可以填入该工号对应的教师名称,导入时以教师工号为准",
"说明:选填,只能填写大于或等于0的整数,如果不填默认为0",
"说明:选填,只能填写大于或等于0的整数,如果不填默认为0",
"说明:选填,填写实训教室的名称,多个实训场地以“,”分隔",
"说明:选填,填写连排节数,默认连排节数为1"
};
for (int i = 0; i < headerList.length; i++) {
headList.add(new KeyValueBean(headerList[i],explainList[i]));
}
work = Utils.genericSheet("导入排课教学计划", headList, null, work);
work = courseSheet(work);
return Utils.writeToWork(work, "teachClassTemplate.xls");
}
public HSSFWorkbook courseSheet(HSSFWorkbook work) {
List<KeyValueBean> headList = new ArrayList<KeyValueBean>();
List<Map<String,Object>> data = new ArrayList<Map<String,Object>>();
String[] headerList = new String[]{"课程编号","课程名称"};
String[] explainList = new String[]{"说明:对应系统课程编号","说明:课程编号对应的课程名称"};
for (int i = 0; i < headerList.length; i++) {
headList.add(new KeyValueBean(headerList[i],explainList[i]));
}
List<ZhxyInfoCourseVO> courseList = zhxyInfoCourseDAO.getAllInfoCourse(null);
if(CollectionUtils.isNotEmpty(courseList)){
for (ZhxyInfoCourseVO zhxyInfoCourseVO : courseList) {
Map<String,Object> map = new HashMap<String, Object>();
map.put(headerList[0], zhxyInfoCourseVO.getNumber());
map.put(headerList[1], zhxyInfoCourseVO.getName());
data.add(map);
}
}
return Utils.genericSheet("课程列表(参考)", headList, data, work);
}
结果视图:
标签:headList,work,String,双重,Excel,headerList,选填,new,下载 来源: https://blog.csdn.net/Z_passionate/article/details/89278025