|
| 1 | +--- |
| 2 | +title: Hyperlink display text behavior | Syncfusion |
| 3 | +description: This page explains how Syncfusion XlsIO handles empty string display text in hyperlinks, consistent with Microsoft Excel behavior. |
| 4 | +platform: document-processing |
| 5 | +control: XlsIO |
| 6 | +documentation: UG |
| 7 | +--- |
| 8 | + |
| 9 | +# How does XlsIO handle empty string display text in hyperlinks? |
| 10 | + |
| 11 | +As per Microsoft Excel behavior, hyperlinks cannot be assigned with empty display text values. When the display text of a hyperlink is set to an empty string, Excel automatically uses the hyperlink address itself as the display text. Syncfusion XlsIO follows the same behavior. |
| 12 | + |
| 13 | +If a user does not provide a <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IHyperLink.html#Syncfusion_XlsIO_IHyperLink_TextToDisplay">TextToDisplay</a> value explicitly after assigning a hyperlink <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IHyperLink.html#Syncfusion_XlsIO_IHyperLink_Address">Address</a>, XlsIO uses the address value as the display text to match Excel behavior. If <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IHyperLink.html#Syncfusion_XlsIO_IHyperLink_TextToDisplay">TextToDisplay</a> is assigned after the <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IHyperLink.html#Syncfusion_XlsIO_IHyperLink_Address">Address</a>, that value is used. |
| 14 | + |
| 15 | +{% tabs %} |
| 16 | +{% highlight c# tabtitle="C# [Cross-platform]" %} |
| 17 | +//Case 1: Without TextToDisplay - address itself is used as display text |
| 18 | +IHyperLink hyperlink1 = sheet.HyperLinks.Add(sheet.Range["A1"]); |
| 19 | +hyperlink1.Type = ExcelHyperLinkType.Url; |
| 20 | +hyperlink1.Address = "http://www.syncfusion.com"; //Display text will be "http://www.syncfusion.com" |
| 21 | + |
| 22 | +//Case 2: With TextToDisplay - provided text is used as display text |
| 23 | +IHyperLink hyperlink2 = sheet.HyperLinks.Add(sheet.Range["A2"]); |
| 24 | +hyperlink2.Type = ExcelHyperLinkType.Url; |
| 25 | +hyperlink2.Address = "http://www.syncfusion.com"; |
| 26 | +hyperlink2.TextToDisplay = "syncfusion"; //Display text will be "syncfusion" |
| 27 | +{% endhighlight %} |
| 28 | + |
| 29 | +{% highlight c# tabtitle="C# [Windows-specific]" %} |
| 30 | +//Case 1: Without TextToDisplay - address itself is used as display text |
| 31 | +IHyperLink hyperlink1 = sheet.HyperLinks.Add(sheet.Range["A1"]); |
| 32 | +hyperlink1.Type = ExcelHyperLinkType.Url; |
| 33 | +hyperlink1.Address = "http://www.syncfusion.com"; //Display text will be "http://www.syncfusion.com" |
| 34 | + |
| 35 | +//Case 2: With TextToDisplay - provided text is used as display text |
| 36 | +IHyperLink hyperlink2 = sheet.HyperLinks.Add(sheet.Range["A2"]); |
| 37 | +hyperlink2.Type = ExcelHyperLinkType.Url; |
| 38 | +hyperlink2.Address = "http://www.syncfusion.com"; |
| 39 | +hyperlink2.TextToDisplay = "syncfusion"; //Display text will be "syncfusion" |
| 40 | +{% endhighlight %} |
| 41 | + |
| 42 | +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} |
| 43 | +'Case 1: Without TextToDisplay - address itself is used as display text |
| 44 | +Dim hyperlink1 As IHyperLink = sheet.HyperLinks.Add(sheet.Range("A1")) |
| 45 | +hyperlink1.Type = ExcelHyperLinkType.Url |
| 46 | +hyperlink1.Address = "http://www.syncfusion.com" 'Display text will be "http://www.syncfusion.com" |
| 47 | + |
| 48 | +'Case 2: With TextToDisplay - provided text is used as display text |
| 49 | +Dim hyperlink2 As IHyperLink = sheet.HyperLinks.Add(sheet.Range("A2")) |
| 50 | +hyperlink2.Type = ExcelHyperLinkType.Url |
| 51 | +hyperlink2.Address = "http://www.syncfusion.com" |
| 52 | +hyperlink2.TextToDisplay = "syncfusion" 'Display text will be "syncfusion" |
| 53 | +{% endhighlight %} |
| 54 | +{% endtabs %} |
0 commit comments