Worksheets

Programmatically changes on the worksheet level are available through the following operations.

Documentation

createWorksheet

Create a new worksheet.

Parameter Description
options Worksheet options.

POST /api/:guid/worksheet

renameWorksheet

Rename the worksheet.

Parameter Description
worksheet Worksheet position.
newValue New title.

POST /api/:guid/worksheet/rename

moveWorksheet

Move a worksheet position.

Parameter Description
from Worksheet position.
to New position.

POST /api/:guid/worksheet/move

deleteWorksheet

Delete a worksheet by its position.

Parameter Description
worksheetPosition Worksheet position.

DELETE /api/:guid/worksheet/:worksheetPosition

Examples

Create a new worksheet

The worksheet position and unique-id is returned.

const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };

// Create a new worksheet. @See Jspreadsheet documentation for more options
const result = await (await fetch(`${baseUrl}/${guid}/worksheet`, {
    method: 'POST',
    headers,
    body: new URLSearchParams({
        'options[worksheetName]': 'New worksheet',
        'options[minDimensions][0]': '10',
        'options[minDimensions][1]': '10',
    }),
})).json();

console.log(result);

Rename worksheet

How to rename a remote worksheet.

const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };

// Rename the first worksheet
await fetch(`${baseUrl}/${guid}/worksheet/rename`, {
    method: 'POST',
    headers,
    body: new URLSearchParams({
        'worksheet': '0',
        'newValue': 'New title for the first worksheet',
    }),
});

Update worksheet position

How to change the worksheet order on a remote spreadsheet.

const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };

// Move the second worksheet to the first position
await fetch(`${baseUrl}/${guid}/worksheet/move`, {
    method: 'POST',
    headers,
    body: new URLSearchParams({
        'from': '1',
        'to': '0',
    }),
});

Delete worksheet

How to delete a remote worksheet.

const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };

// Delete the first worksheet
await fetch(`${baseUrl}/${guid}/worksheet/0`, {
    method: 'DELETE',
    headers,
});