-
I have excel file with such contents:
-
A1: SomeString
-
A2: 2
All fields are set to String format.
-
-
When I read the file in java using POI, it tells that A2 is in numeric cell format.
- The problem is that the value in A2 can be 2 or 2.0 (and I want to be able to distinguish them) so I can’t just use
.toString().
What can I do to read the value as string?
Set cell type to string
I had same problem. I did
cell.setCellType(Cell.CELL_TYPE_STRING);before reading the string value, which solved the problem regardless of how the user formatted the cell.