Class CellRangeUtil

java.lang.Object
org.apache.poi.ss.util.CellRangeUtil

public final class CellRangeUtil extends Object
Utility class that builds on CellRangeAddress Portions of this class may be moved to CellRangeAddressBase
  • Field Details

  • Method Details

    • intersect

      public static int intersect(CellRangeAddress crA, CellRangeAddress crB)
      Get the type of intersection between two cell ranges
      Parameters:
      crB - - the specified range
      Returns:
      code which reflects how the specified range is related to this range.
      Possible return codes are:
      • NO_INTERSECTION - the specified range is outside of this range;
      • OVERLAP - both ranges partially overlap
      • INSIDE - the specified range is inside of this one
      • ENCLOSES - the specified range encloses (possibly exactly the same as) this range
      See Also:
    • mergeCellRanges

      public static CellRangeAddress[] mergeCellRanges(CellRangeAddress[] cellRanges)
      Do all possible cell merges between cells of the list so that:
      • if a cell range is completely inside of another cell range, it gets removed from the list
      • if two cells have a shared border, merge them into one bigger cell range
      Parameters:
      cellRanges - the ranges to merge
      Returns:
      list of merged cell ranges
    • contains

      public static boolean contains(CellRangeAddress crA, CellRangeAddress crB)
      Check if cell range A contains cell range B (B <= A) TODO: move this into CellRangeAddressBase
      Parameters:
      crA - cell range A
      crB - cell range B
      Returns:
      true if cell range A contains cell range B
    • hasExactSharedBorder

      public static boolean hasExactSharedBorder(CellRangeAddress crA, CellRangeAddress crB)
      Check if the two cell ranges have a shared border.
      Returns:
      true if the ranges have a complete shared border (i.e. the two ranges together make a simple rectangular region.
    • createEnclosingCellRange

      public static CellRangeAddress createEnclosingCellRange(CellRangeAddress crA, CellRangeAddress crB)
      Create an enclosing CellRange for the two cell ranges.
      Returns:
      enclosing CellRange