/// <summary>
/// Inserts the cell at the specified position. Both indexes are 1-based indexes!
/// The RowCollection, the rows CellCollection and the ColumnCollection
/// will be resized automatically.
/// </summary>
/// <param name="rowIndex">Index of the row.</param>
/// <param name="columnIndex">Index of the column.</param>
/// <param name="cell">The cell.</param>
public void InsertCellAt(int rowIndex, int columnIndex, Cell cell)
{
if (this.RowCollection.Count <= rowIndex)
{
for (int i = 0; i < rowIndex - this.RowCollection.Count; i++)
{
this.RowCollection.Add(new Row(this, "row" + this.RowCollection.Count.ToString() + i.ToString()));
}
this.RowCollection[rowIndex - 1].InsertCellAt(columnIndex - 1, cell);
cell.Row = this.RowCollection[rowIndex - 1];
}
else if (this.RowCollection.Count + 1 == rowIndex)
{
Row row = new Row(this, this.RowCollection[this.RowCollection.Count - 1].StyleName);
row.InsertCellAt(columnIndex - 1, cell);
cell.Row = row;
this.RowCollection.Add(row);
}
else
{
this.RowCollection[rowIndex - 1].InsertCellAt(columnIndex - 1, cell);
cell.Row = this.RowCollection[rowIndex - 1];
}
}