main
黄海 8 months ago
parent 2196bcf591
commit 7e2907127b

@ -13,6 +13,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -87,10 +88,153 @@ public class A10 {
//县区名称
System.out.println("正在进行" + cityName + "的数据填充~");
String sourceExcel = file.getAbsolutePath();
List<List<String>> dataList = ExcelKit.readSecondTable(sourceExcel, 0, tableKeyword,
tableHeadRows, tableLetterIndex);
ExcelKit.printTable(dataList);
List<List<String>> dataList = ExcelKit.readSheet(sourceExcel, 4);
//我们认为第一行就是市州的统计数据,如果不是而是写到了最后的,就人为调整到第一行
// 在本例中,跳过第一行,就是县区
for (int i = 1; i < dataList.size(); i++) {
List<String> row = dataList.get(i);
String areaName = row.getFirst();
// 列的情况
// 行政区划 类型 年份 学段 数值 上级行政区划
// 行的情况
//1、学前学校总数 I
int colIdx = ExcelKit.transLetter2Num("I");
String xq_school_count = row.get(colIdx).trim();
//2、学前招生总数 O
colIdx = ExcelKit.transLetter2Num("O");
String xq_enroll_count = row.get(colIdx).trim();
//3、学前在校生总数 P
colIdx = ExcelKit.transLetter2Num("P");
String xq_student_count = row.get(colIdx).trim();
//4、学前教职工总数 M
colIdx = ExcelKit.transLetter2Num("M");
String xq_teacher_count = row.get(colIdx).trim();
//5、学前专任教师数 N
colIdx = ExcelKit.transLetter2Num("N");
String xq_special_teacher_count = row.get(colIdx).trim();
//6、小学学校总数 S
colIdx = ExcelKit.transLetter2Num("S");
String xx_school_count = row.get(colIdx).trim();
//7、小学招生总数 Z
colIdx = ExcelKit.transLetter2Num("Z");
String xx_enroll_count = row.get(colIdx).trim();
//8、小学在校生总数 AA
colIdx = ExcelKit.transLetter2Num("AA");
String xx_student_count = row.get(colIdx).trim();
//9、小学教职工总数 X
colIdx = ExcelKit.transLetter2Num("X");
String xx_teacher_count = row.get(colIdx).trim();
//10、小学专任教师数 Y
colIdx = ExcelKit.transLetter2Num("Y");
String xx_special_teacher_count = row.get(colIdx).trim();
//11、初中学校总数 AD
colIdx = ExcelKit.transLetter2Num("AD");
String cz_school_count = row.get(colIdx).trim();
//12、初中招生总数 AJ
colIdx = ExcelKit.transLetter2Num("AJ");
String cz_enroll_count = row.get(colIdx).trim();
//13、初中在校生总数 AK
colIdx = ExcelKit.transLetter2Num("AK");
String cz_student_count = row.get(colIdx).trim();
//14、初中教职工总数 AH
colIdx = ExcelKit.transLetter2Num("AH");
String cz_teacher_count = row.get(colIdx).trim();
//15、初中专任教师数 AI
colIdx = ExcelKit.transLetter2Num("AI");
String cz_special_teacher_count = row.get(colIdx).trim();
//16、高中学校总数 AN
colIdx = ExcelKit.transLetter2Num("AN");
String gz_school_count = row.get(colIdx).trim();
//17、高中招生总数 AQ
colIdx = ExcelKit.transLetter2Num("AQ");
String gz_enroll_count = row.get(colIdx).trim();
//18、高中在校生总数 AR
colIdx = ExcelKit.transLetter2Num("AR");
String gz_student_count = row.get(colIdx).trim();
//19、高中教职工总数 AO
colIdx = ExcelKit.transLetter2Num("AO");
String gz_teacher_count = row.get(colIdx).trim();
//20、高中专任教师数 AP
colIdx = ExcelKit.transLetter2Num("AP");
String gz_special_teacher_count = row.get(colIdx).trim();
//21、中职学校总数 AU
colIdx = ExcelKit.transLetter2Num("AU");
String zz_school_count = row.get(colIdx).trim();
//22、中职招生总数 AX
colIdx = ExcelKit.transLetter2Num("AX");
String zz_enroll_count = row.get(colIdx).trim();
//23、中职在校生总数 AY
colIdx = ExcelKit.transLetter2Num("AY");
String zz_student_count = row.get(colIdx).trim();
//24、中职教职工总数 AV
colIdx = ExcelKit.transLetter2Num("AV");
String zz_teacher_count = row.get(colIdx).trim();
//25、中职专任教师数 AW
colIdx = ExcelKit.transLetter2Num("AW");
String zz_special_teacher_count = row.get(colIdx).trim();
//学前
Row outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "学校总数", "2023", "学前", xq_school_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "招生总数", "2023", "学前", xq_enroll_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "在校生总数", "2023", "学前", xq_student_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "教职工总数", "2023", "学前", xq_teacher_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "专任教师数", "2023", "学前", xq_special_teacher_count, cityName)), dataStyle);
//小学
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "学校总数", "2023", "小学", xx_school_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "招生总数", "2023", "小学", xx_enroll_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "在校生总数", "2023", "小学", xx_student_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "教职工总数", "2023", "小学", xx_teacher_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "专任教师数", "2023", "小学", xx_special_teacher_count, cityName)), dataStyle);
//初中
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "学校总数", "2023", "初中", cz_school_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "招生总数", "2023", "初中", cz_enroll_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "在校生总数", "2023", "初中", cz_student_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "教职工总数", "2023", "初中", cz_teacher_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "专任教师数", "2023", "初中", cz_special_teacher_count, cityName)), dataStyle);
//高中
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "学校总数", "2023", "高中", gz_school_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "招生总数", "2023", "高中", gz_enroll_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "在校生总数", "2023", "高中", gz_student_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "教职工总数", "2023", "高中", gz_teacher_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "专任教师数", "2023", "高中", gz_special_teacher_count, cityName)), dataStyle);
//中职
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "学校总数", "2023", "中职", zz_school_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "招生总数", "2023", "中职", zz_enroll_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "在校生总数", "2023", "中职", zz_student_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "教职工总数", "2023", "中职", zz_teacher_count, cityName)), dataStyle);
outRow = outSheet.createRow(++rowIndex);
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(areaName, "专任教师数", "2023", "中职", zz_special_teacher_count, cityName)), dataStyle);
}
}
}
//保存文件

@ -414,6 +414,7 @@ public class ExcelKit {
&& row.getCell(0).toString().contains(keyword)) {
if (start == -1)
start = rowIndex;
System.out.println("找到" + keyword + ",start=" + start);
}
if (start > 0 && row == null) {
end = rowIndex - 1;

Loading…
Cancel
Save