Spreadsheet meta
Meta information are a useful tool to keep information from a cell hidden from the user. Manage the cell meta information of your online spreadsheets using the following methods.Documentation
Methods
Available methods for cell comments management.| Method | Description |
|---|---|
| getMeta | Get the meta information of a cell.
getMeta(cellNames?: string): Promise<{ [cellName: string]: object }>
@param cellNames - cell names and/or ranges. GET /api/:guid/meta
|
| setMeta | Add meta information to the spreadsheet cells.
setMeta(metas: { cellName: string; value: object | null }[]): Promise<void>
@param metas[].cellName - reference cell. @param metas[].value - cell meta information. If null, remove current meta information from cell. POST /api/:guid/meta
|
| resetMeta | Remove all the meta information.
resetMeta(): Promise<void>
DELETE /api/:guid/meta
|
Examples
Read the meta information
Get all meta information from a 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);
// Get all meta information
spreadsheet.getMeta().then((metas) => {
console.log(metas);
});
// {
// B2: {
// key: "value",
// },
// D4: {
// key2: "value 2",
// },
// }
<?php
require 'vendor/autoload.php';
use jspreadsheet\Jspreadsheet;
// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';
// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Create a new client
$client = new Jspreadsheet($token);
// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);
// Reset
$result = $spreadsheet->getCells()->resetMeta();
// Result
print_r($result);
// {"success":1,"message":"Updated"}
Get the meta information from a cell
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);
// Get the meta information
spreadsheet.getMeta("A1") // A1,A2,A3 or A1:A3 for multiple cells
.then((metas) => {
console.log(metas);
});
<?php
require 'vendor/autoload.php';
use jspreadsheet\Jspreadsheet;
// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';
// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Create a new client
$client = new Jspreadsheet($token);
// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);
// Get the meta information
$result = $spreadsheet->getCells('A1')->getMeta(); // A1,A2,A3 or A1:A3 for multiple cells in the same request.
Add meta information
Meta information are hidden information related to the cells in your 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);
// New meta information
const meta = [
{
cellName: "B2",
value: {
key: "value",
},
},
{
cellName: "D4",
value: {
key2: "value 2",
},
},
];
// Update meta information
spreadsheet.setMeta(meta)
.then(() => {
// It worked correctly
})
.catch((err) => {
console.log(err);
});
<?php
require 'vendor/autoload.php';
use jspreadsheet\Jspreadsheet;
// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';
// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Create a new client
$client = new Jspreadsheet($token);
// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);
// Result
$meta = [
'B2' => ['key' => 'value'],
'D4' => ['key2' => 'value 2']
];
// Update meta information
$result = $spreadsheet->getCells()->setMeta($meta);
// Result
print_r($result);
// { "success": 1, "message": "Updated" }
Reset the meta information
The following code will reset the meta information of the whole table.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);
// Reset
spreadsheet.resetMeta().then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
<?php
require 'vendor/autoload.php';
use jspreadsheet\Jspreadsheet;
// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';
// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Create a new client
$client = new Jspreadsheet($token);
// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);
// Get all meta information
$result = $spreadsheet->getCells()->getMeta();
// Result
print_r($result);
// {"B2":{"key":"value"},"C3":{"name":"The Name"},"D4":{"key2":"value 2"}}