|
|
@@ -1,5 +1,9 @@
|
|
|
package com.ssj.sys.controller;
|
|
|
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
|
|
+import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.ssj.bean.common.framework.core.domain.Response;
|
|
|
import com.ssj.bean.sys.sort.domain.Sort;
|
|
|
@@ -17,6 +21,7 @@ import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -1269,7 +1274,7 @@ public class SysZuoybController extends BaseController {
|
|
|
}
|
|
|
/**
|
|
|
* 作业知识点基础数据保存
|
|
|
- * @param content
|
|
|
+ * @param
|
|
|
* @return
|
|
|
* 创建人:ZhangCaibao
|
|
|
* 2017年7月5日 上午10:40:51
|
|
|
@@ -1832,19 +1837,15 @@ public class SysZuoybController extends BaseController {
|
|
|
params.put("banben", request.getParameter("banben") == null ? "" : request.getParameter("banben"));
|
|
|
ServletOutputStream os = null;
|
|
|
try {
|
|
|
- os = response.getOutputStream(); // 获得输出流
|
|
|
+ // 获得输出流
|
|
|
+ os = response.getOutputStream();
|
|
|
response.reset(); // 清空输出流
|
|
|
-
|
|
|
- String filesName = new String(fileName.toString().getBytes("gb2312"), "ISO8859-1") +".xlsx";
|
|
|
+ exportExcelHead(response,fileName.toString());
|
|
|
int rownum = 1; // 添加的起始行
|
|
|
-
|
|
|
+
|
|
|
|
|
|
ClassPathResource classPathResource = new ClassPathResource("/excel/report/report7.xlsx");
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(classPathResource.getInputStream());
|
|
|
- response.setHeader("Content-disposition", "attachment; filename=" + filesName); // 设定输出文件头
|
|
|
- // response.setContentType("application/msexcel"); //定义输出类型
|
|
|
- response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
- response.setCharacterEncoding("utf-8");
|
|
|
XSSFSheet sheet = workbook.getSheetAt(0); // 读取第一个工作簿
|
|
|
XSSFRow row;
|
|
|
XSSFCell cell = null;
|
|
|
@@ -1852,7 +1853,7 @@ public class SysZuoybController extends BaseController {
|
|
|
List<Map<String, Object>> list = zuoybKnowHowDetailsService.getKonwDetail(params);
|
|
|
int endRow = rownum;
|
|
|
int startRow = rownum;
|
|
|
-
|
|
|
+
|
|
|
int idnum =6;
|
|
|
int detailnum =23;
|
|
|
int detailStartRow =rownum ;
|
|
|
@@ -2154,7 +2155,6 @@ public class SysZuoybController extends BaseController {
|
|
|
|
|
|
) throws Exception {
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
-
|
|
|
StringBuffer fileName =new StringBuffer("单元");
|
|
|
if(EQ_courseName != null){
|
|
|
fileName.append(EQ_courseName);
|
|
|
@@ -2171,86 +2171,21 @@ public class SysZuoybController extends BaseController {
|
|
|
params.put("banben", banben);
|
|
|
ServletOutputStream os = null;
|
|
|
try {
|
|
|
- os = response.getOutputStream(); // 获得输出流
|
|
|
- response.reset(); // 清空输出流
|
|
|
-
|
|
|
- String filesName = new String(fileName.toString().getBytes("gb2312"), "ISO8859-1") +".xlsx";
|
|
|
- int rownum = 1; // 添加的起始行
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("/excel/report/report13.xlsx");
|
|
|
- XSSFWorkbook workbook = new XSSFWorkbook(classPathResource.getInputStream());
|
|
|
- response.setHeader("Content-disposition", "attachment; filename=" + filesName); // 设定输出文件头
|
|
|
- // response.setContentType("application/msexcel"); //定义输出类型
|
|
|
- response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
- response.setCharacterEncoding("utf-8");
|
|
|
- XSSFSheet sheet = workbook.getSheetAt(0); // 读取第一个工作簿
|
|
|
- XSSFRow row;
|
|
|
- XSSFCell cell = null;
|
|
|
- XSSFCellStyle style = this.getxStyle(workbook);
|
|
|
+ os = response.getOutputStream();
|
|
|
+ // 清空输出流
|
|
|
+ response.reset();
|
|
|
+ //设置导出文件名以及文件头信息
|
|
|
+ exportExcelHead(response,fileName.toString());
|
|
|
List<Map<String, Object>> list=zuoybKnowHowDetailsSortService.getKonwVersion(EQ_libId, EQ_courseName, EQ_grade, banben, semester, LIKE_name);
|
|
|
- int endRow = rownum;
|
|
|
- int startRow = rownum;
|
|
|
-
|
|
|
- int idnum =6;
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- row = sheet.createRow(rownum);
|
|
|
- int j = 0;
|
|
|
- myCreateCellx(j++, list.get(i).get("course_name")!=null?list.get(i).get("course_name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("name")!=null?list.get(i).get("name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("id").toString(), row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("num")!=null?list.get(i).get("num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("module")!=null?list.get(i).get("module").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("create_time")!=null?list.get(i).get("create_time").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("s_id")!=null?list.get(i).get("s_id").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("alias")!=null?list.get(i).get("alias").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("semester")!=null?list.get(i).get("semester").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_num")!=null?list.get(i).get("s_num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("grade_num")!=null?list.get(i).get("grade_num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_type")!=null?list.get(i).get("s_type").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_create_time")!=null?list.get(i).get("s_create_time").toString():"", row, cell, style); // 列1
|
|
|
- if (i > 0) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (list.get(i).get("id").toString().equals(list.get(i - 1).get("id").toString())) {
|
|
|
- endRow++;// 则合并结束行号+1
|
|
|
- if (i == list.size() - 1) {
|
|
|
- for (int a = 0; a < idnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(startRow, // first
|
|
|
- endRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if (startRow != endRow) {
|
|
|
- for (int a = 0; a < idnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(startRow, // first
|
|
|
- endRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
- startRow = rownum;// 为下次合并做准备,把合并开始行号赋值为下一行开始号
|
|
|
- endRow = rownum;// 合并结束行同合并开始行
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- rownum++;
|
|
|
- }
|
|
|
+ //科目 单元 单元ID 单元序号 模块 创建时间 单元版本ID 单元版本别名 学期 排序 年级 版本 创建时间
|
|
|
+ String firstHead = "科目|course_name;单元|name;单元ID|id;单元序号|num;模块|module;创建时间|create_time";
|
|
|
+ List<ExcelExportEntity> entityList = new ArrayList<>();
|
|
|
+ addEntity(entityList,firstHead,new int[]{2});
|
|
|
+ String lastHead = "单元版本ID|s_id;单元版本别名|alias;学期|semester;排序|s_num;年级|grade_num;版本|s_type;创建时间|s_create_time";
|
|
|
+ addEntity(entityList,lastHead);
|
|
|
+ //把我们构造好的bean对象放到params就可以了
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(fileName.toString(), fileName.toString(), ExcelType.XSSF), entityList,
|
|
|
+ list);
|
|
|
workbook.write(os);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -2277,7 +2212,6 @@ public class SysZuoybController extends BaseController {
|
|
|
|
|
|
) throws Exception {
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
-
|
|
|
StringBuffer fileName =new StringBuffer("知识点");
|
|
|
if(EQ_courseName != null){
|
|
|
fileName.append(EQ_courseName);
|
|
|
@@ -2296,146 +2230,27 @@ public class SysZuoybController extends BaseController {
|
|
|
try {
|
|
|
os = response.getOutputStream(); // 获得输出流
|
|
|
response.reset(); // 清空输出流
|
|
|
-
|
|
|
- String filesName = new String(fileName.toString().getBytes("gb2312"), "ISO8859-1") +".xlsx";
|
|
|
- int rownum = 1; // 添加的起始行
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("/excel/report/report14.xlsx");
|
|
|
- XSSFWorkbook workbook = new XSSFWorkbook(classPathResource.getInputStream());
|
|
|
-
|
|
|
- response.setHeader("Content-disposition", "attachment; filename=" + filesName); // 设定输出文件头
|
|
|
- // response.setContentType("application/msexcel"); //定义输出类型
|
|
|
- response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
- response.setCharacterEncoding("utf-8");
|
|
|
- XSSFSheet sheet = workbook.getSheetAt(0); // 读取第一个工作簿
|
|
|
- XSSFRow row;
|
|
|
- XSSFCell cell = null;
|
|
|
- XSSFCellStyle style = this.getxStyle(workbook);
|
|
|
+ exportExcelHead(response,fileName.toString());
|
|
|
+
|
|
|
+ //科目 单元 单元ID 单元序号 模块 添加时间
|
|
|
+ // 知识点 知识点ID 一级模块 教学目标 重难点标识 要点梳理 要点梳理图片 二级模块 前知识点 后知识点 题目类型 重点章节 识记
|
|
|
+ // 理解 运用 时长(分钟) 知识点属性 知识点排序 添加时间
|
|
|
+ // 知识点版本id 知识点版本名称 学期 排序 年级 版本 一级模块 二级模块 教学目标 重难点标识 要点梳理 识记 理解 运用 知识点属性 添加时间
|
|
|
+
|
|
|
+ String firstHead = "科目|course_name;单元|name;单元ID|id;单元序号|num;模块|module;添加时间|t_create_time";
|
|
|
+ String howHead = "知识点|detail_name;知识点ID|detail_id;一级模块|t11_module;教学目标|jxmb;重难点标识|zdbx;要点梳理|ydsl;要点梳理图片|img;";
|
|
|
+ howHead += "二级模块|two_module;前知识点|before_name;后知识点|after_name;题目类型|type;重点章节|is_hot;识记|memorize;理解|understanding;";
|
|
|
+ howHead += "运用|apply;时长(分钟)|duration;知识点属性|attr_type;知识点排序|detail_num;添加时间|detail_create_time";
|
|
|
+ List<ExcelExportEntity> entityList = new ArrayList<>();
|
|
|
+ addEntity(entityList,firstHead,new int[]{2});
|
|
|
+ addEntity(entityList,howHead,new int[]{7});
|
|
|
+ String lastHead = "知识点版本id|s_id;知识点版本名称|alias;学期|semester;排序|s_num;年级|grade_num;版本|s_type;";
|
|
|
+ lastHead += "一级模块|s_module;二级模块|s_two_module;教学目标|s_jxmb;重难点标识|s_zdbx;要点梳理|s_ydsl;识记|s_memorize;理解|s_understanding;运用|s_apply;知识点属性|s_attr_type;添加时间|s_create_time";
|
|
|
+ addEntity(entityList,lastHead);
|
|
|
List<Map<String, Object>> list=zuoybKnowHowDetailsSortService.getKonwDetailVersion(EQ_libId, EQ_courseName, EQ_grade, banben, semester, LIKE_name);
|
|
|
- int endRow = rownum;
|
|
|
- int startRow = rownum;
|
|
|
-
|
|
|
- int idnum =6;
|
|
|
- int detailnum =23;
|
|
|
- int detailStartRow =rownum ;
|
|
|
- int detailEndRow = rownum;
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- row = sheet.createRow(rownum);
|
|
|
- int j = 0;
|
|
|
- myCreateCellx(j++, list.get(i).get("course_name")!=null?list.get(i).get("course_name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("name")!=null?list.get(i).get("name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("id").toString(), row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("num")!=null?list.get(i).get("num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("module")!=null?list.get(i).get("module").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("t_create_time")!=null?list.get(i).get("t_create_time").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("detail_name")!=null?list.get(i).get("detail_name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("detail_id")!=null?list.get(i).get("detail_id").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("t11_module")!=null?list.get(i).get("t11_module").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("jxmb")!=null?list.get(i).get("jxmb").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("zdbx")!=null?list.get(i).get("zdbx").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("ydsl")!=null?list.get(i).get("ydsl").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("img")!=null?list.get(i).get("img").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("two_module")!=null?list.get(i).get("two_module").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("before_name")!=null?list.get(i).get("before_name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("after_name")!=null?list.get(i).get("after_name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("type")!=null?list.get(i).get("type").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("is_hot")!=null?list.get(i).get("is_hot").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("memorize")!=null?list.get(i).get("memorize").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("understanding")!=null?list.get(i).get("understanding").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("apply")!=null?list.get(i).get("apply").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("duration")!=null?list.get(i).get("duration").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("attr_type")!=null?list.get(i).get("attr_type").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("detail_num")!=null?list.get(i).get("detail_num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("detail_create_time")!=null?list.get(i).get("detail_create_time").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("s_id")!=null?list.get(i).get("s_id").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("alias")!=null?list.get(i).get("alias").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("semester")!=null?list.get(i).get("semester").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_num")!=null?list.get(i).get("s_num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("grade_num")!=null?list.get(i).get("grade_num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_type")!=null?list.get(i).get("s_type").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("s_module")!=null?list.get(i).get("s_module").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_two_module")!=null?list.get(i).get("s_two_module").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_jxmb")!=null?list.get(i).get("s_jxmb").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_zdbx")!=null?list.get(i).get("s_zdbx").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_ydsl")!=null?list.get(i).get("s_ydsl").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_memorize")!=null?list.get(i).get("s_memorize").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_understanding")!=null?list.get(i).get("s_understanding").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_apply")!=null?list.get(i).get("s_apply").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("s_attr_type")!=null?list.get(i).get("s_attr_type").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_create_time")!=null?list.get(i).get("s_create_time").toString():"", row, cell, style); // 列1
|
|
|
- if (i > 0) {
|
|
|
-
|
|
|
- if (list.get(i).get("detail_id")!=null&&list.get(i).get("detail_id").toString().equals(list.get(i - 1).get("detail_id").toString())) {
|
|
|
- detailEndRow++;// 则合并结束行号+1
|
|
|
- if (i == list.size() - 1) {
|
|
|
- for (int a = idnum; a < detailnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
|
|
|
- detailEndRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if (detailStartRow != detailEndRow) {
|
|
|
- for (int a = idnum; a < detailnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
|
|
|
- detailEndRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- detailStartRow = rownum;// 为下次合并做准备,把合并开始行号赋值为下一行开始号
|
|
|
- detailEndRow = rownum;// 合并结束行同合并开始行
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (list.get(i).get("id").toString().equals(list.get(i - 1).get("id").toString())) {
|
|
|
- endRow++;// 则合并结束行号+1
|
|
|
- if (i == list.size() - 1) {
|
|
|
- for (int a = 0; a < idnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(startRow, // first
|
|
|
- endRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if (startRow != endRow) {
|
|
|
- for (int a = 0; a < idnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(startRow, // first
|
|
|
- endRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
- startRow = rownum;// 为下次合并做准备,把合并开始行号赋值为下一行开始号
|
|
|
- endRow = rownum;// 合并结束行同合并开始行
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- rownum++;
|
|
|
- }
|
|
|
+ //把我们构造好的bean对象放到params就可以了
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(fileName.toString(), fileName.toString(), ExcelType.XSSF), entityList,
|
|
|
+ list);
|
|
|
workbook.write(os);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -2462,7 +2277,6 @@ public class SysZuoybController extends BaseController {
|
|
|
|
|
|
) throws Exception {
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
-
|
|
|
StringBuffer fileName =new StringBuffer("考点");
|
|
|
if(EQ_courseName != null){
|
|
|
fileName.append(EQ_courseName);
|
|
|
@@ -2479,160 +2293,31 @@ public class SysZuoybController extends BaseController {
|
|
|
params.put("banben", banben);
|
|
|
ServletOutputStream os = null;
|
|
|
try {
|
|
|
- os = response.getOutputStream(); // 获得输出流
|
|
|
- response.reset(); // 清空输出流
|
|
|
-
|
|
|
- String filesName = new String(fileName.toString().getBytes("gb2312"), "ISO8859-1") +".xlsx";
|
|
|
- int rownum = 1; // 添加的起始行
|
|
|
+ // 获得输出流
|
|
|
+ os = response.getOutputStream();
|
|
|
+ // 清空输出流
|
|
|
+ response.reset();
|
|
|
+
|
|
|
+ exportExcelHead(response,fileName.toString());
|
|
|
+
|
|
|
+ //科目 单元 单元ID 单元序号 添加时间
|
|
|
+ // 知识点 知识点ID 一级模块 教学目标 重难点标识 要点梳理 知识点排序 添加时间
|
|
|
+ // 考点ID 考点内容 要点梳理 要点梳理图片 考点排序 标签 级别 添加时间
|
|
|
+ // 考点版本ID 考点版本别名 学期 排序 年级 版本 添加时间
|
|
|
+
|
|
|
+ String firstHead = "科目|course_name;单元|name;单元ID|id;单元序号|num;添加时间|t_create_time";
|
|
|
+ String howHead = "知识点|detail_name;知识点ID|detail_id;一级模块|t11_module;教学目标|jxmb;重难点标识|zdbx;要点梳理|ydsl;知识点排序|detail_num;添加时间|detail_create_time;";
|
|
|
+ String kdHead = "考点ID|d_id;考点内容|d_name;要点梳理|d_ydsl;要点梳理图片|d_img;考点排序|d_num;标签|d_label;级别|d_level;添加时间|d_create_time";
|
|
|
+ List<ExcelExportEntity> entityList = new ArrayList<>();
|
|
|
+ addEntity(entityList,firstHead,new int[]{2});
|
|
|
+ addEntity(entityList,howHead,new int[]{6});
|
|
|
+ addEntity(entityList,kdHead,new int[]{13});
|
|
|
+ String lastHead = "考点版本ID|s_id;考点版本别名|alias;学期|semester;排序|2s_num;年级|grade_num;版本|s_type;添加时间|s_create_time";
|
|
|
+ addEntity(entityList,lastHead);
|
|
|
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("/excel/report/report15.xlsx");
|
|
|
- XSSFWorkbook workbook = new XSSFWorkbook(classPathResource.getInputStream());
|
|
|
- response.setHeader("Content-disposition", "attachment; filename=" + filesName); // 设定输出文件头
|
|
|
- // response.setContentType("application/msexcel"); //定义输出类型
|
|
|
- response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
- response.setCharacterEncoding("utf-8");
|
|
|
- XSSFSheet sheet = workbook.getSheetAt(0); // 读取第一个工作簿
|
|
|
- XSSFRow row;
|
|
|
- XSSFCell cell = null;
|
|
|
- XSSFCellStyle style = this.getxStyle(workbook);
|
|
|
List<Map<String, Object>> list=zuoybKnowHowDetailsSortService.getKonwDetailKdVersion(EQ_libId, EQ_courseName, EQ_grade, banben, semester, LIKE_name);
|
|
|
- int endRow = rownum;
|
|
|
- int startRow = rownum;
|
|
|
-
|
|
|
- int idnum =5;
|
|
|
- int detailStartRow =rownum ;
|
|
|
- int detailEndRow = rownum;
|
|
|
- int detailnum =12;
|
|
|
- int kdnum =19;
|
|
|
- int kdStartRow =rownum ;
|
|
|
- int kdEndRow = rownum;
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- row = sheet.createRow(rownum);
|
|
|
- int j = 0;
|
|
|
- myCreateCellx(j++, list.get(i).get("course_name")!=null?list.get(i).get("course_name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("name")!=null?list.get(i).get("name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("id").toString(), row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("num")!=null?list.get(i).get("num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("t_create_time")!=null?list.get(i).get("t_create_time").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("detail_name")!=null?list.get(i).get("detail_name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("detail_id")!=null?list.get(i).get("detail_id").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("t11_module")!=null?list.get(i).get("t11_module").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("jxmb")!=null?list.get(i).get("jxmb").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("zdbx")!=null?list.get(i).get("zdbx").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("ydsl")!=null?list.get(i).get("ydsl").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("detail_num")!=null?list.get(i).get("detail_num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("detail_create_time")!=null?list.get(i).get("detail_create_time").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("d_id")!=null?list.get(i).get("d_id").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("d_name")!=null?list.get(i).get("d_name").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("d_ydsl")!=null?list.get(i).get("d_ydsl").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("d_img")!=null?list.get(i).get("d_img").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("d_num")!=null?list.get(i).get("d_num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("d_label")!=null?list.get(i).get("d_label").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("d_level")!=null?list.get(i).get("d_level").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("d_create_time")!=null?list.get(i).get("d_create_time").toString():"", row, cell, style); // 列1
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- myCreateCellx(j++, list.get(i).get("s_id")!=null?list.get(i).get("s_id").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("alias")!=null?list.get(i).get("alias").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("semester")!=null?list.get(i).get("semester").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_num")!=null?list.get(i).get("s_num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("grade_num")!=null?list.get(i).get("grade_num").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_type")!=null?list.get(i).get("s_type").toString():"", row, cell, style); // 列1
|
|
|
- myCreateCellx(j++, list.get(i).get("s_create_time")!=null?list.get(i).get("s_create_time").toString():"", row, cell, style); // 列1
|
|
|
- if (i > 0) {
|
|
|
-
|
|
|
- if (list.get(i).get("detail_id")!=null&&list.get(i).get("detail_id").toString().equals(list.get(i - 1).get("detail_id").toString())) {
|
|
|
- detailEndRow++;// 则合并结束行号+1
|
|
|
- if (i == list.size() - 1) {
|
|
|
- for (int a = idnum; a < detailnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
|
|
|
- detailEndRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if (detailStartRow != detailEndRow) {
|
|
|
- for (int a = idnum; a < detailnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
|
|
|
- detailEndRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- detailStartRow = rownum;// 为下次合并做准备,把合并开始行号赋值为下一行开始号
|
|
|
- detailEndRow = rownum;// 合并结束行同合并开始行
|
|
|
- }
|
|
|
- if (list.get(i).get("d_id")!=null&&list.get(i).get("d_id").toString().equals(list.get(i - 1).get("d_id").toString())) {
|
|
|
- kdEndRow++;// 则合并结束行号+1
|
|
|
- if (i == list.size() - 1) {
|
|
|
- for (int a = detailnum; a < kdnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(kdStartRow, // first
|
|
|
- kdEndRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if (kdStartRow != kdEndRow) {
|
|
|
- for (int a = detailnum; a < kdnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(kdStartRow, // first
|
|
|
- kdEndRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- kdStartRow = rownum;// 为下次合并做准备,把合并开始行号赋值为下一行开始号
|
|
|
- kdEndRow = rownum;// 合并结束行同合并开始行
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (list.get(i).get("id").toString().equals(list.get(i - 1).get("id").toString())) {
|
|
|
- endRow++;// 则合并结束行号+1
|
|
|
- if (i == list.size() - 1) {
|
|
|
- for (int a = 0; a < idnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(startRow, // first
|
|
|
- endRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if (startRow != endRow) {
|
|
|
- for (int a = 0; a < idnum; a++) {
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(startRow, // first
|
|
|
- endRow, // last row (0-based)
|
|
|
- a, // first column (0-based)
|
|
|
- a // last column (0-based)
|
|
|
- ));// 合并单元格
|
|
|
- }
|
|
|
- }
|
|
|
- startRow = rownum;// 为下次合并做准备,把合并开始行号赋值为下一行开始号
|
|
|
- endRow = rownum;// 合并结束行同合并开始行
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- rownum++;
|
|
|
- }
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(fileName.toString(), fileName.toString(), ExcelType.XSSF), entityList,
|
|
|
+ list);
|
|
|
workbook.write(os);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -2691,4 +2376,31 @@ public class SysZuoybController extends BaseController {
|
|
|
cell.setCellValue(new XSSFRichTextString(value));
|
|
|
cell.setCellStyle(style);
|
|
|
}
|
|
|
+
|
|
|
+ private void addEntity(List<ExcelExportEntity> entity,String exportHead,int[] mergeRely){
|
|
|
+ String[] headArr = exportHead.split(";");
|
|
|
+ for (String str:headArr){
|
|
|
+ int index = str.indexOf("|");
|
|
|
+ ExcelExportEntity entity1 = new ExcelExportEntity(str.substring(0,index), str.substring(index+1),20);
|
|
|
+ entity1.setMergeRely(mergeRely);
|
|
|
+ entity1.setNeedMerge(true);
|
|
|
+ entity1.setMergeVertical(true);
|
|
|
+ entity.add(entity1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void addEntity(List<ExcelExportEntity> list,String exportHead){
|
|
|
+ String[] headArr = exportHead.split(";");
|
|
|
+ for (String str:headArr){
|
|
|
+ int index = str.indexOf("|");
|
|
|
+ list.add(new ExcelExportEntity(str.substring(0,index), str.substring(index+1),20));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportExcelHead(HttpServletResponse response, String fileName) throws Exception{
|
|
|
+ String lastFileName = new String(fileName.getBytes("gb2312"), "ISO8859-1") +".xlsx";
|
|
|
+ //设定输出文件头
|
|
|
+ response.setHeader("Content-disposition", "attachment; filename="+ lastFileName);
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ }
|
|
|
}
|