Java读取Excel文件
来源:互联网 发布:用java打印菱形思路 编辑:程序博客网 时间:2024/06/03 19:21
通过java读取Excel文件获取数据
获取单元格中的内容
public String getValue(Cell cell) { String cellvalue = null; if (cell != null) { // 判断当前Cell的Type switch (cell.getCellType()) { // 如果当前Cell的Type为NUMERIC case Cell.CELL_TYPE_NUMERIC: case Cell.CELL_TYPE_FORMULA: { // 判断当前的cell是否为Date if (DateUtil.isCellDateFormatted(cell)) { // 如果是Date类型则,转化为Data格式 Date date = cell.getDateCellValue(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); cellvalue = sdf.format(date); } // 如果是纯数字 else { cell.setCellType(Cell.CELL_TYPE_STRING); cellvalue = cell.getRichStringCellValue().getString(); } break; } // 如果当前Cell的Type为STRING case Cell.CELL_TYPE_STRING: // 取得当前的Cell字符串 cellvalue = cell.getRichStringCellValue().getString(); break; // 如果当前Cell的Type为BOOLEAN case Cell.CELL_TYPE_BOOLEAN: cellvalue = String.valueOf(cell.getBooleanCellValue()); break; // 默认的Cell值 default: cellvalue = null; } } else { cellvalue = null; } if (cellvalue != null) { cellvalue = cellvalue.equals("") ? null : cellvalue; } return cellvalue;}
阅读全文
0 0
- java读取excel文件
- java读取excel 文件
- java读取excel文件
- Java读取Excel文件
- java读取Excel文件
- java 读取excel 文件
- java读取Excel文件
- Java 读取Excel文件
- JAVA读取excel文件
- java读取Excel文件.
- java读取excel文件
- java读取Excel文件
- Java读取Excel文件
- Java读取Excel文件
- java读取excel文件
- java 读取excel文件
- java读取Excel文件
- java读取excel文件
- Nexus 私有仓库搭建与 Maven 集成
- Linux必学命令-系统管理,系统安全类
- 使用sklearn包构建二元决策树预测红酒口感
- Redis Jedis 之 JedisSentinelPool 源码分析
- 实用VPC虚拟私有云设计原则
- Java读取Excel文件
- Java写入Excel文件
- 成为程序员ing日记
- vim使用教程
- 在内存中float数是如何转化为int数的zhang_he_xiang的博客CSDN
- CSSbackground的详细使用
- 使用@Order调整配置类加载顺序
- Java文件上传
- Spring MVC文件上传