/** * Moves the supplied cell to a new column, which * must not already have a cell there! * @param cell The cell to move * @param newColumn The new column number (0 based) */ public void moveCell(HSSFCell cell, short newColumn) { // Ensure the destination is free if(cells.length > newColumn && cells[newColumn] != null) { throw new IllegalArgumentException("Asked to move cell to column " + newColumn + " but there's already a cell there"); } // Check it's one of ours if(! cells[cell.getColumnIndex()].equals(cell)) { throw new IllegalArgumentException("Asked to move a cell, but it didn't belong to our row"); } // Move the cell to the new position // (Don't remove the records though) removeCell(cell, false); cell.updateCellNum(newColumn); addCell(cell); }
/** * Use this to create new cells within the row and return it. * <p> * The cell that is returned will be of the requested type. * The type can be changed either through calling setCellValue * or setCellType, but there is a small overhead to doing this, * so it is best to create the required type up front. * * @param columnIndex - the column number this cell represents * * @return HSSFCell a high level representation of the created cell. * @throws IllegalArgumentException if columnIndex < 0 or greater than 255, * the maximum number of columns supported by the Excel binary format (.xls) */ @Override public HSSFCell createCell(int columnIndex, CellType type) { short shortCellNum = (short)columnIndex; if(columnIndex > 0x7FFF) { shortCellNum = (short)(0xffff - columnIndex); } HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), shortCellNum, type); addCell(cell); sheet.getSheet().addValueRecord(getRowNum(), cell.getCellValueRecord()); return cell; }
/** * create a high level HSSFCell object from an existing low level record. Should * only be called from HSSFSheet or HSSFRow itself. * @param cell low level cell to create the high level representation from * @return HSSFCell representing the low level record passed in */ HSSFCell createCellFromRecord(CellValueRecordInterface cell) { HSSFCell hcell = new HSSFCell(book, sheet, cell); addCell(hcell); int colIx = cell.getColumn(); if (row.isEmpty()) { row.setFirstCol(colIx); row.setLastCol(colIx + 1); } else { if (colIx < row.getFirstCol()) { row.setFirstCol(colIx); } else if (colIx > row.getLastCol()) { row.setLastCol(colIx + 1); } /*else { // added cell is within first and last cells }*/ } // TODO - RowRecord column boundaries need to be updated for cell comments too return hcell; }
/** * Moves the supplied cell to a new column, which * must not already have a cell there! * @param cell The cell to move * @param newColumn The new column number (0 based) */ public void moveCell(HSSFCell cell, short newColumn) { // Ensure the destination is free if(cells.length > newColumn && cells[newColumn] != null) { throw new IllegalArgumentException("Asked to move cell to column " + newColumn + " but there's already a cell there"); } // Check it's one of ours if(! cells[cell.getColumnIndex()].equals(cell)) { throw new IllegalArgumentException("Asked to move a cell, but it didn't belong to our row"); } // Move the cell to the new position // (Don't remove the records though) removeCell(cell, false); cell.updateCellNum(newColumn); addCell(cell); }
/** * Moves the supplied cell to a new column, which * must not already have a cell there! * @param cell The cell to move * @param newColumn The new column number (0 based) */ public void moveCell(HSSFCell cell, short newColumn) { // Ensure the destination is free if(cells.length > newColumn && cells[newColumn] != null) { throw new IllegalArgumentException("Asked to move cell to column " + newColumn + " but there's already a cell there"); } // Check it's one of ours if(! cells[cell.getColumnIndex()].equals(cell)) { throw new IllegalArgumentException("Asked to move a cell, but it didn't belong to our row"); } // Move the cell to the new position // (Don't remove the records though) removeCell(cell, false); cell.updateCellNum(newColumn); addCell(cell); }
/** * Moves the supplied cell to a new column, which * must not already have a cell there! * @param cell The cell to move * @param newColumn The new column number (0 based) */ public void moveCell(HSSFCell cell, short newColumn) { // Ensure the destination is free if(cells.length > newColumn && cells[newColumn] != null) { throw new IllegalArgumentException("Asked to move cell to column " + newColumn + " but there's already a cell there"); } // Check it's one of ours if(! cells[cell.getColumnIndex()].equals(cell)) { throw new IllegalArgumentException("Asked to move a cell, but it didn't belong to our row"); } // Move the cell to the new position // (Don't remove the records though) removeCell(cell, false); cell.updateCellNum(newColumn); addCell(cell); }
/** * 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 columnIndex - the column number this cell represents * * @return HSSFCell a high level representation of the created cell. * @throws IllegalArgumentException if columnIndex < 0 or greater than 255, * the maximum number of columns supported by the Excel binary format (.xls) */ public HSSFCell createCell(int columnIndex, int type) { short shortCellNum = (short)columnIndex; if(columnIndex > 0x7FFF) { shortCellNum = (short)(0xffff - columnIndex); } HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), shortCellNum, type); addCell(cell); sheet.getSheet().addValueRecord(getRowNum(), cell.getCellValueRecord()); return cell; }
/** * 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 columnIndex - the column number this cell represents * * @return HSSFCell a high level representation of the created cell. * @throws IllegalArgumentException if columnIndex < 0 or greater than 255, * the maximum number of columns supported by the Excel binary format (.xls) */ public HSSFCell createCell(int columnIndex, int type) { short shortCellNum = (short)columnIndex; if(columnIndex > 0x7FFF) { shortCellNum = (short)(0xffff - columnIndex); } HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), shortCellNum, type); addCell(cell); sheet.getSheet().addValueRecord(getRowNum(), cell.getCellValueRecord()); return cell; }
/** * Use this to create new cells within the row and return it. * <p> * The cell that is returned will be of the requested type. * The type can be changed either through calling setCellValue * or setCellType, but there is a small overhead to doing this, * so it is best to create the required type up front. * * @param columnIndex - the column number this cell represents * * @return HSSFCell a high level representation of the created cell. * @throws IllegalArgumentException if columnIndex < 0 or greater than 255, * the maximum number of columns supported by the Excel binary format (.xls) */ @Override public HSSFCell createCell(int columnIndex, CellType type) { short shortCellNum = (short)columnIndex; if(columnIndex > 0x7FFF) { shortCellNum = (short)(0xffff - columnIndex); } HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), shortCellNum, type); addCell(cell); sheet.getSheet().addValueRecord(getRowNum(), cell.getCellValueRecord()); return cell; }
/** * create a high level HSSFCell object from an existing low level record. Should * only be called from HSSFSheet or HSSFRow itself. * @param cell low level cell to create the high level representation from * @return HSSFCell representing the low level record passed in */ HSSFCell createCellFromRecord(CellValueRecordInterface cell) { HSSFCell hcell = new HSSFCell(book, sheet, cell); addCell(hcell); int colIx = cell.getColumn(); if (row.isEmpty()) { row.setFirstCol(colIx); row.setLastCol(colIx + 1); } else { if (colIx < row.getFirstCol()) { row.setFirstCol(colIx); } else if (colIx > row.getLastCol()) { row.setLastCol(colIx + 1); } else { // added cell is within first and last cells } } // TODO - RowRecord column boundaries need to be updated for cell comments too return hcell; }
/** * create a high level HSSFCell object from an existing low level record. Should * only be called from HSSFSheet or HSSFRow itself. * @param cell low level cell to create the high level representation from * @return HSSFCell representing the low level record passed in */ HSSFCell createCellFromRecord(CellValueRecordInterface cell) { HSSFCell hcell = new HSSFCell(book, sheet, cell); addCell(hcell); int colIx = cell.getColumn(); if (row.isEmpty()) { row.setFirstCol(colIx); row.setLastCol(colIx + 1); } else { if (colIx < row.getFirstCol()) { row.setFirstCol(colIx); } else if (colIx > row.getLastCol()) { row.setLastCol(colIx + 1); } /*else { // added cell is within first and last cells }*/ } // TODO - RowRecord column boundaries need to be updated for cell comments too return hcell; }
/** * create a high level HSSFCell object from an existing low level record. Should * only be called from HSSFSheet or HSSFRow itself. * @param cell low level cell to create the high level representation from * @return HSSFCell representing the low level record passed in */ HSSFCell createCellFromRecord(CellValueRecordInterface cell) { HSSFCell hcell = new HSSFCell(book, sheet, cell); addCell(hcell); int colIx = cell.getColumn(); if (row.isEmpty()) { row.setFirstCol(colIx); row.setLastCol(colIx + 1); } else { if (colIx < row.getFirstCol()) { row.setFirstCol(colIx); } else if (colIx > row.getLastCol()) { row.setLastCol(colIx + 1); } else { // added cell is within first and last cells } } // TODO - RowRecord column boundaries need to be updated for cell comments too return hcell; }