|
|
|
@ -10,22 +10,22 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class YunXiaoExportExcelUtil {
|
|
|
|
|
|
|
|
|
|
public void exportToExcel(String filePath, List<Record> list1) {
|
|
|
|
|
public void exportToExcel(String filePath, List<Record> list1, List<Record> list2, List<Record> list3) {
|
|
|
|
|
try (XSSFWorkbook workbook = new XSSFWorkbook()) {
|
|
|
|
|
//第一个 Sheet
|
|
|
|
|
XSSFSheet sheet1 = workbook.createSheet("整体情况");
|
|
|
|
|
// 创建样式
|
|
|
|
|
CellStyle headerStyle = createHeaderStyle(workbook);
|
|
|
|
|
CellStyle dataStyle = createDataStyle(workbook);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//第一个 Sheet
|
|
|
|
|
XSSFSheet sheet1 = workbook.createSheet("整体建设情况");
|
|
|
|
|
// 设置列宽
|
|
|
|
|
sheet1.setColumnWidth(0, 4000); // 学段
|
|
|
|
|
sheet1.setColumnWidth(1, 8000); // 科目名称
|
|
|
|
|
sheet1.setColumnWidth(2, 5000); // 课程数量
|
|
|
|
|
|
|
|
|
|
// 创建表头
|
|
|
|
|
Row headerRow = sheet1.createRow(0);
|
|
|
|
|
headerRow.setHeight((short) (28 * 20));
|
|
|
|
|
|
|
|
|
|
String[] headers = {
|
|
|
|
|
"学段", "科目名称", "课程数量"
|
|
|
|
|
};
|
|
|
|
@ -47,6 +47,39 @@ public class YunXiaoExportExcelUtil {
|
|
|
|
|
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); // 课程数量
|
|
|
|
|
// 创建表头
|
|
|
|
|
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);
|
|
|
|
|