/** * Validate the range limits against the supplied version of Excel * * @param ssVersion the version of Excel to validate against * @throws IllegalArgumentException if the range limits are outside of the allowed range */ public void validate(SpreadsheetVersion ssVersion) { validateRow(_firstRow, ssVersion); validateRow(_lastRow, ssVersion); validateColumn(_firstCol, ssVersion); validateColumn(_lastCol, ssVersion); } /**
public RowMajorCellAddressIterator(CellRangeAddressBase ref) { r = firstRow = ref.getFirstRow(); c = firstCol = ref.getFirstColumn(); lastRow = ref.getLastRow(); lastCol = ref.getLastColumn(); // whole row and whole column ranges currently not supported if (firstRow < 0) throw new IllegalStateException("First row cannot be negative."); if (firstCol < 0) throw new IllegalStateException("First column cannot be negative."); // avoid infinite iteration if (firstRow > lastRow) throw new IllegalStateException("First row cannot be greater than last row."); if (firstCol > lastCol) throw new IllegalStateException("First column cannot be greater than last column."); }
@Override public int hashCode() { return (getMinColumn() + (getMaxColumn() << 8) + (getMinRow() << 16) + (getMaxRow() << 24)); } }
public int getOffsetRows() { return target.getRow() - region.getFirstRow(); }
public int getOffsetColumns() { return target.getCol() - region.getFirstColumn(); }
public int getOffsetRows() { return target.getRow() - region.getFirstRow(); }
public int getOffsetColumns() { return target.getCol() - region.getFirstColumn(); }
/** * Useful for logic like table/range styling, where some elements apply based on relative position in a range. * @param rowInd * @param colInd * @return set of {@link CellPosition}s occupied by the given coordinates. Empty if the coordinates are not in the range, never null. * @since 3.17 beta 1 */ public Set<CellPosition> getPosition(int rowInd, int colInd) { Set<CellPosition> positions = EnumSet.noneOf(CellPosition.class); if (rowInd > getFirstRow() && rowInd < getLastRow() && colInd > getFirstColumn() && colInd < getLastColumn()) { positions.add(CellPosition.INSIDE); return positions; // entirely inside, matches no boundaries } // check edges if (rowInd == getFirstRow()) positions.add(CellPosition.TOP); if (rowInd == getLastRow()) positions.add(CellPosition.BOTTOM); if (colInd == getFirstColumn()) positions.add(CellPosition.LEFT); if (colInd == getLastColumn()) positions.add(CellPosition.RIGHT); return positions; }
@Override public boolean equals(Object other) { if (other instanceof CellRangeAddressBase) { CellRangeAddressBase o = (CellRangeAddressBase) other; return ((getMinRow() == o.getMinRow()) && (getMaxRow() == o.getMaxRow()) && (getMinColumn() == o.getMinColumn()) && (getMaxColumn() == o.getMaxColumn())); } return false; }
/** * Validate the range limits against the supplied version of Excel * * @param ssVersion the version of Excel to validate against * @throws IllegalArgumentException if the range limits are outside of the allowed range */ public void validate(SpreadsheetVersion ssVersion) { validateRow(_firstRow, ssVersion); validateRow(_lastRow, ssVersion); validateColumn(_firstCol, ssVersion); validateColumn(_lastCol, ssVersion); } /**
private Integer setVerticalCellRange(LinkedDataRecord linkedDataRecord, CellRangeAddressBase range) { if (linkedDataRecord == null) { return null; } List<Ptg> ptgList = new ArrayList<>(); int rowCount = (range.getLastRow() - range.getFirstRow()) + 1; int colCount = (range.getLastColumn() - range.getFirstColumn()) + 1; for (Ptg ptg : linkedDataRecord.getFormulaOfLink()) { if (ptg instanceof AreaPtgBase) { AreaPtgBase areaPtg = (AreaPtgBase) ptg; areaPtg.setFirstRow(range.getFirstRow()); areaPtg.setLastRow(range.getLastRow()); areaPtg.setFirstColumn(range.getFirstColumn()); areaPtg.setLastColumn(range.getLastColumn()); ptgList.add(areaPtg); } } linkedDataRecord.setFormulaOfLink(ptgList.toArray(new Ptg[ptgList.size()])); return rowCount * colCount; }
@Override public boolean equals(Object other) { if (other instanceof CellRangeAddressBase) { CellRangeAddressBase o = (CellRangeAddressBase) other; return ((getMinRow() == o.getMinRow()) && (getMaxRow() == o.getMaxRow()) && (getMinColumn() == o.getMinColumn()) && (getMaxColumn() == o.getMaxColumn())); } return false; }
/** * Validate the range limits against the supplied version of Excel * * @param ssVersion the version of Excel to validate against * @throws IllegalArgumentException if the range limits are outside of the allowed range */ public void validate(SpreadsheetVersion ssVersion) { validateRow(_firstRow, ssVersion); validateRow(_lastRow, ssVersion); validateColumn(_firstCol, ssVersion); validateColumn(_lastCol, ssVersion); } /**
public RowMajorCellAddressIterator(CellRangeAddressBase ref) { r = firstRow = ref.getFirstRow(); c = firstCol = ref.getFirstColumn(); lastRow = ref.getLastRow(); lastCol = ref.getLastColumn(); // whole row and whole column ranges currently not supported if (firstRow < 0) throw new IllegalStateException("First row cannot be negative."); if (firstCol < 0) throw new IllegalStateException("First column cannot be negative."); // avoid infinite iteration if (firstRow > lastRow) throw new IllegalStateException("First row cannot be greater than last row."); if (firstCol > lastCol) throw new IllegalStateException("First column cannot be greater than last column."); }
@Override public int hashCode() { return (getMinColumn() + (getMaxColumn() << 8) + (getMinRow() << 16) + (getMaxRow() << 24)); } }
/** * Validate the range limits against the supplied version of Excel * * @param ssVersion the version of Excel to validate against * @throws IllegalArgumentException if the range limits are outside of the allowed range */ public void validate(SpreadsheetVersion ssVersion) { validateRow(_firstRow, ssVersion); validateRow(_lastRow, ssVersion); validateColumn(_firstCol, ssVersion); validateColumn(_lastCol, ssVersion); } /**
/** * Useful for logic like table/range styling, where some elements apply based on relative position in a range. * @param rowInd * @param colInd * @return set of {@link CellPosition}s occupied by the given coordinates. Empty if the coordinates are not in the range, never null. * @since 3.17 beta 1 */ public Set<CellPosition> getPosition(int rowInd, int colInd) { Set<CellPosition> positions = EnumSet.noneOf(CellPosition.class); if (rowInd > getFirstRow() && rowInd < getLastRow() && colInd > getFirstColumn() && colInd < getLastColumn()) { positions.add(CellPosition.INSIDE); return positions; // entirely inside, matches no boundaries } // check edges if (rowInd == getFirstRow()) positions.add(CellPosition.TOP); if (rowInd == getLastRow()) positions.add(CellPosition.BOTTOM); if (colInd == getFirstColumn()) positions.add(CellPosition.LEFT); if (colInd == getLastColumn()) positions.add(CellPosition.RIGHT); return positions; }
private Integer setVerticalCellRange(LinkedDataRecord linkedDataRecord, CellRangeAddressBase range) { if (linkedDataRecord == null) { return null; } List<Ptg> ptgList = new ArrayList<>(); int rowCount = (range.getLastRow() - range.getFirstRow()) + 1; int colCount = (range.getLastColumn() - range.getFirstColumn()) + 1; for (Ptg ptg : linkedDataRecord.getFormulaOfLink()) { if (ptg instanceof AreaPtgBase) { AreaPtgBase areaPtg = (AreaPtgBase) ptg; areaPtg.setFirstRow(range.getFirstRow()); areaPtg.setLastRow(range.getLastRow()); areaPtg.setFirstColumn(range.getFirstColumn()); areaPtg.setLastColumn(range.getLastColumn()); ptgList.add(areaPtg); } } linkedDataRecord.setFormulaOfLink(ptgList.toArray(new Ptg[ptgList.size()])); return rowCount * colCount; }
private Integer setVerticalCellRange(LinkedDataRecord linkedDataRecord, CellRangeAddressBase range) { if (linkedDataRecord == null) { return null; } List<Ptg> ptgList = new ArrayList<Ptg>(); int rowCount = (range.getLastRow() - range.getFirstRow()) + 1; int colCount = (range.getLastColumn() - range.getFirstColumn()) + 1; for (Ptg ptg : linkedDataRecord.getFormulaOfLink()) { if (ptg instanceof AreaPtgBase) { AreaPtgBase areaPtg = (AreaPtgBase) ptg; areaPtg.setFirstRow(range.getFirstRow()); areaPtg.setLastRow(range.getLastRow()); areaPtg.setFirstColumn(range.getFirstColumn()); areaPtg.setLastColumn(range.getLastColumn()); ptgList.add(areaPtg); } } linkedDataRecord.setFormulaOfLink(ptgList.toArray(new Ptg[ptgList.size()])); return rowCount * colCount; }