/**
   * * Transforms the contents of a given cell from the POI-model to a {@link Formula} and sets the
   * formula as content of the given cell from the internal model.
   *
   * @param cell The given cell from the internal model.
   * @param poiCell The given cell form the POI-model.
   */
  protected void transformFormulaContent(Cell cell, org.apache.poi.ss.usermodel.Cell poiCell) {

    // Create formula and add to cell.
    Formula formula = new Formula();
    cell.setFormula(formula);
    formula.setCell(cell);
    formula.setFormulaString(poiCell.getCellFormula());

    // Set formula result type.
    switch (poiCell.getCachedFormulaResultType()) {
      case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
        formula.setResultType(CellContentType.NUMERIC);
        cell.setNumericContent(poiCell.getNumericCellValue());
        break;
      case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
        formula.setResultType(CellContentType.TEXT);
        cell.setTextContent(poiCell.getStringCellValue());
        break;
      case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
        formula.setResultType(CellContentType.BOOLEAN);
        cell.setBooleanContent(poiCell.getBooleanCellValue());
        break;
      case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
        formula.setResultType(CellContentType.ERROR);
        cell.setErrorContent(FormulaError.forInt(poiCell.getErrorCellValue()).toString());
        break;
      default:
        break;
    }

    // Set formula content.
    Stack<Ptg> ptgs = getPtgStackFor(poiCell);
    transform(cell, ptgs, formula, ptgs.size());
  }
Ejemplo n.º 2
0
 @Override
 protected String getValueText() {
   return FormulaError.forInt(_value).getString();
 }