This article is a mirror article of machine translation, please click here to jump to the original article.

View: 46066|Reply: 0

[Source] NPOI judgment of cell date type

[Copy link]
Posted on 2021-5-14 12:43:50 | | | |
NPOI currently uses two sets of classes, one is for reading and writing XLS; One is to read and write XLSX

When reading a file, most of them judge the cell type, and the method is similar, except that the date type is different.

Cells of the default date type are considered numeric types by NPOI (CellType.Numeric)

In the higher version, use HSSFDateUtil.IsCellDateFormatted(cell).

But there is no such class in the lower version, and there is NPOI.SS.UserModel.DateUtil.IsCellDateFormatted(cell) on the Internet, which has the same effect.

If it is a time type and returns true when correct,If it is not a time type, an exception will appear

solution

DateTime is of type Numeric in NPOI, and if it is a Numeric type, use it. Net's built-in DateUtil.IsCellDateFormatted(cell) method determines whether it is a DateTime type, and if both are true, take the DateCellValue property of the cell







Previous:POI uses three methods: HSSF, XSSF, SXSSF
Next:Redis MISCONF Redis is configured to save RDB snapshots
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com