In a Google docs spreadsheet. If cells A1 & A2 are merged, is there a way to confirm they are merged, using google apps script?
There is a merge function in GAS
There seems to be a workaround exploiting the fact that merged cells always return a white background. The code below appears to work for me; I will appreciate it if anyone can confirm.
function testMerged() {
var WHITE = '#ffffff';
var NON_WHITE = '#fffffe';
var range = SpreadsheetApp.getActiveSheet().getDataRange();
range.setBackground(NON_WHITE);
range.getBackgrounds().forEach(function (row, rowNum) {
row.forEach(function (col, colNum) {
if (col === WHITE) { Logger.log('Cell merged at row ' + rowNum + ' col ' + colNum); }
});
});
range.setBackground(WHITE);
}