NPOI时间格式判断

switch (cell.CellType) { case CellType.BLANK: //空数据类型处理 dr[iRow] = ""; break; case CellType.STRING: //字符串类型 dr[iRow] = cell.StringCellValue; break; case CellType.NUMERIC: //数字类型 if (DateUtil.IsValidExcelDate(cell.NumericCellValue)) { dr[iRow] = cell.DateCellValue; } else { dr[iRow] = cell.NumericCellValue; } break; case CellType.FORMULA: HSSFFormulaEvaluator e = new HSSFFormulaEvaluator(hssfworkbook); dr[iRow] = e.Evaluate(cell).StringValue; break; default: dr[iRow] = ""; break; }

posted @ 2017-12-14 17:53  天朝95  阅读(949)  评论(0编辑  收藏  举报