/** * Use this to create new cells within the row and return it. * <p> * The cell that is returned is a {@link CellType#BLANK}. The type can be changed * either through calling setCellValue or setCellType. * * @param column - the column number this cell represents * @return Cell a high level representation of the created cell. * @throws IllegalArgumentException if columnIndex < 0 or greater than a maximum number of supported columns * (255 for *.xls, 1048576 for *.xlsx) */ @Override public SXSSFCell createCell(int column, CellType type) { checkBounds(column); SXSSFCell cell = new SXSSFCell(this, type); _cells.put(column, cell); return cell; }
/** * Returns the cell at the given (0 based) index, with the specified {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy} * * @return the cell at the given (0 based) index * @throws IllegalArgumentException if cellnum < 0 or the specified MissingCellPolicy is invalid */ @Override public SXSSFCell getCell(int cellnum, MissingCellPolicy policy) { checkBounds(cellnum); final SXSSFCell cell = _cells.get(cellnum); switch (policy) { case RETURN_NULL_AND_BLANK: return cell; case RETURN_BLANK_AS_NULL: boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK); return (isBlank) ? null : cell; case CREATE_NULL_AS_BLANK: return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell; default: throw new IllegalArgumentException("Illegal policy " + policy); } }
/** * Use this to create new cells within the row and return it. * <p> * The cell that is returned is a {@link CellType#BLANK}. The type can be changed * either through calling setCellValue or setCellType. * * @param column - the column number this cell represents * @return Cell a high level representation of the created cell. * @throws IllegalArgumentException if columnIndex < 0 or greater than a maximum number of supported columns * (255 for *.xls, 1048576 for *.xlsx) */ @Override public SXSSFCell createCell(int column, CellType type) { checkBounds(column); SXSSFCell cell = new SXSSFCell(this, type); _cells.put(column, cell); return cell; }
/** * Use this to create new cells within the row and return it. * <p> * The cell that is returned is a {@link Cell#CELL_TYPE_BLANK}. The type can be changed * either through calling setCellValue or setCellType. * * @param column - the column number this cell represents * @return Cell a high level representation of the created cell. * @throws IllegalArgumentException if columnIndex < 0 or greate than a maximum number of supported columns * (255 for *.xls, 1048576 for *.xlsx) */ public Cell createCell(int column, int type) { checkBounds(column); if(column>=_cells.length) { SXSSFCell[] newCells=new SXSSFCell[Math.max(column+1,_cells.length*2)]; System.arraycopy(_cells,0,newCells,0,_cells.length); _cells=newCells; } _cells[column]=new SXSSFCell(this,type); if(column>_maxColumn) _maxColumn=column; return _cells[column]; }
/** * Returns the cell at the given (0 based) index, with the specified {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy} * * @return the cell at the given (0 based) index * @throws IllegalArgumentException if cellnum < 0 or the specified MissingCellPolicy is invalid */ @Override public SXSSFCell getCell(int cellnum, MissingCellPolicy policy) { checkBounds(cellnum); final SXSSFCell cell = _cells.get(cellnum); switch (policy) { case RETURN_NULL_AND_BLANK: return cell; case RETURN_BLANK_AS_NULL: boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK); return (isBlank) ? null : cell; case CREATE_NULL_AS_BLANK: return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell; default: throw new IllegalArgumentException("Illegal policy " + policy); } }