Merged cells
It is possible to define the merged cells during the spreadsheet initialization or programmatically as follow:
The following methods are available for merge cells management: setMerge, getMerge, removeMerge, destroyMerged
<html>
<script src="https://jspreadsheet.com/v7/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v7/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<div id="spreadsheet"></div>
<textarea id="log"></textarea><br/>
<script>
let data = [
['Mazda', 2001, 2000, '2006-01-01'],
['Pegeout', 2010, 5000, '2005-01-01'],
['Honda Fit', 2009, 3000, '2004-01-01'],
['Honda CRV', 2010, 6000, '2003-01-01'],
];
let table = jspreadsheet(document.getElementById('spreadsheet'), {
data:data,
colHeaders: ['Model', 'Year', 'Price', 'Date'],
colWidths: [ 300, 80, 100, 100 ],
columns: [
{ type: 'text' },
{ type: 'text' },
{ type: 'text' },
{ type: 'calendar' },
],
mergeCells:{
A1:[2,1]
},
minDimensions:[10,10],
license: 'Yzk3YTUwYjFiNTczMzg3MGY2ZmI4ZDE4NDNjZTEwNmJmMWM0NDE2MDA3NTMxNTFhMjQzYzJhN2EwZmM5ZGE2ZGIzM2QxNDVmMGU5MjExNzIxYmNkMmFiYzcxMDJhNWY1ZWJhMDUxOGU0M2Y3MWIxODI1YTJiMWM0YmJmNWUyZmYsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpJNE1qa3pPVGs1TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==',
});
document.getElementById("setmerge").onclick = () => table.setMerge('A3', 2, 3);
document.getElementById("removemerge").onclick = () => table.removeMerge('A3');
document.getElementById("getmerge").onclick = () => {
document.getElementById("log").innerHTML = JSON.stringify(table.getMerge());
}
</script>
<input type="button" value="setMerge('A3', 2, 3)" id="setmerge" />
<input type="button" value="removeMerge('A3')" id="removemerge" />
<input type="button" value="Get all merged cells" id="getmerge" />
</html>