/**
* Check if a cell contains a date
* Since dates are stored internally in Excel as double values
* we infer it is a date if it is formatted as such.
* @see #isADateFormat(int, String)
* @see #isInternalDateFormat(int)
由于日期在Excel内是以double值存储的,所以一个cell如果是这种格式,我们可以推断它是一个日期。
*/
public static boolean isCellDateFormatted(Cell cell) {
if (cell == null) return false;
boolean bDate = false;
double d = cell.getNumericCellValue();
if ( DateUtil.isValidExcelDate(d) ) {
CellStyle style = cell.getCellStyle();
if(style==null) return false;
int i = style.getDataFormat();
String f = style.getDataFormatString();
bDate = isADateFormat(i, f);
}
return bDate;
}poi cell日期判断 源代码注释
最新推荐文章于 2024-11-30 17:52:09 发布
本文介绍了一个用于检查Excel单元格是否为日期格式的方法。通过检查单元格的数值内容及格式字符串来确定其是否代表日期。
2648

被折叠的 条评论
为什么被折叠?



