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

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

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

Cell.removeCellComment介绍

[英]Removes the comment for this cell, if there is one.
[中]删除此单元格的注释(如果有)。

代码示例

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

private void removeCellComment(Sheet sheet, int rowNum, int colNum) {
  Row row = sheet.getRow(rowNum);
  if( row == null ) return;
  Cell cell = row.getCell(colNum);
  if (cell == null) return;
  cell.removeCellComment();
}

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

public void clearCell(int col, int row) {
  Sheet sheet = getSheet();
  Cell cell = PoiExcelHelper.getCell(col, row, sheet);
  if (cell != null) {
    cell.removeCellComment();
    cell.removeHyperlink();
    sheet.getRow(row).removeCell(cell);
  }
}

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

protected void copyCell(Cell cellFrom, int colTo, int rowTo) {
  Sheet sheet = getSheet();
  Cell cellTo = PoiExcelHelper.getCell(colTo, rowTo, sheet);
  if (cellFrom == null) {
    if (cellTo != null) {
      clearCell(colTo, rowTo);
    }
    return;
  }
  if (cellTo == null) {
    cellTo = PoiExcelHelper.getOrCreateCell(colTo, rowTo, sheet);
  }
  PoiExcelHelper.copyCellValue(cellFrom, cellTo);
  PoiExcelHelper.copyCellStyle(cellFrom, cellTo, sheet);
  cellTo.removeCellComment();
  // PoiExcelHelper.copyCellComment(cellFrom, cellTo);
}

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

public void clearCell(CellRef cellRef) {
  if (cellRef == null || cellRef.getSheetName() == null) return;
  Sheet sheet = workbook.getSheet(cellRef.getSheetName());
  if (sheet == null) return;
  removeCellComment(sheet, cellRef.getRow(), cellRef.getCol());
  Row row = sheet.getRow(cellRef.getRow());
  if (row == null) return;
  Cell cell = row.getCell(cellRef.getCol());
  if (cell == null) {
    CellAddress cellAddress = new CellAddress(cellRef.getRow(), cellRef.getCol());
    if (sheet.getCellComment(cellAddress) != null) {
      cell = row.createCell(cellRef.getCol());
      cell.removeCellComment();
    }
    return;
  }
  cell.setCellType(CellType.BLANK);
  cell.setCellStyle(workbook.getCellStyleAt(0));
  if (cell.getCellComment() != null) {
    cell.removeCellComment();
  }
  findAndRemoveExistingCellRegion(cellRef);
}

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

相关文章