Spreadsheet Defined Names
Get and set your online spreadsheets defined names.
Documentation
The following methods are available to interact with the spreadsheet defined names programmatically.
getDefinedNames
Get the defined names for a spreadsheet
GET /api/:guid/definedNames
setDefinedNames
Set a defined names for a spreadsheet
| Parameter | Description |
|---|---|
definedNames[].name |
new defined name name. |
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
Get the defined names
Get the defined names from an online spreadsheet
const baseUrl = 'http://localhost:8009/api';
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const headers = { 'Authorization': `Bearer ${token}` };
// Request the defined names
const data = await (await fetch(`${baseUrl}/${guid}/definedNames`, { headers })).json();
console.log(data);
Set the defined names
Set new defined names for an online spreadsheet
const baseUrl = 'http://localhost:8009/api';
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const headers = { 'Authorization': `Bearer ${token}` };
// Set the defined name TEST = SHEET1!A1:B3
await fetch(`${baseUrl}/${guid}/definedNames`, {
method: 'POST',
headers,
body: new URLSearchParams({
'definedNames[0][name]': 'TEST',
'definedNames[0][value]': 'SHEET1!A1:B3',
}),
});