Article:
 |
|
Reading and Writing Excel Files with POI
|
| Subject: |
|
Reading Data From Excel using HSSFWorkbook +Java |
| Date: |
|
2008-01-11 22:22:39 |
| From: |
|
SudheeshKumar
|
|
|
|
Hi,
when i am reading the date 11/1/2008 i am getting some integer values.I want to How to read Date field from excel and time (time is in yhe format 9:00
Thanks In advance
Sudheeh
|
Showing messages 1 through 3 of 3.
-
Reading Data From Excel using HSSFWorkbook +Java
2008-02-11 05:47:11
Kris...
[View]
-
Reading Data From Excel using HSSFWorkbook +Java
2008-04-21 03:59:20
Unnati
[View]
-
Reading Data From Excel using HSSFWorkbook +Java
2008-04-20 21:16:57
Unnati
[View]
HSSFRow row = newXREFSheet.getRow(rowNo);
if (row != null) {
HSSFCell cell = row.getCell((short) col);
if (cell != null) {
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:
HSSFCellStyle style = cell.getCellStyle();
if(style.getIndex() == 35){
cellVal = cell.getDateCellValue().toString();
String date = new SimpleDateFormat("MM/dd/yyyy").
format(new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(cellVal.toString()));
cellVal = date;
}
else{
cellVal = String.valueOf(cell.getNumericCellValue());
}
break;
case HSSFCell.CELL_TYPE_STRING:
cellVal = cell.getStringCellValue();
break;
case HSSFCell.CELL_TYPE_FORMULA:
cellValDoub = cell.getNumericCellValue();
df = new DecimalFormat("##");
cellVal = df.format(cellValDoub).toString();
break;
default:
break;
}
}
}