Custom, user-defined names are identifiers to represent information in the spreadsheet, used mostly in formulas. A custom name can refer to a cell, a range of cells, a computed value, or a formula. You can define a custom name and then use the name in formulas. When the formula is evaluated, the custom name's value is referenced and evaluated.
Return to the overview of Managing Formulas in Cells.
Using Code
Define the custom name using the AddCustomName method.
Examples
To add a custom name for a cell specified with A1 notation, use the AddCustomName method as shown in this code:
C# | Copy Code |
---|---|
FarPoint.Win.Spread.Model.DefaultSheetDataModel d = new FarPoint.Win.Spread.Model.DefaultSheetDataModel(); d.AddCustomName("test", "$B$1", 0, 0); |
VB | Copy Code |
---|---|
Dim d FarPoint.Win.Spread.Model.DefaultSheetDataModel = New FarPoint.Win.Spread.Model.DefaultSheetDataModel() d.AddCustomName("test", "$B$1", 0, 0) |
To add a custom name for a computed value, use the AddCustomName method as shown in this code:
C# | Copy Code |
---|---|
FarPoint.Win.Spread.Model.DefaultSheetDataModel d; d = (FarPoint.Win.Spread.Model.DefaultSheetDataModel)FpSpread1.Sheets[0].Models.Data; d.AddCustomName("alpha", "101", 0, 0); |
VB | Copy Code |
---|---|
Dim d As New FarPoint.Win.Spread.Model.DefaultSheetDataModel d = (FarPoint.Win.Spread.Model.DefaultSheetDataModel)FpSpread1.Sheets(0).Models.Data d.AddCustomName("alpha", "101", 0, 0) |
The following example adds two names where one is a range reference and the other is a formula that references it.
C# | Copy Code |
---|---|
FarPoint.Win.Spread.Model.DefaultSheetDataModel d; d = (FarPoint.Win.Spread.Model.DefaultSheetDataModel)FpSpread1.Sheets[0].DataModel; d.AddCustomName("Sales", "Sheet2!$F$20:$F$50", 0, 0); d.AddCustomName("NetSales", "Sales-SUM(Sheet1!$H$30, Sheet1!$H$40:$H$50)"); |
VB | Copy Code |
---|---|
Dim d As New FarPoint.Win.Spread.Model.DefaultSheetDataModel d = (FarPoint.Win.Spread.Model.DefaultSheetDataModel)FpSpread1.Sheets(0).DataModel d.AddCustomName("Sales", "Sheet2!$F$20:$F$50", 0, 0) |