Merged cells
Manage merged cells of your online spreadsheets using the following methods.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”Available methods for cell comments management.
| Method | Description |
|---|---|
| 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
Section titled “Examples”Get merge cells
Section titled “Get merge cells”Read merged cells information
import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Get merge information A1,A2,A3 or A1:A3 for multiple cellsspreadsheet.getMerge("A1").then((merges) => { console.log(merges)});
// {// A1: [2, 2],// }Set merge cells
Section titled “Set merge cells”Defining the merging of cells
import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst 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
Section titled “Reset merged cells”Revert a merged cells to regular cells.
import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Remove mergespreadsheet.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 clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Resetspreadsheet.resetMerge().then(() => { // It worked correctly}).catch((err) => { // Something went wrong console.log(err);});