add display
attribute to hyperlinks
#2791
No reviewers
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#2791
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "patch-1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.Google Sheets does not currently import XLSB but does import XLS (so we'd need to check that behavior, but that can happen in a different issue/PR)
External links seem to work without the attribute in Google Sheets (you can try the examples on https://docs.sheetjs.com/docs/csf/features/hyperlinks) but we can reproduce the issue with internal links.
Did you test if the patch works with same-sheet links (e.g.
ws["C1"].l = { Target: "#E2" };
)Testing today (2022-09-23):
mailto
links work without display