/// <summary> /// 设置列索引 /// </summary> private void SetColumnIndex( Cell cell ) { if ( cell.ColumnIndex > 0 ) { _indexManager.AddIndex( cell.ColumnIndex,cell.ColumnSpan ); return; } cell.ColumnIndex = _indexManager.GetIndex( cell.ColumnSpan ); }
/// <summary> /// 添加单元格 /// </summary> /// <param name="cell">单元格</param> public void Add( Cell cell ) { if ( cell == null ) return; cell.Row = this; SetColumnIndex( cell ); Cells.Add( cell ); }
public void TestInit() { _cell = new Cell( "a" ); _cell.Row = new Row(2); }
/// <summary> /// 添加单元格 /// </summary> private void AddCell( Row row, Cell cell, int rowIndex ) { row.Add( cell ); if ( cell.RowSpan <= 1 ) return; for ( int i = 1; i < cell.RowSpan; i++ ) AddPlaceholderCell( cell, rowIndex + i ); }
/// <summary> /// 为下方受rowspan影响的行添加占位单元格 /// </summary> private void AddPlaceholderCell( Cell cell, int rowIndex ) { var row = CreateRow( rowIndex ); row.Add( new NullCell { ColumnIndex = cell.ColumnIndex, ColumnSpan = cell.ColumnSpan } ); }