Package io.keikai.axyra.sheets
Class NamedRange
java.lang.Object
io.keikai.axyra.sheets.NamedRange
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();
A NamedRange is a snapshot of the definition: it does not follow
a later change to the name in the workbook. Two names are equal when their
name, formula and scope match; the workbook they came from is not part of
that comparison.
-
Constructor Summary
ConstructorsConstructorDescriptionNamedRange(String name, String formula, int sheetScope) A detached name — one that carries no workbook, soasRange()has nothing to resolve against. -
Method Summary
Modifier and TypeMethodDescriptionasRange()Returns the cells this name points at, resolved from the formula held by this object.booleanformula()Returns the formula the name stands for: for a named range, a reference such as"Sheet1!$A$1:$B$10"; for a named constant, its value.inthashCode()booleanReturns whether this name is workbook-scoped, that is visible on every sheet.name()Returns the defined name, as written in the workbook.intReturns the 0-based index of the sheet this name is scoped to, or-1for workbook scope.toString()
-
Constructor Details
-
NamedRange
A detached name — one that carries no workbook, soasRange()has nothing to resolve against. UseWorkbook.findName(String)to obtain an attached one.- Parameters:
name- the defined nameformula- the reference or constant the name stands for, e.g."Sheet1!$A$1:$B$10"sheetScope- the 0-based index of the sheet the name is scoped to, or-1for workbook scope
-
-
Method Details
-
name
Returns the defined name, as written in the workbook. -
formula
Returns the formula the name stands for: for a named range, a reference such as"Sheet1!$A$1:$B$10"; for a named constant, its value. -
sheetScope
public int sheetScope()Returns the 0-based index of the sheet this name is scoped to, or-1for workbook scope. -
isWorkbookScoped
public boolean isWorkbookScoped()Returns whether this name is workbook-scoped, that is visible on every sheet. -
asRange
Returns the cells this name points at, resolved from the formula held by this object.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
-
hashCode
public int hashCode() -
toString
-