Skip to content

Fixed undefined ref error when setting a data validation that is a range of cells at the worksheet level #1480

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

Merged
merged 2 commits into from
Oct 1, 2020

Conversation

Bene-Graham
Copy link
Contributor

Fixed undefined ref error when setting a data validation that is a range of cells at the worksheet level

Summary

In the case where a data validation is set at the worksheet level with a range of cells "A1:A100" the error Cannot set property 'marked' of undefined would occur.

From what I could tell the original code would call const addr = colCache.decodeAddress(dv.address); this would return the value "A1" in the case of the following "A1:A100". Later on in the code it would try to mark "A1" dvMap[otherAddress].marked = true;, but in the dvMap it would be "A1:A100" and the error occurs.

I changed decodeAddress to decodeEx so that we can detect if the address is a single cell vs a range(dimension?). If a dimensions property exist on the return object from decodeEx, it will shortcircuit and use the range.

Test plan

I added a integration test demonstrating it now works with no error: spec/integration/issues/issue-1027-sheet-defined-data-validate.spec.js

@Bene-Graham
Copy link
Contributor Author

One additional thing I believe this will solve the following issue: #1109 and #1027

Copy link
Member

@alubbe alubbe left a comment

Choose a reason for hiding this comment

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

Thank you for this PR, I just have some minor modifications that I'd like to see and then we're good to go

Copy link
Member

@alubbe alubbe left a comment

Choose a reason for hiding this comment

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

thank you!

@alubbe alubbe merged commit ab776ef into exceljs:master Oct 1, 2020
@Bene-Graham Bene-Graham deleted the fix-bug-1027 branch October 1, 2020 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants