Beispiel #1
0
        /// <summary>
        /// Static method. Returns an enumerable of <c>CellRef</c>s representing all the cells in the given range. Cell order is
        /// left-to-right then top-to-bottom
        /// </summary>
        /// <example>
        /// <code>
        /// var cellRefs = CellRef.Range("A1","B2").ToArray();
        /// Console.WriteLine(cellRefs[0]); //outputs "A1"
        /// Console.WriteLine(cellRefs[1]); //outputs "B1"
        /// Console.WriteLine(cellRefs[2]); //outputs "A2"
        /// Console.WriteLine(cellRefs[3]); //outputs "B2"
        /// </code>
        /// </example>
        /// <param name="topLeft"></param>
        /// <param name="bottomRight"></param>
        /// <returns></returns>
        public static IEnumerable <CellRef> Range(string topLeft, string bottomRight)
        {
            var tl   = new CellRef(topLeft);
            var br   = new CellRef(bottomRight);
            var list = new List <CellRef>();

            for (var y = tl.Row; y <= br.Row; y++)
            {
                for (var x = tl.ColumnNumber; x <= br.ColumnNumber; x++)
                {
                    list.Add(new CellRef(y, x));
                }
            }

            return(list);
        }
Beispiel #2
0
 public bool Equals(CellRef other)
 {
     return(ColumnNumber == other.ColumnNumber && Row == other.Row);
 }