getDateTime method

DateTime? getDateTime()

Get Range Date time value.

Implementation

DateTime? getDateTime() {
  final DateTime minimumDateValue = DateTime(0001);
  Range range = worksheet.getRangeByIndex(row, column);
  final double? dValue = range.number;

  if (dValue == null ||
      dValue.isNaN ||
      dValue < 0 ||
      range.type != CellType.dateTime) {
    return minimumDateValue;
  }

  final DateTime? dateValue = range.dateTime;
  // ignore: prefer_final_locals
  for (int iRow = row, iLastRow = lastRow; iRow <= iLastRow; iRow++) {
    // ignore: prefer_final_locals
    for (int iCol = column, iLastCol = lastColumn; iCol <= iLastCol; iCol++) {
      double? dVal;
      range = worksheet.getRangeByIndex(iRow, iCol);
      dVal = range.number;

      if (dVal == null || dValue != dVal || range.type != CellType.dateTime) {
        return minimumDateValue;
      }
    }
  }
  return dateValue;
}