Ejemplo n.º 1
0
        /// <summary>
        /// Gets a list of all the cell values in the specified row
        /// </summary>
        /// <param name="row">The 1-based row index</param>
        /// <returns>An enumerable of objects representing the values of cells in the row</returns>
        public IEnumerable <object> Row(int row)
        {
            var topLeft     = new CellRef(row, MinColumnNumber);
            var bottomRight = new CellRef(row, MaxColumnNumber);

            return(this[topLeft.ToString(), bottomRight.ToString()]);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a list of all the cell values at the specified ordinal column index.
        /// </summary>
        /// <param name="column">The column index </param>
        /// <returns>An enumerable of objects representing the values of cells in the column</returns>
        public IEnumerable <object> Column(int column)
        {
            var topLeft     = new CellRef(MinRow, column);
            var bottomRight = new CellRef(MaxRow, column);

            return(this[topLeft.ToString(), bottomRight.ToString()]);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Indexer. Returns the value of the cell at the given CellRef, e.g. sheetReader[new CellRef("C3")] returns the value
        ///     of the cell at C3, if present, or null if the cell is empty.
        /// </summary>
        /// <param name="cellRef"></param>
        /// <exception cref="IndexOutOfRangeException">
        ///     Will throw if the requested index is beyond the used range of the workbook. Avoid this exception by checking the
        ///     WorksheetDimension or Max/MinRow and Max/MinColumnNumber properties.
        /// </exception>
        public object this[CellRef cellRef]
        {
            get
            {
                var cellRefString = cellRef.ToString();
                if (_values.ContainsKey(cellRefString))
                {
                    return(_values[cellRefString]);
                }

                if (cellRef.ColumnNumber > WorksheetDimension.BottomRight.ColumnNumber ||
                    cellRef.Row > WorksheetDimension.BottomRight.Row)
                {
                    throw new IndexOutOfRangeException();
                }

                var value = GetValue(cellRefString);
                return(value);
            }
        }
Ejemplo n.º 4
0
        public void IntegerConstructorWorks()
        {
            var cellRef = new CellRef(1, 1);

            cellRef.ToString().Should().Be("A1");
        }
Ejemplo n.º 5
0
        public void ToStringWorks()
        {
            var aa1 = new CellRef("AA1");

            aa1.ToString().Should().Be("AA1");
        }