Spreadsheet

The following methods helps with the management of basic spreadsheet features.

Documentation

Methods

The following methods are available to interact with the spreadsheet headers programmatically.
MethodDescription
getSpreadsheet Get a Jspreadsheet object. This is an internal method of the client api and does not reflect any changes to the spreadsheet.
getSpreadsheet(guid: string, worksheetIndex?: number): IJspreadsheet
@param guid - spreadsheet guid.
@param worksheetIndex - worksheet position.
create Create a new spreadsheet and return its Jspreadsheet object.
create(options?: {
description?: string;
config?: Partial<Spreadsheet> | Partial<Worksheet>;
}) : Promise<IJspreadsheet>

@param options[].description - new spreadsheet name.
@param options[].config - new spreadsheet settings.

POST /api/create
listSpreadsheets List spreadsheets owned by the user.
listSpreadsheets(): Promise<
{
sheet_guid: string;
sheet_description: string;
sheet_updated: string;
sheet_status: number;
sheet_privacy: number;
}[]
>
delete Delete a existing spreadsheet.
delete() : Promise<void>

DELETE /api/:guid
getPrivacy Get spreadsheet privacy.
getPrivacy(): Promise<privacyEnum>;

GET /api/:guid/privacy
setPrivacy Change spreadsheet privacy.
setPrivacy(privacy: privacyEnum): Promise<void>
@param privacy - privacy number.

POST /api/:guid/privacy
setName Set the title of the spreadsheet.
setName(name?: string): Promise<void>
@param name - new title of the spreadsheet.

POST /api/:guid/spreadsheet


Examples

Create spreadsheet

Creating new spreadsheets.


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

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Create the client instance
$client = new Jspreadsheet($token);

// Options for the new worksheet @See Jspreadsheet documentation for more options
$options = [
    'minDimensions' => [10, 10]
];

// Create a new worksheet
$data = $client->create($options);


// Array ( [success] => 1 [token] => 5c609bcc-1b79-48a8-8f2c-5b89572c7d6f  )

import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Create a new client instance
const client = new Client({ token });

// Options for the new spreadsheet @See Jspreadsheet documentation for more options
const config = {
    minDimensions: [10, 10],
};

// Create a new spreadsheet
client.create({ config }).then((newSpreadsheet) => {
    console.log(newSpreadsheet);
});

List spreadsheets

PHP
NodeJS

import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Create a new client
const client = new Client({ token });

client.listSpreadsheets().then((result) => {
    // User spreadsheets
    console.log(result);
});

Delete spreadsheet

Removing spreadsheets.


PHP
NodeJS

import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client({ token });

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

spreadsheet.delete().then(() => {
    console.log('Spreadsheet removed');
});

Get Privacy

Getting spreadsheet privacy.


PHP
NodeJS

import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client({ token });

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

spreadsheet.getPrivacy().then((privacy) => {
    console.log(privacy);
});

Set Privacy

Setting spreadsheet privacy.


PHP
NodeJS

import { Client } from '@jspreadsheet/client';
import { privacyEnum } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client({ token });

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

spreadsheet.setPrivacy(privacyEnum.Private).then(() => {
    console.log("Privacy changed");
});

Set Name

Setting spreadsheet name.


PHP
NodeJS

import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client({ token });

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

spreadsheet.setName("New name").then(() => {
    console.log("Name changed");
});