Class Range

  • All Implemented Interfaces:
    Ref

    public class Range
    extends Object
    implements Ref
    Definition of a range of cells.
    • Method Detail

      • getWorksheet

        public Worksheet getWorksheet()
        Get parent worksheet.
        Returns:
        Parent worksheet.
      • getTop

        public int getTop()
        Get top row.
        Returns:
        Top row.
      • getLeft

        public int getLeft()
        Get left column.
        Returns:
        Left column.
      • getBottom

        public int getBottom()
        Get bottom row.
        Returns:
        Bottom row.
      • getRight

        public int getRight()
        Get right column.
        Returns:
        Right column.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toAbsoluteString

        public String toAbsoluteString()
        Get an absolute reference to this Range. ex: $A$1:$A$5
        Returns:
        absolute reference
      • style

        public StyleSetter style()
        Get a new style setter for this range.
        Returns:
        Newly created style setter.
      • merge

        public void merge()
        Merge cells within this range.
      • contains

        public boolean contains​(int r,
                                int c)
        Check if this range contains the given cell coordinates.
        Parameters:
        r - Zero-based row number.
        c - Zero-based column number.
        Returns:
        true if this range contains the given cell coordinates.
      • validateWithList

        public ListDataValidation validateWithList​(Range listRange)
        Construct a new ListDataValidation
        Parameters:
        listRange - The Range of the list this validation references
        Returns:
        a new list data validation object
      • validateWithListByFormula

        public ListFormulaDataValidation validateWithListByFormula​(String formula)
        Construct a new ListDataValidation
        Parameters:
        formula - The Formula to retrieve the validation list
        Returns:
        a new list data validation object
      • validateWithFormula

        public CustomDataValidation validateWithFormula​(String formula)
        Construct a new ListDataValidation
        Parameters:
        formula - The custom validation formula
        Returns:
        a new custom validation
      • setName

        public void setName​(String name)
        Specifically define this range by assigning it a name. It will be visible in the cell range dropdown menu.
        Parameters:
        name - string representing the name of this cell range
      • isFolderScope

        public boolean isFolderScope()
        Check if this range has a folder scope. It is used by Worksheet.addNamedRange(Range, String).
        Returns:
        true if the range has a folder scope, false if it is visible only by the worksheet contains the range
      • setFolderScope

        public void setFolderScope​(boolean folderScope)
        Set the visibility of this range
        Parameters:
        folderScope - true to allow to see the range by all worksheet
      • setHyperlink

        public void setHyperlink​(HyperLink hyperLink)
      • createTable

        public Table createTable()
      • createTable

        public Table createTable​(String... headers)