private ColumnContext _GetColumnContextForHeader(ExcelRange headerRange) { var result = new ColumnContext(); foreach (var cell in headerRange) { if (_CellHasValue(cell, "ID")) { result.IdIdx = cell.Start.Column; } else if (_CellHasValue(cell, "More")) { result.MoreIdx = cell.Start.Column; } else if (_CellHasValue(cell, "Rating")) { result.RatingIdx = cell.Start.Column; } else if (_CellHasValue(cell, "Tip")) { result.TipIdx = cell.Start.Column; } else if (_CellHasValue(cell, "Category")) { result.CategoryIdx = cell.Start.Column; } else if (_CellHasValue(cell, "Key Topic")) { result.KeyTopicIdx = cell.Start.Column; } } return(result); }
private WisdomDrop _CreateWisdomDrop(ColumnContext colCtx, ExcelRange row) { var idString = _GetCellValue(row[row.Start.Row, colCtx.IdIdx]); var ratingString = _GetCellValue(row[row.Start.Row, colCtx.RatingIdx]); var result = new WisdomDrop { Tip = _GetCellValue(row[row.Start.Row, colCtx.TipIdx]), Id = !string.IsNullOrEmpty(idString) && Guid.TryParse(idString, out var parsedId) ? parsedId : (Guid?)null, Category = _GetCellValue(row[row.Start.Row, colCtx.CategoryIdx]), Rating = !string.IsNullOrEmpty(ratingString) && int.TryParse(ratingString, out var parsedRating) ? parsedRating : 0, KeyTopic = _GetCellValue(row[row.Start.Row, colCtx.KeyTopicIdx]) }; return(result); }