Warm tip: This article is reproduced from stackoverflow.com, please click
java maven apache-poi

Alternative to POI's getCellNum method

发布于 2020-03-28 23:15:28

I am working on a legacy system that uses the getCellNum method in

<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11</version> 

its usage:

private void setValue(BpShipment entity, HSSFCell cell) {
    if (cell != null) {
        int cnum = cell.getCellNum(); // not found error
        // the rest of the code

When I started using the newer POI version on some new code

<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>

I started having an error in the legacy code saying that getCellNum() can't be resolved. Does any one know what is the replacement for getCellNum in the newer POI versions ?

Note:

Both legacy code class and new code class exist in the same maven project, so I can only use one of the POI dependencies, or can I use both? Thanks.

Questioner
Jalil.Jarjanazy
Viewed
62
maio290 2020-01-31 17:50

It's listed in the deprecated list:

org.apache.poi.hssf.usermodel.HSSFCell.getCellNum() (Oct 2008) use HSSFCell.getColumnIndex()