问题描述
我对
的版本有点迷茫<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
我尝试了 3.17、4.0.0 和 5.0.0 版本。
if (c.getCellType () == CellType.NUMERIC.getCode())
{
}
或
if (c.getCellTypeEnum () == CellType.NUMERIC)
{
}
我正在使用带有 Maven 和 Java 11 的 Eclipe。在版本更改后,我执行了“更新项目”来更新 Maven。
解决方法
在 apache poi 3.17
Cell.getCellType
中返回 int
但已弃用。 Cell.getCellTypeEnum
返回 CellType
。见apache poi 3.17 API: Interface Cell。
所以使用 apache poi 3.17
肯定是
if (cell.getCellTypeEnum() == CellType.NUMERIC)
在 apache poi
大于或等于版本 4.0.0
Cell.getCellType
中返回 CellType
。 Cell.getCellTypeEnum
也返回 CellType
但已弃用。见apache poi 4.0 API: Interface Cell。
所以使用 apache poi
大于或等于版本 4.0.0
它必须
if (cell.getCellType() == CellType.NUMERIC)