Skip to content

Merged cells

Manage merged cells of your online spreadsheets using the following methods.

Available methods for cell comments management.

MethodDescription
getMergeGet the merged cell information.
@param cellNames - cell names and/or ranges.

Jworksheet getMerge(cellNames?: string): Promise<{ [cellName: string]: [number, number]; }>

GET /api/:guid/:worksheetIndex/merge/:cellNames
setMergeMerge cells.
@param merge.cellName - cell where the merge starts.
@param merge.spans - number of columns and rows that this merge occupies.

Jworksheet setMerge(merges: { cellName: string; spans: [number, number]; } | { cellName: string; spans: [number, number]; }[]): Promise<void>

POST /api/:guid/:worksheetIndex/merge
removeMergeRevert merged cells to normal visualization.
@param cellNames - cell names.

Jworksheet removeMerge(cellNames: string): Promise<void>

DELETE /api/:guid/:worksheetIndex/merge/:cellNames
resetMergeRevert all merged cells to normal visualization.

Jworksheet resetMerge(): Promise<void>

DELETE /api/:guid/:worksheetIndex/merge

Read merged cells information

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 = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Get merge information A1,A2,A3 or A1:A3 for multiple cells
worksheet.getMerge("A1").then((merges) => {
console.log(merges);
});
Terminal window
curl -X GET "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/merge/A1" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"

Defining the merging of cells

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 = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Merge of A1 with B1, A2 and B2: (Colspan and Rowspan From A1)
worksheet
.setMerge([{ cellName: "A1", spans: [2, 2] }])
.then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
Terminal window
curl -X POST "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/merge" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \
-H "Content-Type: application/json" \
-d '{
"merge": [
{
"cellName": "A1",
"spans": [2, 2]
}
]
}'

Revert a merged cells to regular cells.

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 = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Remove merge
worksheet
.removeMerge("A1")
.then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
Terminal window
curl -X DELETE "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/merge/A1" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"

Reset all merged cells

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 = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet object
const worksheet = spreadsheet.getWorksheet(0);
// Reset
worksheet
.resetMerge()
.then(() => {
// It worked correctly
})
.catch((err) => {
// Something went wrong
console.log(err);
});
Terminal window
curl -X DELETE "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/merge" \
-H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"