HSSF POI:如何知道单元格中的数据是否属于日期类型? [英] HSSF POI : How to know if data in cell is of Type Date?
本文介绍了HSSF POI:如何知道单元格中的数据是否属于日期类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前我有我的代码
bean.setREPO_DATE(row.getCell(16).getDateCellValue());
如果单元格在excel中格式化为日期,它就可以正常工作.
it works fine if cell is formatted as date in excel.
然而,它也会将一些整数或长整数(如 1234 或 5699)转换为日期.我也知道这背后的原因.
However it also converts some integer or long like 1234 or 5699 to date. I know the reason behind this too.
但是我想在执行上述行之前进行检查.像这样
However i want to apply a check before executing above line. Something like this
if(row.getCell(16).isOfDateFormat){
bean.setREPO_DATE(row.getCell(16).getDateCellValue());
}
请指导我..
提前致谢!
推荐答案
试试这个,
使用import org.apache.poi.ss.usermodel.DateUtil;
if(DateUtil.isCellDateFormatted(cell))
{
cell.getDateCellValue();
}
这篇关于HSSF POI:如何知道单元格中的数据是否属于日期类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文