Skip to content

Columns

The following methods are available for column operations.

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

MethodDescription
insertColumnAdd a new column.
@param options.data - new column data.
@param options.properties - new column properties.
@param options.insertBefore - insert before or after the reference column.
@param options.numOfColumns - number of columns to insert.
@param options.columnNumber - reference column for insert.

Jspreadsheet insertColumn(options: { data?: string[][], properties?: Column[], insertBefore?: boolean, numOfColumns: number, columnNumber?: number }): Promise<void>

POST /api/:guid/columns
moveColumnChange the column position.
@param from - column number.
@param to - to the position.

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

POST /api/:guid/columns/move
deleteColumnDelete one or multiple columns.
@param columnNumber - column number.
@param numOfColumns - number of columns. The default is 1.

Jspreadsheet deleteColumn(columnNumber: number, numOfColumns?: number): Promise<void>
POST /api/:guid/columns/delete
setWidthDefine the width of one or multiple columns.
@param column - column number(s).
@param width - new width.

`Jspreadsheet setWidth(column: number
getWidthGet the with of one or multiple columns.
@param columns - column number. If not informed, all columns will be returned.

`Jspreadsheet getWidth(columns?: number
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);
// Insert before flag
const insertBefore = true;
// Column properties
const properties = [{
title: "new A",
type: "text",
}];
// Add a new column on the second position. Position start on zero
spreadsheet.insertColumn({
columnNumber: 1,
numOfColumns: 1,
insertBefore,
properties,
}).then(() => {
// It worked correctly
}).catch((err) => {
// Something went wrong
console.log(err);
});
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);
// Insert before flag
const insertBefore = false;
// Column properties
const properties = [
{
title: "new A",
type: "text",
},
];
// Add a new column at the end
spreadsheet.insertColumn({
numOfColumns: 1,
insertBefore,
properties,
}).then(() => {
// It worked correctly
}).catch((err) => {
// Something went wrong
console.log(err);
});
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);
// Move the first column to the second position
spreadsheet.moveColumn(0, 1).then(() => {
// It worked correctly
}).catch((err) => {
// Something went wrong
console.log(err);
});

Delete the column from a specific position

Section titled “Delete the column from a specific position”
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);
// Delete first column
spreadsheet.deleteColumn(0).then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
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);
// Delete the first 2 columns
spreadsheet.deleteColumn(0, 2).then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
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);
// Set the position of the third column to 200px
spreadsheet.setWidth(2, 200).then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
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);
// Define the width of the forth and fifth columns to 250px
spreadsheet.setWidth([3, 4], 250).then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
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 the width from multiple columns
spreadsheet.getWidth([3, 4]).then((widths) => {
console.log(widths);
});
// {
// "3": 250,
// "4": 250,
// }