main
黄海 8 months ago
parent 10f1162d81
commit c28cc9286d

@ -22,7 +22,7 @@ public class A1 {
static String sampleExcelPath = "D:\\dsWork\\YunNanDsBase\\Doc\\待处理\\市\\【8】人口总体情况\\人口总体情况.xlsx";
//源文件
static String parentPath = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\2023年数据更新表\\16州市数据更新表汇总20241021";
static String parentPath = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\133个县区报告2022\\县区研究报告";
public static void main(String[] args) throws IOException, InvalidFormatException {
//初始化数据库连接
@ -55,6 +55,8 @@ public class A1 {
for (File file : files) {
//判断file是不是目录是目录的需要跳过
if (file.isDirectory()) continue;
if (!file.getName().endsWith(".xlsx") && !file.getName().endsWith(".xls"))
continue;
//城市名称
String cityName = ru.getCityOrAreaName(file.getName());
if (StrKit.isBlank(cityName)) {
@ -62,12 +64,13 @@ public class A1 {
System.exit(0);
}
System.out.println("正在进行" + cityName + "的数据填充~");
//如果源文件或者示例文件是xls格式则转化为xlsx格式
String sourceExcel = file.getAbsolutePath();
List<List<String>> dataList=ExcelKit.readSecondTable(sourceExcel, 0, "自动计算招生数、在校生数",
//System.out.println(file.getName());
List<List<String>> dataList = ExcelKit.readSecondTable(sourceExcel, 0, "自动计算招生数、在校生数",
2, "K");
System.out.println(dataList);
ExcelKit.printTable(dataList);
break;
}
}
//保存文件

@ -543,7 +543,7 @@ public class ExcelKit {
}
}
start += headRows;//第二个表的表头有几行
System.out.println("第二个表格开始行索引=" + start + ",结束行索引=" + end);
//System.out.println("第二个表格开始行索引=" + start + ",结束行索引=" + end);
//输出第二个表格的数据
for (rowIndex = start; rowIndex <= end; rowIndex++) {
Row row = sheet.getRow(rowIndex);
@ -563,4 +563,13 @@ public class ExcelKit {
fis.close();
return dataList;
}
public static void printTable(List<List<String>> dataList) {
for (List<String> row : dataList) {
for (String cell : row) {
System.out.print(cell + "\t");
}
System.out.println();
}
}
}

Loading…
Cancel
Save