apache poi - XSSF read formatted cell value

2019-06-27 04:13发布

问题:

Is there any way I can get to the formatted value that excel shows in a row, versus the raw value I am getting returned from the stream?

Or would this fall under the "formula evaluation" category, which this does not support?

回答1:

If you have the Cell that you're trying to get the data out of, try the following

DataFormatter formatter = new DataFormatter();
String formattedCellValue = formatter.formatCellValue(myCell);

If that doesn't get exactly what you're looking for, there are a number of different methods in the DataFormatter class that do the trick. Check out the API.