/** * Determines if the given {@link CellAddress} lies within the bounds * of this range. * <p>NOTE: It is up to the caller to ensure the reference is * for the correct sheet, since this instance doesn't have a sheet reference. * * @param ref the CellAddress to check * @return True if the reference lies within the bounds, false otherwise. * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap */ public boolean isInRange(CellAddress ref) { return isInRange(ref.getRow(), ref.getColumn()); }
/** * Determines if the given {@link CellReference} lies within the bounds * of this range. * <p>NOTE: It is up to the caller to ensure the reference is * for the correct sheet, since this instance doesn't have a sheet reference. * * @param ref the CellReference to check * @return True if the reference lies within the bounds, false otherwise. * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap */ public boolean isInRange(CellReference ref) { return isInRange(ref.getRow(), ref.getCol()); }
/** * Determines if the given {@link Cell} lies within the bounds * of this range. * <p>NOTE: It is up to the caller to ensure the reference is * for the correct sheet, since this instance doesn't have a sheet reference. * * @param cell the Cell to check * @return True if the cell lies within the bounds, false otherwise. * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap */ public boolean isInRange(Cell cell) { return isInRange(cell.getRowIndex(), cell.getColumnIndex()); }
/** * A range is returned only for the part of the table matching this enum instance and containing the given cell reference. * Null is returned for all other cases, such as: * <ul> * <li>Cell on a different sheet than the table * <li>Cell outside the table * <li>this Enum part is not included in the table (i.e. no header/totals row) * <li>this Enum is for a table part not yet implemented in POI, such as pivot table elements * </ul> * The returned range can be used to determine how style options may or may not apply to this cell. * For example, {@link #wholeTable} borders only apply to the outer boundary of a table, while the * rest of the styling, such as font and color, could apply to all the interior cells as well. * * @param table table to evaluate * @param cell CellReference to evaluate * @return range in the table representing this class of cells, if it contains the given cell, or null if not applicable. * Stripe style types return only the stripe range containing the given cell, or null. */ public CellRangeAddressBase appliesTo(Table table, CellReference cell) { if (table == null || cell == null) return null; if ( ! cell.getSheetName().equals(table.getSheetName())) return null; if ( ! table.contains(cell)) return null; final CellRangeAddressBase range = getRange(table, cell); if (range != null && range.isInRange(cell.getRow(), cell.getCol())) return range; // else return null; }
/** * Finds and returns the {@link DataValidationContext} for the cell, if there is * one. Lookup is based on the first match from * {@link DataValidation#getRegions()} for the cell's sheet. DataValidation * regions must be in the same sheet as the DataValidation. Allowed values * expressions may reference other sheets, however. * * @param cell reference to check * @return the DataValidationContext applicable to the given cell, or null if no * validation applies */ public DataValidationContext getValidationContextForCell(CellReference cell) { final Sheet sheet = workbook.getSheet(cell.getSheetName()); if (sheet == null) return null; final List<? extends DataValidation> dataValidations = getValidations(sheet); if (dataValidations == null) return null; for (DataValidation dv : dataValidations) { final CellRangeAddressList regions = dv.getRegions(); if (regions == null) return null; // current implementation can't return null for (CellRangeAddressBase range : regions.getCellRangeAddresses()) { if (range.isInRange(cell)) { return new DataValidationContext(dv, this, range, cell); } } } return null; }
if (! region.isInRange(target)) { throw new IllegalArgumentException(target + " is not within " + region);
/** * Determines if the given {@link CellAddress} lies within the bounds * of this range. * <p>NOTE: It is up to the caller to ensure the reference is * for the correct sheet, since this instance doesn't have a sheet reference. * * @param ref the CellAddress to check * @return True if the reference lies within the bounds, false otherwise. * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap */ public boolean isInRange(CellAddress ref) { return isInRange(ref.getRow(), ref.getColumn()); }
/** * Determines if the given {@link Cell} lies within the bounds * of this range. * <p>NOTE: It is up to the caller to ensure the reference is * for the correct sheet, since this instance doesn't have a sheet reference. * * @param cell the Cell to check * @return True if the cell lies within the bounds, false otherwise. * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap */ public boolean isInRange(Cell cell) { return isInRange(cell.getRowIndex(), cell.getColumnIndex()); }
/** * Determines if the given {@link CellReference} lies within the bounds * of this range. * <p>NOTE: It is up to the caller to ensure the reference is * for the correct sheet, since this instance doesn't have a sheet reference. * * @param ref the CellReference to check * @return True if the reference lies within the bounds, false otherwise. * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap */ public boolean isInRange(CellReference ref) { return isInRange(ref.getRow(), ref.getCol()); }
/** * A range is returned only for the part of the table matching this enum instance and containing the given cell reference. * Null is returned for all other cases, such as: * <ul> * <li>Cell on a different sheet than the table * <li>Cell outside the table * <li>this Enum part is not included in the table (i.e. no header/totals row) * <li>this Enum is for a table part not yet implemented in POI, such as pivot table elements * </ul> * The returned range can be used to determine how style options may or may not apply to this cell. * For example, {@link #wholeTable} borders only apply to the outer boundary of a table, while the * rest of the styling, such as font and color, could apply to all the interior cells as well. * * @param table table to evaluate * @param cell CellReference to evaluate * @return range in the table representing this class of cells, if it contains the given cell, or null if not applicable. * Stripe style types return only the stripe range containing the given cell, or null. */ public CellRangeAddressBase appliesTo(Table table, CellReference cell) { if (table == null || cell == null) return null; if ( ! cell.getSheetName().equals(table.getSheetName())) return null; if ( ! table.contains(cell)) return null; final CellRangeAddressBase range = getRange(table, cell); if (range != null && range.isInRange(cell.getRow(), cell.getCol())) return range; // else return null; }
/** * Finds and returns the {@link DataValidationContext} for the cell, if there is * one. Lookup is based on the first match from * {@link DataValidation#getRegions()} for the cell's sheet. DataValidation * regions must be in the same sheet as the DataValidation. Allowed values * expressions may reference other sheets, however. * * @param cell reference to check * @return the DataValidationContext applicable to the given cell, or null if no * validation applies */ public DataValidationContext getValidationContextForCell(CellReference cell) { final Sheet sheet = workbook.getSheet(cell.getSheetName()); if (sheet == null) return null; final List<? extends DataValidation> dataValidations = getValidations(sheet); if (dataValidations == null) return null; for (DataValidation dv : dataValidations) { final CellRangeAddressList regions = dv.getRegions(); if (regions == null) return null; // current implementation can't return null for (CellRangeAddressBase range : regions.getCellRangeAddresses()) { if (range.isInRange(cell)) { return new DataValidationContext(dv, this, range, cell); } } } return null; }
if (! region.isInRange(target)) { throw new IllegalArgumentException(target + " is not within " + region);