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

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

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

Cell.getErrorCellValue介绍

[英]Get the value of the cell as an error code.

For strings, numbers, and booleans, we throw an exception. For blank cells we return a 0.
[中]获取单元格的值作为错误代码。
对于字符串、数字和布尔值,我们抛出一个异常。对于空白单元格,我们返回0。

代码示例

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

break;
case Cell.CELL_TYPE_ERROR:
  System.out.println(cell.getErrorCellValue());
  break;

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

FormulaError error = FormulaError.forInt(cell.getErrorCellValue());

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

break;   
case ERROR:   
  destCell.setCellErrorValue(srcCell.getErrorCellValue());   
  break;   
case FORMULA:

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

return CellValue.valueOf(cell.getBooleanCellValue());
case ERROR:
  return CellValue.getError(cell.getErrorCellValue());
case FORMULA:
  return evaluateFormulaCellValue(cell);

代码示例来源:origin: looly/hutool

break;
case ERROR:
  final FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
  value = (null == error) ? StrUtil.EMPTY : error.getString();
  break;

代码示例来源:origin: looly/hutool

break;
case ERROR:
  final FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
  value = (null == error) ? StrUtil.EMPTY : error.getString();
  break;

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

return "";
case ERROR:
  return FormulaError.forInt(cell.getErrorCellValue()).getString();
default:
  throw new RuntimeException("Unexpected celltype (" + cellType + ")");

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

break;
case ERROR:
  setCellErrorValue(srcCell.getErrorCellValue());
  break;

代码示例来源:origin: xresloader/xresloader

static private Byte cal_cell2err(Cell c, CellValue cv) {
  if (null == cv) {
    return c.getErrorCellValue();
  }
  return cv.getErrorValue();
}

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

@Override
  public Cell adapt(org.apache.poi.ss.usermodel.Cell cell) {
    return new ErrorCell(cell.getErrorCellValue());
  }
},

代码示例来源:origin: com.github.mygreen/excel-cellformatter

/**
 * エラーセルの値を評価する。
 * @param cell
 * @param locale
 * @return
 */
private CellFormatResult getErrorCellValue(final Cell cell, final Locale locale) {
  final CellType cellType = cell.getCellTypeEnum();
  assert cellType == CellType.ERROR;
  return getErrorCellValue(cell.getErrorCellValue(), locale);
}

代码示例来源: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());
  }
},

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

private static void setCellDataValue(Cell oldCell, Cell newCell) {
  switch (oldCell.getCellType()) {
    case Cell.CELL_TYPE_BLANK:
      newCell.setCellValue(oldCell.getStringCellValue());
      break;
    case Cell.CELL_TYPE_BOOLEAN:
      newCell.setCellValue(oldCell.getBooleanCellValue());
      break;
    case Cell.CELL_TYPE_ERROR:
      newCell.setCellErrorValue(oldCell.getErrorCellValue());
      break;
    case Cell.CELL_TYPE_FORMULA:
      newCell.setCellFormula(oldCell.getCellFormula());
      break;
    case Cell.CELL_TYPE_NUMERIC:
      newCell.setCellValue(oldCell.getNumericCellValue());
      break;
    case Cell.CELL_TYPE_STRING:
      newCell.setCellValue(oldCell.getRichStringCellValue());
      break;
  }
}

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

public String getValue(int x, int y){
  Row row = this.activeSheet.getRow(y);
  if(row==null) return "";
  Cell cell = row.getCell(x);
  if(cell==null) return "";
  int type = cell.getCellType();
  switch(type){
  case 0:
    return cell.getNumericCellValue() + "";
  case 1:
    return cell.getStringCellValue();
  case 2:
    return cell.getCellFormula();
  case 3:
    return "";
  case 4:
    return cell.getBooleanCellValue() + "";
  case 5:
    return cell.getErrorCellValue() + "";
  default:
    return "";
  }
}

代码示例来源:origin: org.paxml/paxml-core

