Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Customizing Interaction in Cells > Managing Formulas in Cells > Creating and Using a Custom Name |
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.
You can create sheet level or workbook level custom names. The scope of the sheet level custom name is limited to the sheet for which it was created. This allows you to use the same name on several sheets. Formulas in a sheet will ignore sheet level custom names on other sheets.
Use the AddCustomName method in the SheetView class to add workbook or sheet level custom names. The sheetViewScope parameter in the AddCustomName method can be set to true for a sheet level custom name and false for a workbook level custom name. Use the AddModelScopeCustomName method to add sheet level custom names.
Avoid using custom names that start with C# or R# patterns (# stands for any number).
Define the custom name using the AddCustomName method for the workbook or sheet.
To add a custom name for a cell specified with A1 notation, use the AddCustomName method as shown in the following example, which creates a workbook level custom name.
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 As 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 FarPoint.Win.Spread.Model.DefaultSheetDataModel d = DirectCast(FpSpread1.Sheets(0).Models.Data, FarPoint.Win.Spread.Model.DefaultSheetDataModel) d.AddCustomName("alpha", "101", 0, 0) |
The following example adds a name that is a range reference.
C# |
Copy Code
|
---|---|
FarPoint.Win.Spread.Model.DefaultSheetDataModel d; d = (FarPoint.Win.Spread.Model.DefaultSheetDataModel)FpSpread1.Sheets[0].Models.Data; d.AddCustomName("Sales", "Sheet1!$F$20:$F$50", 0, 0); |
VB |
Copy Code
|
---|---|
Dim d As New FarPoint.Win.Spread.Model.DefaultSheetDataModel d = DirectCast(FpSpread1.Sheets(0).Models.Data, FarPoint.Win.Spread.Model.DefaultSheetDataModel) d.AddCustomName("Sales", "Sheet1!$F$20:$F$50", 0, 0) |