|
|
|
@ -10,59 +10,235 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class YunXiaoExportExcelUtil {
|
|
|
|
|
|
|
|
|
|
public void exportToExcel(String filePath, List<Record> list) {
|
|
|
|
|
/**
|
|
|
|
|
* 导出课程整体的建设情况
|
|
|
|
|
*
|
|
|
|
|
* @param filePath
|
|
|
|
|
* @param list1
|
|
|
|
|
* @param list2
|
|
|
|
|
*/
|
|
|
|
|
public void LessonConstructionExportExcel(String filePath, List<Record> list1, List<Record> list2) {
|
|
|
|
|
try (XSSFWorkbook workbook = new XSSFWorkbook()) {
|
|
|
|
|
XSSFSheet sheet = workbook.createSheet("课程整体");
|
|
|
|
|
// 创建样式
|
|
|
|
|
CellStyle headerStyle = createHeaderStyle(workbook);
|
|
|
|
|
CellStyle dataStyle = createDataStyle(workbook);
|
|
|
|
|
|
|
|
|
|
//第一个 Sheet
|
|
|
|
|
XSSFSheet sheet1 = workbook.createSheet("整体建设情况");
|
|
|
|
|
// 设置列宽
|
|
|
|
|
sheet.setColumnWidth(0, 4000); // 区域
|
|
|
|
|
sheet.setColumnWidth(1, 5000); // 机构编号
|
|
|
|
|
sheet.setColumnWidth(2, 8000); // 机构名称
|
|
|
|
|
sheet.setColumnWidth(3, 4000); // 办学类型
|
|
|
|
|
sheet.setColumnWidth(4, 3000); // 教职工数
|
|
|
|
|
sheet.setColumnWidth(5, 3000); // 专任教师数
|
|
|
|
|
sheet.setColumnWidth(6, 3000); // 班级数
|
|
|
|
|
sheet.setColumnWidth(7, 3000); // 在校生数
|
|
|
|
|
sheet1.setColumnWidth(0, 4000); // 学段
|
|
|
|
|
sheet1.setColumnWidth(1, 8000); // 科目名称
|
|
|
|
|
sheet1.setColumnWidth(2, 5000); // 课程数量
|
|
|
|
|
// 创建表头
|
|
|
|
|
Row headerRow = sheet1.createRow(0);
|
|
|
|
|
headerRow.setHeight((short) (28 * 20));
|
|
|
|
|
String[] headers = {
|
|
|
|
|
"学段", "科目名称", "课程数量"
|
|
|
|
|
};
|
|
|
|
|
for (int i = 0; i < headers.length; i++) {
|
|
|
|
|
Cell cell = headerRow.createCell(i);
|
|
|
|
|
cell.setCellValue(headers[i]);
|
|
|
|
|
cell.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
int rowNum = 1;
|
|
|
|
|
// 填充数据
|
|
|
|
|
for (Record record : list1) {
|
|
|
|
|
Row row = sheet1.createRow(rowNum++);
|
|
|
|
|
row.setHeight((short) (28 * 20));
|
|
|
|
|
// 学段
|
|
|
|
|
createCell(row, 0, record.getStr("stage_name"), dataStyle);
|
|
|
|
|
// 科目名称
|
|
|
|
|
createCell(row, 1, record.getStr("subject_name"), dataStyle);
|
|
|
|
|
// 建设数量
|
|
|
|
|
createCell(row, 2, record.getStr("lesson_count"), dataStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//第二个 Sheet
|
|
|
|
|
XSSFSheet sheet2 = workbook.createSheet("年级课程建设情况");
|
|
|
|
|
// 设置列宽
|
|
|
|
|
sheet2.setColumnWidth(0, 4000); // 学段
|
|
|
|
|
sheet2.setColumnWidth(1, 8000); // 科目名称
|
|
|
|
|
sheet2.setColumnWidth(2, 8000); // 册
|
|
|
|
|
sheet2.setColumnWidth(3, 5000); // 课程数量
|
|
|
|
|
// 创建表头
|
|
|
|
|
Row headerRow = sheet.createRow(0);
|
|
|
|
|
headerRow = sheet2.createRow(0);
|
|
|
|
|
headerRow.setHeight((short) (28 * 20));
|
|
|
|
|
String[] headers2 = {
|
|
|
|
|
"学段", "科目名称", "册", "课程数量"
|
|
|
|
|
};
|
|
|
|
|
for (int i = 0; i < headers2.length; i++) {
|
|
|
|
|
Cell cell = headerRow.createCell(i);
|
|
|
|
|
cell.setCellValue(headers2[i]);
|
|
|
|
|
cell.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
rowNum = 1;
|
|
|
|
|
// 填充数据
|
|
|
|
|
for (Record record : list2) {
|
|
|
|
|
Row row = sheet2.createRow(rowNum++);
|
|
|
|
|
row.setHeight((short) (28 * 20));
|
|
|
|
|
// 学段
|
|
|
|
|
createCell(row, 0, record.getStr("stage_name"), dataStyle);
|
|
|
|
|
// 科目名称
|
|
|
|
|
createCell(row, 1, record.getStr("subject_name"), dataStyle);
|
|
|
|
|
//册
|
|
|
|
|
createCell(row, 2, record.getStr("book_name"), dataStyle);
|
|
|
|
|
// 建设数量
|
|
|
|
|
createCell(row, 3, record.getStr("lesson_count"), dataStyle);
|
|
|
|
|
}
|
|
|
|
|
// 保存文件
|
|
|
|
|
try (FileOutputStream fileOut = new FileOutputStream(filePath)) {
|
|
|
|
|
workbook.write(fileOut);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出按学区、学校查询的课程建设情况
|
|
|
|
|
*
|
|
|
|
|
* @param filePath
|
|
|
|
|
* @param list1
|
|
|
|
|
* @param list2
|
|
|
|
|
* @param list3
|
|
|
|
|
*/
|
|
|
|
|
public void LessonConstructionInfoByXzqhSchool(String filePath, List<Record> list1, List<Record> list2, List<Record> list3, List<Record> list4) {
|
|
|
|
|
try (XSSFWorkbook workbook = new XSSFWorkbook()) {
|
|
|
|
|
// 创建样式
|
|
|
|
|
CellStyle headerStyle = createHeaderStyle(workbook);
|
|
|
|
|
CellStyle dataStyle = createDataStyle(workbook);
|
|
|
|
|
|
|
|
|
|
//第一个 Sheet
|
|
|
|
|
XSSFSheet sheet1 = workbook.createSheet("区域建设情况");
|
|
|
|
|
// 设置列宽
|
|
|
|
|
sheet1.setColumnWidth(0, 7000); // 县区名称
|
|
|
|
|
sheet1.setColumnWidth(1, 4000); // 数量
|
|
|
|
|
// 创建表头
|
|
|
|
|
Row headerRow = sheet1.createRow(0);
|
|
|
|
|
headerRow.setHeight((short) (28 * 20));
|
|
|
|
|
String[] headers = {
|
|
|
|
|
"区域", "机构编号", "机构名称", "办学类型",
|
|
|
|
|
"教职工数", "专任教师数", "班级数", "在校生数"
|
|
|
|
|
"县区", "课程数量"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < headers.length; i++) {
|
|
|
|
|
Cell cell = headerRow.createCell(i);
|
|
|
|
|
cell.setCellValue(headers[i]);
|
|
|
|
|
cell.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
int rowNum = 1;
|
|
|
|
|
// 填充数据
|
|
|
|
|
for (Record record : list1) {
|
|
|
|
|
Row row = sheet1.createRow(rowNum++);
|
|
|
|
|
row.setHeight((short) (28 * 20));
|
|
|
|
|
// 县区名称
|
|
|
|
|
createCell(row, 0, record.getStr("gather_regionc"), dataStyle);
|
|
|
|
|
// 建设数量
|
|
|
|
|
createCell(row, 1, record.getStr("c"), dataStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//第二个 Sheet
|
|
|
|
|
XSSFSheet sheet2 = workbook.createSheet("区域课程建设情况");
|
|
|
|
|
// 设置列宽
|
|
|
|
|
sheet2.setColumnWidth(0, 5000); // 县区名称
|
|
|
|
|
sheet2.setColumnWidth(1, 5000); // 学段
|
|
|
|
|
sheet2.setColumnWidth(2, 5000); // 科目名称
|
|
|
|
|
sheet2.setColumnWidth(3, 5000); // 课程数量
|
|
|
|
|
// 创建表头
|
|
|
|
|
headerRow = sheet2.createRow(0);
|
|
|
|
|
headerRow.setHeight((short) (28 * 20));
|
|
|
|
|
String[] headers2 = {
|
|
|
|
|
"县区名称", "学段", "科目名称", "课程数量"
|
|
|
|
|
};
|
|
|
|
|
for (int i = 0; i < headers2.length; i++) {
|
|
|
|
|
Cell cell = headerRow.createCell(i);
|
|
|
|
|
cell.setCellValue(headers2[i]);
|
|
|
|
|
cell.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
rowNum = 1;
|
|
|
|
|
// 填充数据
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
Row row = sheet.createRow(rowNum++);
|
|
|
|
|
for (Record record : list2) {
|
|
|
|
|
Row row = sheet2.createRow(rowNum++);
|
|
|
|
|
row.setHeight((short) (28 * 20));
|
|
|
|
|
//县区名称
|
|
|
|
|
createCell(row, 0, record.getStr("gather_regionc"), dataStyle);
|
|
|
|
|
// 学段
|
|
|
|
|
createCell(row, 1, record.getStr("stage_name"), dataStyle);
|
|
|
|
|
// 科目名称
|
|
|
|
|
createCell(row, 2, record.getStr("subject_name"), dataStyle);
|
|
|
|
|
// 建设数量
|
|
|
|
|
createCell(row, 3, record.getStr("c"), dataStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 区域
|
|
|
|
|
createCell(row, 0, record.getStr("县区"), dataStyle);
|
|
|
|
|
// 机构编号
|
|
|
|
|
createCell(row, 1, record.getStr("单位号"), dataStyle);
|
|
|
|
|
// 机构名称
|
|
|
|
|
createCell(row, 2, record.getStr("单位名称"), dataStyle);
|
|
|
|
|
// 办学类型
|
|
|
|
|
createCell(row, 3, record.getStr("学校类型"), dataStyle);
|
|
|
|
|
//教职工数
|
|
|
|
|
createCell(row, 4, String.valueOf(record.getInt("教职工数")), dataStyle);
|
|
|
|
|
//专任教师数
|
|
|
|
|
createCell(row, 5, String.valueOf(record.getInt("专任教师数")), dataStyle);
|
|
|
|
|
//班级数
|
|
|
|
|
createCell(row, 6, String.valueOf(record.getInt("班级数")), dataStyle);
|
|
|
|
|
//在校生数
|
|
|
|
|
createCell(row, 7, String.valueOf(record.getInt("在校生数")), dataStyle);
|
|
|
|
|
//第三个 Sheet
|
|
|
|
|
XSSFSheet sheet3 = workbook.createSheet("学校课程建设情况");
|
|
|
|
|
// 设置列宽
|
|
|
|
|
sheet3.setColumnWidth(0, 5000); // 县区名称
|
|
|
|
|
sheet3.setColumnWidth(1, 8000); // 学校
|
|
|
|
|
sheet3.setColumnWidth(2, 5000); // 课程数量
|
|
|
|
|
// 创建表头
|
|
|
|
|
headerRow = sheet3.createRow(0);
|
|
|
|
|
headerRow.setHeight((short) (28 * 20));
|
|
|
|
|
String[] headers3 = {
|
|
|
|
|
"县区名称", "学校", "课程数量"
|
|
|
|
|
};
|
|
|
|
|
for (int i = 0; i < headers3.length; i++) {
|
|
|
|
|
Cell cell = headerRow.createCell(i);
|
|
|
|
|
cell.setCellValue(headers3[i]);
|
|
|
|
|
cell.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
rowNum = 1;
|
|
|
|
|
// 填充数据
|
|
|
|
|
for (Record record : list3) {
|
|
|
|
|
Row row = sheet3.createRow(rowNum++);
|
|
|
|
|
row.setHeight((short) (28 * 20));
|
|
|
|
|
//县区名称
|
|
|
|
|
createCell(row, 0, record.getStr("gather_regionc"), dataStyle);
|
|
|
|
|
// 学校
|
|
|
|
|
createCell(row, 1, record.getStr("organization_name"), dataStyle);
|
|
|
|
|
// 建设数量
|
|
|
|
|
createCell(row, 2, record.getStr("c"), dataStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//第四个 Sheet
|
|
|
|
|
XSSFSheet sheet4 = workbook.createSheet("学校课程建设详情");
|
|
|
|
|
// 设置列宽
|
|
|
|
|
sheet4.setColumnWidth(0, 8000); // 县区名称
|
|
|
|
|
sheet4.setColumnWidth(1, 5000); // 学段
|
|
|
|
|
sheet4.setColumnWidth(2, 8000); // 学校
|
|
|
|
|
sheet4.setColumnWidth(3, 5000); // 科目
|
|
|
|
|
sheet4.setColumnWidth(4, 5000); // 教师
|
|
|
|
|
sheet4.setColumnWidth(5, 10000); // 课程名称
|
|
|
|
|
|
|
|
|
|
// 创建表头
|
|
|
|
|
headerRow = sheet4.createRow(0);
|
|
|
|
|
headerRow.setHeight((short) (28 * 20));
|
|
|
|
|
String[] headers4 = {
|
|
|
|
|
"县区名称", "学段", "学校", "科目", "教师", "课程名称"
|
|
|
|
|
};
|
|
|
|
|
for (int i = 0; i < headers4.length; i++) {
|
|
|
|
|
Cell cell = headerRow.createCell(i);
|
|
|
|
|
cell.setCellValue(headers4[i]);
|
|
|
|
|
cell.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
rowNum = 1;
|
|
|
|
|
// 填充数据
|
|
|
|
|
for (Record record : list4) {
|
|
|
|
|
Row row = sheet4.createRow(rowNum++);
|
|
|
|
|
row.setHeight((short) (28 * 20));
|
|
|
|
|
//县区名称
|
|
|
|
|
createCell(row, 0, record.getStr("gather_regionc"), dataStyle);
|
|
|
|
|
//学段
|
|
|
|
|
createCell(row, 1, record.getStr("stage_name"), dataStyle);
|
|
|
|
|
// 学校
|
|
|
|
|
createCell(row, 2, record.getStr("organization_name"), dataStyle);
|
|
|
|
|
//科目
|
|
|
|
|
createCell(row, 3, record.getStr("subject_name"), dataStyle);
|
|
|
|
|
// 教师
|
|
|
|
|
createCell(row, 4, record.getStr("teacher_name"), dataStyle);
|
|
|
|
|
// 课程
|
|
|
|
|
createCell(row, 5, record.getStr("lesson_name"), dataStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保存文件
|
|
|
|
@ -103,23 +279,19 @@ public class YunXiaoExportExcelUtil {
|
|
|
|
|
font.setBold(true);
|
|
|
|
|
font.setFontHeightInPoints((short) 11);
|
|
|
|
|
style.setFont(font);
|
|
|
|
|
|
|
|
|
|
return style;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CellStyle createDataStyle(XSSFWorkbook workbook) {
|
|
|
|
|
CellStyle style = workbook.createCellStyle();
|
|
|
|
|
|
|
|
|
|
// 设置边框
|
|
|
|
|
style.setBorderTop(BorderStyle.THIN);
|
|
|
|
|
style.setBorderRight(BorderStyle.THIN);
|
|
|
|
|
style.setBorderBottom(BorderStyle.THIN);
|
|
|
|
|
style.setBorderLeft(BorderStyle.THIN);
|
|
|
|
|
|
|
|
|
|
// 设置居中对齐
|
|
|
|
|
style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
|
|
|
|
|
|
return style;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|