Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache poi - XSSF read formatted cell value

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?

like image 493
Adam Davis Avatar asked Aug 14 '13 16:08

Adam Davis


People also ask

How do you find the cell value in POI?

Evaluate the Formula to Get the Cell Value Apache POI provides a FormulaEvaluator class, which enables us to calculate the results of formulas in Excel sheets. So, we can use FormulaEvaluator to calculate the cell value at runtime directly.

How do you find the value of a string from a numeric cell?

In Excel sheet before entering a numeric value inside a cell ,enter ~ symbol(tild) and enter the value. For Example: ~123. This might help you. You can use a POI DataFormatter to automatically convert any Cell type to String.

How do you read a cell value in Excel?

We can get the value of a cell (its content) by using the INDEX Function. The INDEX Function looks up a cell contained within a specified range and returns its value. In the example above, the range specified in the INDEX formula is “A1:J10”, the row is cell “C3” (“3”), and the column is cell “C4” (“5”).


1 Answers

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.

like image 67
akokskis Avatar answered Nov 03 '22 01:11

akokskis