/** used internally to add a cell. */ private void addCell(HSSFCell cell) { short column = cell.getCellNum(); if (row.getFirstCol() == -1) { row.setFirstCol(column); } if (row.getLastCol() == -1) { row.setLastCol(column); } if (column >= cells.length) { HSSFCell[] oldCells = cells; int newSize = oldCells.length * 2; if (newSize < column + 1) newSize = column + 1; cells = new HSSFCell[newSize]; System.arraycopy(oldCells, 0, cells, 0, oldCells.length); } cells[column] = cell; if (column < row.getFirstCol()) { row.setFirstCol(column); } if (column > row.getLastCol()) { row.setLastCol(column); } }
/** * 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())); } }