private IEnumerable <IEnumerable <Cell> > GetRows(CellCoordinate @from, CellCoordinate to, bool replaceEmpty = false) { for (int i = from.Row; i <= to.Row; i++) { yield return(GetRow(i, from.Column, to.Column, replaceEmpty)); } }
public ValuesRange GetSubRange(string range) { (CellCoordinate from, CellCoordinate to) = CellCoordinate.ParseRange(range); IEnumerable <Cell> elems = GetRows(@from, to).SelectMany(x => x); return(new ValuesRange(elems)); }
private void UpdateMinMax(Cell cell) { int minRow = MinCell.Row < cell.Coordinate.Row ? MinCell.Row : cell.Coordinate.Row; int maxRow = MaxCell.Row > cell.Coordinate.Row ? MaxCell.Row : cell.Coordinate.Row; Column minColl = MinCell.Column < cell.Coordinate.Column ? MinCell.Column : cell.Coordinate.Column; Column maxColl = MaxCell.Column > cell.Coordinate.Column ? MaxCell.Column : cell.Coordinate.Column; MaxCell = new CellCoordinate(maxRow, maxColl); MinCell = new CellCoordinate(minRow, minColl); }
public static (CellCoordinate from, CellCoordinate to) ParseRange(string range) { Match matching = RangeRegex.Match(range); if (!matching.Success) { throw new FormatException($"Unexpected cell range coordinates {range}"); } Match from = SingleCellRegex.Match(matching.Groups["from"].Value); Match to = SingleCellRegex.Match(matching.Groups["to"].Value); CellCoordinate fromCoordinate = Parse(from.Value); return(fromCoordinate, string.IsNullOrEmpty(to.Value) ? fromCoordinate : Parse(to.Value)); }
private IEnumerable <Cell> GetRow(int rowIndex, Column @from, Column to, bool replaceEmpty = false) { for (int i = Column.ToNumber(from); i <= Column.ToNumber(to); i++) { var coordinate = new CellCoordinate(rowIndex, Column.FromNumber(i)); if (_store.TryGetValue(coordinate, out Cell item)) { yield return(GetCell(item, replaceEmpty)); } else { yield return(new Cell { Coordinate = coordinate }); } } }
public object this[string coordinate] => _store.GetValueOrDefault(CellCoordinate.Parse(coordinate)).Value;
public object this[CellCoordinate coordinate] => _store.GetValueOrDefault(coordinate).Value;
public bool Equals(CellCoordinate other) { return(Row == other.Row && Column.Equals(other.Column)); }