add display
attribute to hyperlinks
#2791
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
This resolves an import issue with Google Sheets where the cell's text content is lost. On import, Sheets converts hyperlinks to a
HYPERLINK
formula. When the<hyperlink>
lacks adisplay
attribute, it drops the text content of the cell and replaces it with the location of the hyperlink.Example
An XLSX with the following
<hyperlink>
:When imported into Google Sheets,
E2
becomes:Change
This change automatically sets the
display
attribute of a<hyperlink>
based on the cell's value.I don't see much of a reason to expose the
display
attribute in the API like theTooltip
property, since it "should" always be the cell's value.I've only made this change to the XLSX format renderer. Contributions for XLSB and other formats, tests, and feedback on my implementation are welcome.
Quirks Observed
When opening an XLSX in Excel generated by this package (before this PR), Excel natively sets the
display
attribute of all<hyperlink>
s on save, even if they previously did not have this attribute.Excel will render the underlying text content of the cell and ignores the
display
attribute of the<hyperlink>
, even if they differ. Google Sheets clobbers the text content and only uses thedisplay
attribute to set theHYPERLINK
formula's link label.