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.
getMerge(
cellNames?: string
): Promise<{ [cellName: string]: [number, number] }>

@param cellNames - cell names and/or ranges.

GET /api/:guid/merge
setMerge Merge cells.
setMerge(merge: {
cellName: string;
colspan: number;
rowspan: number;
force?: boolean;
}): Promise<void>

@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.

POST /api/:guid/merge
setMerge Merge cells.
setMerge(
merges: { cellName: string; spans: [number, number] }[]
): Promise<void>

@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.

POST /api/:guid/merge
removeMerge Revert merged cells to normal visualization.
removeMerge(cellName: string): Promise<void>
@param cellName - cell name.

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

DELETE /api/:guid/merge


Examples

Get merge cells

Read merged cells information

NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
const client = new Client(token);

// 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],
// }
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Get merge information
$result = $spreadsheet->getMerge('A1');

// Result
print_r($result);

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


Set merge cells

Defining the merging of cells

NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
const client = new Client(token);

// 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);
});
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Merge of A1 with B1, A2 and B2:
$result = $spreadsheet->setMerge('A1', 2, 2); // Colspan and Rowspan From A1

// Result
print_r($result);

// {"success":1,"message":"Updated"}


Reset merged cells

Revert a merged cells to regular cells.


NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
const client = new Client(token);

// 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);
});
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Remove merge
$result = $spreadsheet->removeMerge('A1');

// Result
print_r($result);

// {"success":1,"message":"Updated"}

Reset all merged cells


NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
const client = new Client(token);

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

// Reset
spreadsheet.resetMerge().then(() => {
    // It worked correctly
})
.catch((err) => {
    // Something went wrong
    console.log(err);
});
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Reset
$result = $spreadsheet->resetMerge();

// Result
print_r($result);

// {"success":1,"message":"Updated"}