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.
MethodDescription
getMeta Get the meta information of a cell.
@param cellNames - cell names and/or ranges.

Jspreadsheet getMeta(cellNames?: string): Promise<{ [cellName: string]: object }>

GET /api/:guid/meta
setMeta Add meta information to the spreadsheet cells.
@param metas[].cellName - reference cell.
@param metas[].value - cell meta information. If null, remove current meta information from cell.

Jspreadsheet setMeta(metas: { cellName: string; value: object | null }[]): Promise<void>

POST /api/:guid/meta
resetMeta Remove all the meta information.

Jspreadsheet resetMeta(): Promise<void>

DELETE /api/:guid/meta


Examples


Read the meta information

Get all meta information from a spreadsheet

import { Client } from "@intrasheets/client";

// Create a new client
const client = new Client({
  // API Server
  baseUrl: "http://localhost:8009/api",
  // Your authentication token
  token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// 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",
//     },
// }


Get the meta information from a cell

import { Client } from "@intrasheets/client";

// Create a new client
const client = new Client({
  // API Server
  baseUrl: "http://localhost:8009/api",
  // Your authentication token
  token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// 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);
    });


Add meta information

Meta information are hidden information related to the cells in your spreadsheet.

import { Client } from "@intrasheets/client";

// Create a new client
const client = new Client({
  // API Server
  baseUrl: "http://localhost:8009/api",
  // Your authentication token
  token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// 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);
});


Reset the meta information

The following code will reset the meta information of the whole table.

import { Client } from "@intrasheets/client";

// Create a new client
const client = new Client({
  // API Server
  baseUrl: "http://localhost:8009/api",
  // Your authentication token
  token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

// Reset
spreadsheet.resetMeta().then(() => {
    // It worked correctly
})
.catch((err) => {
    // Something went wrong
    console.log(err);
});