/**
* 获取cell中的数据
* @param cell
* @return
*/
private String readCell(HSSFCell cell) {
if (null == cell) {
return "";
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING: {
return Strings.trim(cell.getStringCellValue());
}
case HSSFCell.CELL_TYPE_NUMERIC: {
if(HSSFDateUtil.isCellDateFormatted(cell)){
return sdf.format(cell.getDateCellValue());
}else{
return Strings.trim(new BigDecimal(cell.getNumericCellValue())
.toString());
}
}
case HSSFCell.CELL_TYPE_BOOLEAN: {
return Strings.trim(String.valueOf(cell.getBooleanCellValue()));
}
case HSSFCell.CELL_TYPE_FORMULA: {
return Strings.trim(String.valueOf(cell.getCellFormula()));
}
default: {
return Strings.trim(cell.getStringCellValue());
}
}
}
posted on 2006-12-21 16:10
有猫相伴的日子 阅读(1046)
评论(0) 编辑 收藏 所属分类:
jdk