|
|
|
@ -15,6 +15,7 @@ import org.apache.poi.xwpf.usermodel.XWPFChart;
|
|
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class C1 {
|
|
|
|
@ -49,6 +50,7 @@ public class C1 {
|
|
|
|
|
|
|
|
|
|
//找到parentPath下一级目录中所有文件
|
|
|
|
|
File[] files = new File(parentPath).listFiles();
|
|
|
|
|
int rowIndex = 0;
|
|
|
|
|
//处理这个目录
|
|
|
|
|
if (files != null) {
|
|
|
|
|
for (File file : files) {
|
|
|
|
@ -81,7 +83,7 @@ public class C1 {
|
|
|
|
|
List<List<String>> source2 = ExcelKit.readSheet(workbook);
|
|
|
|
|
|
|
|
|
|
//遍历source1
|
|
|
|
|
int rowIndex = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < source1.size(); i++) {
|
|
|
|
|
List<String> r = source1.get(i);
|
|
|
|
|
rowIndex++;
|
|
|
|
@ -114,14 +116,62 @@ public class C1 {
|
|
|
|
|
//应用一下样式
|
|
|
|
|
ExcelKit.applyStyle(outRow, 0, 6, dataStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//城区
|
|
|
|
|
|
|
|
|
|
//镇区
|
|
|
|
|
|
|
|
|
|
//乡村
|
|
|
|
|
break;
|
|
|
|
|
//2022年基数:遍历source2
|
|
|
|
|
for (int i = 0; i < source2.size(); i++) {
|
|
|
|
|
List<String> r = source2.get(i);
|
|
|
|
|
rowIndex++;
|
|
|
|
|
Row outRow = outSheet.createRow(rowIndex);
|
|
|
|
|
// 需要写死列的对应关系
|
|
|
|
|
outRow.createCell(0).setCellValue(r.getFirst());//年份
|
|
|
|
|
outRow.createCell(1).setCellValue("2022年基数");//基数
|
|
|
|
|
outRow.createCell(2).setCellValue("");//区域分类
|
|
|
|
|
outRow.createCell(3).setCellValue(source2.getFirst().get(4));//总量数值
|
|
|
|
|
outRow.createCell(4).setCellValue("");//区域数值
|
|
|
|
|
outRow.createCell(5).setCellValue(cityName);//行政区划
|
|
|
|
|
outRow.createCell(6).setCellValue("云南省");//上级行政区划
|
|
|
|
|
//应用一下样式
|
|
|
|
|
ExcelKit.applyStyle(outRow, 0, 6, dataStyle);
|
|
|
|
|
}
|
|
|
|
|
//城区+镇区+乡村
|
|
|
|
|
List<String> areaList = new ArrayList<>();
|
|
|
|
|
areaList.add("城区");
|
|
|
|
|
areaList.add("镇区");
|
|
|
|
|
areaList.add("乡村");
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < areaList.size(); k++) {
|
|
|
|
|
String areaName = areaList.get(k);
|
|
|
|
|
for (int i = 0; i < source1.size(); i++) {
|
|
|
|
|
List<String> r = source1.get(i);
|
|
|
|
|
rowIndex++;
|
|
|
|
|
Row outRow = outSheet.createRow(rowIndex);
|
|
|
|
|
// 需要写死列的对应关系
|
|
|
|
|
outRow.createCell(0).setCellValue(r.getFirst());//年份
|
|
|
|
|
outRow.createCell(1).setCellValue("");//总量分类
|
|
|
|
|
outRow.createCell(2).setCellValue(areaName);//区域分类
|
|
|
|
|
outRow.createCell(3).setCellValue("");//总量数值
|
|
|
|
|
outRow.createCell(4).setCellValue(r.get(k + 1));//区域数值
|
|
|
|
|
outRow.createCell(5).setCellValue(cityName);//行政区划
|
|
|
|
|
outRow.createCell(6).setCellValue("云南省");//上级行政区划
|
|
|
|
|
//应用一下样式
|
|
|
|
|
ExcelKit.applyStyle(outRow, 0, 6, dataStyle);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < source2.size(); i++) {
|
|
|
|
|
if (i == 0) continue;
|
|
|
|
|
List<String> r = source2.get(i);
|
|
|
|
|
rowIndex++;
|
|
|
|
|
Row outRow = outSheet.createRow(rowIndex);
|
|
|
|
|
// 需要写死列的对应关系
|
|
|
|
|
outRow.createCell(0).setCellValue(r.getFirst());//年份
|
|
|
|
|
outRow.createCell(1).setCellValue("");//基数
|
|
|
|
|
outRow.createCell(2).setCellValue(areaName);//区域分类
|
|
|
|
|
outRow.createCell(3).setCellValue("");//总量数值
|
|
|
|
|
outRow.createCell(4).setCellValue(r.get(k + 1));//区域数值
|
|
|
|
|
outRow.createCell(5).setCellValue(cityName);//行政区划
|
|
|
|
|
outRow.createCell(6).setCellValue("云南省");//上级行政区划
|
|
|
|
|
//应用一下样式
|
|
|
|
|
ExcelKit.applyStyle(outRow, 0, 6, dataStyle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|