Esempio n. 1
0
        /// <summary>
        ///     获取cell的CellSpan信息
        /// </summary>
        /// <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++)
                {
                    CellRangeAddress 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);
        }
Esempio n. 2
0
 /// <summary>
 /// 获取cell的CellSpan信息
 /// </summary>
 /// <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;
 }