-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Added insert rows functionality #1291
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
Added insert rows functionality #1291
Conversation
Merge pull request exceljs#1289 from Subhajitdas298/master
Resolved conflict with latest master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 quick comments - but the PR looks good!
We just did a group review - once those two points are addressed, this is good to go 👍 |
Added option to inherit style for addRow/s and insertRow/s without affecting existing implementations. Added test cases for same. |
@alubbe Please review the latest changes. Thanks |
@alubbe Please review my recent changes and provide latest review. Thank you |
|
||
insertRows(pos, values, styleOption = 'n') { | ||
this.spliceRows(pos, 0, ...values); | ||
if (styleOption !== 'n') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Siemienik I remember we had a discussion around cloning/copying style objects - could you review this part of the new code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the best idea to maintain style's is change logic of setters to use Object.freez and copy values there. ( When any setter style is being used then all style object should be copy and freez)
I didn't know yet how this solution impact to this pr.
For instance:
set fill(fill){
style = Object.freez({ ...style, fill:Object.freez(fill)});
}
(Written on smartfon - sorry for any mistake)
Edit: this will made styles immutable and protect us
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style setting logic is based on already existing logic in splice method.
rDst.style = rSrc.style; // eslint-disable-next-line no-loop-func rSrc.eachCell({includeEmpty: true}, (cell, colNumber) => { rDst.getCell(colNumber).style = cell.style; }); rDst.height = rSrc.height;
Are you suggesting something like, this:
rDst.style = Object.freeze({...rSrc.style}); // eslint-disable-next-line no-loop-func rSrc.eachCell({includeEmpty: true}, (cell, colNumber) => { rDst.getCell(colNumber).style = Object.freeze({...cell.style}); }); rDst.height = rSrc.height;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Siemienik are you saying, to do it like this:
rDst.getCell(colNumber).style = Object.freeze({...cell.style}); });
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Siemienik the existing property specific setter actual logic is in "_applyStyle" in row.js and again in cell's setter. This is not using Object.freeze yet. This may be added in another PR.
This pr directly copies style internally, just like spilceRows.
I have update the copy logic with Object.freeze as you told.
@Siemienik @alubbe Please review. Thank you.
The new changes look great - just left a comment regarding the copying of styles, let's see what @Siemienik has to say |
Summary
Added convenience method to insert any rows in between existing rows.
Test plan
Added 3 new test cases for insert row.