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.
MethodDescription
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


update cell example

NodeJS
PHP
<?php
require 'vendor/autoload.php';

// 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 spreadsheet instance and request configuration
$result = $spreadsheet->getCell('C4')->setValue('New value');

// { "success": 1, "message": "Updated" }
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 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.

NodeJS
PHP
<?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 spreadsheet instance and request configuration
$result = $spreadsheet->getCell('C4,D4,D5')->getValue();

// [{"x":2,"y":3,"name":"C4","value":"C4"},{"x":3,"y":3,"name":"D4","value":null},{"x":3,"y":4,"name":"D5","value":null}]
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 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


NodeJS
PHP
<?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 spreadsheet instance and request configuration
$result = $spreadsheet->getCell('C1:C2')->getValue();

// [{"x":2,"y":0,"name":"C1","value":null},{"x":2,"y":1,"name":"C2","value":null}]
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 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,
//     },
// ]