Women in Technology

Hear us Roar



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

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Reading Data From Excel using HSSFWorkbook +Java
    2008-02-11 05:47:11  Kris... [View]

    This might solve your problem

    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;
    }
    }
    }
    • Reading Data From Excel using HSSFWorkbook +Java
      2008-04-21 03:59:20  Unnati [View]

      Hi,

      I tried using the above code but still time in the excel column is displayed in numeric format and not in time format. Please suggest on this...
      Its urgent.

      Thanks in advance.

    • Reading Data From Excel using HSSFWorkbook +Java
      2008-04-20 21:16:57  Unnati [View]

      Hi, I tried the above code to read date and time value using POI but This column is displayed in numeric value and not in time format. i.e. 0.3069444444444444 is displayed for time 7:22:00 AM. Can u please tell me what the conversion method is for this? Also Plz tell what can be done for below Eg. 14321926 in excel gets displayed as 1.4321926E7 .
      Please help...

      Thanks in advance.
      Regards,
      Unnati.