Skip to main content

Hyperlinks超链接

Format Support格式支持 (click to show)

Cell Hyperlinks单元格超链接: XLSX/M, XLSB, BIFF8 XLS, XLML, ODS, HTML

Tooltips工具提示: XLSX/M, XLSB, BIFF8 XLS, XLML

Hyperlinks are stored in the l key of cell objects. 超链接存储在单元格对象的l键中。 The Target field of the hyperlink object is the target of the link, including the URI fragment. 超链接对象的Target字段是链接的目标,包括URI片段。Tooltips are stored in the Tooltip field and are displayed when hovering over the text.工具提示存储在Tooltip字段中,并在将鼠标悬停在文本上时显示。

For example, the following snippet creates a link from cell A3 to https://sheetjs.com with the tip "Find us @ SheetJS.com!":例如,以下代码段创建了从单元格A3https://sheetjs.com提示"Find us @ SheetJS.com!"

ws [ "A1" ] . l   =   {   Target :   "https://sheetjs.com" ,   Tooltip :   "Find us @ SheetJS.com!"   } ;

Note that Excel does not automatically style hyperlinks. 请注意,Excel不会自动设置超链接的样式。They will be displayed using default style. 它们将使用默认样式显示。SheetJS Pro Basic extends this export with support for hyperlink styling.SheetJS Pro Basic扩展了此导出,支持超链接样式。

HTTP / HTTPS links can be used directly:可以直接使用HTTP/HTTPS链接:

ws [ "A2" ] . l   =   {   Target :   "https://docs.sheetjs.com/#hyperlinks"   } ; 
ws [ "A3" ] . l = { Target : "http://localhost:7262/yes_localhost_works" } ;

Excel also supports mailto email links with subject line:Excel还支持带有主题行的mailto电子邮件链接:

ws [ "A4" ] . l   =   {   Target :   "mailto:[email protected]"   } ; 
ws [ "A5" ] . l = { Target : "mailto:[email protected]?subject=Test Subject" } ;

Links to absolute paths should use the file:// URI scheme:指向绝对路径的链接应使用file://URI方案:

ws [ "B1" ] . l   =   {   Target :   "file:///SheetJS/t.xlsx"   } ;   /* Link to /SheetJS/t.xlsx */ 
ws [ "B2" ] . l = { Target : "file:///c:/SheetJS.xlsx" } ; /* Link to c:\SheetJS.xlsx */

Links to relative paths can be specified without a scheme:可以在没有方案的情况下指定指向相对路径的链接:

ws [ "B3" ] . l   =   {   Target :   "SheetJS.xlsb"   } ;   /* Link to SheetJS.xlsb */ 
ws [ "B4" ] . l = { Target : "../SheetJS.xlsm" } ; /* Link to ../SheetJS.xlsm */

Relative Paths have undefined behavior in the SpreadsheetML 2003 format. 在电子表格ML 2003格式中,相对路径具有未定义的行为。Excel 2019 will treat a ..\ parent mark as two levels up.Excel 2019将把..\父标记视为向上两级。

Links where the target is a cell or range or defined name in the same workbook ("Internal Links") are marked with a leading hash character:目标是同一工作簿中的单元格或区域或定义名称的链接(“内部链接”)用前导哈希字符标记:

ws [ "C1" ] . l   =   {   Target :   "#E2"   } ;   /* Link to cell E2 */ 
ws [ "C2" ] . l = { Target : "#Sheet2!E2" } ; /* Link to cell E2 in sheet Sheet2 */
ws [ "C3" ] . l = { Target : "#SomeDefinedName" } ; /* Link to Defined Name */

HTML

The HTML DOM parser will process <a> links in the table:HTML DOM解析器将处理表中的<a>链接:

Result
Loading...
Live EditorLive编辑器