XLSX
超链接
外部链接和内部工作表跳转
外部链接
为单元格添加可点击的超链接,指向网页地址:
{
"worksheets": [
{
"name": "链接",
"rows": [
{ "cells": [{ "value": "搜索引擎" }, { "value": "代码" }] },
{ "cells": [{ "value": "Google" }, { "value": "GitHub" }] }
],
"hyperlinks": [
{
"cell": "A2",
"target": { "type": "external", "url": "https://www.google.com" },
"tooltip": "打开 Google"
},
{
"cell": "B2",
"target": { "type": "external", "url": "https://github.com" },
"display": "GitHub 仓库"
}
]
}
]
}
{
name: "链接",
rows: [
{ cells: [{ value: "搜索引擎" }, { value: "代码" }] },
{ cells: [{ value: "Google" }, { value: "GitHub" }] },
],
hyperlinks: [
{
cell: "A2",
target: { type: "external", url: "https://www.google.com" },
tooltip: "打开 Google",
},
{
cell: "B2",
target: { type: "external", url: "https://github.com" },
display: "GitHub 仓库",
},
],
}
内部链接
跳转到同一工作簿中的其他工作表:
{
"worksheets": [
{
"name": "汇总",
"rows": [{ "cells": [{ "value": "跳转到数据表" }] }],
"hyperlinks": [
{
"cell": "A1",
"target": { "type": "internal", "location": "数据!A1" },
"tooltip": "跳转到数据表"
}
]
},
{
"name": "数据",
"rows": [
{ "cells": [{ "value": "名称" }, { "value": "数值" }] },
{ "cells": [{ "value": "项目 A" }, { "value": 100 }] }
]
}
]
}
{
name: "汇总",
rows: [{ cells: [{ value: "跳转到数据表" }] }],
hyperlinks: [
{
cell: "A1",
target: { type: "internal", location: "数据!A1" },
tooltip: "跳转到数据表",
},
],
}
超链接选项参考
| 选项 | 类型 | 说明 |
|---|---|---|
cell | string | 单元格引用,如 "A2" |
target | object | 链接目标 |
tooltip | string | 鼠标悬停提示 |
display | string | 显示文本(覆盖单元格值) |
target 选项
| 属性 | 类型 | 说明 |
|---|---|---|
type | string | "external" 或 "internal" |
url | string | 外部 URL(type 为 external 时) |
location | string | 内部位置,如 "Sheet2!A1"(type 为 internal 时) |