Represents a named reference defined in the workbook.

Named references allow for names to be used in formulas instead of complex formulas or cell references. For example, instead of using the formula =SUM(E1:E20), a named reference with a name of 'Sales' can be defined to point to the range of E1:E20 (the named reference's formula would be defined like this: =Sheet1!$E$1:$E$20). Then the original formula could be expressed as =SUM(Sales).

Each named reference has an associated scope, which can either be the [[workbook]] to which the named reference belongs or one of the [[Worksheet]] instances in the Workbook. The scope determines how the name must be referenced in formulas for different cells. A scope of the workbook means the named reference must be accessed by a formula in any cell of the workbook by specifying only the name. A scope of the worksheet means formulas used in other worksheets must reference the name by first specifying the worksheet scope, such as =SUM( Sheet2!Sales ). If the formula is in the same worksheet as the scope of the named reference, the formula can reference the name with or without the worksheet name.

Named references from external workbooks must always be referenced with the scope first. If the named reference's scope is the external workbook, the name is accessed by specifying the workbook file name followed by the name, such as in the following formula: ='C:\ExternalWorkbook.xls'!SalesTax. If the named reference has a scope of a worksheet in the workbook, it is referenced by specifying the file name, worksheet, and name: ='C:\[ExternalWorkbook.xls]Sheet1'!SalesTax.

Named references with different scopes can have the same names, but if two named references have the same scope, they must have case-insensitively unique names.

Hierarchy

Hierarchy

Implements

  • IChangeInfoContext

Constructors

Properties

$type: Type
$t: Type
nextHashCode: number

Accessors

  • get comment(): string
  • Gets or sets the comment associated with the named reference or table. The comment associated with the named reference or table.

    Throws

    [[ArgumentException]] The value assigned is greater than 255 characters in length.

    Returns string

  • set comment(a): void
  • Parameters

    • a: string

    Returns void

  • get formula(): string
  • Gets the formula which defines the named reference. The formula which defines the named reference.

    See

    • [[setFormula]]
    • [[setFormula]]

    Returns string

  • get isSimpleReferenceFormula(): boolean
  • Gets the value indicating whether the [[formula]] is a simple formula referring to a single cell, a single region, or multiple regions in the same workbook as the named reference.

    If the reference is surrounded by parentheses or whitespace or the named reference has some other complex formula this will return false.

    Returns boolean

  • get name(): string
  • Gets or sets the name of the reference.

    See the overview on [[scope]] for details on how to access a named reference by name in formulas.

    The name of the reference.

    Throws

    [[ArgumentNullException]] The value assigned is null or empty.

    Throws

    [[ArgumentException]] The value assigned is longer than 255 characters.

    Throws

    [[ArgumentException]] The value assigned is not a valid named reference. The name must begin with a letter, underscore (), or a backslash (). All other characters in the name must be letters, numbers, periods, underscores (), or backslashes (). The name cannot be a an A1 cell reference (1 to 3 letters followed by 1 to 6 numbers). In addition, the name cannot be 'r', 'R', 'c', or 'C' or start with a row or column reference in R1C1 cell reference mode ('R' followed by 1 to 6 numbers or 'C' followed by 1 to 6 numbers).

    Throws

    [[InvalidOperationException]] The value assigned is the name of another named reference with the same Scope. Names are compared case-insensitively.

    Returns string

  • set name(a): void
  • Parameters

    • a: string

    Returns void

  • get referencedCell(): WorksheetCell
  • Gets the [[WorksheetCell]] referenced by the [[formula]].

    If named reference is a reference to one or more regions, this will return null.

    See

    [[isSimpleReferenceFormula]]

    Returns WorksheetCell

  • get referencedRegion(): WorksheetRegion
  • Gets the [[WorksheetRegion]] referenced by the [[formula]].

    If the named reference is a reference to a single cell or multiple regions, this will return null.

    See

    [[isSimpleReferenceFormula]]

    Returns WorksheetRegion

  • get referencedRegions(): WorksheetRegion[]
  • Gets the array of [[WorksheetRegion]] instances referenced by the [[formula]].

    If the named reference is a reference to a single cell or region, this will return null.

    See

    [[isSimpleReferenceFormula]]

    Returns WorksheetRegion[]

  • get scope(): any
  • Gets the scope of the named reference.

    This can either be the workbook which the named reference belongs to or one of the worksheets in the workbook.

    The scope determines how formulas need to preface a name in order to use the named reference.

    If the scope is the workbook, formulas in any cell in the workbook can reference the named reference by specifying just the name or the workbook's file name, an exclamation point, and the name: =MyWorkbookName ='C:\MyWorkbook.xls'!MyWorkbookName When cells in other workbook's want to reference the named reference, they must use the second format by first specifying the file name when the workbook-scoped named reference exists.

    If the scope is a worksheet, formulas in cells of the worksheet can reference the named reference by specifying just the name. In addition, they can fully qualify the named reference with the worksheet name and, optionally, the workbook file name: =MyWorksheetName =Sheet1!MyWorksheetName ='C:\[MyWorkbook.xls]Sheet1'!MyWorksheetName Formulas in cells of other worksheets in the same workbook can use the named reference as well, but they must specify the worksheet name and, optionally, the workbook file name: =Sheet2!OtherWorksheetName ='C:\[MyWorkbook.xls]Sheet2'!OtherWorksheetName Formulas in cells of other workbooks can also used the named reference, but they must specify the workbook file name, worksheet name, and named reference name.

    The scope of the named reference.

    Returns any

Methods

  • Parameters

    • other: any

    Returns boolean

  • Sets the formula for a named reference.

    The formula will be parsed using the [[CellReferenceMode]] of the [[workbook]] to which the NamedReference is applied. If the NamedReference has been removed from its collection, the A1 reference mode will be used to parse the formula.

    Throws

    [[ArgumentNullException]] 'formula' is null or empty.

    Throws

    [[ArgumentException]] 'formula' is not a valid formula. The inner exception will contain the [[FormulaParseException]] describing the reason the formula was not valid.

    See

    [[formula]]

    Parameters

    • formula: string

      The string containing the formula value.

    Returns void

  • Sets the formula for a named reference.

    Throws

    [[ArgumentNullException]] 'formula' is null or empty.

    Throws

    [[InvalidEnumArgumentException]] 'cellReferenceMode' is not defined in the [[CellReferenceMode]] enumeration.

    Throws

    [[ArgumentException]] 'formula' is not a valid formula. The inner exception will contain the [[FormulaParseException]] describing the reason the formula was not valid.

    See

    [[formula]]

    Parameters

    • formula: string

      The string containing the formula value.

    • cellReferenceMode: CellReferenceMode

      The mode used to interpret cell references in the formula.

    Returns void

  • Sets the formula for a named reference.

    Throws

    [[ArgumentNullException]] 'formula' is null or empty.

    Throws

    [[InvalidEnumArgumentException]] 'cellReferenceMode' is not defined in the [[CellReferenceMode]] enumeration.

    Throws

    [[ArgumentException]] 'formula' is not a valid formula. The inner exception will contain the [[FormulaParseException]] describing the reason the formula was not valid.

    See

    [[formula]]

    Parameters

    • formula: string

      The string containing the formula value.

    • cellReferenceMode: CellReferenceMode

      The mode used to interpret cell references in the formula.

    • culture: string | CultureInfo

      The culture used to parse the formula.

    Returns void

  • Gets the string representation of the named reference.

    Returns string

  • Parameters

    • item1: any
    • item2: any

    Returns number

  • Parameters

    • item1: any
    • item2: any

    Returns number

  • Parameters

    • item1: any
    • item2: any

    Returns boolean

  • Parameters

    • a: any
    • b: any

    Returns boolean

  • Parameters

    • a: any
    • b: any

    Returns boolean