Skip to content

Commit

Permalink
fix mergecell bug in table
Browse files Browse the repository at this point in the history
  • Loading branch information
Aserus authored Mar 22, 2018
1 parent 8ee71b8 commit 3c3ef56
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,8 @@ module.exports = (function() {
Workbook.prototype.pushDown = function(workbook, sheet, tables, currentRow, numRows) {
var self = this;

var mergeCells = sheet.find("mergeCells");

// Update merged cells below this row
sheet.findall("mergeCells/mergeCell").forEach(function(mergeCell) {
var mergeRange = self.splitRange(mergeCell.attrib.ref),
Expand All @@ -1020,6 +1022,22 @@ module.exports = (function() {
});

}


//add new merge cell
if (mergeStart.row == currentRow) {
for (var i = 1; i <= numRows; i++) {
var newMergeCell = self.cloneElement(mergeCell);
mergeStart.row += 1;
mergeEnd.row += 1;
newMergeCell.attrib.ref = self.joinRange({
start: self.joinRef(mergeStart),
end: self.joinRef(mergeEnd)
});
mergeCells.attrib.count += 1;
mergeCells._children.push(newMergeCell);
}
}
});

// Update named tables below this row
Expand Down

0 comments on commit 3c3ef56

Please sign in to comment.