示例#1
0
 /// 获取cell的CellSpan信息
 /// <param name="cell"></param>
 /// <returns></returns>
 public static CellSpan GetSpan(this ICell cell)
 {
     var cellSpan = new CellSpan(1,1);
     if (cell.IsMergedCell)
     {
         int regionsNum = cell.Sheet.NumMergedRegions;
         for (int i = 0; i < regionsNum; i++)
         {
             var range = cell.Sheet.GetMergedRegion(i);
             if (range.FirstRow == cell.RowIndex && range.FirstColumn == cell.ColumnIndex)
             {
                 cellSpan.RowSpan = range.LastRow - range.FirstRow + 1;
                 cellSpan.ColSpan = range.LastColumn - range.FirstColumn + 1;
                 break;
             }
         }
     }
     return cellSpan;
 }
示例#2
0
        public static CellSpan GetSpan(this ICell cell)
        {
            var cellSpan = new CellSpan(1, 1);

            if (cell.IsMergedCell)
            {
                int regionsNum = cell.Sheet.NumMergedRegions;
                for (int i = 0; i < regionsNum; i++)
                {
                    var range = cell.Sheet.GetMergedRegion(i);
                    if (range.FirstRow == cell.RowIndex && range.FirstColumn == cell.ColumnIndex)
                    {
                        cellSpan.RowSpan = range.LastRow - range.FirstRow + 1;
                        cellSpan.ColSpan = range.LastColumn - range.FirstColumn + 1;
                        break;
                    }
                }
            }
            return(cellSpan);
        }