Name

Name class

Represents a defined name for a range of cells.

public class Name

Properties

Name Description
Comment { get; set; } Gets and sets the comment of the name. Only applies for Excel 2007.
FullText { get; } Gets the name full text of the object with the scope setting.
IsReferred { get; } Indicates whether this name is referred by other formulas.
IsVisible { get; set; } Indicates whether the name is visible.
R1C1RefersTo { get; set; } Gets or sets a R1C1 reference of the Name.
RefersTo { get; set; } Returns or sets the formula that the name is defined to refer to, beginning with an equal sign.
SheetIndex { get; set; } Indicates this name belongs to Workbook or Worksheet. 0 = Global name, otherwise index to sheet (one-based)
Text { get; set; } Gets the name text of the object.

Methods

Name Description
GetRange() Gets the range if this name refers to a range.
GetRange(bool) Gets the range if this name refers to a range
GetRange(int, int, int) Gets the range if this name refers to a range. If the reference of this name is not absolute, the range may be different for different cell.
GetRanges() Gets all ranges referred by this name.
GetRanges(bool) Gets all ranges referred by this name.
GetReferredAreas(bool) Gets all references referred by this name.
GetRefersTo(bool, bool) Get the reference of this Name.
GetRefersTo(bool, bool, int, int) Get the reference of this Name based on specified cell.
SetRefersTo(string, bool, bool) Set the reference of this Name.
override ToString() Returns a string represents the current Range object.

Examples


[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Creating a named range
Range range = worksheet.Cells.CreateRange("B4", "G14");
//Setting the name of the named range
range.Name = "TestRange";
//Saving the modified Excel file in default (that is Excel 2000) format
workbook.Save("output.xls");   

[Visual Basic]

'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Accessing the first worksheet in the Excel file
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Creating a named range
Dim range As Range = worksheet.Cells.CreateRange("B4", "G14")
'Setting the name of the named range
range.Name = "TestRange"
'Saving the modified Excel file in default (that is Excel 2000) format
workbook.Save("output.xls")

See Also