Пример #1
0
 public override int GetOrdinal(string name)
 {
     if (CurRow.Count > 0)
     {
         return(CurRow.FindIndex(s => (name == s.Name)));
     }
     throw new MockDbException("CurRowNames is null.");
 }
Пример #2
0
 public override bool Read()
 {
     if (_index++ == 0)
     {
         return(CurRow.Count > 0);
     }
     CurRow.Clear();
     return(false);
 }
Пример #3
0
        private ICell FetchCurCell(CellType type, LayoutStyle style)
        {
            if (CurRow == null)
            {
                return(null);
            }
            var cell = CurRow.GetCell(CurColumnIndex) ?? CurRow.CreateCell(CurColumnIndex, type);

            CurColumnIndex++; //移到下一格

            if (style != null)
            {
                cell.CellStyle = Sheet.Workbook.GetCellStyleAt(style.StoreIndex);
            }
            return(cell);
        }
Пример #4
0
        public string GetCellValue(int columnIndex, string defaultValue = null)
        {
            if (CurRow == null)
            {
                return(defaultValue);
            }
            var cell = CurRow.GetCell(columnIndex);

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

            var strValue = cell.ToString();

            return(string.IsNullOrEmpty(strValue) ? defaultValue : strValue);
        }
Пример #5
0
        public int GetCellIntValue(int columnIndex, int defaultValue = 0)
        {
            if (CurRow == null)
            {
                return(defaultValue);
            }
            var cell = CurRow.GetCell(columnIndex);

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

            var strValue = cell.ToString();
            int res;

            return(int.TryParse(strValue, out res) ? res : defaultValue);
        }
Пример #6
0
        public DateTime GetCellDateTimeValue(int columnIndex, DateTime defaultValue)
        {
            if (CurRow == null)
            {
                return(defaultValue);
            }
            var cell = CurRow.GetCell(columnIndex);

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

            try
            {
                return(cell.DateCellValue);
            }
            catch
            {
                var      strValue = cell.ToString();
                DateTime res;
                return(DateTime.TryParse(strValue, out res) ? res : defaultValue);
            }
        }
Пример #7
0
        public double GetCellNumericValue(int columnIndex, double defaultValue = 0)
        {
            if (CurRow == null)
            {
                return(defaultValue);
            }
            var cell = CurRow.GetCell(columnIndex);

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

            try
            {
                return(cell.NumericCellValue);
            }
            catch
            {
                var    strValue = cell.ToString();
                double res;
                return(double.TryParse(strValue, out res) ? res : defaultValue);
            }
        }