AODL.Document.Content.Tables.Table.InsertCellAt C# (CSharp) Method

InsertCellAt() public method

Inserts the cell at the specified position. The RowCollection, the rows CellCollection and the ColumnCollection will be resized automatically.
public InsertCellAt ( int rowIndex, int columnIndex, Cell cell ) : void
rowIndex int Index of the row.
columnIndex int Index of the column.
cell Cell The cell.
return void
		public void InsertCellAt(int rowIndex, int columnIndex, Cell cell)
		{
			while ( _rows.Count <= rowIndex )
			{
				_rows.Add ( new Row(this, String.Format("row{0}",_rows.Count)));
			}

			Row row = _rows [ rowIndex ] ;
			row.InsertCellAt ( columnIndex, cell ) ;
			cell.Row = row ;
		}

Usage Example

 void Example1()
 {
     //Create new spreadsheet document
     SpreadsheetDocument spreadsheetDocument = new SpreadsheetDocument();
     spreadsheetDocument.New();
     //Create a new table
     Table table = new Table(spreadsheetDocument, "First", "tablefirst");
     //Create a new cell, without any extra styles
     Cell cell = table.CreateCell();
     //Add a paragraph to this cell
     Paragraph paragraph = ParagraphBuilder.CreateSpreadsheetParagraph(spreadsheetDocument);
     //Create some Formated text
     FormatedText fText = new FormatedText(spreadsheetDocument, "T1", "Some Text");
     //fText.TextStyle.TextProperties.Bold = "bold";
     fText.TextStyle.TextProperties.Underline = LineStyles.dotted;
     //Add formated text
     paragraph.TextContent.Add(fText);
     //Add paragraph to the cell
     cell.Content.Add(paragraph);
     //Insert the cell at row index 2 and column index 3
     //All need rows, columns and cells below the given
     //indexes will be build automatically.
     table.InsertCellAt(2, 3, cell);
     //Insert table into the spreadsheet document
     spreadsheetDocument.TableCollection.Add(table);
     spreadsheetDocument.SaveTo("example1_formated.ods");
 }
All Usage Examples Of AODL.Document.Content.Tables.Table::InsertCellAt