Class NamedRange

java.lang.Object
io.keikai.axyra.sheets.NamedRange

public final class NamedRange extends Object
A defined name (named range). sheetScope is the 0-based sheet index it is scoped to, or -1 for workbook scope.

Instances handed out by Workbook.names() and Workbook.findName(String) stay attached to their workbook, so asRange() resolves straight to the cells the name points at — a template can be authored in Excel and filled in by key:


 wb.findName("TaxRate").asRange().setFormula("=0.07");
 CellValue[][] data = wb.findName("Inputs").asRange().values();
 

Two names are equal when their name, formula and scope match; the workbook they came from is not part of that comparison.

  • Constructor Summary

    Constructors
    Constructor
    Description
    NamedRange(String name, String formula, int sheetScope)
    A detached name — one that carries no workbook, so asRange() has nothing to resolve against.
  • Method Summary

    Modifier and Type
    Method
    Description
    The cells this name points at.
    boolean
     
    The formula the name resolves to — for a named range, a reference such as "Sheet1!$A$1:$B$10"; for a named constant, its value.
    int
     
    boolean
    Whether this name is workbook-scoped (visible on every sheet).
    The defined name, as written in the workbook.
    int
    The 0-based index of the sheet this name is scoped to, or -1.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • NamedRange

      public NamedRange(String name, String formula, int sheetScope)
      A detached name — one that carries no workbook, so asRange() has nothing to resolve against. Use Workbook.findName(String) to obtain an attached one.
  • Method Details

    • name

      public String name()
      The defined name, as written in the workbook.
    • formula

      public String formula()
      The formula the name resolves to — for a named range, a reference such as "Sheet1!$A$1:$B$10"; for a named constant, its value.
    • sheetScope

      public int sheetScope()
      The 0-based index of the sheet this name is scoped to, or -1.
    • isWorkbookScoped

      public boolean isWorkbookScoped()
      Whether this name is workbook-scoped (visible on every sheet).
    • asRange

      public Range asRange()
      The cells this name points at.

      A sheet-scoped name whose formula carries no Sheet! qualifier resolves against the sheet it is scoped to. Whole-column and whole-row names (Sheet1!$B:$B) expand to the grid's limits.

      Throws:
      IllegalStateException - if this name is detached from its workbook (built with the public constructor rather than read from a workbook)
      IllegalArgumentException - if the name does not resolve to a single rectangular area on a sheet of this workbook — a named constant, a multi-area union, an external or 3-D reference
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object