Spreadsheet defined names
Get and set data to and from your online spreadsheets.Documentation
Methods
The following methods are available to interact with the spreadsheet headers programmatically.| Method | Description |
|---|---|
| getDefinedNames | Get the defined names for a spreadsheet
getDefinedNames(): Promise<{ [definedName: string]: string }>
GET /api/:guid/names
|
| setDefinedNames | Set a defined names for a spreadsheet
setDefinedNames(
@param definedNames[].name - new defined name name. @param definedNames[].name - new defined name value. POST /api/:guid/names
|
Examples
Get the defined names from an online spreadsheet
NodeJS
PHP
import { Client } from '@jspreadsheet/client';
// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';
// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Create a new client
const client = new Client(token);
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Request data
spreadsheet.getDefinedNames().then((data) => {
console.log(data);
});
// Not available in the PHP client library.
Set new defined names for an online spreadsheet
NodeJS
PHP
import { Client } from '@jspreadsheet/client';
// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';
// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Create a new client
const client = new Client(token);
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Set Data
spreadsheet.setDefinedNames([
{
name: "TEST",
value: "SHEET1!A1:B3",
},
]).then(() => {
// It worked correctly
}).catch((err) => {
// Something went wrong
console.log(err);
});
// Not available in the PHP client library.