I am currently working on a project that reads an excel file using Apache POI.
My task seems to be simple, I just need to get the cell value as it was display in the excel file. I am aware of performing a switch statement based on the cell type of a cell. But if the data is something like
9,000.00
POI gives me 9000.0
when I do getNumericCellValue()
. When I force the cell to be a string type and do getStringCellValue()
it then gives me 9000
. What I need is the data as how it was presented in excel.
I found some post telling to use DataFormat
class but as per my understanding, it requires your code to be aware of the format that the cell has. In my case, I am not aware of the format that the cell might have.
So, how can I retrieve the cell value as how it was presented in excel?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…