|
|
|
@ -55,17 +55,17 @@ public class C9 {
|
|
|
|
|
for (File file : files) {
|
|
|
|
|
//判断file是不是目录,是目录的需要跳过
|
|
|
|
|
if (file.isDirectory()) continue;
|
|
|
|
|
//城市名称
|
|
|
|
|
String cityName = ru.getCityOrAreaName(file.getName());
|
|
|
|
|
String fileName = file.getName();
|
|
|
|
|
|
|
|
|
|
//判断是否为docx文件
|
|
|
|
|
if (fileName.endsWith(".docx") && !fileName.startsWith("~")) {
|
|
|
|
|
//城市名称
|
|
|
|
|
String cityName = ru.getCityOrAreaName(file.getName());
|
|
|
|
|
if (StrKit.isBlank(cityName)) {
|
|
|
|
|
System.out.println("文件名无法解析为城市:" + fileName);
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
System.out.println("正在处理" + cityName + "市州文件...");
|
|
|
|
|
System.out.println("正在处理" + cityName + "...");
|
|
|
|
|
//数据在图表1
|
|
|
|
|
int chartNumber = 1;
|
|
|
|
|
//chartNumber:第几个图表
|
|
|
|
@ -73,8 +73,10 @@ public class C9 {
|
|
|
|
|
//expectLimit:期望的数据行数,首先用POI进行解析,如果获取的行数大于预期行数,就是正确的,否则就需要二次调用python进行读取
|
|
|
|
|
List<List<String>> source = ExcelKit.getChartData(file.getAbsolutePath(), chartNumber - 1, 6);
|
|
|
|
|
|
|
|
|
|
System.out.println("当前城市数据条目数量=" + source.size());
|
|
|
|
|
//遍历source
|
|
|
|
|
for (List<String> r : source) {
|
|
|
|
|
|
|
|
|
|
Row outRow = outSheet.createRow(++rowIndex);
|
|
|
|
|
// 导出数据
|
|
|
|
|
//上级行政区划,行政区划,年份,总人口变化,总人口预测
|
|
|
|
@ -82,13 +84,13 @@ public class C9 {
|
|
|
|
|
|
|
|
|
|
double value = Double.parseDouble(r.get(1));
|
|
|
|
|
if (year < 2023) {
|
|
|
|
|
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList( "云南省",cityName, r.getFirst().substring(0, 4), String.format("%.2f", value), "")), dataStyle);
|
|
|
|
|
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList("云南省", cityName, r.getFirst().substring(0, 4), String.format("%.2f", value), "")), dataStyle);
|
|
|
|
|
}
|
|
|
|
|
if (year > 2023) {
|
|
|
|
|
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList("云南省",cityName, r.getFirst().substring(0, 4), "", String.format("%.2f", value))), dataStyle);
|
|
|
|
|
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList("云南省", cityName, r.getFirst().substring(0, 4), "", String.format("%.2f", value))), dataStyle);
|
|
|
|
|
}
|
|
|
|
|
if (year == 2023) {
|
|
|
|
|
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList("云南省",cityName, r.getFirst().substring(0, 4), String.format("%.2f", value), String.format("%.2f", value))), dataStyle);
|
|
|
|
|
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList("云南省", cityName, r.getFirst().substring(0, 4), String.format("%.2f", value), String.format("%.2f", value))), dataStyle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|