[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Expressions.Reference

Reference Class

Represents a reference in a formula.

A Reference describes a cell, a range, a worksheet-qualified reference, a 3D worksheet reference, or a reference to an external workbook. Use its row, column, range, worksheet, and workbook properties to build or inspect formula references programmatically.

If a row or column index is relative, use the base row or base column in the parse or unparse context when converting the reference to text.

Inheritance
Reference
Namespace: GrapeCity.Documents.Excel.Expressions
Assembly: DS.Documents.Excel.dll
Syntax
public sealed class Reference : IEquatable<Reference>, ICloneable
Public NotInheritable Class Reference
    Implements IEquatable(Of Reference), ICloneable
Examples
FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("SUM(Sheet1:Sheet3!D4:G10)");
FunctionNode functionNode = (FunctionNode)syntaxTree.Root;
ReferenceNode referenceNode = (ReferenceNode)functionNode.Children[0];
Reference reference = referenceNode.Reference;
reference.LastWorksheetName = null;

Reference addedReference = new Reference();
addedReference.Row = 1;
addedReference.Column = 1;
functionNode.Children.Add(new ReferenceNode(addedReference));
string formulaText = syntaxTree.ToString();

Constructors

Name Description
Reference()

Properties

Name Description
Column

Gets or sets the 0-based column index.

This property stores the column index of the reference. The default value is 0.

HasColumn

Gets whether the reference includes a column part.

This property indicates whether the reference contains column information. The default value is true. If the reference is in an error state, this property returns false.

HasRow

Gets whether the reference includes a row part.

This property indicates whether the reference contains row information. The default value is true. If the reference is in an error state, this property returns false.

IsColumnRelative

Gets whether the column part of this reference is relative.

This property indicates whether the column is stored as a relative reference rather than an absolute one. The default value is true. If this reference contains an error, this property returns false.

IsError

Gets whether the reference contains an error.

The default value is false. This property returns true when the reference has the error flag, when the worksheet name is "#REF", or when the reference points to an external workbook without a worksheet name.

IsLastColumnRelative

Gets whether the last column part of this reference is relative.

For a range reference, this property returns whether the end column is stored as a relative reference. For a non-range reference, it returns the same value as IsColumnRelative. The default value is true. If this reference contains an error, this property returns false.

IsLastRowRelative

Gets whether the last row in the reference is relative.

For a range reference, this property indicates whether the ending row is stored as a relative row reference. For a non-range reference, it returns the same value as IsRowRelative. If the reference contains an error, this property returns false.

IsRange

Gets whether this reference represents a range.

The default value is false. This property returns true when the reference has the range attribute set. If the reference contains an error, this property returns false.

IsRowRelative

Gets whether the row part of this reference is relative.

This property indicates whether the row is stored as a relative reference rather than an absolute one. The default value is true. If this reference contains an error, this property returns false.

LastColumn

Gets or sets the 0-based end column index.

For a range reference, this property stores the last column in the range. If the reference is not a range, it returns the same value as Column. If the range does not contain column information, it returns the maximum worksheet column index.

LastRow

Gets or sets the 0-based end row index.

For a range reference, this property stores the last row in the range. If the reference is not a range, it returns the same value as Row. If the reference is a range that does not contain row information, it returns the maximum row index.

LastWorksheetName

Gets or sets the name of the end worksheet of the 3D reference.

Use this property together with WorksheetName to inspect or update the worksheet span represented by a 3D reference.

Row

Gets or sets the 0-based row index.

This property stores the row index of the reference. The default value is 0.

Workbook

Gets or sets the external workbook reference.

Use this property to retrieve or update the workbook component of an external reference, such as a reference that points to a worksheet in another workbook. The default value is null.

WorksheetName

Gets or sets the name of the worksheet.

Use this property to retrieve or update the start worksheet name associated with this reference. For a 3D reference, use LastWorksheetName to read or update the end worksheet name.

Methods

Name Description
Clone()

Creates a copy of this reference.

The returned Reference contains the same reference settings as this instance, including workbook, worksheet, row, column, and kind information. This method performs a shallow copy.

Equals(Reference)

Equality comparison.

Equals(object)

Compares this reference with another object.

If obj is a Reference, this method compares it by using Equals(Reference). If obj is null or is not a Reference, this method returns false.

GetHashCode()

This object doesn't support getting hash code, because all fields are mutable.

ToString()

Converts the reference to text using the specified unparse context.

Use UnParseContext to control how the reference is converted, including whether the result uses A1 or R1C1 notation and which base row and base column are applied when relative references are resolved.

ToString(UnParseContext)

Converts the reference to text using the specified unparse context.

Use UnParseContext to control how the reference is converted, including whether the result uses A1 or R1C1 notation and which base row and base column are applied when relative references are resolved.