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

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

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

Cell.setCellErrorValue介绍

[英]Set a error value for the cell
[中]设置单元格的错误值

代码示例

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

public void copyValue(Cell destCell) {
  switch (_cellType) {
    case BLANK:   destCell.setCellType(CellType.BLANK);          return;
    case NUMERIC: destCell.setCellValue(_numberValue);           return;
    case BOOLEAN: destCell.setCellValue(_booleanValue);          return;
    case STRING:  destCell.setCellValue(_stringValue);           return;
    case ERROR:   destCell.setCellErrorValue((byte)_errorValue); return;
    default: throw new IllegalStateException("Unexpected data type (" + _cellType + ")");
  }
}

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

protected void setCellValue(Cell cell, CellValue cv) {
  CellType cellType = cv.getCellType();
  switch (cellType) {
    case BOOLEAN:
      cell.setCellValue(cv.getBooleanValue());
      break;
    case ERROR:
      cell.setCellErrorValue(cv.getErrorValue());
      break;
    case NUMERIC:
      cell.setCellValue(cv.getNumberValue());
      break;
    case STRING:
      cell.setCellValue(createRichTextString(cv.getStringValue()));
      break;
    case BLANK:
      // never happens - blanks eventually get translated to zero
    case FORMULA:
      // this will never happen, we have already evaluated the formula
    default:
      throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
  }
}

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

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

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

public void copyValue(Cell destCell) {
  switch (_cellType) {
    case Cell.CELL_TYPE_BLANK:   destCell.setCellType(Cell.CELL_TYPE_BLANK);    return;
    case Cell.CELL_TYPE_NUMERIC: destCell.setCellValue(_numberValue);           return;
    case Cell.CELL_TYPE_BOOLEAN: destCell.setCellValue(_booleanValue);          return;
    case Cell.CELL_TYPE_STRING:  destCell.setCellValue(_stringValue);           return;
    case Cell.CELL_TYPE_ERROR:   destCell.setCellErrorValue((byte)_errorValue); return;
  }
  throw new IllegalStateException("Unexpected data type (" + _cellType + ")");
}

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

public void copyValue(Cell destCell) {
  switch (_cellType) {
    case Cell.CELL_TYPE_BLANK:   destCell.setCellType(Cell.CELL_TYPE_BLANK);    return;
    case Cell.CELL_TYPE_NUMERIC: destCell.setCellValue(_numberValue);           return;
    case Cell.CELL_TYPE_BOOLEAN: destCell.setCellValue(_booleanValue);          return;
    case Cell.CELL_TYPE_STRING:  destCell.setCellValue(_stringValue);           return;
    case Cell.CELL_TYPE_ERROR:   destCell.setCellErrorValue((byte)_errorValue); return;
  }
  throw new IllegalStateException("Unexpected data type (" + _cellType + ")");
}

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

public void copyValue(Cell destCell) {
  switch (_cellType) {
    case BLANK:   destCell.setCellType(CellType.BLANK);          return;
    case NUMERIC: destCell.setCellValue(_numberValue);           return;
    case BOOLEAN: destCell.setCellValue(_booleanValue);          return;
    case STRING:  destCell.setCellValue(_stringValue);           return;
    case ERROR:   destCell.setCellErrorValue((byte)_errorValue); return;
    default: throw new IllegalStateException("Unexpected data type (" + _cellType + ")");
  }
}

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

@Override
public void update(org.apache.poi.ss.usermodel.Cell cell, Workbook workbook) {
  this.getStyle().applyTo(cell, workbook);
  cell.setCellErrorValue(errorCode);
}

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

private static void setCellValue(Cell cell, CellValue cv) {
  int cellType = cv.getCellType();
  switch (cellType) {
    case HSSFCell.CELL_TYPE_BOOLEAN:
      cell.setCellValue(cv.getBooleanValue());
      break;
    case HSSFCell.CELL_TYPE_ERROR:
      cell.setCellErrorValue(cv.getErrorValue());
      break;
    case HSSFCell.CELL_TYPE_NUMERIC:
      cell.setCellValue(cv.getNumberValue());
      break;
    case HSSFCell.CELL_TYPE_STRING:
      cell.setCellValue(new HSSFRichTextString(cv.getStringValue()));
      break;
    case HSSFCell.CELL_TYPE_BLANK:
      // never happens - blanks eventually get translated to zero
    case HSSFCell.CELL_TYPE_FORMULA:
      // this will never happen, we have already evaluated the formula
    default:
      throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
  }
}

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

