main
黄海 8 months ago
parent 8b20fdc4cd
commit 1076a3c21e

@ -3,6 +3,7 @@ package com.dsideal.base.Tools.FillData.City;
import com.dsideal.base.DataEase.Model.ExcelReader;
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
import com.dsideal.base.Tools.Util.ReadDocxUtil;
import com.jfinal.kit.StrKit;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.ss.usermodel.*;
@ -77,7 +78,6 @@ public class C1 {
}
sampleWorkbook.close();
//开始读取市州word文档
String parentPath = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\16个州市报告2022\\分析报告20240510";
@ -155,15 +155,20 @@ public class C1 {
XWPFChart chart28 = charts.get(27);
workbook = chart28.getWorkbook();
sheet = workbook.getSheet("Sheet1");
String jiShu="";
//遍历输出sheet的内容
int secondRowIndex = 0;
for (Row row : sheet) {
secondRowIndex++;
if (secondRowIndex == 1 || secondRowIndex == 2) continue;//表头和2022年都跳过
if (secondRowIndex == 1) continue;//表头都跳过
if (secondRowIndex == 2) {//2022年是重复的取一回就行了
jiShu = ExcelReader.readCell(row.getCell(4));//2022年基数
}
rowIndex++;
//年份
int columnIndex = 0;
if(row.getCell(columnIndex)==null) break;
if (row.getCell(columnIndex) == null) break;
String value = ExcelReader.readCell(row.getCell(columnIndex));
outRow = outSheet.createRow(rowIndex - 1);
outRow.createCell(columnIndex).setCellValue(value);
@ -194,7 +199,52 @@ public class C1 {
outRow.createCell(columnIndex).setCellValue("云南省");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
}
//重复读取,跳过表头
rowIndex--;
for (Row row : sheet) {
//年份
int columnIndex = 0;
if (row.getCell(columnIndex) == null) break;
String value = ExcelReader.readCell(row.getCell(columnIndex));
if(StrKit.isBlank(value)) continue;
rowIndex++;
outRow = outSheet.createRow(rowIndex - 1);
outRow.createCell(columnIndex).setCellValue(value);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//总量分类
columnIndex = 1;
outRow.createCell(columnIndex).setCellValue("2022年基数");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//区域分类
columnIndex = 2;
outRow.createCell(columnIndex).setCellValue("");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//总量数值
columnIndex = 3;
value = ExcelReader.readCell(row.getCell(4));
outRow.createCell(columnIndex).setCellValue(jiShu);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//区域数值
columnIndex = 4;
outRow.createCell(columnIndex).setCellValue("");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//行政区划
columnIndex = 5;
outRow.createCell(columnIndex).setCellValue(cityName);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//上级行政区划
columnIndex = 6;
outRow.createCell(columnIndex).setCellValue("云南省");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
}
workbook.close();
//城区
//镇区
//乡村
break;
}
}

Loading…
Cancel
Save