/** * add a row to the sheet * * @param addLow whether to add the row to the low level model - false if its already there */ private void addRow(HSSFRow row, boolean addLow) { _rows.put(Integer.valueOf(row.getRowNum()), row); if (addLow) { _sheet.addRow(row.getRowRecord()); } boolean firstRow = _rows.size() == 1; if (row.getRowNum() > getLastRowNum() || firstRow) { _lastrow = row.getRowNum(); } if (row.getRowNum() < getFirstRowNum() || firstRow) { _firstrow = row.getRowNum(); } }
private void notifyRowShifting(HSSFRow row) { String msg = "Row[rownum=" + row.getRowNum() + "] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for (Cell cell : row) { HSSFCell hcell = (HSSFCell) cell; if (hcell.isPartOfArrayFormulaGroup()) { hcell.notifyArrayFormulaChanging(msg); } } }
/** * 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; }
HSSFRow hrow = lastrow; if (hrow == null || hrow.getRowNum() != cval.getRow()) { hrow = getRow(cval.getRow()); lastrow = hrow;
private void removeCell(HSSFCell cell, boolean alsoRemoveRecords) { int column=cell.getColumnIndex(); if(column < 0) { throw new RuntimeException("Negative cell indexes not allowed"); } if(column >= cells.length || cell != cells[column]) { throw new RuntimeException("Specified cell is not from this row"); } if(cell.isPartOfArrayFormulaGroup()){ cell.notifyArrayFormulaChanging(); } cells[column]=null; if(alsoRemoveRecords) { CellValueRecordInterface cval = cell.getCellValueRecord(); sheet.getSheet().removeValueRecord(getRowNum(), cval); } if (cell.getColumnIndex()+1 == row.getLastCol()) { row.setLastCol(calculateNewLastCellPlusOne(row.getLastCol())); } if (cell.getColumnIndex() == row.getFirstCol()) { row.setFirstCol(calculateNewFirstCell(row.getFirstCol())); } }
/** * Generates name for output as row number in case * <tt>{@link #isOutputRowNumbers()} == true</tt> */ protected String getRowName( HSSFRow row ) { return String.valueOf( row.getRowNum() + 1 ); }
/** * Generates name for output as row number in case * <tt>{@link #isOutputRowNumbers()} == true</tt> */ protected String getRowName( HSSFRow row ) { return String.valueOf( row.getRowNum() + 1 ); }
/** * Obtain the region over which to merge a cell. * @param first Column number of first cell from which to merge. * @param last Column number of last cell over which to merge. * @return The region over which to merge a cell. */ private CellRangeAddress getMergeCellsRegion(int first, int last) { return new CellRangeAddress(this.currentRow.getRowNum(), this.currentRow.getRowNum(), first, last); }
/** * Obtain the region over which to merge a cell. * @param first Column number of first cell from which to merge. * @param last Column number of last cell over which to merge. * @return The region over which to merge a cell. */ private CellRangeAddress getMergeCellsRegion(int first, int last) { return new CellRangeAddress(this.currentRow.getRowNum(), first, this.currentRow.getRowNum(), last); }
/** * Adds a row to the sheet * @param sheet the sheet * @param rowNum row Number * @param cellValues values of the cell to be added in the row * @return row number of the cell */ private static int addRow(HSSFSheet sheet, int rowNum, List<String> cellValues) { HSSFRow row = sheet.createRow(rowNum); for (int i = 0; i < cellValues.size(); i++) { addCell(row, i, cellValues.get(i)); } return row.getRowNum(); }
private void notifyRowShifting(HSSFRow row) { String msg = "Row[rownum=" + row.getRowNum() + "] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for (Cell cell : row) { HSSFCell hcell = (HSSFCell) cell; if (hcell.isPartOfArrayFormulaGroup()) { hcell.notifyArrayFormulaChanging(msg); } } }
private void notifyRowShifting(HSSFRow row) { String msg = "Row[rownum=" + row.getRowNum() + "] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for (Cell cell : row) { HSSFCell hcell = (HSSFCell) cell; if (hcell.isPartOfArrayFormulaGroup()) { hcell.notifyArrayFormulaChanging(msg); } } }
private void notifyRowShifting(HSSFRow row){ String msg = "Row[rownum="+row.getRowNum()+"] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for(Cell cell : row){ HSSFCell hcell = (HSSFCell)cell; if(hcell.isPartOfArrayFormulaGroup()){ hcell.notifyArrayFormulaChanging(msg); } } }