private static void setCellValue(Cell cell, CellValue cv) {
  int cellType = cv.getCellType();
  switch (cellType) {
    case HSSFCell.CELL_TYPE_BOOLEAN:
      cell.setCellValue(cv.getBooleanValue());
      break;
    case HSSFCell.CELL_TYPE_ERROR:
      cell.setCellErrorValue(cv.getErrorValue());
      break;
    case HSSFCell.CELL_TYPE_NUMERIC:
      cell.setCellValue(cv.getNumberValue());
      break;
    case HSSFCell.CELL_TYPE_STRING:
      cell.setCellValue(new HSSFRichTextString(cv.getStringValue()));
      break;
    case HSSFCell.CELL_TYPE_BLANK:
      // never happens - blanks eventually get translated to zero
    case HSSFCell.CELL_TYPE_FORMULA:
      // this will never happen, we have already evaluated the formula
    default:
      throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
  }
}

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

private static void setCellValue(Cell cell, CellValue cv) {
  int cellType = cv.getCellType();
  switch (cellType) {
    case XSSFCell.CELL_TYPE_BOOLEAN:
      cell.setCellValue(cv.getBooleanValue());
      break;
    case XSSFCell.CELL_TYPE_ERROR:
      cell.setCellErrorValue(cv.getErrorValue());
      break;
    case XSSFCell.CELL_TYPE_NUMERIC:
      cell.setCellValue(cv.getNumberValue());
      break;
    case XSSFCell.CELL_TYPE_STRING:
      cell.setCellValue(new XSSFRichTextString(cv.getStringValue()));
      break;
    case XSSFCell.CELL_TYPE_BLANK:
      // never happens - blanks eventually get translated to zero
    case XSSFCell.CELL_TYPE_FORMULA:
      // this will never happen, we have already evaluated the formula
    default:
      throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
  }
}

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

protected void setCellValue(Cell cell, CellValue cv) {
  CellType cellType = cv.getCellType();
  switch (cellType) {
    case BOOLEAN:
      cell.setCellValue(cv.getBooleanValue());
      break;
    case ERROR:
      cell.setCellErrorValue(cv.getErrorValue());
      break;
    case NUMERIC:
      cell.setCellValue(cv.getNumberValue());
      break;
    case STRING:
      cell.setCellValue(createRichTextString(cv.getStringValue()));
      break;
    case BLANK:
      // never happens - blanks eventually get translated to zero
    case FORMULA:
      // this will never happen, we have already evaluated the formula
    default:
      throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
  }
}

代码示例来源: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: net.sf.jxls/jxls-core

private static void moveCell(org.apache.poi.ss.usermodel.Cell srcCell, org.apache.poi.ss.usermodel.Cell destCell) {
  destCell.setCellStyle(srcCell.getCellStyle());
  switch (srcCell.getCellType()) {
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
      destCell.setCellValue(srcCell.getRichStringCellValue());
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
      destCell.setCellValue(srcCell.getNumericCellValue());
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK:
      destCell.setCellType(org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK);
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
      destCell.setCellValue(srcCell.getBooleanCellValue());
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
      destCell.setCellErrorValue(srcCell.getErrorCellValue());
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
      break;
    default:
      break;
  }
  srcCell.setCellType(org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK);
}

代码示例来源:origin: SheetJS/jxls

private static void moveCell(org.apache.poi.ss.usermodel.Cell srcCell, org.apache.poi.ss.usermodel.Cell destCell) {
  destCell.setCellStyle(srcCell.getCellStyle());
  switch (srcCell.getCellType()) {
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
    destCell.setCellValue(srcCell.getRichStringCellValue());
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
    destCell.setCellValue(srcCell.getNumericCellValue());
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK:
    destCell.setCellType(org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK);
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
    destCell.setCellValue(srcCell.getBooleanCellValue());
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
    destCell.setCellErrorValue(srcCell.getErrorCellValue());
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
    break;
  default:
    break;
  }
  srcCell.setCellType(org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK);
}

代码示例来源:origin: SheetJS/jxls

