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 headers programmatically.
| Method | Description |
|---|---|
| getDefinedNames | Get the defined names for a spreadsheet Jspreadsheet getDefinedNames() : Promise<{ [definedName: string]: string }> GET /api/:guid/names |
| 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/names |
Examples
Section titled “Examples”Get the defined names from an online spreadsheet
Section titled “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);});Set new defined names for an online spreadsheet
Section titled “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);});