예제 #1
0
 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));
     }
 }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }
예제 #5
0
 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
             });
         }
     }
 }
예제 #6
0
 public object this[string coordinate] => _store.GetValueOrDefault(CellCoordinate.Parse(coordinate)).Value;
예제 #7
0
 public object this[CellCoordinate coordinate] => _store.GetValueOrDefault(coordinate).Value;
예제 #8
0
 public bool Equals(CellCoordinate other)
 {
     return(Row == other.Row && Column.Equals(other.Column));
 }