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. Jworksheet getMerge(cellNames?: string): Promise<{ [cellName: string]: [number, number]; }> GET /api/:guid/:worksheetIndex/merge/:cellNames |
| setMerge | Merge 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 |
| removeMerge | Revert merged cells to normal visualization. @param cellNames - cell names. Jworksheet removeMerge(cellNames: string): Promise<void> DELETE /api/:guid/:worksheetIndex/merge/:cellNames |
| resetMerge | Revert all merged cells to normal visualization.Jworksheet resetMerge(): Promise<void> DELETE /api/:guid/:worksheetIndex/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 Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Get merge information A1,A2,A3 or A1:A3 for multiple cellsworksheet.getMerge("A1").then((merges) => { console.log(merges);});curl -X GET "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/merge/A1" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"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);
// Get Jworksheet objectconst 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); });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] } ] }'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);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Remove mergeworksheet .removeMerge("A1") .then(() => { // It worked correctly }) .catch((err) => { // Something went wrong console.log(err); });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 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 Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Resetworksheet .resetMerge() .then(() => { // It worked correctly }) .catch((err) => { // Something went wrong console.log(err); });curl -X DELETE "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/merge" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"