int sheetMergeCount = workSheet.GetSelectedRanges().Count; List<int> rangeIndexList = new List<int>(); int rowIndex =0; for (int i = 0; i < sheetMergeCount; i++) { Range range = (Range)workSheet.GetSelectedRanges()[i]; if (range.RowCount == 0) continue; for (int r = 0; r < range.RowCount; r++) { rowIndex = range.FirstRow - 1; rangeIndexList.Add(rowIndex + r); } }
C# 获取已合并的单元格,并获取合并的行数