public int getOffsetRows() { return target.getRow() - region.getFirstRow(); }
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."); }
/** * 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; }
public int getOffsetRows() { return target.getRow() - region.getFirstRow(); }
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."); }
/** * 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; }