Merged cells
Manage merged cells of your online spreadsheets using the following routes.
Documentation
getMerge
Get the merged cell information.
| Parameter | Description |
|---|---|
cellNames |
Cell names and/or ranges. |
GET /api/:guid/:worksheetIndex/merge/:cellNames
setMerge
Merge cells.
| Parameter | Description |
|---|---|
merge.cellName |
Cell where the merge starts. |
merge.spans |
Number of columns and rows that this merge occupies. |
POST /api/:guid/:worksheetIndex/merge
removeMerge
Revert merged cells to normal visualization.
| Parameter | Description |
|---|---|
cellNames |
Cell names. |
DELETE /api/:guid/:worksheetIndex/merge/:cellNames
resetMerge
Revert all merged cells to normal visualization.
DELETE /api/:guid/:worksheetIndex/merge
Examples
Get merge cells
Read merged cells information
const baseUrl = 'http://localhost:8009/api';
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const headers = { 'Authorization': `Bearer ${token}` };
// Get merge information. Use A1,A2,A3 or A1:A3 for multiple cells
const merges = await (await fetch(`${baseUrl}/${guid}/0/merge/A1`, { headers })).json();
console.log(merges);
Set merge cells
Defining the merging of cells
const baseUrl = 'http://localhost:8009/api';
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const headers = { 'Authorization': `Bearer ${token}` };
// Merge of A1 with B1, A2 and B2: (Colspan and Rowspan From A1)
await fetch(`${baseUrl}/${guid}/0/merge`, {
method: 'POST',
headers,
body: new URLSearchParams({
'merge[0][cellName]': 'A1',
'merge[0][spans][0]': '2',
'merge[0][spans][1]': '2',
}),
});
Reset merged cells
Revert a merged cells to regular cells.
const baseUrl = 'http://localhost:8009/api';
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const headers = { 'Authorization': `Bearer ${token}` };
// Remove merge from A1
await fetch(`${baseUrl}/${guid}/0/merge/A1`, {
method: 'DELETE',
headers,
});
Reset all merged cells
const baseUrl = 'http://localhost:8009/api';
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const headers = { 'Authorization': `Bearer ${token}` };
// Reset all merged cells
await fetch(`${baseUrl}/${guid}/0/merge`, {
method: 'DELETE',
headers,
});