POI使用笔记
2016-06-20 15:19
260 查看
1、获取单元格中的值
public String getStringValue(HSSFCell cell) {
if (cell == null)
return "";
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_BLANK:
return "";
case HSSFCell.CELL_TYPE_BOOLEAN:
return cell.getBooleanCellValue() + "";
case HSSFCell.CELL_TYPE_NUMERIC: {
if (HSSFDateUtil.isCellDateFormatted(cell)) {
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
return sdf.format(cell.getDateCellValue());
} else {
double tmp = cell.getNumericCellValue();
if (tmp % (int) tmp == 0) {
return "" + (int) tmp;
}
return tmp + "";
}
}
case HSSFCell.CELL_TYPE_STRING:
return cell.getStringCellValue();
case HSSFCell.CELL_TYPE_FORMULA:
return cell.getCellFormula();
default:
return cell.getErrorCellValue() + "";
}
}
相关文章推荐
- 使用POI读写word docx文件(笔记记录)
- Java POI 操作Excel总结笔记--使用配置和使用案例篇
- Java POI 操作Excel总结笔记--使用配置和使用案例篇
- TreeView使用笔记
- 如何使用Java POI生成Excel表文件 !
- 《C# 设计模式》笔记: 第4章 在C#中使用类和对象
- 使用VC和MATCOM结合开发应用程序心得笔记
- 学习笔记,VB.NET使用DirectSound9 (1) 简单播放
- Oracle 9I安装使用笔记
- C#学习笔记(十六):使用打开保存文件对话框
- 兔八哥笔记7:WebLogic Platform8.1使用点滴(1)
- C#字符串的使用笔记
- 学习笔记,VB.NET使用DirectSound9 (2) 声音的特性
- CVS使用笔记
- c++ stl iostream 使用笔记一
- UltraEdit 使用技巧笔记(转载自DBA note)
- C#学习笔记(十六):使用打开保存文件对话框
- C#字符串的使用笔记
- Windows SDK笔记(六):使用对话框资源建立窗口
- JSP学习笔记(二)-----使用Tomcat运行JSP文件