Skip to content

Spreadsheet Defined Names

Get and set your online spreadsheets defined names.

The following methods are available to interact with the spreadsheet defined names programmatically.

MethodDescription
getDefinedNamesGet the defined names for a spreadsheet

Jspreadsheet getDefinedNames(): Promise<{ [definedName: string]: string }>

GET /api/:guid/definedNames
setDefinedNamesSet a defined names for a spreadsheet

Jspreadsheet setDefinedNames(definedNames: { name: string; value?: string }[]): Promise<void>

@param definedNames[].name - new defined name name.
@param definedNames[].value - new defined name value. If the value of this property is an empty string, that defined name, if any, will be removed.

POST /api/:guid/definedNames

Get the defined names from an online spreadsheet

import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Request data
spreadsheet.getDefinedNames().then((data) => {
console.log(data);
});
Terminal window
curl -X GET "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/definedNames" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"

Set new defined names for an online spreadsheet

import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Defined names
const names = [{
name: "TEST",
value: "SHEET1!A1:B3",
}];
// Set Data
spreadsheet.setDefinedNames(names).then(() => {
// It worked correctly
}).catch((err) => {
// Something went wrong
console.log(err);
});
Terminal window
curl -X POST "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/definedNames" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \
-H "Content-Type: application/json" \
-d '{
"names": [
{
"name": "TEST",
"value": "SHEET1!A1:B3"
}
]
}'