1 function onLoad(e) { 2 var rows = e.data; 3 var sender = e.sender; 4 var mergecount = sender.getTotalCount() 5 var marges = new Array(); 6 var num = 1; 7 for (var i = 0; i < mergecount; i++) { 8 if (i < mergecount - 1) { 9 var k = i + 1 - num; 10 if (rows[i + 1]["ganwname"] == rows[i]["ganwname"]) { 11 num++; 12 13 //动态添加合并的参数,rowIndex开始行数(0开始),columnIndex列数(0开始),rowSpan合并的行数,colSpan合并的列数 14 marges.push({ 15 rowIndex : k, 16 columnIndex : 2, 17 rowSpan : num, 18 colSpan : 1 19 }, { 20 rowIndex : k, 21 columnIndex : 3, 22 rowSpan : num, 23 colSpan : 1 24 }); 25 26 sender.mergeCells(marges); 27 continue; 28 } 29 num = 1; 30 } 31 } 32 }