ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Reading and Writing Excel Files with POI
Subject:   Reading Data From Excel using HSSFWorkbook +Java
Date:   2008-02-11 05:47:11
From:   Kris...
Response to: Reading Data From Excel using HSSFWorkbook +Java

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;
}
}
}


1 to 2 of 2
  1. Reading Data From Excel using HSSFWorkbook +Java
    2008-04-21 03:59:20  Unnati [View]

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

1 to 2 of 2