Skip to content

Commit

Permalink
Merge pull request #75 from Aserus/patch-1
Browse files Browse the repository at this point in the history
fix mergecell bug in table
  • Loading branch information
kant2002 authored May 26, 2018
2 parents f3af722 + 3c3ef56 commit bd302ea
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 @@ -1023,6 +1023,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 @@ -1039,6 +1041,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 bd302ea

Please sign in to comment.