Exemplo n.º 1
0
 @Override
 public String getTextString() {
   StringBuilder sb = new StringBuilder();
   for (int j = 0; j < numOfCells; ++j) {
     CellValue cellValue = getCellValueAt(j);
     if (cellValue != null) {
       sb.append(cellValue.getStringValue());
     }
   }
   return sb.length() == 0 ? null : sb.toString();
 }
Exemplo n.º 2
0
  private Object evaluateCellFormula(final HSSFWorkbook workbook, final Cell cell) {
    FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
    CellValue cellValue = evaluator.evaluate(cell);
    Object result = null;

    if (cellValue.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
      result = cellValue.getBooleanValue();
    } else if (cellValue.getCellType() == Cell.CELL_TYPE_NUMERIC) {
      result = cellValue.getNumberValue();
    } else if (cellValue.getCellType() == Cell.CELL_TYPE_STRING) {
      result = cellValue.getStringValue();
    }

    return result;
  }