public Object getCellValue(Cell cell) {
  CellValue cellValue = evaluator.evaluate(cell);
  switch (cellValue.getCellType()) {
  case Cell.CELL_TYPE_BOOLEAN:
    return cellValue.getBooleanValue();
  case Cell.CELL_TYPE_NUMERIC:
    return cellValue.getNumberValue();
  case Cell.CELL_TYPE_STRING:
    return cellValue.getStringValue();
  case Cell.CELL_TYPE_BLANK:
    return "";
  case Cell.CELL_TYPE_ERROR:
    return cellValue.getError(cell.getErrorCellValue()).getStringValue();
    // CELL_TYPE_FORMULA will never happen
  case Cell.CELL_TYPE_FORMULA:
    throw new PaxmlRuntimeException("Internal error: invalid case");
  default:
    return null;
  }
}

代码示例来源:origin: org.paxml/PaxmlCore

public Object getCellValue(Cell cell) {
  CellValue cellValue = evaluator.evaluate(cell);
  switch (cellValue.getCellType()) {
  case Cell.CELL_TYPE_BOOLEAN:
    return cellValue.getBooleanValue();
  case Cell.CELL_TYPE_NUMERIC:
    return cellValue.getNumberValue();
  case Cell.CELL_TYPE_STRING:
    return cellValue.getStringValue();
  case Cell.CELL_TYPE_BLANK:
    return "";
  case Cell.CELL_TYPE_ERROR:
    return cellValue.getError(cell.getErrorCellValue()).getStringValue();
    // CELL_TYPE_FORMULA will never happen
  case Cell.CELL_TYPE_FORMULA:
    throw new PaxmlRuntimeException("Internal error: invalid case");
  default:
    return null;
  }
}

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

private String getCellValue(Cell cell) {
  if (cell == null) {
    return null;
  }
  if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
    return cell.getStringCellValue();
  } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
    return cell.getNumericCellValue() + "";
  } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
    return cell.getBooleanCellValue() + "";
  }else if(cell.getCellType() == Cell.CELL_TYPE_BLANK){
    return cell.getStringCellValue();
  }else if(cell.getCellType() == Cell.CELL_TYPE_ERROR){
    return cell.getErrorCellValue() + "";
  } 
  else {
    return null;
  }
}

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

private String getCellValue(Cell cell) {
   if (cell == null) {
     return null;
   }
   if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
     return cell.getStringCellValue();
   } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
     return cell.getNumericCellValue() + "";
   } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
     return cell.getBooleanCellValue() + "";
   }else if(cell.getCellType() == Cell.CELL_TYPE_BLANK){
     return cell.getStringCellValue();
   }else if(cell.getCellType() == Cell.CELL_TYPE_ERROR){
     return cell.getErrorCellValue() + "";
   } 
   else {
     return null;
   }
 }

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

private String getCellValue(Cell cell) {
  if (cell == null) {
    return null;
  }
  if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
    return cell.getStringCellValue();
  } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
    return cell.getNumericCellValue() + "";
  } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
    return cell.getBooleanCellValue() + "";
  }else if(cell.getCellType() == Cell.CELL_TYPE_BLANK){
    return cell.getStringCellValue();
  }else if(cell.getCellType() == Cell.CELL_TYPE_ERROR){
    return cell.getErrorCellValue() + "";
  } 
  else {
    return null;
  }
}

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

//use this method for getting values from excel.It might help u.
private String getCellValue(Cell cell) {
  if (cell == null) {
    return null;
  }
  if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
    return cell.getStringCellValue();
  } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
    return cell.getNumericCellValue() + "";
  } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
    return cell.getBooleanCellValue() + "";
  }else if(cell.getCellType() == Cell.CELL_TYPE_BLANK){
    return cell.getStringCellValue();
  }else if(cell.getCellType() == Cell.CELL_TYPE_ERROR){
    return cell.getErrorCellValue() + "";
  } 
  else {
    return null;
  }
}

相关文章