Spreadsheet Defined Names
Get and set your online spreadsheets defined names.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”The following methods are available to interact with the spreadsheet defined names programmatically.
| Method | Description |
|---|---|
getDefinedNames | Get the defined names for a spreadsheet Jspreadsheet getDefinedNames(): Promise<{ [definedName: string]: string }> GET /api/:guid/definedNames |
setDefinedNames | Set 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 |
Examples
Section titled “Examples”Get the defined names
Section titled “Get the defined names”Get the defined names from an online spreadsheet
import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Request dataspreadsheet.getDefinedNames().then((data) => { console.log(data);});curl -X GET "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/definedNames" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"Set the defined names
Section titled “Set the defined names”Set new defined names for an online spreadsheet
import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Defined namesconst names = [{ name: "TEST", value: "SHEET1!A1:B3",}];
// Set Dataspreadsheet.setDefinedNames(names).then(() => { // It worked correctly}).catch((err) => { // Something went wrong console.log(err);});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" } ] }'