Hyperlinks
A hyperlink is the object in a cell’s l property: { Target, Tooltip }.
A hyperlink in l does not change the text style. Excel shows links with theme color 10.
utils.cell_set_hyperlink(cell, target, tooltip) sets the link and that color together.
utils.cell_set_internal_link(cell, target, tooltip) does the same for a location inside the workbook.
const XLSX = require("@agent-sheet/wasm");const cell = { t: "s", v: "site" };XLSX.utils.cell_set_hyperlink(cell, "https://example.com", "Open");console.log(JSON.stringify(cell));const inner = { t: "s", v: "go" };XLSX.utils.cell_set_internal_link(inner, "Sheet2!A1");console.log(inner.l.Target);{"t":"s","v":"site","l":{"Target":"https://example.com","Tooltip":"Open"},"s":{"color":{"theme":10}}}#Sheet2!A1Round trip
Section titled “Round trip”const XLSX = require("@agent-sheet/wasm");const ws = XLSX.utils.aoa_to_sheet([["site"]]);XLSX.utils.cell_set_hyperlink(ws.A1, "https://example.com", "Open the site");const wb = XLSX.utils.book_new();XLSX.utils.book_append_sheet(wb, ws, "S");const back = XLSX.read(XLSX.write(wb, { type: "buffer", bookType: "xlsx" }));console.log(back.Sheets.S.A1.l.Target);https://example.com