24小时热门版块排行榜    

查看: 588  |  回复: 3

wxyuan2014

铜虫 (小有名气)

[求助] 利用Java读取excel 已有1人参与

请问:我的excel中的数据都是小数点后八位,例如2.33800951。而用程序读取之后的程序只有小数点后两位。这是读取的代码cell = sheet.getCell(i, j);
                                        str[j] = cell.getContents();请问怎么改才能把小数点后面的部分全部读出?谢谢!
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

必运动
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

jianliu67

木虫 (小有名气)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
wxyuan2014: 金币+10 2016-08-08 11:10:36
Cell A = sheet.getCell(i, j);
if (A.getType() == CellType.NUMBER) {
    NumberCell nc = (NumberCell) A;
    double doubleA = nc.getValue();
}
2楼2016-08-07 02:42:53
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wxyuan2014

铜虫 (小有名气)

引用回帖:
2楼: Originally posted by jianliu67 at 2016-08-07 02:42:53
Cell A = sheet.getCell(i, j);
if (A.getType() == CellType.NUMBER) {
    NumberCell nc = (NumberCell) A;
    double doubleA = nc.getValue();
}

没有这个语句吗?str=cell.getContents()

发自小木虫Android客户端
必运动
3楼2016-08-08 08:46:51
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

jianliu67

木虫 (小有名气)

引用回帖:
3楼: Originally posted by wxyuan2014 at 2016-08-07 12:46:51
没有这个语句吗?str=cell.getContents()
...

有, 但是不好. 看下面的解释:
http://jexcelapi.sourceforge.net ... .html#getContents()

public java.lang.String getContents()

    Quick and dirty function to return the contents of this cell as a string. For more complex manipulation of the contents, it is necessary to cast this interface to correct subinterface.

    Returns:
        the contents of this cell as a string
4楼2016-08-09 08:17:01
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 wxyuan2014 的主题更新
信息提示
请填处理意见