Class AreaReference


  • public class AreaReference
    extends Object
    • Constructor Detail

      • AreaReference

        public AreaReference​(String reference,
                             SpreadsheetVersion version)
        Create an area ref from a string representation. Sheet names containing special characters should be delimited and escaped as per normal syntax rules for formulas.
        The area reference must be contiguous (i.e. represent a single rectangle, not a union of rectangles)
    • Method Detail

      • isWholeColumnReference

        public static boolean isWholeColumnReference​(SpreadsheetVersion version,
                                                     CellReference topLeft,
                                                     CellReference botRight)
        Is the reference for a whole-column reference, such as C:C or D:G ?
      • isWholeColumnReference

        public boolean isWholeColumnReference()
      • generateContiguous

        public static AreaReference[] generateContiguous​(SpreadsheetVersion version,
                                                         String reference)
        Takes a non-contiguous area reference, and returns an array of contiguous area references
        Returns:
        an array of contiguous area references.
      • isSingleCell

        public boolean isSingleCell()
        Returns:
        false if this area reference involves more than one cell
      • getFirstCell

        public CellReference getFirstCell()
        Returns:
        the first cell reference which defines this area. Usually this cell is in the upper left corner of the area (but this is not a requirement).
      • getLastCell

        public CellReference getLastCell()
        Note - if this area reference refers to a single cell, the return value of this method will be identical to that of getFirstCell()
        Returns:
        the second cell reference which defines this area. For multi-cell areas, this is cell diagonally opposite the 'first cell'. Usually this cell is in the lower right corner of the area (but this is not a requirement).
      • getAllReferencedCells

        public CellReference[] getAllReferencedCells()
        Returns a reference to every cell covered by this area
      • formatAsString

        public String formatAsString()
        Returns a text representation of this area reference.

        Example return values:

        ResultComment
        A1:A1Single cell area reference without sheet
        A1:$C$1Multi-cell area reference without sheet
        Sheet1!A$1:B4Standard sheet name
        'O''Brien''s Sales'!B5:C6' Sheet name with special characters
        Returns:
        the text representation of this area reference as it would appear in a formula.