-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
The SetCellHyperlink method doesn't allow you to set the display value of the hyperlink. Instead, the library expects us to set the cell value separately to act as the link text. This works fine when using Excel or LibreOffice to view the generated xlsx, but Google Sheets only checks the hyperlink's display value when trying to get the cell text, and falls back to displaying the link location if unset. This means that excelize spreadsheets imported into Google Sheets display wrongly (see below).
For some reason, this only seems to affect location hyperlinks and not external hyperlinks.
Opening the produced file in Excel, saving without making any changes, then importing into Google Sheets causes the link text to work, as Microsoft Excel will set the display value on the hyperlink when saving.
Steps to reproduce the issue:
- Create a simple spreadsheet that sets the value of a cell & sets it's hyperlink:
f := excelize.NewFile()
f.SetCellStr("Sheet1", "A1", "Location link text")
f.SetCellHyperLink("Sheet1", "A1", "Sheet1!A5", "Location")
f.SaveAs("demo.xlsx")- Create a new google sheet, go to File -> Import -> Upload, and upload the produced
demo.xlsx.
Describe the results you received:
The cell text is #gid=1908937434&range=A5 and the cell links to cell A5.
Describe the results you expected:
The cell text is Location link text and the cell links to cell A5.
Output of go version:
go version go1.16 darwin/amd64
Excelize version or commit ID:
v2.3.2
Environment details (OS, Microsoft Excel™ version, physical, etc.):
MacOS 11.1 (Big Sur)
Google Sheets
Excel Version: 16.16.27
