I am writing a bit of code to read an excel file. At this point I am trying to determine the type of a cell.
val wb:HSSFWorkbook= new HSSFWorkbook(fileInput)
val sheet:HSSFSheet = wb.getSheetAt(0);
val rows = sheet.rowIterator()
while(rows.hasNext()){
var row = rows.next()
val cells = row.cellIterator()
while(cells.hasNext()){
val cell = cells.next()
println(cell.getCellType()== org.apache.poi.hssf.usermodel.HSSFCell.CELL_TYPE_NUMERIC)}}
It says
value CELL_TYPE_NUMERIC is not a member of object org.apache.poi.hssf.usermodel.HSSFCell
I dont understand why i cannot access this field. Could you please help on that.
regards
Scala treats static fields a bit different. In scala there are no static fields, so scala builds virtual
objects for the static fields in java classes. AsCELL_TYPE_NUMERICis not defined onorg.apache.poi.hssf.usermodel.HSSFCellbut onorg.apache.poi.ss.usermodel.Cell, you can’t access it from there, because inheritance is not taken into account on static members. You can access the field directly:If inheritance was taken into account, this would lead to inconsistencies with how scala
objects work. In scala a companion object does not inherit anything from the companion of the classes superclass.