您的位置:首页 > 编程语言 > Java开发

JAVA 读取EXCEL

2011-07-07 23:54 141 查看
private static String getCellFormatValue(HSSFCell cell) {
String cellvalue = "";
if (cell != null) {
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:
cellvalue = String.valueOf(cell.getNumericCellValue());
case HSSFCell.CELL_TYPE_FORMULA: {

if (HSSFDateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue();
cellvalue = cell.getDateCellValue().toLocaleString();
} else {
double num = new Double((double) cell.getNumericCellValue());
cellvalue = String.valueOf(num);
}
break;
}

case HSSFCell.CELL_TYPE_STRING:
cellvalue = cell.getStringCellValue();
break;
default:
cellvalue = "";
}
} else {
cellvalue = "";
}
return cellvalue.trim();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: