Spreadsheet 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.
Method |
Description |
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
Property |
Description |
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.
<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>
jspreadsheet.setLicense('ZGExZDk5ZDJjODJiNTBmYmZiOWVkYjRmN2MyYmM1MDQzNjIzMjA5ODUzNWI3MzdlZDNiMWY2YTFlMDU4MTBmZWQ5NTBjN2FhYjVhNDYwNjM0MjZlOTUyZDExNTVhNGZiYzk5YmY2MDU1ZDdhZTFmMjMyYmRhNTZjYmYwZjYyZjgsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpRME1ERTBOek01TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==');
jspreadsheet.setExtensions({ formula });
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>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";
const license = 'ZGExZDk5ZDJjODJiNTBmYmZiOWVkYjRmN2MyYmM1MDQzNjIzMjA5ODUzNWI3MzdlZDNiMWY2YTFlMDU4MTBmZWQ5NTBjN2FhYjVhNDYwNjM0MjZlOTUyZDExNTVhNGZiYzk5YmY2MDU1ZDdhZTFmMjMyYmRhNTZjYmYwZjYyZjgsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpRME1ERTBOek01TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==';
export default function App() {
const spreadsheet = useRef();
const data = [
[10, "=SUM(Summary)"],
[20, ""],
[30, ""],
[40, ""],
[50, ""]
];
const definedNames = {
Summary: 'Sheet1!A1:A6',
}
const extensions = { formula };
return (
<Spreadsheet ref={spreadsheet} license={license} extensions={extensions} definedNames={definedNames}>
<Worksheet data={data} minDimensions={[6,6]} />
</Spreadsheet>
);
}
<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 = 'ZGExZDk5ZDJjODJiNTBmYmZiOWVkYjRmN2MyYmM1MDQzNjIzMjA5ODUzNWI3MzdlZDNiMWY2YTFlMDU4MTBmZWQ5NTBjN2FhYjVhNDYwNjM0MjZlOTUyZDExNTVhNGZiYzk5YmY2MDU1ZDdhZTFmMjMyYmRhNTZjYmYwZjYyZjgsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpRME1ERTBOek01TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==';
export default {
components: {
Spreadsheet,
Worksheet,
},
data() {
const data = [
[10, "=SUM(Summary)"],
[20, ""],
[30, ""],
[40, ""],
[50, ""]
];
const definedNames = {
Summary: 'Sheet1!A1:A6',
}
const extensions = { formula };
return {
data,
definedNames,
extensions,
license,
};
}
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import "jspreadsheet/dist/jspreadsheet.css"
import "jsuites/dist/jsuites.css"
import formula from "@jspreadsheet/formula-pro";
jspreadsheet.setLicense('ZGExZDk5ZDJjODJiNTBmYmZiOWVkYjRmN2MyYmM1MDQzNjIzMjA5ODUzNWI3MzdlZDNiMWY2YTFlMDU4MTBmZWQ5NTBjN2FhYjVhNDYwNjM0MjZlOTUyZDExNTVhNGZiYzk5YmY2MDU1ZDdhZTFmMjMyYmRhNTZjYmYwZjYyZjgsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpRME1ERTBOek01TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==');
jspreadsheet.setExtensions({ formula });
@Component({
selector: "app-root",
template: `<div #spreadsheet></div>`,
})
export class AppComponent {
@ViewChild("spreadsheet") spreadsheet: ElementRef;
worksheets: jspreadsheet.worksheetInstance[];
ngAfterViewInit() {
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',
}
});
}
}