Thank you for the reply.
The following code:
System.out.println("Cell " + getEquivalentColumnName(j) + ":" + (i + 1) + "
style = " + cell.getCellStyle().getDataFormatString());
Results in (for example):
Cell H:430 style = 000\-00000\-000
So that looks correct. However the following code:
DataFormatter formatter = new DataFormatter();
FormulaEvaluator evaluator =
workbook.getCreationHelper().createFormulaEvaluator();
...
if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
if (cell.getCachedFormulaResultType() == Cell.CELL_TYPE_ERROR) {
data[i][j] = "#VALUE!";
}
else {
data[i][j] = formatter.formatCellValue(cell, evaluator);
}
}
else {
try {
data[i][j] = formatter.formatCellValue(cell);
}
catch(Exception e) {
System.out.println("Cell " + getEquivalentColumnName(j) + ":" + i
+ " could not be formatted. Switched to string type.");
cell.setCellType(Cell.CELL_TYPE_STRING);
data[i][j] = cell.getRichStringCellValue().toString();
}
}
With a cell value of 12312345123, results in data[i][j] == "12312345123" and
not "123-12345-123".
I hope that helps clarify the issue.
Should I be searching to see if a format exists for 000\-00000\-000 and if
not then adding it prior to attempting to format? It would appear that the
format must be there as I am getting the appropriate format back.
Any help would be appreciated.
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/Reading-cell-values-that-have-a-custom-format-tp5486315p5486553.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]