项目中使用POI 5.0以后的依赖
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
在函数中使用Cell.setCellType()时,会显示此函数过时
深入源码
![](https://img-blog.csdnimg.cn/aabe44c8b1f6463d929d4898ff2cacb4.png)
![](https://img-blog.csdnimg.cn/9a5cca72f7e043e0b3f7cbdbaf3b171a.png)
虽然Cell
接口中的方法被@Deprecated
注解标识,但是抽象类CellBase
重写了该方法。看到这里就明白了,我们不用Cell
作为数据类型,也不用CellBase
的实现类,转用CellBase
抽象类作为数据类型。
解决方法
使用CellBase
类型的单元格对象