From f7742c0f61731981ba216f952bcfe1f03fcb7daf Mon Sep 17 00:00:00 2001 From: mtyszler Date: Sun, 5 Jan 2020 16:15:51 +0100 Subject: [PATCH] According to rstudio#418, improve buttons.html5.min.js. This builds on commit 6b56d58521aeabb62f060fd3a2780f361dfc5b2f and process the col/row span information to merge the cells at the excel output via the function excelHtml5 --- .../Buttons/js/buttons.html5.min.js | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/inst/htmlwidgets/lib/datatables-extensions/Buttons/js/buttons.html5.min.js b/inst/htmlwidgets/lib/datatables-extensions/Buttons/js/buttons.html5.min.js index fe89fcdf..fbaacf44 100644 --- a/inst/htmlwidgets/lib/datatables-extensions/Buttons/js/buttons.html5.min.js +++ b/inst/htmlwidgets/lib/datatables-extensions/Buttons/js/buttons.html5.min.js @@ -444,16 +444,114 @@ p.title && (r([p.title], g), k(g, /*d.header.length*/ d.header[d.header.length - 1].length - 1)); p.messageTop && (r([p.messageTop], g), k(g, /*d.header.length*/ d.header[d.header.length - 1].length - 1)); + /* ----- BEGIN added Code ----- */ //c.header && (r(d.header, g), i("row:last c", e).attr("s", "2")); if(c.header){ + row_start_headers = g; for (o = 0; o < d.header.length; o++){ r(d.header[o], g); i("row:last c", e).attr("s", "2"); } } + // process merged cells: + var mgCnt = 0; + var merges=[]; + if (c.header) { + //for each header row + for(o=0; o < d.header.length; o++) + { + //for each column (cell) in the row + for(oj=0; oj startCol){ //end column + merges[mgCnt] = merges[mgCnt] + ":" + eC; + } else { + merges[mgCnt] = merges[mgCnt] + ":" + sC; + } + + if(endRow > startRow) { //end row + merges[mgCnt] = merges[mgCnt] + eR; + } else { + merges[mgCnt] = merges[mgCnt] + sR; + } + + mgCnt++; //increment number of merge ranges + } + } + } + } + } + + + if (mgCnt > 0) { + //add each merge range as a child + var oc = i("mergeCells", e); + for(o=0;o