NanoXLSX.Core 3.2.1
Loading...
Searching...
No Matches
NanoXLSX.DefinedName Class Referencesealed

Class representing a defined name within a workbook. A defined name is a descriptive text that represents a cell, a range of cells, a formula, or a constant value, and can be referenced from formulas in worksheets (e.g. =SUM(MyRange)). More...

Inheritance diagram for NanoXLSX.DefinedName:

Public Types

enum  NameType { Cell , Range , Formula , Constant }
 Enum to specify the type of the defined name. More...

Public Member Functions

bool Equals (DefinedName other)
 Determines whether the specified DefinedName instance is equal to the current instance. Two instances are considered equal when their Name, TextValue, Comment, and LocalSheet (compared by reference) match.
override bool Equals (object obj)
 Determines whether the specified object is equal to the current instance.
override int GetHashCode ()
 Returns a hash code consistent with Equals(DefinedName).
int CompareTo (DefinedName other)
 Compares this instance with another DefinedName for ordering. The order is determined by Name (ordinal), then by scope (workbook scope sorts before any worksheet-scoped name; for worksheet-scoped names by Worksheet.SheetID), then by TextValue, then by Comment.
override string ToString ()
 Returns a textual representation of the defined name (intended for debugging).

Properties

NameType Type [get]
 Type of the defined name.
string Name [get]
 Gets the name of the defined name as it appears in the workbook (e.g. MyRange).
Worksheet TargetWorksheet [get]
 Gets the target worksheet in case of Cell or Range values. For other types, like formulas or constants, the target worksheet is null.
string TextValue [get]
 Gets the textual reference of the defined name. This is stored verbatim and may be a cell address (e.g. $A$1), a range (e.g. $A$1:$A$10), a formula (e.g. SUM(Sheet1!$A$1:$A$10)), or a constant value.
object Value [get]
 Gets the raw reference of the defined Name. The value will be transformed in its appropriate text value (TextValue). If the object is not supported (integer, float, date / date and time, boolean or string), Object.ToString will be used to determine the text value.
Worksheet LocalSheet [get]
 Gets the worksheet that scopes (constraint) this defined name. If null, the defined name has workbook scope and is visible from any worksheet. If non-null, the defined name is scoped to the referenced worksheet (mapped to the localSheetId attribute on save).
string Comment [get]
 Gets the optional comment associated with the defined name. Maps to the comment attribute in OOXML. May be null when no comment was set.
FormulaError Error [get]
 Gets a possible error of the whole value in a defined name. Default is FormulaError.NoError.
bool HasExternalReferences [get]
 Gets whether the value contains a reference or multiple references to an external source (e.g. an external workbook).

Detailed Description

Class representing a defined name within a workbook. A defined name is a descriptive text that represents a cell, a range of cells, a formula, or a constant value, and can be referenced from formulas in worksheets (e.g. =SUM(MyRange)).

Remarks
A defined name has a workbook scope by default (LocalSheet is null). When a Worksheet is supplied as LocalSheet, the defined name is scoped to that worksheet (corresponding to the localSheetId attribute in the OOXML representation). The TextValue is stored verbatim — NanoXLSX does not parse or evaluate it.

Definition at line 32 of file DefinedName.cs.

Member Enumeration Documentation

◆ NameType

Enum to specify the type of the defined name.

Enumerator
Cell 

Defined name is a single cell.

Range 

Defined name is a cell range.

Formula 

Defined name is a formula.

Constant 

Defined name is a constant value.

Definition at line 38 of file DefinedName.cs.

Member Function Documentation

◆ CompareTo()

int NanoXLSX.DefinedName.CompareTo ( DefinedName other)

Compares this instance with another DefinedName for ordering. The order is determined by Name (ordinal), then by scope (workbook scope sorts before any worksheet-scoped name; for worksheet-scoped names by Worksheet.SheetID), then by TextValue, then by Comment.

