コード例 #1
0
  /**
   * Use this to create new cells within the row and return it.
   *
   * <p>The cell that is returned is a CELL_TYPE_BLANK. The type can be changed either through
   * calling setCellValue or setCellType.
   *
   * @param column - the column number this cell represents
   * @return HSSFCell a high level representation of the created cell.
   */
  public HSSFCell createCell(short column, int type) {
    HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), column, type);

    addCell(cell);
    sheet.addValueRecord(getRowNum(), cell.getCellValueRecord());
    return cell;
  }
コード例 #2
0
  /**
   * remove the HSSFCell from this row.
   *
   * @param cell to remove
   */
  public void removeCell(HSSFCell cell) {
    CellValueRecordInterface cval = cell.getCellValueRecord();

    sheet.removeValueRecord(getRowNum(), cval);
    short column = cell.getCellNum();
    if (cell != null && column < cells.length) {
      cells[column] = null;
    }

    if (cell.getCellNum() == row.getLastCol()) {
      row.setLastCol(findLastCell(row.getLastCol()));
    }
    if (cell.getCellNum() == row.getFirstCol()) {
      row.setFirstCol(findFirstCell(row.getFirstCol()));
    }
  }