public override int GetOrdinal(string name) { if (CurRow.Count > 0) { return(CurRow.FindIndex(s => (name == s.Name))); } throw new MockDbException("CurRowNames is null."); }
public override bool Read() { if (_index++ == 0) { return(CurRow.Count > 0); } CurRow.Clear(); return(false); }
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); }
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); }
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); }
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); } }
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); } }