Difference between revisions of "Documentation/How Tos/Calc: HYPERLINK function"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__
+
{{DISPLAYTITLE:HYPERLINK function}}
 +
{{Documentation/CalcFunc SpreadsheetTOC
 +
|ShowPrevNext=block
 +
|PrevPage=Documentation/How_Tos/Calc:_DDE_function
 +
|NextPage=Documentation/How_Tos/Calc:_STYLE_function
 +
}}__NOTOC__
  
 
== HYPERLINK ==
 
== HYPERLINK ==
Line 13: Line 18:
 
: To edit a hyperlinked cell, select a nearby cell, and navigate to the hyperlinked cell using the keyboard arrows (if you click directly, it will open the hyperlink).
 
: To edit a hyperlinked cell, select a nearby cell, and navigate to the hyperlinked cell using the keyboard arrows (if you click directly, it will open the hyperlink).
  
: For common, straightforward usage of <tt>'''HYPERLINK'''</tt>, see the [[#Example:|Examples section]].
+
: For common, straightforward usage of <tt>'''HYPERLINK'''</tt>, see the [[#Example:|Example section]].
  
  
Line 20: Line 25:
 
:: If a cell contains a <tt>'''HYPERLINK'''</tt> function (even if the <tt>'''HYPERLINK'''</tt> function is not evaluated):
 
:: If a cell contains a <tt>'''HYPERLINK'''</tt> function (even if the <tt>'''HYPERLINK'''</tt> function is not evaluated):
  
:: 1. that cell becomes a hyperlinked cell; that is, if you click on it it will attempt to open a page in a browser window.
+
:: 1. that cell becomes a hyperlinked cell; that is, if you click on it, it will attempt to open a page in a browser window.
  
::: For example, in a cell with <tt>'''=IF(TRUE(); "some text"; HYPERLINK("<nowiki>http://www.example.com</nowiki>"))'''</tt> the <tt>'''HYPERLINK'''</tt> function is never evaluated - but nevertheless the cell becomes a hyperlinked cell (although the link will fail - see 2. below).
+
::: For example, in a cell with <br /><tt>'''=IF(TRUE(); "some text"; HYPERLINK("<nowiki>http://www.example.com</nowiki>"))'''</tt> <br />the <tt>'''HYPERLINK'''</tt> function is never evaluated - but nevertheless the cell becomes a hyperlinked cell (although the link will fail - see 2. below).
  
 
:: 2. the <u>formula</u> in the cell is evaluated '''twice'''.
 
:: 2. the <u>formula</u> in the cell is evaluated '''twice'''.
Line 28: Line 33:
 
::: ii) The second time, any <tt>'''HYPERLINK'''</tt> function returns <tt>'''celltext'''</tt> (or <tt>'''linkaddress'''</tt> if no <tt>'''celltext'''</tt> is given), and the result of the formula is displayed in the cell.
 
::: ii) The second time, any <tt>'''HYPERLINK'''</tt> function returns <tt>'''celltext'''</tt> (or <tt>'''linkaddress'''</tt> if no <tt>'''celltext'''</tt> is given), and the result of the formula is displayed in the cell.
  
::: For example, <tt>'''= "h" & HYPERLINK("ttp://"; "ot ") & HYPERLINK("<nowiki>www.example.com</nowiki>"; "link")'''</tt> evaluates twice. The first time  <tt>'''"h"'''</tt> & <tt>'''"ttp://"'''</tt> & <tt>'''"<nowiki>www.example.com</nowiki>"'''</tt> are concatenated to form <tt>'''"<nowiki>http://www.example.com</nowiki>"'''</tt> - the address to link to. The second time <tt>'''"h"'''</tt> & <tt>'''"ot "'''</tt> & <tt>'''"link"'''</tt> are concatenated to form <tt>'''"hot link"'''</tt> - the text that appears in the cell.
+
::: For example, <br /><tt>'''= "h" & HYPERLINK("ttps://"; "ot ") & HYPERLINK("<nowiki>www.example.com</nowiki>"; "link")'''</tt> evaluates twice. The first time  <tt>'''"h"'''</tt> & <tt>'''"ttps://"'''</tt> & <tt>'''"<nowiki>www.example.com</nowiki>"'''</tt> are concatenated to form <tt>'''"<nowiki>http://www.example.com</nowiki>"'''</tt> - the address to link to. The second time <tt>'''"h"'''</tt> & <tt>'''"ot "'''</tt> & <tt>'''"link"'''</tt> are concatenated to form <tt>'''"hot link"'''</tt> - the text that appears in the cell.
  
::: For example, <tt>'''= "h" & HYPERLINK("ttp://"; "ere is ") & HYPERLINK("www.example.com")'''</tt> evaluates firstly to concatenate <tt>'''"h"'''</tt> & <tt>'''"ttp://"'''</tt> & <tt>'''"www.example.com"'''</tt>, forming <tt>'''"<nowiki>http://www.example.com</nowiki>"'''</tt> - the address to link to, and secondly to concatenate <tt>'''"h"'''</tt> & <tt>'''"ere is "'''</tt> & <tt>'''"www.example.com"'''</tt>, forming <tt>'''"here is <nowiki>www.example.com</nowiki>"'''</tt> - the text that appears in the cell.
+
::: For example, <br /> <tt>'''= "h" & HYPERLINK("ttps://"; "ere is ") & HYPERLINK("www.example.com")'''</tt> evaluates firstly to concatenate <tt>'''"h"'''</tt> & <tt>'''"ttps://"'''</tt> & <tt>'''"www.example.com"'''</tt>, forming <tt>'''"<nowiki>http://www.example.com</nowiki>"'''</tt> - the address to link to, and secondly to concatenate <tt>'''"h"'''</tt> & <tt>'''"ere is "'''</tt> & <tt>'''"www.example.com"'''</tt>, forming <tt>'''"here is <nowiki>www.example.com</nowiki>"'''</tt> - the text that appears in the cell.
  
 
:: 3. If any error is returned, the cell ceases to be a hyperlinked cell.
 
:: 3. If any error is returned, the cell ceases to be a hyperlinked cell.
Line 37: Line 42:
  
 
=== Example: ===
 
=== Example: ===
<tt>'''=HYPERLINK("<nowiki>http://www.example.org</nowiki>")'''</tt>
+
<tt>'''=HYPERLINK("<nowiki>https://www.example.org</nowiki>")'''</tt>
: displays <tt>'''<nowiki>http://www.example.org</nowiki>'''</tt> in the cell and opens the hyperlink <tt>'''<nowiki>http://www.example.org</nowiki>'''</tt> when clicked.
+
: displays <tt>'''<nowiki>https://www.example.org</nowiki>'''</tt> in the cell and opens the hyperlink <tt>'''<nowiki>https://www.example.org</nowiki>'''</tt> when clicked.
  
<tt>'''=HYPERLINK("<nowiki>http://www.example.org</nowiki>"; "Click here")'''</tt>
+
<tt>'''=HYPERLINK("<nowiki>https://www.example.org</nowiki>"; "Click here")'''</tt>
: displays <tt>'''Click here'''</tt> in the cell and opens the hyperlink <tt>'''<nowiki>http://www.example.org</nowiki>'''</tt> when clicked.
+
: displays <tt>'''Click here'''</tt> in the cell and opens the hyperlink <tt>'''<nowiki>https://www.example.org</nowiki>'''</tt> when clicked.
  
<tt>'''=HYPERLINK("<nowiki>http://www.</nowiki>"; "Click ") & "example.org"'''</tt>
+
<tt>'''=HYPERLINK("<nowiki>https://www.</nowiki>"; "Click ") & "example.org"'''</tt>
: displays <tt>'''Click example.org'''</tt> in the cell and opens the hyperlink <tt>'''<nowiki>http://www.example.org</nowiki>'''</tt> when clicked.
+
: displays <tt>'''Click example.org'''</tt> in the cell and opens the hyperlink <tt>'''<nowiki>https://www.example.org</nowiki>'''</tt> when clicked.
  
=== See also: ===
+
=== Issues: ===
'''[[Documentation/How_Tos/Calc: Spreadsheet functions|Spreadsheet functions]]'''
+
* Text rotated through 90 degrees may not be clickable ({{bug|74471}}).
 +
* The mouse pointer may not revert after leaving the "Format Cells" dialog ({{bug|74490}}).
  
[[Documentation/How_Tos/Calc: Functions listed alphabetically|'''Functions listed alphabetically''']],
+
{{SeeAlso|EN|
[[Documentation/How_Tos/Calc: Functions listed by category|'''Functions listed by category''']]
+
* [[Documentation/How_Tos/Calc: Spreadsheet functions|Spreadsheet functions]]
  
=== Issues: ===
+
* [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]]
* Text rotated through 90 degrees may not be clickable (issue 74471).
+
* [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}}
* The mouse pointer may not revert after leaving the "Format Cells" dialog (issue 74490).
+
[[Category: Documentation/Reference/Calc/Spreadsheet functions]]

Latest revision as of 13:41, 14 September 2024



HYPERLINK

Sets a cell to open a hyperlink (in another application) when clicked.

Syntax:

HYPERLINK(linkaddress; celltext)

A cell containing a HYPERLINK function will open a hyperlink when the cell is clicked.
linkaddress is the address (as text) that is opened. celltext is the text displayed in the cell. If celltext is omitted, linkaddress is displayed in the cell.
To edit a hyperlinked cell, select a nearby cell, and navigate to the hyperlinked cell using the keyboard arrows (if you click directly, it will open the hyperlink).
For common, straightforward usage of HYPERLINK, see the Example section.


If you need a fuller explanation of the unique way in which HYPERLINK works, it follows now:
If a cell contains a HYPERLINK function (even if the HYPERLINK function is not evaluated):
1. that cell becomes a hyperlinked cell; that is, if you click on it, it will attempt to open a page in a browser window.
For example, in a cell with
=IF(TRUE(); "some text"; HYPERLINK("http://www.example.com"))
the HYPERLINK function is never evaluated - but nevertheless the cell becomes a hyperlinked cell (although the link will fail - see 2. below).
2. the formula in the cell is evaluated twice.
i) The first time, any HYPERLINK function returns linkaddress, and the result of the formula becomes the address to link to.
ii) The second time, any HYPERLINK function returns celltext (or linkaddress if no celltext is given), and the result of the formula is displayed in the cell.
For example,
= "h" & HYPERLINK("ttps://"; "ot ") & HYPERLINK("www.example.com"; "link") evaluates twice. The first time "h" & "ttps://" & "www.example.com" are concatenated to form "http://www.example.com" - the address to link to. The second time "h" & "ot " & "link" are concatenated to form "hot link" - the text that appears in the cell.
For example,
= "h" & HYPERLINK("ttps://"; "ere is ") & HYPERLINK("www.example.com") evaluates firstly to concatenate "h" & "ttps://" & "www.example.com", forming "http://www.example.com" - the address to link to, and secondly to concatenate "h" & "ere is " & "www.example.com", forming "here is www.example.com" - the text that appears in the cell.
3. If any error is returned, the cell ceases to be a hyperlinked cell.
The examples above illustrate how HYPERLINK works - but not how it should be used.

Example:

=HYPERLINK("https://www.example.org")

displays https://www.example.org in the cell and opens the hyperlink https://www.example.org when clicked.

=HYPERLINK("https://www.example.org"; "Click here")

displays Click here in the cell and opens the hyperlink https://www.example.org when clicked.

=HYPERLINK("https://www."; "Click ") & "example.org"

displays Click example.org in the cell and opens the hyperlink https://www.example.org when clicked.

Issues:

  • Text rotated through 90 degrees may not be clickable (Issue 74471 ).
  • The mouse pointer may not revert after leaving the "Format Cells" dialog (Issue 74490 ).



See Also

Personal tools