/// <summary> /// Gets the cell at the specified coordinates or creates it if a cell does not exist there. /// </summary> /// <param name="sheetData">The sheet data.</param> /// <param name="columnIndex">Index of the column.</param> /// <param name="rowIndex">Index of the row.</param> /// <returns> /// The new cell. /// </returns> public static Cell GetCell(this SheetData sheetData, uint columnIndex, uint rowIndex) { while (rowIndex > sheetData.OfType <Row>().Count()) { sheetData.AddRow(); } var row = (Row)sheetData.ElementAt((int)rowIndex - 1); while (columnIndex > row.OfType <Cell>().Count()) { var paddingCell = new Cell(); paddingCell.SetCellReference((uint)row.OfType <Cell>().Count() + 1, rowIndex); row.Append(paddingCell); } Cell cell = (Cell)row.ElementAt((int)columnIndex - 1); return(cell); }