Apache POI 4.1.2 Migration issue with CELL_TYPE_NUMERIC

1.8k views Asked by At

I had POI 3.17 before in my project and as the black duck scan resutl was shwoing vulnerability I had to switch to 4.0 or better. After I downloaded the 4.1.2 jar ( THIS IS A ANT PROJECT). I am having build issues which says this :

Compiling 500 source files to C:\Users\k\project\ts\ts\build\WEB-INF\classes C:\Users\k\project\ts\ts\tool\src\com\vh\tool\services\DNBBatchThread.java:197: error: cannot find symbol [javac]

if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC)
^

1

There are 1 answers

0
Stunner On

As of today(24th April 2020) , the latest version of POI is 4.1.2 In latest version , the getCellType() method returns CellType Enum. So your code should be like below.

switch (cell.getCellType()) {

   case NUMERIC:
                 //Do Something
                 break;
   case STRING:
                 //Do something
                 break;

}

Note: In the above case statements , NUMERIC and STRING are of type CellType enum values.