public void ParseValidId(string id, int expectedRow, int expectedColumn) { var(row, column) = ExcelNumber.ToIndexes(id); Assert.That(row, Is.EqualTo(expectedRow)); Assert.That(column, Is.EqualTo(expectedColumn)); }
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])); }
private Dictionary <int, ICell> CreateCells(XmlElement rowElement, IReadOnlyList <string> sharedStrings) { var cells = new Dictionary <int, ICell>(); foreach (XmlElement c in rowElement.GetElementsByTagName("c")) { var(_, column) = ExcelNumber.ToIndexes(c.GetAttribute("r")); cells[column] = new Cell(this, column, c, sharedStrings); } return(cells); }
public ICell this[string columnName] { get { if (columnName == null) { throw new ArgumentNullException(nameof(columnName)); } var index = ExcelNumber.ToNumerical(columnName); return(this[index]); } }
public void GetCellByValidId(int row, int column) { var id = ExcelNumber.ToCellId(row, column); using (var book = Book.Open(BookTest.NormalData)) { var sheet = book["TestSheet1"]; Assert.That(sheet[id], Is.Not.Null); Assert.That(sheet[id].Row.Index, Is.EqualTo(row)); Assert.That(sheet[id].Index, Is.EqualTo(column)); } }
public ICell this[string cellId] { get { if (cellId == null) { throw new ArgumentNullException(nameof(cellId)); } var(row, column) = ExcelNumber.ToIndexes(cellId); return(this[row][column]); } }
public void InstanciateWithInvalidIndex(int row, int column) { Assert.That(() => ExcelNumber.ToCellId(row, column), Throws.Exception.TypeOf <ArgumentOutOfRangeException>()); }
public void ConvertToId(int row, int column, string expectedId) { var id = ExcelNumber.ToCellId(row, column); Assert.That(id, Is.EqualTo(expectedId)); }
public void ParseNullNumber() { Assert.That(() => ExcelNumber.ToNumerical(null), Throws.Exception.TypeOf <ArgumentNullException>()); }
public void ParseInvalidNumber(string alphabetical) { Assert.That(() => ExcelNumber.ToNumerical(alphabetical), Throws.Exception.TypeOf <FormatException>()); }
public void ParseValidNumber(string alphabetical, int expected) { var numerical = ExcelNumber.ToNumerical(alphabetical); Assert.That(numerical, Is.EqualTo(expected)); }
public void ParseNullId() { Assert.That(() => ExcelNumber.ToIndexes(null), Throws.ArgumentNullException); }
public void ParseInvalidId(string id) { Assert.That(() => ExcelNumber.ToIndexes(id), Throws.Exception.TypeOf <FormatException>()); }