cell method

Data cell(
  1. CellIndex cellIndex
)

returns the DataObject at position of cellIndex

Implementation

Data cell(CellIndex cellIndex) {
  _checkMaxColumn(cellIndex.columnIndex);
  _checkMaxRow(cellIndex.rowIndex);
  if (cellIndex.columnIndex < 0 || cellIndex.rowIndex < 0) {
    _damagedExcel(
        text:
            '${cellIndex.columnIndex < 0 ? "Column" : "Row"} Index: ${cellIndex.columnIndex < 0 ? cellIndex.columnIndex : cellIndex.rowIndex} Negative index does not exist.');
  }

  /// increasing the row count
  if (_maxRows < (cellIndex.rowIndex + 1)) {
    _maxRows = cellIndex.rowIndex + 1;
  }

  /// increasing the column count
  if (_maxColumns < (cellIndex.columnIndex + 1)) {
    _maxColumns = cellIndex.columnIndex + 1;
  }

  /// checking if the map has been already initialized or not?
  /// if the user has called this class by its own
  /* if (_sheetData == null) {
    _sheetData = Map<int, Map<int, Data>>();
  } */

  /// if the sheetData contains the row then start putting the column
  if (_sheetData[cellIndex.rowIndex] != null) {
    if (_sheetData[cellIndex.rowIndex]![cellIndex.columnIndex] == null) {
      _sheetData[cellIndex.rowIndex]![cellIndex.columnIndex] =
          Data.newData(this, cellIndex.rowIndex, cellIndex.columnIndex);
    }
  } else {
    /// else put the column with map showing.
    _sheetData[cellIndex.rowIndex] = {
      cellIndex.columnIndex:
          Data.newData(this, cellIndex.rowIndex, cellIndex.columnIndex)
    };
  }

  return _sheetData[cellIndex.rowIndex]![cellIndex.columnIndex]!;
}