" + cell.getNumericCellValue() -6ren">
gpt4 book ai didi

java - 将电话号码从 double 转换为整数

转载 作者:行者123 更新时间:2023-12-01 19:54:44 24 4
gpt4 key购买 nike

我正在使用 Apache POI 从 Excel 获取电话号码。

System.out.println(
"---------->" + cell.getNumericCellValue() + "--" + (int) cell.getNumericCellValue()
);

sel.setContactno(String.valueOf(cell.getNumericCellValue()));

输出:

---------->8.902305623E9--2147483647

异常(exception)是

java.lang.IllegalStateException: Cannot get a STRING value from a NUMERIC cell

如何正确获取电话号码?

最佳答案

java.lang.IllegalStateException - if the cell type returned by getCellType() is CellType.STRING

很可能cell.getNumericCellValue()似乎不包含double。请验证您的 Excel 数据。

编辑:我认为电话号码首先不应该只是一个实体。它可以由本地代码、国家代码等组成,其中可以包含+等特殊字符。因此它绝对不应该是数字。该组合物应提供所需的灵 active 。但这完全取决于您/操作的要求。

关于java - 将电话号码从 double 转换为整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49974889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com