Columns

The following methods are available for column operations.

Documentation

insertColumn

Add one or more columns.

Parameter Description
columns Position, data and options of new columns.

POST /api/:guid/:worksheetIndex/columns/insert

moveColumn

Move one or more columns.

Parameter Description
from Index of the first column to be moved.
to Index where columns should be moved to.
quantity Number of columns to be moved.

POST /api/:guid/:worksheetIndex/columns/move

deleteColumn

Remove one or more columns.

Parameter Description
columns Indexes of the columns that should be removed.

DELETE /api/:guid/:worksheetIndex/columns/:columnIndexes

setWidth

Define the width of one or multiple columns.

Parameter Description
column Column number(s).
width New width.

POST /api/:guid/:worksheetIndex/width

getWidth

Get the width of one or multiple columns.

Parameter Description
columns Column number. If not informed, all columns will be returned.

GET /api/:guid/:worksheetIndex/width/:columns

setColumnVisibility

Change the visibility of one or more columns.

Parameter Description
columns Affected columns.
visible Column visibility.

POST /api/:guid/:worksheetIndex/columns/show

POST /api/:guid/:worksheetIndex/columns/hide

Examples

Insert columns

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}` };

// Add a new column on the second position, with data and column properties. Position start on zero
await fetch(`${baseUrl}/${guid}/0/columns/insert`, {
    method: 'POST',
    headers,
    body: new URLSearchParams({
        'columns[0][column]': '1',
        'columns[0][data][0]': '1',
        'columns[0][data][1]': '2',
        'columns[0][data][2]': '3',
        'columns[0][data][3]': '4',
        'columns[0][data][4]': '5',
        'columns[0][options][title]': 'new A',
        'columns[0][options][type]': 'text',
    }),
});

Change a column position

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 first column to the second position
await fetch(`${baseUrl}/${guid}/0/columns/move`, {
    method: 'POST',
    headers,
    body: new URLSearchParams({
        'from': '0',
        'to': '1',
        'quantity': '1',
    }),
});

Delete columns

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 columns at indexes 0 and 2
await fetch(`${baseUrl}/${guid}/0/columns/0,2`, {
    method: 'DELETE',
    headers,
});

Column width

Define the width of a column

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}` };

// Set the width of the third column to 200px
await fetch(`${baseUrl}/${guid}/0/width`, {
    method: 'POST',
    headers,
    body: new URLSearchParams({
        'column': '2',
        'width': '200',
    }),
});

Define the width of multiple columns

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}` };

// Define the width of the forth and fifth columns to 250px
await fetch(`${baseUrl}/${guid}/0/width`, {
    method: 'POST',
    headers,
    body: new URLSearchParams({
        'column[0]': '3',
        'column[1]': '4',
        'width': '250',
    }),
});

Get the width from multiple columns

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}` };

// Get the width from the forth and fifth columns
const widths = await (await fetch(`${baseUrl}/${guid}/0/width/3,4`, { headers })).json();
console.log(widths);