POI reading of Excel custom date format (example code)
Reading Excel data with POI: (version No.: poi3.7)
@H_ 404_ 4@1 , read Excel
@H_ 404_ 4 @ 2. Excel data processing:
The excel storage date and time are stored in numerical type. When reading, POI first judges whether it is a numerical type, and then judges and converts it
@H_ 404_ 4@1 Cell_type_numeric:
1. Pure numeric format: getnumericcellvalue() gets data directly
2. Date format: deal with date formats without text, such as yyyy MM DD, D / M / yyyy, H: mm, HH: mm, etc
1). Judge whether it is a date format: hssfdateutil isCellDateFormatted(cell)
2). Judge the date or time
cell. getCellStyle(). getDataFormat() == HSSFDataFormat. getBuiltinFormat("h:mm")
OR: cell. getCellStyle(). getDataFormat() == HSSFDataFormat. getBuiltinFormat("yyyy-MM-dd")
3. User defined date format: deal with date formats including text, such as yyyy, m month, d day, H hour, mm minute, yyyy, m month, etc
Judge cell getCellStyle(). Getdataformat() value, parsing numeric format
Mm / D, yyyy ----- > 31
Mm / D ----- > 58
H h h mm min -- > 32
@H_ 404_ 4@2 . character format (cell_type_string): get the content directly
@H_ 404_ 4 @ * universal treatment scheme:
All date formats can be determined by the getdataformat () value
yyyy-MM-dd----- 14
Mm / D, yyyy --- 31
Mm / yyyy --------- 57
Mm / D ------------- 58
HH:mm----------- 20
H h h mm min --------- 32
The above POI reading of Excel custom date format (example code) is all the content shared by Xiaobian. I hope it can give you a reference and support programming tips.