Parameters
otherOther defined name, or null. A null comparand sorts after this instance.
Returns
Negative, zero, or positive integer following the standard IComparable<T> contract.

Definition at line 479 of file DefinedName.cs.

◆ Equals() [1/2]

bool NanoXLSX.DefinedName.Equals ( DefinedName other)

Determines whether the specified DefinedName instance is equal to the current instance. Two instances are considered equal when their Name, TextValue, Comment, and LocalSheet (compared by reference) match.

Parameters
otherOther defined name instance, or null.
Returns
True if equal, otherwise false.

Definition at line 424 of file DefinedName.cs.

◆ Equals() [2/2]

override bool NanoXLSX.DefinedName.Equals ( object obj)

Determines whether the specified object is equal to the current instance.

Parameters
objOther object, or null.
Returns
True if the object is a DefinedName equal to this instance.

Definition at line 447 of file DefinedName.cs.

◆ GetHashCode()

override int NanoXLSX.DefinedName.GetHashCode ( )

Returns a hash code consistent with Equals(DefinedName).

Returns
Hash code derived from the public members of this instance.

Definition at line 456 of file DefinedName.cs.

◆ ToString()

override string NanoXLSX.DefinedName.ToString ( )

Returns a textual representation of the defined name (intended for debugging).

Returns
A short string with name, scope and reference.

Definition at line 517 of file DefinedName.cs.

Property Documentation

◆ Comment

string NanoXLSX.DefinedName.Comment
get

Gets the optional comment associated with the defined name. Maps to the comment attribute in OOXML. May be null when no comment was set.

Definition at line 123 of file DefinedName.cs.

◆ Error

FormulaError NanoXLSX.DefinedName.Error
get

Gets a possible error of the whole value in a defined name. Default is FormulaError.NoError.

Remarks
Errors within formula expressions are not set to an error in this property. The default will be FormulaError.NoError.

Definition at line 129 of file DefinedName.cs.

◆ HasExternalReferences

bool NanoXLSX.DefinedName.HasExternalReferences
get

Gets whether the value contains a reference or multiple references to an external source (e.g. an external workbook).

Definition at line 134 of file DefinedName.cs.

◆ LocalSheet

Worksheet NanoXLSX.DefinedName.LocalSheet
get

Gets the worksheet that scopes (constraint) this defined name. If null, the defined name has workbook scope and is visible from any worksheet. If non-null, the defined name is scoped to the referenced worksheet (mapped to the localSheetId attribute on save).

Definition at line 117 of file DefinedName.cs.

◆ Name

string NanoXLSX.DefinedName.Name
get

Gets the name of the defined name as it appears in the workbook (e.g. MyRange).

Definition at line 91 of file DefinedName.cs.

◆ TargetWorksheet

Worksheet NanoXLSX.DefinedName.TargetWorksheet
get

Gets the target worksheet in case of Cell or Range values. For other types, like formulas or constants, the target worksheet is null.

Definition at line 96 of file DefinedName.cs.

◆ TextValue

string NanoXLSX.DefinedName.TextValue
get

Gets the textual reference of the defined name. This is stored verbatim and may be a cell address (e.g. $A$1), a range (e.g. $A$1:$A$10), a formula (e.g. SUM(Sheet1!$A$1:$A$10)), or a constant value.

Remarks
Do not add the target worksheet name (e.g. Sheet1) in front of the Reference in case of cells or ranges. The worksheet is automatically added by the defined TargetWorksheet

Definition at line 104 of file DefinedName.cs.

◆ Type

NameType NanoXLSX.DefinedName.Type
get

Type of the defined name.

Definition at line 86 of file DefinedName.cs.

◆ Value

object NanoXLSX.DefinedName.Value
get

Gets the raw reference of the defined Name. The value will be transformed in its appropriate text value (TextValue). If the object is not supported (integer, float, date / date and time, boolean or string), Object.ToString will be used to determine the text value.

Definition at line 110 of file DefinedName.cs.


The documentation for this class was generated from the following file: