/** * Returns row index of a row in the sheet that contains this cell * * @return zero-based row index of a row in the sheet that contains this cell */ @Override public int getRowIndex() { return _row.getRowNum(); }
private void rebuildRows() { //rebuild the _rows map List<XSSFRow> rowList = new ArrayList<>(_rows.values()); _rows.clear(); for(XSSFRow r : rowList) { // Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory final Integer rownumI = new Integer(r.getRowNum()); // NOSONAR _rows.put(rownumI, r); } }
/** * update cell references when shifting rows * * @param n the number of rows to move */ protected void shift(int n) { int rownum = getRowNum() + n; String msg = "Row[rownum=" + getRowNum() + "] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for(Cell c : this){ ((XSSFCell)c).updateCellReferencesForShifting(msg); } setRowNum(rownum); }
protected boolean nextRow(boolean skipEmptyRows) { currentRowNumber++; currentColumnNumber = -1; if (!currentRowIterator.hasNext()) { currentRow = null; return false; } currentRow = (XSSFRow) currentRowIterator.next(); while (skipEmptyRows && currentRowIsEmpty()) { if (!currentRowIterator.hasNext()) { currentRow = null; return false; } currentRow = (XSSFRow) currentRowIterator.next(); } if (currentRow.getRowNum() != currentRowNumber) { if (currentRow.getRowNum() == currentRowNumber + 1) { currentRowNumber++; } else { throw new IllegalStateException(currentPosition() + ": The next row (" + currentRow.getRowNum() + ") has a gap of more than 1 empty line with the previous."); } } return true; }
private void initRows(CTWorksheet worksheetParam) { _rows.clear(); tables = new TreeMap<>(); sharedFormulas = new HashMap<>(); arrayFormulas = new ArrayList<>(); for (CTRow row : worksheetParam.getSheetData().getRowArray()) { XSSFRow r = new XSSFRow(row, this); // Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory final Integer rownumI = Integer.valueOf(r.getRowNum()); // NOSONAR _rows.put(rownumI, r); } }
/** * Compares two <code>XSSFRow</code> objects. Two rows are equal if they belong to the same worksheet and * their row indexes are equal. * * @param other the <code>XSSFRow</code> to be compared. * @return <ul> * <li> * the value <code>0</code> if the row number of this <code>XSSFRow</code> is * equal to the row number of the argument <code>XSSFRow</code> * </li> * <li> * a value less than <code>0</code> if the row number of this this <code>XSSFRow</code> is * numerically less than the row number of the argument <code>XSSFRow</code> * </li> * <li> * a value greater than <code>0</code> if the row number of this this <code>XSSFRow</code> is * numerically greater than the row number of the argument <code>XSSFRow</code> * </li> * </ul> * @throws IllegalArgumentException if the argument row belongs to a different worksheet */ @Override public int compareTo(XSSFRow other) { if (this.getSheet() != other.getSheet()) { throw new IllegalArgumentException("The compared rows must belong to the same sheet"); } int thisRow = this.getRowNum(); int otherRow = other.getRowNum(); return Integer.compare(thisRow, otherRow); }
/** * Returns hyperlink associated with this cell * * @return hyperlink associated with this cell or <code>null</code> if not found */ @Override public XSSFHyperlink getHyperlink() { return getSheet().getHyperlink(_row.getRowNum(), _cellNum); }
/** * Removes the hyperlink for this cell, if there is one. */ @Override public void removeHyperlink() { getSheet().removeHyperlink(_row.getRowNum(), _cellNum); }
void nextMeetingAssignmentListCell(List<MeetingAssignment> meetingAssignmentList, Function<MeetingAssignment, String> stringFunction, List<String> filteredConstraintNames) { if (meetingAssignmentList == null) { meetingAssignmentList = Collections.emptyList(); } HardMediumSoftScore score = meetingAssignmentList.stream() .map(indictmentMap::get).filter(Objects::nonNull) .flatMap(indictment -> indictment.getConstraintMatchSet().stream()) // Filter out filtered constraints .filter(constraintMatch -> filteredConstraintNames == null || filteredConstraintNames.contains(constraintMatch.getConstraintName())) .map(constraintMatch -> (HardMediumSoftScore) constraintMatch.getScore()) // Filter out positive constraints .filter(indictmentScore -> !(indictmentScore.getHardScore() >= 0 && indictmentScore.getSoftScore() >= 0)) .reduce(Score::add).orElse(HardMediumSoftScore.ZERO); XSSFCell cell = getXSSFCellOfScore(score); if (!meetingAssignmentList.isEmpty()) { ClientAnchor anchor = creationHelper.createClientAnchor(); anchor.setCol1(cell.getColumnIndex()); anchor.setCol2(cell.getColumnIndex() + 4); anchor.setRow1(currentRow.getRowNum()); anchor.setRow2(currentRow.getRowNum() + 4); Comment comment = currentDrawing.createCellComment(anchor); String commentString = getMeetingAssignmentListString(meetingAssignmentList); comment.setString(creationHelper.createRichTextString(commentString)); cell.setCellComment(comment); } cell.setCellValue(meetingAssignmentList.stream().map(stringFunction).collect(joining("\n"))); currentRow.setHeightInPoints(Math.max(currentRow.getHeightInPoints(), meetingAssignmentList.size() * currentSheet.getDefaultRowHeightInPoints())); }
private int writeHidden(XSSFRow xRow, int rowIndex, boolean hidden) { short level = xRow.getCTRow().getOutlineLevel(); for (Iterator<Row> it = rowIterator(); it.hasNext();) { xRow = (XSSFRow) it.next(); // skip rows before the start of this group if(xRow.getRowNum() < rowIndex) { continue; } if (xRow.getCTRow().getOutlineLevel() >= level) { xRow.getCTRow().setHidden(hidden); rowIndex++; } } return rowIndex; }
private void removeOverwritten(XSSFVMLDrawing vml, int startRow, int endRow, final int n){ for (Iterator<Row> it = rowIterator() ; it.hasNext() ; ) { XSSFRow row = (XSSFRow)it.next(); int rownum = row.getRowNum(); final Integer rownumI = Integer.valueOf(row.getRowNum()); // NOSONAR int idx = _rows.headMap(rownumI).size(); worksheet.getSheetData().removeRow(idx);
/** * Assign a hyperlink to this cell. If the supplied hyperlink is null, the * hyperlink for this cell will be removed. * * @param hyperlink the hyperlink to associate with this cell */ @Override public void setHyperlink(Hyperlink hyperlink) { if (hyperlink == null) { removeHyperlink(); return; } XSSFHyperlink link = (XSSFHyperlink)hyperlink; // Assign to us link.setCellReference( new CellReference(_row.getRowNum(), _cellNum).formatAsString() ); // Add to the lists getSheet().addHyperlink(link); }
int rownum = row.getRowNum();
/** * Returns row index of a row in the sheet that contains this cell * * @return zero-based row index of a row in the sheet that contains this cell */ @Override public int getRowIndex() { return _row.getRowNum(); }
/** * Returns row index of a row in the sheet that contains this cell * * @return zero-based row index of a row in the sheet that contains this cell */ public int getRowIndex() { return _row.getRowNum(); }
private void rebuildRows() { //rebuild the _rows map List<XSSFRow> rowList = new ArrayList<>(_rows.values()); _rows.clear(); for(XSSFRow r : rowList) { // Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory final Integer rownumI = new Integer(r.getRowNum()); // NOSONAR _rows.put(rownumI, r); } }
/** * Returns hyperlink associated with this cell * * @return hyperlink associated with this cell or <code>null</code> if not found */ public XSSFHyperlink getHyperlink() { return getSheet().getHyperlink(_row.getRowNum(), _cellNum); }