internal static Dictionary <int, PropertySetter> GetPropertySetterDictionaryByColumnNumber(Dictionary <string, int> customHeaderNumbers, IEnumerable <PropertySetter> setters) { var i = 0; var cellSettersDictionaryForRead = new Dictionary <int, PropertySetter>(); foreach (var item in setters) { var columnNumber = customHeaderNumbers.ContainsKey(item.PropertyName) ? customHeaderNumbers[item.PropertyName] : i; if (cellSettersDictionaryForRead.ContainsKey(columnNumber)) { throw new ExcelToEnumerableConfigException( $"Trying to map property '{item.PropertyName}' to column '{CellRef.NumberToColumnName(columnNumber + 1)}' but that column is already mapped to property '{cellSettersDictionaryForRead[columnNumber].PropertyName}'."); } cellSettersDictionaryForRead.Add(columnNumber, item); i++; } if (cellSettersDictionaryForRead.Count < customHeaderNumbers.Count) { throw new ExcelToEnumerableInvalidHeaderException(new[] { "" }, new[] { "" }); } return(cellSettersDictionaryForRead); }
public void NumberToColumnNameWorks() { CellRef.NumberToColumnName(27).Should().Be("AA"); }