org.apache.poi.ss.usermodel.Cell.getCachedFormulaResultType()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(235)

本文整理了Java中org.apache.poi.ss.usermodel.Cell.getCachedFormulaResultType()方法的一些代码示例,展示了Cell.getCachedFormulaResultType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cell.getCachedFormulaResultType()方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Cell
类名称:Cell
方法名:getCachedFormulaResultType

Cell.getCachedFormulaResultType介绍

[英]Only valid for formula cells
[中]仅对公式单元格有效

代码示例

代码示例来源:origin: org.apache.poi/poi

@Override
public CellType evaluateFormulaCell(Cell cell) { return cell.getCachedFormulaResultType(); }
/**

代码示例来源:origin: org.apache.poi/poi

/**
* Note that this assumes the cell cached value is up to date and in sync with data edits
 *
* @param cell The {@link Cell} to check.
* @param type The {@link CellType} to check for.
* @return true if the cell or cached cell formula result type match the given type
*/
public static boolean isType(Cell cell, CellType type) {
  final CellType cellType = cell.getCellType();
  return cellType == type 
     || (cellType == CellType.FORMULA 
       && cell.getCachedFormulaResultType() == type
       );
}

代码示例来源:origin: org.apache.poi/poi

/**
 * Returns the ultimate cell type, following the results of formulas.  If
 * the cell is a {@link CellType#FORMULA}, this returns the result of
 * {@link Cell#getCachedFormulaResultType()}.  Otherwise this returns the
 * result of {@link Cell#getCellType()}.
 * 
 * @param cell The cell.
 *
 * @return The ultimate type of this cell.
 */
public static CellType ultimateType(Cell cell) {
  CellType type = cell.getCellType();
  if (type == CellType.FORMULA)
    return cell.getCachedFormulaResultType();
  else
    return type;
}

代码示例来源:origin: stackoverflow.com

