Skip to content

Columns

The following methods are available for column operations.

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

MethodDescription
insertColumnAdd one or more columns.
@param columns - position, data and options of new columns.

Jworksheet insertColumn(columns: { column: number; data?: (string | number | boolean)[]; options?: Record<string, any>; }[]): Promise<void>

POST /api/:guid/:worksheetIndex/columns/insert
moveColumnMove one or more columns.
@param from - Index of the first column to be moved.
@param to - Index where columns should be moved to.
@param quantity - Number of columns to be moved.

Jworksheet moveColumn(from: number, to: number, quantity: number): Promise<void>

POST /api/:guid/:worksheetIndex/columns/move
deleteColumnRemove one or more columns.
@param columns - Indexes of the columns that should be removed.

Jworksheet deleteColumn(columns: number[]): Promise<void>

DELETE /api/:guid/:worksheetIndex/columns/:columnIndexes
setWidthDefine the width of one or multiple columns.
@param column - column number(s).
@param width - new width.

Jworksheet setWidth(column: number, width: number): Promise<void>
Jworksheet setWidth(column: number[], width: number | number[]): Promise<void>

POST /api/:guid/:worksheetIndex/width
getWidthGet the with of one or multiple columns.
@param columns - column number. If not informed, all columns will be returned.

Jworksheet getWidth(columns?: number | number[] : Promise<{ [columnNumber: string]: number; }>
Jworksheet getWidth(columns?: undefined): Promise<number[]>;

GET /api/:guid/:worksheetIndex/width/:columns
setColumnVisibilityChange the visibility of one or more columns.
@param columns - affected columns.
@param visible - column visibility.

Jworksheet setColumnVisibility(columns: number | number[], visible: boolean): Promise<void>

POST /api/:guid/:worksheetIndex/columns/show
POST /api/:guid/:worksheetIndex/columns/hide
import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Column data
const data = ["1", "2", "3", "4", "5"];
// Column properties
const options = {
title: "new A",
type: "text",
};
// Add a new column on the second position. Position start on zero
worksheet.insertColumn([{
column: 1,
data,
options,
}]).then(() => {
// It worked correctly
});
Terminal window
curl -X POST "http://localhost:8009/api/15eb1171-5a64-45bf-be96-f52b6125a045/0/columns/insert" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \
-H "Content-Type: application/json" \
-d '{
"columns": [
{
"column": 1,
"data": ["1", "2", "3", "4", "5"],
"options": {
"title": "new A",
"type": "text"
}
}
]
}'
import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Move the first column to the second position
worksheet.moveColumn(0, 1, 1).then(() => {
// It worked correctly
});
Terminal window
curl -X POST "http://localhost:8009/api/15eb1171-5a64-45bf-be96-f52b6125a045/0/columns/move" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \
-H "Content-Type: application/json" \
-d '{
"from": 0,
"to": 1,
"count": 1
}'
import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Delete first column
worksheet.deleteColumn([0, 2]).then(() => {
// It worked correctly
});
Terminal window
curl -X DELETE "http://localhost:8009/api/15eb1171-5a64-45bf-be96-f52b6125a045/0/columns/0,2" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"
import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Set the position of the third column to 200px
worksheet
.setWidth(2, 200)
.then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
Terminal window
curl -X POST "http://localhost:8009/api/15eb1171-5a64-45bf-be96-f52b6125a045/0/width" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \
-H "Content-Type: application/json" \
-d '{
"column": 2,
"width": 200
}'
import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Define the width of the forth and fifth columns to 250px
worksheet
.setWidth([3, 4], 250)
.then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
Terminal window
curl -X POST "http://localhost:8009/api/15eb1171-5a64-45bf-be96-f52b6125a045/0/width" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \
-H "Content-Type: application/json" \
-d '{
"columns": [3, 4],
"width": 250
}'
import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Get the width from multiple columns
worksheet.getWidth([3, 4]).then((widths) => {
console.log(widths);
});
Terminal window
curl -X GET "http://localhost:8009/api/15eb1171-5a64-45bf-be96-f52b6125a045/0/width/3,4" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"