Spread.NET 14 Formula Reference
Formula Overview / Custom Names in Formulas
In This Topic
    Custom Names in Formulas
    In This Topic

    Formulas may include custom, user-defined names. Custom names are identifiers to represent information in the spreadsheet. A custom name can refer to a cell, a range of cells, a computed value, or a formula. (Methods that deal with custom names provide the same functionality as the Name in Excel.) A custom name can contain up to 255 characters and can include letters, numbers, or underscores. The first character must be a letter or an underscore.

    The name's value can be assigned or retrieved as either a string object or as an expression object. Refer to the Assembly Reference for more details on the methods that add or get custom names.

    From the example in C#:

    dataModel.AddCustomName("Total", new FarPoint.CalcEngine.CellExpression(3, 2));

    a name called Total is created that represents the cell at absolute location 3,2. Assuming A1 notation (ReferenceStyle = A1), then this would be equivalent to:

    dataModel.AddCustomName("Total", "$D$3", 0, 0);

    In Excel, this would be equivalent to:

    Name: Total Refers To: =$D$3

    Once the name is defined, the name can be used in formulas. When the formula is evaluated, the name's value is referenced and evaluated. Given the above definition, the following two formula assignments would produce the same result:

    spread.ActiveSheet.SetFormula(0, 0, "Total"); spread.ActiveSheet.SetFormula(0, 0, "$D$3");

    Note that the string versions of the AddCustomName and GetCustomName methods take the base row or base column arguments. These arguments are used to parse or unparse relative addresses in A1 notation. These arguments are ignored when using absolute addresses or when using R1C1 notation. A1 notation requires a base location from which the relative offset is computed.

    For example:

    dataModel.AddCustomName("Beta", "D3", 0, 0); // same as "R[2]C[3]" dataModel.AddCustomName("Gamma", "D3", 4, 4); // same as "R[-2]C[-1]"

    In other words, cell D3 is +3/+2 from cell A1 but -1/-2 from cell E5. In Excel, the Insert > Name > Define dialog uses the active cell as the base location.

    Refer to the product Developer’s Guide for more details on how to create a custom name.

    Refer to the Assembly Reference for more details on the methods that add or get custom names.

    Return to the Formula Overview.