for(Cell cell : row) {
  if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
   System.out.println("Formula is " + cell.getCellFormula());
   switch(cell.getCachedFormulaResultType()) {
     case Cell.CELL_TYPE_NUMERIC:
       System.out.println("Last evaluated as: " + cell.getNumericCellValue());
       break;
     case Cell.CELL_TYPE_STRING:
       System.out.println("Last evaluated as \"" + cell.getRichStringCellValue() + "\"");
       break;
   }
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

return KCellType.EMPTY;
} else if ( type == Cell.CELL_TYPE_FORMULA ) {
 switch ( cell.getCachedFormulaResultType() ) {
  case Cell.CELL_TYPE_BLANK:
  case Cell.CELL_TYPE_ERROR:

代码示例来源:origin: org.apache.poi/poi-ooxml

outputQuotedString(cell.getCellFormula());
_out.write("</f>");
switch (cell.getCachedFormulaResultType()) {
  case NUMERIC:
    double nval = cell.getNumericCellValue();

代码示例来源:origin: org.apache.poi/poi

private ValueAndFormat getCellValue(Cell cell) {
  if (cell != null) {
    final String format = cell.getCellStyle().getDataFormatString();
    CellType type = cell.getCellType();
    if (type == CellType.FORMULA) {
      type = cell.getCachedFormulaResultType();
    }
    switch (type) {
      case NUMERIC:
        return new ValueAndFormat(Double.valueOf(cell.getNumericCellValue()), format, decimalTextFormat);
      case STRING:
      case BOOLEAN:
        return new ValueAndFormat(cell.getStringCellValue(), format);
      default:
        break;
    }
  }
  return new ValueAndFormat("", "");
}
/**

代码示例来源:origin: org.apache.poi/poi-ooxml

private void handleNonStringCell(StringBuilder text, Cell cell, DataFormatter formatter) {
  CellType type = cell.getCellType();
  if (type == CellType.FORMULA) {
    type = cell.getCachedFormulaResultType();
  }
  if (type == CellType.NUMERIC) {
    CellStyle cs = cell.getCellStyle();
    if (cs != null && cs.getDataFormatString() != null) {
      String contents = formatter.formatRawCellContents(
          cell.getNumericCellValue(), cs.getDataFormat(), cs.getDataFormatString());
      checkMaxTextSize(text, contents);
      text.append(contents);
      return;
    }
  }
  // No supported styling applies to this cell
  String contents = ((XSSFCell)cell).getRawValue();
  if (contents != null) {
    checkMaxTextSize(text, contents);
    text.append(contents);
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

text.append(contents);
} else {
  if (cell.getCachedFormulaResultType() == CellType.STRING) {
    handleStringCell(text, cell);
  } else {

代码示例来源:origin: org.apache.poi/poi

cellType = cell.getCachedFormulaResultType();

代码示例来源:origin: stackoverflow.com

List<Double> values = new ArrayList<Double>();
for(Row r : sheet) {
  Cell c = r.getCell(columnNumber);
  if(c != null) {
   if(c.getCellType() == Cell.CELL_TYPE_NUMERIC) {
     valuesadd(c.getNumericCellValue());
   } else if(c.getCellType() == Cell.CELL_TYPE_FORMULA && c.getCachedFormulaResultType() == Cell.CELL_TYPE_NUMERIC) {
     valuesadd(c.getNumericCellValue());
   }
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

copyCellType = srcCell.getCachedFormulaResultType();

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

public int evaluateFormulaCell(Cell cell) {
  return cell.getCachedFormulaResultType();
}

代码示例来源:origin: com.haulmont.thirdparty/poi

public int evaluateFormulaCell(Cell cell) {
  return cell.getCachedFormulaResultType();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

@Override
public CellType evaluateFormulaCell(Cell cell) { return cell.getCachedFormulaResultType(); }
/**

代码示例来源:origin: org.apache.poi/poi-examples

private static CellType ultimateCellType(Cell c) {
  CellType type = c.getCellType();
  if (type == CellType.FORMULA) {
    type = c.getCachedFormulaResultType();
  }
  return type;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
* Note that this assumes the cell cached value is up to date and in sync with data edits
 *
* @param cell The {@link Cell} to check.
* @param type The {@link CellType} to check for.
* @return true if the cell or cached cell formula result type match the given type
*/
public static boolean isType(Cell cell, CellType type) {
  final CellType cellType = cell.getCellType();
  return cellType == type 
     || (cellType == CellType.FORMULA 
       && cell.getCachedFormulaResultType() == type
       );
}

代码示例来源:origin: stackoverflow.com

int cellType = cell.getCellType();
handleCell(cell, cellType);

private void handleCell(Cell cell, int cellType) {
    if (HSSFCell.CELL_TYPE_NUMERIC == cellType)
      System.out.print(cell.getNumericCellValue() + "     ");
    else if (HSSFCell.CELL_TYPE_STRING == cellType)
      System.out.print(cell.getStringCellValue() + "     ");
    else if (HSSFCell.CELL_TYPE_BOOLEAN == cellType)
      System.out.print(cell.getBooleanCellValue() + "     ");
    else if (HSSFCell.CELL_TYPE_BLANK == cellType)
      System.out.print("BLANK     ");
    else if (HSSFCell.CELL_TYPE_FORMULA == cellType)
      handleCell(cell, cell.getCachedFormulaResultType());
    else 
      System.out.print("Unknown cell type " + cellType);
  }

代码示例来源:origin: openl-tablets/openl-tablets

public int getNativeType() {
  Cell cell = getCell();
  if (cell == null) {
    return IGrid.CELL_TYPE_BLANK;
  }
  CellType type = cell.getCellType();
  if (type == CellType.FORMULA) {
    return getIGridCellType(cell.getCachedFormulaResultType());
  }
  return getIGridCellType(type);
}

代码示例来源:origin: tobyweston/simple-excel

@Override
  public Cell adapt(org.apache.poi.ss.usermodel.Cell cell) {
    if (cell.getCachedFormulaResultType() == CELL_TYPE_ERROR)
      return new ErrorCell(cell.getErrorCellValue());
    return new FormulaCell(cell.getCellFormula());
  }
},

相关文章