示例#1
0
        public static IEnumerable <ICell> Range(this IRow row, string from, string to)
        {
            if (row == null)
            {
                throw new ArgumentNullException(nameof(row));
            }

            if (from == null)
            {
                throw new ArgumentNullException(nameof(from));
            }

            if (to == null)
            {
                throw new ArgumentNullException(nameof(to));
            }

            var start = ExcelNumber.ToNumerical(from);
            var end   = ExcelNumber.ToNumerical(to);

            if (end < start)
            {
                throw new InvalidOperationException($"'{nameof(from)}' should be less or equal to '{nameof(to)}'");
            }

            return(Enumerable.Range(start, end - start + 1).Select(i => row[i]));
        }
示例#2
0
        public ICell this[string columnName]
        {
            get
            {
                if (columnName == null)
                {
                    throw new ArgumentNullException(nameof(columnName));
                }

                var index = ExcelNumber.ToNumerical(columnName);
                return(this[index]);
            }
        }
示例#3
0
 public void ParseNullNumber()
 {
     Assert.That(() => ExcelNumber.ToNumerical(null), Throws.Exception.TypeOf <ArgumentNullException>());
 }
示例#4
0
 public void ParseInvalidNumber(string alphabetical)
 {
     Assert.That(() => ExcelNumber.ToNumerical(alphabetical), Throws.Exception.TypeOf <FormatException>());
 }
示例#5
0
        public void ParseValidNumber(string alphabetical, int expected)
        {
            var numerical = ExcelNumber.ToNumerical(alphabetical);

            Assert.That(numerical, Is.EqualTo(expected));
        }