main
黄海 9 months ago
parent 0b91768d47
commit 1a5eb2e8df

@ -111,15 +111,59 @@ public class C1 {
int rowIndex = 0;
Row outRow;
for (Row row : sheet) {
//遍历row中每一列中间以tab隔开然后换行
rowIndex++;
if (rowIndex == 1) continue;
//年份
int columnIndex = 0;
String value = ExcelReader.readCell(row.getCell(columnIndex));
outRow = outSheet.createRow(rowIndex - 1);
outRow.createCell(columnIndex).setCellValue(value);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//总量分类
columnIndex = 1;
outRow.createCell(columnIndex).setCellValue("总入园数");
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(value);
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();
//==============================================================================
//读取第28个图表
XWPFChart chart28 = charts.get(27);
workbook = chart28.getWorkbook();
sheet = workbook.getSheet("Sheet1");
//遍历输出sheet的内容
int secondRowIndex = 0;
for (Row row : sheet) {
secondRowIndex++;
if (secondRowIndex == 1 || secondRowIndex == 2) continue;//表头和2022年都跳过
rowIndex++;
if (rowIndex == 1) {
continue;
}
//年份
int columnIndex = 0;
if(row.getCell(columnIndex)==null) break;
String value = ExcelReader.readCell(row.getCell(columnIndex));
outRow = outSheet.createRow(rowIndex - 1);
outRow.createCell(columnIndex).setCellValue(value);
@ -154,9 +198,7 @@ public class C1 {
outRow.getCell(columnIndex).setCellStyle(dataStyle);
}
workbook.close();
break;
//XWPFChart chart28 = charts.get(27);
}
}
}

Loading…
Cancel
Save