做的是获取Excel表格数据求解有没有人解释一下什么意思

private Map<String, Integer> getCombineCellData(Sheet sheet) {
        int combineCellNum = sheet.getNumMergedRegions();
        for(int i = 0; i < combineCellNum; i++) {
            CellRangeAddress cell = sheet.getMergedRegion(i);
            int firstColumnNum = cell.getFirstColumn();
            int firstRow = cell.getFirstRow();
            if (firstColumnNum == 3 && firstRow == 0) {
                Map<String, Integer> result = new HashMap<>();
                result.put("firstIndex", firstColumnNum);
                result.put("lastIndex", cell.getLastColumn());
                return result;
            }
        }
        return null;
    }

这也没啥逻辑,哪句代码不清楚?

哪不理解?

以下所述,均基于合理的命名规范而来:

private Map<String, Integer> getCombineCellData(Sheet sheet) { //方法定义
int combineCellNum = sheet.getNumMergedRegions(); // 获取表格的区域
for(int i = 0; i < combineCellNum; i++) { // 遍历所有数据
CellRangeAddress cell = sheet.getMergedRegion(i); // 获取对应单元格
int firstColumnNum = cell.getFirstColumn(); // 获取第一列
int firstRow = cell.getFirstRow(); // 获取第一行
if (firstColumnNum == 3 && firstRow == 0) { //
Map<String, Integer> result = new HashMap<>();
result.put("firstIndex", firstColumnNum); // 添加数据
result.put("lastIndex", cell.getLastColumn()); //
return result;
}
}
return null;
}

这样的话, 明白不?