Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public void NumberToColumnNameWorks()
 {
     CellRef.NumberToColumnName(27).Should().Be("AA");
 }