Defined names

A defined name is a user-defined label or identifier representing a specific cell, range of cells, formula, or constant value. A defined name can be used in place of a cell or range reference in a formula, making it easier to read and understand. For example, you might define Sales, which refers to the range of cells containing your sales data. Then, instead of referring to those cells as A1:A10 in a formula, you can use the name Sales instead.

Enterprise feature
This feature is only available with the premium extension for formulas.

Documentation

Methods

You can use the following methods to read or create new defined names programmatically in your spreadsheet software.
MethodDescription
getDefinedNames Get a defined name.
@param {string} index - defined name identification.
spreadsheet.getDefinedNames(index: String) => Object
setDefinedNames Create a one or multiple defined names.
@param {array} - Array with the new defined names.
spreadsheet.setDefinedNames(names: Object[]) => void


Settings

All available properties to define a validation
PropertyDescription
definedNames: array An array of defined names


Example

Basic spreadsheet with defined names

Here's a simple example of how to use defined names in your calculations within a spreadsheet.



Source code

<html>
<script src="https://jspreadsheet.com/v10/jspreadsheet.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v10/jspreadsheet.css" type="text/css" />
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />

<div id="spreadsheet"></div>

<script>
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('ZThhYmExZmQ5ZDc0ZDkwZjYwOGI0MTExYjFiNGJkZmUzMzg1YTQ2MTRkMjFlZGI1YmMyZjc4MTc5ZDI2MjhmNzk4NWRkYTUzZmRlMDA3NzRiMGFkYmU0ZjZlZGY2NjRmYzJjZmI3ZjUzZDI0ZTlkNDQzMTFkMTJjNTBhZjc0YWMsZXlKdVlXMWxJam9pU25Od2NtVmhaSE5vWldWMElpd2laR0YwWlNJNk1UY3dPVEkyT0RBek1Dd2laRzl0WVdsdUlqcGJJbXB6Y0hKbFlXUnphR1ZsZEM1amIyMGlMQ0pqYjJSbGMyRnVaR0p2ZUM1cGJ5SXNJbXB6YUdWc2JDNXVaWFFpTENKamMySXVZWEJ3SWl3aWQyVmlJaXdpYkc5allXeG9iM04wSWwwc0luQnNZVzRpT2lJek5DSXNJbk5qYjNCbElqcGJJblkzSWl3aWRqZ2lMQ0oyT1NJc0luWXhNQ0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Set the extension
jspreadsheet.setExtensions({ formula });

// Create a new spreadsheet
let worksheets = jspreadsheet(document.getElementById('spreadsheet'), {
    toolbar: true,
    worksheets: [{
        data: [
            [10, "=SUM(Summary)"],
            [20, ""],
            [30, ""],
            [40, ""],
            [50, ""]
        ],
        minDimensions: [6, 6],
    }],
    definedNames: {
        Summary: 'Sheet1!A1:A6',
    }
});
</script>
</html>

React example

import React, { useRef } from "react";
import { Spreadsheet, Worksheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";

const license = 'ZThhYmExZmQ5ZDc0ZDkwZjYwOGI0MTExYjFiNGJkZmUzMzg1YTQ2MTRkMjFlZGI1YmMyZjc4MTc5ZDI2MjhmNzk4NWRkYTUzZmRlMDA3NzRiMGFkYmU0ZjZlZGY2NjRmYzJjZmI3ZjUzZDI0ZTlkNDQzMTFkMTJjNTBhZjc0YWMsZXlKdVlXMWxJam9pU25Od2NtVmhaSE5vWldWMElpd2laR0YwWlNJNk1UY3dPVEkyT0RBek1Dd2laRzl0WVdsdUlqcGJJbXB6Y0hKbFlXUnphR1ZsZEM1amIyMGlMQ0pqYjJSbGMyRnVaR0p2ZUM1cGJ5SXNJbXB6YUdWc2JDNXVaWFFpTENKamMySXVZWEJ3SWl3aWQyVmlJaXdpYkc5allXeG9iM04wSWwwc0luQnNZVzRpT2lJek5DSXNJbk5qYjNCbElqcGJJblkzSWl3aWRqZ2lMQ0oyT1NJc0luWXhNQ0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklsMHNJbVJsYlc4aU9uUnlkV1Y5';

export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();
    // Data
    const data = [
        [10, "=SUM(Summary)"],
        [20, ""],
        [30, ""],
        [40, ""],
        [50, ""]
    ];
    // Defined names
    const definedNames = {
        Summary: 'Sheet1!A1:A6',
    }
    // Extensions
    const extensions = { formula };

    // Render component
    return (
        <Spreadsheet ref={spreadsheet} license={license} extensions={extensions} definedNames={definedNames}>
            <Worksheet data={data} minDimensions={[6,6]} />
        </Spreadsheet>
    );
}

Vue example

<template>
    <Spreadsheet ref="spreadsheet" :license="license" :extensions="extensions" :definedNames="definedNames">
        <Worksheet :data="data" />
    </Spreadsheet>
</template>

<script>
import { Spreadsheet, Worksheet } from "@jspreadsheet/vue";
import formula from "@jspreadsheet/formula-pro";

const license = 'ZThhYmExZmQ5ZDc0ZDkwZjYwOGI0MTExYjFiNGJkZmUzMzg1YTQ2MTRkMjFlZGI1YmMyZjc4MTc5ZDI2MjhmNzk4NWRkYTUzZmRlMDA3NzRiMGFkYmU0ZjZlZGY2NjRmYzJjZmI3ZjUzZDI0ZTlkNDQzMTFkMTJjNTBhZjc0YWMsZXlKdVlXMWxJam9pU25Od2NtVmhaSE5vWldWMElpd2laR0YwWlNJNk1UY3dPVEkyT0RBek1Dd2laRzl0WVdsdUlqcGJJbXB6Y0hKbFlXUnphR1ZsZEM1amIyMGlMQ0pqYjJSbGMyRnVaR0p2ZUM1cGJ5SXNJbXB6YUdWc2JDNXVaWFFpTENKamMySXVZWEJ3SWl3aWQyVmlJaXdpYkc5allXeG9iM04wSWwwc0luQnNZVzRpT2lJek5DSXNJbk5qYjNCbElqcGJJblkzSWl3aWRqZ2lMQ0oyT1NJc0luWXhNQ0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklsMHNJbVJsYlc4aU9uUnlkV1Y5';

export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    data() {
        // Data
        const data = [
            [10, "=SUM(Summary)"],
            [20, ""],
            [30, ""],
            [40, ""],
            [50, ""]
        ];
        // Defined names
        const definedNames = {
            Summary: 'Sheet1!A1:A6',
        }
        // Extensions
        const extensions = { formula };

        return {
            data,
            definedNames,
            extensions,
            license,
        };
    }
}
</script>

