cancel
Showing results for 
Search instead for 
Did you mean: 

How to ceck the format of the cell in Excel?

Former Member
0 Kudos

Hi ,

I am using HSSF api to read the excel shet.I m able to read the excel file.But I need to check he format of the cell(or column).

For example:- Suppose my column is Date.I want to check the format for this date(as date acn be written in different format).

I want to check the format of the cell/ column.I am using HSSF api.

Please suggest me.

Sandip

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You can use something like this:


switch(cell.getCellType()) {
  case Cell.CELL_TYPE_STRING:
    System.out.println(cell.getRichStringCellValue().getString());
    break;
  case Cell.CELL_TYPE_NUMERIC:
    if(DateUtil.isCellDateFormatted(cell)) {
      System.out.println(cell.getDateCellValue());
     } 
    else {
      System.out.println(cell.getNumericCellValue());
    }
    break;
    case Cell.CELL_TYPE_BOOLEAN:
      System.out.println(cell.getBooleanCellValue());
      break;
    case Cell.CELL_TYPE_FORMULA:
      System.out.println(cell.getCellFormula());
      break;
    default:
      System.out.println();
}

Hope it helps,

Daniel

siarhei_pisarenka3
Active Contributor
0 Kudos

Wrong forum.