Exemple #1
0
        /// <summary>
        /// Reads a field, as a string.
        /// </summary>
        /// <param name="key">The column</param>
        /// <returns>The value</returns>
        /// <exception cref="InvalidCastException"></exception>
        public string GetString(string key)
        {
            Cell cell = GetCell(key);

            if (cell == null)
            {
                return(null);
            }

            string result = ExcelCellFormatter.CellToString(cell, _document);

            result = result?.Trim( );

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Reads a field, as an integer.
        /// </summary>
        /// <param name="key">The column</param>
        /// <returns>The value</returns>
        /// <exception cref="InvalidCastException"></exception>
        public int?GetInt(string key)
        {
            string value = GetCellText(key);

            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }

            int result;

            if (!ExcelCellFormatter.TryParseInt(value, out result))
            {
                throw new InvalidCastException();
            }
            return(result);
        }