public static void copyCell(org.apache.poi.ss.usermodel.Cell oldCell, org.apache.poi.ss.usermodel.Cell newCell,
    boolean copyStyle) {
  if (copyStyle) {
    newCell.setCellStyle(oldCell.getCellStyle());
  }
  switch (oldCell.getCellType()) {
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
    newCell.setCellValue(oldCell.getRichStringCellValue());
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
    newCell.setCellValue(oldCell.getNumericCellValue());
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK:
    newCell.setCellType(org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK);
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
    newCell.setCellValue(oldCell.getBooleanCellValue());
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
    newCell.setCellErrorValue(oldCell.getErrorCellValue());
    break;
  case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
    newCell.setCellFormula(oldCell.getCellFormula());
    break;
  default:
    break;
  }
}

代码示例来源:origin: net.sf.jxls/jxls-core

public static void copyCell(org.apache.poi.ss.usermodel.Cell oldCell, org.apache.poi.ss.usermodel.Cell newCell,
    boolean copyStyle) {
  if (copyStyle) {
    newCell.setCellStyle(oldCell.getCellStyle());
    copyConditionalFormat(oldCell, newCell);
  }
  switch (oldCell.getCellType()) {
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
      newCell.setCellValue(oldCell.getRichStringCellValue());
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
      newCell.setCellValue(oldCell.getNumericCellValue());
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK:
      newCell.setCellType(org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK);
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
      newCell.setCellValue(oldCell.getBooleanCellValue());
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
      newCell.setCellErrorValue(oldCell.getErrorCellValue());
      break;
    case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
      newCell.setCellFormula(oldCell.getCellFormula());
      break;
    default:
      break;
  }
}

代码示例来源:origin: hyberbin/J-Excel

public static void copyCell(Cell srcCell, Cell distCell){
  distCell.setCellStyle(srcCell.getCellStyle());
  if(srcCell.getCellComment() != null) {
    distCell.setCellComment(srcCell.getCellComment());
  }
  int srcCellType = srcCell.getCellType();
  distCell.setCellType(srcCellType);
  if (srcCellType == Cell.CELL_TYPE_NUMERIC) {
    if (DateUtil.isCellDateFormatted(srcCell)) {
      distCell.setCellValue(srcCell.getDateCellValue());
    } else {
      distCell.setCellValue(srcCell.getNumericCellValue());
    }
  } else if (srcCellType == Cell.CELL_TYPE_STRING) {
    distCell.setCellValue(srcCell.getRichStringCellValue());
  } else if (srcCellType == Cell.CELL_TYPE_BLANK) {
    //nothing
  } else if (srcCellType == Cell.CELL_TYPE_BOOLEAN) {
    distCell.setCellValue(srcCell.getBooleanCellValue());
  } else if (srcCellType == Cell.CELL_TYPE_ERROR) {
    distCell.setCellErrorValue(srcCell.getErrorCellValue());
  } else if (srcCellType == Cell.CELL_TYPE_FORMULA) {
    distCell.setCellFormula(srcCell.getCellFormula());
  } else {
    //nothing
  }
}

代码示例来源:origin: com.github.nic-luo/rober-office

distCell.setCellValue(srcCell.getBooleanCellValue());
} else if (srcCellType == Cell.CELL_TYPE_ERROR) {
  distCell.setCellErrorValue(srcCell.getErrorCellValue());
} else if (srcCellType == Cell.CELL_TYPE_FORMULA) {
  distCell.setCellFormula(srcCell.getCellFormula());

代码示例来源:origin: net.sf.jxls/jxls-core

break;
case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
  newCell.setCellErrorValue(oldCell.getErrorCellValue());
  break;
case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:

代码示例来源:origin: com.gitee.zhaohuihua/zhh-tools

public static void copyCell(Cell src, Cell target, boolean copyValue) {
  if (src == null || target == null) {
    return;
  }
  // 复制样式
  target.setCellStyle(src.getCellStyle());
  // 单元格类型
  int cellType = src.getCellType();
  target.setCellType(cellType);
  if (cellType == Cell.CELL_TYPE_FORMULA) { // 公式
    target.setCellFormula(src.getCellFormula());
  } else if (copyValue) { // 复制内容
    if (cellType == Cell.CELL_TYPE_ERROR) { // 错误
      target.setCellErrorValue(src.getErrorCellValue());
    } else {
      Object value = getCellValue(src);
      setCellValue(target, value);
    }
    // 评论
    Comment comment = src.getCellComment();
    if (comment == null) {
      target.removeCellComment();
    } else {
      target.setCellComment(comment);
    }
  }
}

相关文章