Angular example

import { Component, ViewChild, ElementRef } from "@angular/core";
import * as jspreadsheet from "jspreadsheet";
import formula from "@jspreadsheet/formula-pro";

// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('ZThhYmExZmQ5ZDc0ZDkwZjYwOGI0MTExYjFiNGJkZmUzMzg1YTQ2MTRkMjFlZGI1YmMyZjc4MTc5ZDI2MjhmNzk4NWRkYTUzZmRlMDA3NzRiMGFkYmU0ZjZlZGY2NjRmYzJjZmI3ZjUzZDI0ZTlkNDQzMTFkMTJjNTBhZjc0YWMsZXlKdVlXMWxJam9pU25Od2NtVmhaSE5vWldWMElpd2laR0YwWlNJNk1UY3dPVEkyT0RBek1Dd2laRzl0WVdsdUlqcGJJbXB6Y0hKbFlXUnphR1ZsZEM1amIyMGlMQ0pqYjJSbGMyRnVaR0p2ZUM1cGJ5SXNJbXB6YUdWc2JDNXVaWFFpTENKamMySXVZWEJ3SWl3aWQyVmlJaXdpYkc5allXeG9iM04wSWwwc0luQnNZVzRpT2lJek5DSXNJbk5qYjNCbElqcGJJblkzSWl3aWRqZ2lMQ0oyT1NJc0luWXhNQ0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Set the extension
jspreadsheet.setExtensions({ formula });

// Create component
@Component({
    selector: "app-root",
    template: `<div #spreadsheet></div>`;
})
export class AppComponent {
    @ViewChild("spreadsheet") spreadsheet: ElementRef;
    // Worksheets
    worksheets: jspreadsheet.worksheetInstance[];
    // Create a new data grid
    ngOnInit() {
        // Create spreadsheet
        this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
            toolbar: true,
            worksheets: [{
                data: [
                    [10, "=SUM(Summary)"],
                    [20, ""],
                    [30, ""],
                    [40, ""],
                    [50, ""]
                ],
                minDimensions: [6, 6],
            }],
            definedNames: {
                Summary: 'Sheet1!A1:A6',
            }
        });
    }
}