使用POI 读取 Excel 文件,读取手机号码 变成 1.3471022771E10 [问题点数:40分,结帖人xieyongqiu]

           
不显示删除回复
           
显示所有回复
           
显示星级回复
           
显示得分回复
           
只显示楼主
          收藏
关注
xieyongqiu
maobingxixi
本版等级:

 
结帖率:71.43%
楼主发表于: 2010-09-13 17:33:03
 

使用POI 读取 Excel 文件,读取手机号码 变成  1.3471022771E10   如何 解决?

更多2分享到:

回复次数:15

关注
eemean
eemean
本版等级:

 
#1 得分:5回复于: 2010-09-13 17:34:34
你要多判断一下,CELL TYPE好像有四种类型的,,
关注
xieyongqiu
maobingxixi
本版等级:

 
#2 得分:0回复于: 2010-09-13 17:41:35
   
   if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {

DateFormat format = new SimpleDateFormat(DateUtil.YYYY_MM_DD);

if(HSSFDateUtil.isCellDateFormatted(cell)) {
     // 是否为日期型
      str = format.format(cell.getDateCellValue());
    } else {
     // 是否为数值型
      double d = cell.getNumericCellValue();
     if (d - (int) d < Double.MIN_VALUE) { 
     // 是否为int型
      str = Integer.toString((int) d);
     } else { 
      System.out.println("double.....");
      // 是否为double型
      str = Double.toString(cell.getNumericCellValue());
     }
    }
 
   System.out.println("type=="+cell.getCellType() );
   System.out.println("cell=="+str);

}else if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
str = cell.getRichStringCellValue().getString();
}else if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
 str = cell.getCellFormula();
}else if (cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
 str = " ";
}else if (cell.getCellType() == HSSFCell.CELL_TYPE_ERROR) {
 str = " ";
}

这几种 类型  都做判断了   依然还是    1.3471022771E10

关注
xieyongqiu
maobingxixi
本版等级:

 
#3 得分:0回复于: 2010-09-13 17:51:55
 解决了    是一个转换问题

//将被表示成1.3922433397E10的手机号转化为13922433397,不一定是最好的转换方法
  DecimalFormat df = new DecimalFormat("#");

System.out.println("type666=="+df.format(cell.getNumericCellValue()));

使用POI 读取 Excel 文件,读取手机号码 变成 1.3471022771E10的更多相关文章

  1. android 读取EXcel 文件 读取文件内存卡的权限

    android 采用Java的读取xls文件的方式实现. 需要导入第三方Jxl.jar 包.  代码改自 其他博主  : 这只摘录下 读取xls文件的部分代码,当然这个代码在安卓平台需要添加下面的权限 ...

  2. PHP读取Excel文件(PHPExcel)

    /*     * 读取Excel文件     * */    require_once (dirname(dirname(dirname(__FILE__))).'/PHPExcel/PHPExcel ...

  3. Apache POI 读写 Excel 文件

    目录 写入 Excel 文件 读取 Excel 文件 遍历 Excel 文件 需要的 maven 依赖 完整代码 写入 Excel 文件 // 写入 Excel 文件 // ============= ...

  4. 使用jxl,poi读取excel文件

    作用:在java后台添加一个方法,读取导入的excel内容,根据需要返回相应的sql语句,以完成对临时表的插入操作. 使用jxl读取excel文件 package com.sixthf.bi.sapp ...

  5. JAVA使用POI读取EXCEL文件的简单model

    一.JAVA使用POI读取EXCEL文件的简单model 1.所需要的jar commons-codec-1.10.jarcommons-logging-1.2.jarjunit-4.12.jarlo ...

  6. 使用POI读取excel文件内容

    1.前言 项目中要求读取excel文件内容,并将其转化为xml格式.常见读取excel文档一般使用POI和JExcelAPI这两个工具.这里我们介绍使用POI实现读取excel文档. 2.代码实例: ...

  7. jspsmart(保存文件)+poi(读取excel文件)操作excel文件

    写在前面: 项目环境:jdk1.4+weblogic 需求:能上传excel2003+2007 由于项目不仅需要上传excel2003,还要上传excel2007,故我们抛弃了jxl(只能上传exce ...

  8. 使用Apache下poi创建和读取excel文件

    一:使用apache下poi创建excel文档 @Test /* * 使用Apache poi创建excel文件 */ public void testCreateExcel() { // 1:创建一 ...

  9. java使用POI实现excel文件的读取,兼容后缀名xls和xlsx

    需要用的jar包如下: 如果是maven管理的项目,添加依赖如下: <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --&g ...

随机推荐

  1. One-Hot独热编码

    One-Hot独热编码 Dummy Encoding VS One-Hot Encoding二者都可以对Categorical Variable做处理,定性特征转换为定量特征,转换为定量特征其实就是将 ...

  2. angularJs1.x 版本中 uib-tabset 如何默认激活不同的标签页

     <uib-tabset> 默认有个active属性,根据官方文档,active的默认值是0,也就是说,默认显示索引为0的标签页,可以通过修改这个值来默认显示不同的索引的标签页. 示例: ...

  3. Maven_setting.xml

    <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Soft ...

  4. myeclipse非正常关闭处理办法

    myeclipse正常或非正常关闭后,再次运行,不显示启动时的logo和读条,进入主页面后程序基本就卡死,无法正常运行,解决办法. 方法一:修改工作空间在刚启动Myeclipse的时候会有一个选择工作 ...

  5. 012 Integer to Roman 整数转换成罗马数字

    给定一个整数,将其转为罗马数字.输入保证在 1 到 3999 之间. 详见:https://leetcode.com/problems/integer-to-roman/description/ cl ...

  6. mediawiki安装实现代码高亮的插件GeSHiHighLight

    1.下载新版本的GeSHi(http://qbnz.com/highlighter) 2.解压,复制geshi目录到mediawiki的扩展目录(extensions)下(建议删除contrib和do ...

  7. (转)linux 系统下虚拟用户的作用

    原文:http://blog.csdn.net/luoshao20120430/article/details/16900653            http://blog.csdn.net/u01 ...

  8. Linux Bash 命令行快捷键小结

    编辑命令          光标移动                                                                        剪切.删除 Ctrl ...

  9. springboot相关的pom依赖文件

    <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...

  10. drools的error:Jboss rule 6.4.0 Cannot find a default StatelessKieSession

    drools的kmodule.xml文件,如果是默认加载必须放在META-INF的文件夹下,如下图 官网大佬原话 Have you defined kieSession and KieBase nam ...