1

How do i get the content of a spreadsheet cell from an excel file using POI 3.15 (which is supposed to be the latest stable version at the time of this writing) WITHOUT using a deprecated method?

The problem is apparently, in order to read a cell's content, you need to know the cell's type. But from what I can tell, every single way to get a cell's type is deprecated.

What i tried:

  1. The official documentation: unless i missed something, it looks very incomplete, and doesn't have any example of reading a cell, except this one, which uses the method cell.getCellTypeEnum(), which is deprecated, but returns a non-deprecated org.apache.poi.ss.usermodel.CellType.
  2. I found this issue on stackoverflow: Get Cell Value from Excel Sheet with Apache Poi , which uses a FormulaEvaluator to evaluate the cell's type. The method evaluateFormulaCell is deprecated, and it is unclear what it currently returns, but it seems to be one of the constants Cell.CELL_TYPE_* (according to the documentation), which are all deprecated.
  3. Found this tutorial on google, but it's 2 years old already. It mentions using the method cell.getCellType(), which is now deprecated (and also returns one of the deprecated Cell.CELL_TYPE_* constants).

From what i can tell, there is no non-deprecated way to get a cell's type with POI 3.15, and therefore no non-deprecated way to read a spreadsheet using POI 3.15.

The best possible way i could find is using the deprecated method cell.getCellTypeEnum() , since the value it returns is a value from the enum org.apache.poi.ss.usermodel.CellType , which isn't deprecated.

I am correct, or is there a better way to read spreadsheets using POI 3.15?

EDIT: Apparently my conclusion was correct. It will eventually be fixed by Apache POI in a future release.

Community
  • 1
  • 1
Michaël Vreux
  • 316
  • 1
  • 2
  • 14
  • 4
    We are in the progress of deprecating the old int based enums with real enums. As we have the policy to keep the deprecated api for two full releases, we switch the signature [soon](https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Cell.html#getCellTypeEnum()). So use getCellTypeEnum for now and switch to getCellType, when you upgrade POI the next time. ... sorry for that compromise ... – kiwiwings Dec 13 '16 at 11:38
  • Great, thanks for clarifying this! – Michaël Vreux Dec 13 '16 at 11:47

0 Answers0