|
|
|
@ -16,6 +16,7 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class C1 {
|
|
|
|
@ -45,7 +46,8 @@ public class C1 {
|
|
|
|
|
//应用样式
|
|
|
|
|
XSSFCellStyle headerStyle = ExcelKit.getHeaderStyle(outWorkbook);
|
|
|
|
|
XSSFCellStyle dataStyle = ExcelKit.getDataStyle(outWorkbook);
|
|
|
|
|
//拷贝文件头,第一行
|
|
|
|
|
|
|
|
|
|
//拷贝文件头
|
|
|
|
|
ExcelKit.CopyHead(sampleExcelPath, outSheet, headerStyle);
|
|
|
|
|
|
|
|
|
|
//找到parentPath下一级目录中所有文件
|
|
|
|
@ -81,25 +83,16 @@ public class C1 {
|
|
|
|
|
//遍历source1
|
|
|
|
|
for (int i = 0; i < source1.size(); i++) {
|
|
|
|
|
List<String> r = source1.get(i);
|
|
|
|
|
rowIndex++;
|
|
|
|
|
Row outRow = outSheet.createRow(rowIndex);
|
|
|
|
|
Row outRow = outSheet.createRow(++rowIndex);
|
|
|
|
|
// 需要写死列的对应关系
|
|
|
|
|
outRow.createCell(0).setCellValue(r.getFirst());//年份
|
|
|
|
|
outRow.createCell(1).setCellValue("总入园数");//总量分类
|
|
|
|
|
outRow.createCell(2).setCellValue("");//区域分类
|
|
|
|
|
outRow.createCell(3).setCellValue(r.get(4));//总量数值
|
|
|
|
|
outRow.createCell(4).setCellValue("");//区域数值
|
|
|
|
|
outRow.createCell(5).setCellValue(cityName);//行政区划
|
|
|
|
|
outRow.createCell(6).setCellValue("云南省");//上级行政区划
|
|
|
|
|
//应用一下样式
|
|
|
|
|
ExcelKit.applyStyle(outRow, 0, 6, dataStyle);
|
|
|
|
|
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(r.getFirst(), "总入园数", "", r.get(4), "", cityName, "云南省")), dataStyle);
|
|
|
|
|
//年份,总量分类,区域分类,总量数值,区域数值,行政区划,上级行政区划
|
|
|
|
|
}
|
|
|
|
|
//遍历source2
|
|
|
|
|
for (int i = 0; i < source2.size(); i++) {
|
|
|
|
|
if (i == 0) continue;//跳过2022年,这个年份重复了
|
|
|
|
|
List<String> r = source2.get(i);
|
|
|
|
|
rowIndex++;
|
|
|
|
|
Row outRow = outSheet.createRow(rowIndex);
|
|
|
|
|
Row outRow = outSheet.createRow(++rowIndex);
|
|
|
|
|
// 需要写死列的对应关系
|
|
|
|
|
outRow.createCell(0).setCellValue(r.getFirst());//年份
|
|
|
|
|
outRow.createCell(1).setCellValue("总入园数");//总量分类
|
|
|
|
@ -115,8 +108,7 @@ public class C1 {
|
|
|
|
|
//2022年基数:遍历source2
|
|
|
|
|
for (int i = 0; i < source2.size(); i++) {
|
|
|
|
|
List<String> r = source2.get(i);
|
|
|
|
|
rowIndex++;
|
|
|
|
|
Row outRow = outSheet.createRow(rowIndex);
|
|
|
|
|
Row outRow = outSheet.createRow(++rowIndex);
|
|
|
|
|
// 需要写死列的对应关系
|
|
|
|
|
outRow.createCell(0).setCellValue(r.getFirst());//年份
|
|
|
|
|
outRow.createCell(1).setCellValue("2022年基数");//基数
|
|
|
|
@ -140,8 +132,7 @@ public class C1 {
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < source1.size(); i++) {
|
|
|
|
|
List<String> r = source1.get(i);
|
|
|
|
|
rowIndex++;
|
|
|
|
|
Row outRow = outSheet.createRow(rowIndex);
|
|
|
|
|
Row outRow = outSheet.createRow(++rowIndex);
|
|
|
|
|
// 需要写死列的对应关系
|
|
|
|
|
outRow.createCell(0).setCellValue(r.getFirst());//年份
|
|
|
|
|
outRow.createCell(1).setCellValue("");//总量分类
|
|
|
|
@ -156,18 +147,13 @@ public class C1 {
|
|
|
|
|
for (int i = 0; i < source2.size(); i++) {
|
|
|
|
|
if (i == 0) continue;
|
|
|
|
|
List<String> r = source2.get(i);
|
|
|
|
|
rowIndex++;
|
|
|
|
|
Row outRow = outSheet.createRow(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("");//总量数值
|
|
|
|
|
if (k + 1 < r.size()) {
|
|
|
|
|
outRow.createCell(4).setCellValue(r.get(k + 1));//区域数值
|
|
|
|
|
} else {
|
|
|
|
|
outRow.createCell(4).setCellValue("");//区域数值
|
|
|
|
|
}
|
|
|
|
|
outRow.createCell(4).setCellValue(r.get(k + 1));//区域数值
|
|
|
|
|
|
|
|
|
|
outRow.createCell(5).setCellValue(cityName);//行政区划
|
|
|
|
|
outRow.createCell(6).setCellValue("云南省");//上级行政区划
|
|
|
|
@ -176,6 +162,7 @@ public class C1 {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println("正在处理" + cityName + "市州文件...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|