Warrior990
Warrior990

Reputation: 69

Reading blank cell Apache POI 3.17

I'm using Apache POI 3.17 to read some excel data. My second column (index of 1 because of 0 index) is empty and I want to be able to read it, but can't get my code to read the cell as empty. I have this which isn't working:

Cell c = row.getCell(1, Row.RETURN_BLANK_AS_NULL);
      if (c == null) {
         // do whatever
 }

But the second parameter can't be taken in. I get "RETURN_BLANK_AS_NULL cannot be resolved or is not a field"

Upvotes: 1

Views: 1160

Answers (1)

rgettman
rgettman

Reputation: 178243

The constants in the Row class itself were deprecated as of POI-3.15-beta2, marked for removal as of POI-3.17. This diff shows when those constants were deprecated in June 2016. They were removed in 3.17.

Before 3.17, the enum Row.MissingCellPolicy was already defined as a replacement. If you're using 3.17, then you must use that enum; it is defined as a member of the Row interface. Try

Cell c = row.getCell(1, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);

Upvotes: 2

Related Questions