defineName

Defines a custom name that will be available and used in formulas. If the function is not able to parse the name of the value, it will throw an error.

If the name of the sheet consists of multiple words, separated by space, the sheet name should be wrapped in quotes 'Sheet Name With Space'!$A$1.

Parameters

name String

A new name that will be defined. The names are case-insensitive. You can provide a name that already exists. In such cases, the value is silently updated. To make the name available only in one sheet, qualify it in the way demonstrated in the next example.

value String

The value has to be a valid formula in the form of a string, that is, without a leading = sign. Generally, a name points to a reference. For a maximum compatibility, use references here that are fully qualified (include the name of the sheet to which they refer) and absolute (prefix both row and column with the $ sign).

hidden Boolean (default: false)

To hide this name from the custom-name drop-down in the toolbar, pass true. Even if hidden is set to false, only reference names will be displayed in the drop-down.

Example - defining a few names

<div id="spreadsheet"></div>
<script>
    $("#spreadsheet").kendoSpreadsheet();
    var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");

    // cell reference
    spreadsheet.defineName("MyCell", "Sheet1!$A$1");

    // range reference
    spreadsheet.defineName("MyRange", "Sheet1!$A$1:$C$3");

    // qualified name
    spreadsheet.defineName("Sheet1!Foo", "Sheet1!$B$2");

    // relative reference (incompatible with other programs).
    // relative refs in A1 notation are ambiguous, unless we know
    // the cell where they are used, so we use the RC notation here:
    spreadsheet.defineName("CellsAbove", "R1C[0]:R[-1]C[0]");

    // arbitrary formula
    spreadsheet.defineName("GoldenRatio", "(1+SQRT(5))/2");
</script>

After that, you can use any of those names in formulas. For example, a formula like =SUM(CellsAbove) will return the sum of the cells above it, no matter where it sits. Relative references, such as the CellsAbove example, are not compatible with other spreadsheets, such as Excel, LibreOffice, or Google Sheets. The "qualified" Sheet1!Foo name is visible without qualification only in formulas in the Sheet1 and, for example, you can type =Foo * Foo. If you need the name in formulas from other sheets, you have to refer to it as =Sheet1!Foo.

In this article