| | |
| | | throw new RuntimeException("报表期格式应为 yyyy-MM:" + period); |
| | | } |
| | | int titleRow = -1; |
| | | List<Integer> titleMonths = new ArrayList<Integer>(); |
| | | for (int r = 0; r <= sheet.getLastRowNum(); r++) { |
| | | Row row = sheet.getRow(r); |
| | | if (row == null) continue; |
| | |
| | | if (t == null || !t.contains("全省") || !t.contains("月")) continue; |
| | | java.util.regex.Matcher m = java.util.regex.Pattern.compile("全省(\\d+)月").matcher(t); |
| | | if (!m.find()) continue; |
| | | if (Integer.parseInt(m.group(1)) == targetMonth) { titleRow = r; break; } |
| | | if (titleRow < 0) titleRow = r; // 标题不含目标月份时暂记第一个标题块兜底 |
| | | int titleMonth = Integer.parseInt(m.group(1)); |
| | | titleMonths.add(titleMonth); |
| | | if (titleMonth == targetMonth) { titleRow = r; break; } |
| | | } |
| | | if (titleRow < 0) { |
| | | throw new RuntimeException("未找到「全省N月个体客运量汇总表」标题块,请使用《模板_湖北省公路旅客运输个体户月度生产情况(YYYY.M)》整理后导入"); |
| | | throw new RuntimeException("未找到「全省" + targetMonth + "月个体客运量汇总表」标题块" |
| | | + (titleMonths.isEmpty() ? "" : ",文件中的标题月份为:" + titleMonths) |
| | | + ";请确保模板标题月份与所选报表期一致"); |
| | | } |
| | | Row header = sheet.getRow(titleRow + 1); |
| | | if (header == null) { |