Spreadsheet cells

The cells methods allows the developer to perform read and write cell operations in their online spreadsheets.

Documentation

Methods

The following methods are available to interact with the spreadsheet cells programmatically.

Method Description
getData Get the data from the spreadsheet
getData() : void

GET /api/data
setdATA Set a new data for your spreadsheet
setData(data: any[]) : void
@Param {array} - new data

POST /api/data

Cell values

Update a cell value

import { Client } from '@intrasheets/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 the new value
spreadsheet.setValue([{
    x: 2,
    y: 3,
    value: "New value",
},
]).then(() => {
    // It worked correctly
}).catch((err) => {
    console.log(err);
});

Retrieve cell values

You can request the data in a spreadsheet by defining a single cell, an array of cells or a range of cells, as below:

Get values from cells

It is possible to retrieve the value from one or multiple cells in a single request.

import { Client } from '@intrasheets/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 values
spreadsheet.getValue("C4,D4,D5").then((values) => {
    console.log(values);
});

// [
//     {
//         x: 2,
//         y: 3,
//         name: "C4",
//         value: "C4",
//     },
//     {
//         x: 3,
//         y: 3,
//         name: "D4",
//         value: null,
//     },
//     {
//         x: 3,
//         y: 4,
//         name: "D5",
//         value: null,
//     },
// ]

Read the data from multiple cells by range

import { Client } from '@intrasheets/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 values
spreadsheet.getValue("C1:C2").then((values) => {
    console.log(values);
});

// [
//     {
//         x: 2,
//         y: 0,
//         name: "C1",
//         value: null,
//     },
//     {
//         x: 2,
//         y: 1,
//         name: "C2",
//         value: null,
//     },
// ]