Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix merge cells style problem when using table substitution #174

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,8 @@ module.exports = (function() {
var self = this,
newCellsInserted = 0; // on the original row

const mergeCell = self.sheet.root.findall("mergeCells/mergeCell").find(c => self.splitRange(c.attrib.ref).start === cell.attrib.r)

// if no elements, blank the cell, but don't delete it
if(substitution.length === 0) {
delete cell.attrib.t;
Expand Down Expand Up @@ -1137,6 +1139,23 @@ module.exports = (function() {

// Add the cell that previously held the placeholder
newRow.append(newCell);

if(mergeCell) {
var mergeRange = self.splitRange(mergeCell.attrib.ref),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use let instead of var and make each variable as separate variable on individual line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! I'll work on it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a chance to work on the suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
Thanks for very useful library.
I really need this feature.
Can I know why not merged yet?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muyoungko can I assume that you take care of this scenario in #188 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes~

mergeStart = self.splitRef(mergeRange.start),
mergeEnd = self.splitRef(mergeRange.end);
for (let colNum = self.charToNum(mergeStart.col) + 1; colNum <= self.charToNum(mergeEnd.col); colNum++) {
const lastRow = self.sheet.root.find('sheetData').getItem(mergeStart.row - 1)
const upperCell = lastRow.getItem(colNum - 1)

const cell = self.cloneElement(upperCell);
cell.attrib.r = self.joinRef({
row: newRow.attrib.r,
col: self.numToChar(colNum)
});
newRow.append(cell);
}
}
}

// expand named table range if necessary
Expand Down