Range[] rangeCells = sheet.getMergedCells();// 返回sheet中合並的單元格數組
for (Range r : rangeCells) {//對數組遍歷拿到每個合並的單元格
Cell cellTop = r.getTopLeft();//獲取某個合並的單元格的左上角的單元格
int beginRow= cellTop.getRow();//獲取左上角單元格所在行
int beginColumn=cellTop.getColumn();//獲取左上角單元格所在列
Cell cellBottom = r.getBottomRight();//獲取某個合並的單元格的右下角的單元格
//同上獲取右下角單元格所在行和列
}