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
Section titled “Documentation”Methods
Section titled “Methods”Available methods for cell comments management.
| Method | Description |
|---|---|
| getMeta | Get the meta information of a cell. @param cellNames - cell names and/or ranges. Jworksheet getMeta(cellNames?: string): Promise<{ [cellName: string]: object; }> GET /api/:guid/:worksheetIndex/meta/:cellNames |
| setMeta | Add meta information to the spreadsheet cells. @param metas[].cellName - reference cell. @param metas[].value - cell meta information. If null or ommited, remove current meta information from cell. Jworksheet setMeta(metas: { cellName: string; value: object }[]): Promise<void> POST /api/:guid/:worksheetIndex/meta |
| deleteMeta | Remove meta information. @param cellNames - cell names and/or ranges. If null or ommited, remove meta information from all cells. Jworksheet deleteMeta(cellNames?: string | null): Promise<void> DELETE /api/:guid/:worksheetIndex/meta/:cellNames |
Examples
Section titled “Examples”Read the meta information
Section titled “Read the meta information”Get all meta information from a 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);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Get all meta informationworksheet.getMeta().then((metas) => { console.log(metas);});curl -X GET "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/meta" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"Get the meta information from a cell
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);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Get the meta informationworksheet .getMeta("A1") // A1,A2,A3 or A1:A3 for multiple cells .then((metas) => { console.log(metas); });curl -X GET "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/meta/A1" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"Add meta information
Section titled “Add meta information”Meta information are hidden information related to the cells in your 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);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// New meta informationconst meta = [ { cellName: "B2", value: { key: "value", }, }, { cellName: "D4", value: { key2: "value 2", }, },];
// Update meta informationworksheet .setMeta(meta) .then(() => { // It worked correctly }) .catch((err) => { console.log(err); });curl -X POST "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/meta" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \ -H "Content-Type: application/json" \ -d '{ "metas": [ { "cellName": "B2", "value": { "key": "value" } }, { "cellName": "D4", "value": { "key2": "value 2" } } ] }'Reset the meta information
Section titled “Reset the meta information”The following code will reset the meta information of the whole table.
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);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Resetworksheet .deleteMeta() .then(() => { // It worked correctly }) .catch((err) => { // Something went wrong console.log(err); });curl -X DELETE "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/meta" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"