public static String getCellValue(Cell cell) {
if(cell == null)
return "";
DataFormatter dataFormatter = new DataFormatter();
String res = null;
if(cell.getCellType() == CellType.FORMULA) {
FormulaEvaluator evaluator = cell.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
res = dataFormatter.formatCellValue(cell, evaluator);
} else {
res = dataFormatter.formatCellValue(cell);
}
String dataFormatString = cell.getCellStyle().getDataFormatString();
if (!StringUtil.isNull(dataFormatString)) {
if(dataFormatString.matches("@\".+\"")) {
Pattern p = Pattern.compile("@\"(.+)\"");
Matcher m = p.matcher(dataFormatString);
m.find();
res = res + m.group(1);
}
}
return res;
}