Merged cells

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

Documentation


Methods

Available methods for cell comments management.
MethodDescription
getMerge Get the merged cell information.
@param cellNames - cell names and/or ranges.

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

GET /api/:guid/merge
setMerge Merge cells.
@param merge.cellName - cell where the merge starts.
@param merge.colspan - number of columns that this merge occupies.
@param merge.rowspan - number of rows that this merge occupies.
@param merge.force - if true, merges that conflict with this one will be removed.

Jspreadsheet setMerge(merge: { cellName: string, colspan: number, rowspan: number, force?: boolean }): Promise<void>

POST /api/:guid/merge
setMerge Merge cells.
@param merges[].cellName - cell where the merge starts.
@param merges[].spans[0] - number of columns that this merge occupies.
@param merges[].spans[1] - number of rows that this merge occupies.

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

POST /api/:guid/merge
removeMerge Revert merged cells to normal visualization.
@param cellName - cell name.

Jspreadsheet removeMerge(cellName: string): Promise<void>

DELETE /api/:guid/merge
resetMerge Revert all merged cells to normal visualization.
Jspreadsheet resetMerge(): Promise<void>

DELETE /api/:guid/merge


Examples


Get merge cells

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 merge information A1,A2,A3 or A1:A3 for multiple cells
spreadsheet.getMerge("A1").then((merges) => {
    console.log(merges)
});

// {
//     A1: [2, 2],
// }


Set merge cells

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);

// Merge of A1 with B1, A2 and B2: (Colspan and Rowspan From A1)
spreadsheet.setMerge([{ cellName: "A1", spans: [2, 2] }]).then(() => {
    // It worked correctly
})
.catch((err) => {
    // Something went wrong
    console.log(err);
});


Reset merged cells

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);

// Remove merge
spreadsheet.removeMerge("A1").then(() => {
    // It worked correctly
})
.catch((err) => {
    // Something went wrong
    console.log(err);
});


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);

// Reset
spreadsheet.resetMerge().then(() => {
    // It worked correctly
})
.catch((err) => {
    // Something went wrong
    console.log(err);
});