Merged cells

You can merge cells on your spreadsheet in the table initialization or programatically as follow:


The following methods are available for merge cells management: setMerge, getMerge, removeMerge, destroyMerged





Source code

<html>
<script src="https://bossanova.uk/jspreadsheet/v3/jexcel.js"></script>
<script src="https://jsuites.net/v3/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jspreadsheet/v3/jexcel.css" type="text/css" />
<link rel="stylesheet" href="https://jsuites.net/v3/jsuites.css" type="text/css" />

<div id="spreadsheet"></div>

<script>
var 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'],
];

var table = jexcel(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]
});
</script>

<button type="button" onclick="table.setMerge('A3', 2, 2);">Merge cell A3 (colspan: 2, rowspan: 2)</button>
<button type="button" onclick="table.removeMerge('A3');">Destroy merge from A3</button>
<button type="button" onclick="document.getElementById('console').innerHTML = JSON.stringify(table.getMerge());">Get all merged cells</button>
<button type="button" onclick="table.destroyMerged();">Destroy all merged</button>

</html>