private static void LoadPetrol(ExcelDoc excel) { int i = 4; //начальный индекс string currentCell = "B" + i; while (excel.getValue(currentCell) != null) { currentCell = "D" + i; string number = excel.getValue(currentCell).ToString(); FuelCard fuelCard = fuelCardList.getItem(number); if (fuelCard == null) { i++; currentCell = "B" + i; erorrs.Add("Не найдена карта №" + number); //throw new NullReferenceException("Не найдена карта №" + number); continue; } currentCell = "B" + i; string dateString = excel.getValue1(currentCell).ToString(); DateTime datetime; DateTime.TryParse(dateString, out datetime);//присутствует время, не забываем убирать currentCell = "G" + i; string engineTypeName = excel.getValue(currentCell).ToString(); EngineType engineType = GetEngineType(engineTypeName); currentCell = "H" + i; double value; double.TryParse(excel.getValue(currentCell).ToString(), out value); Fuel fuel = new Fuel(fuelCard, datetime.Date, engineType); fuel.AddValue(value); fuel.Save(); i++; currentCell = "B" + i; } }