Schema Builder
Hyperlinks
Add native Excel hyperlinks without changing the rendered cell value.
Use hyperlink when a cell should keep its normal value but also carry native Excel hyperlink metadata.
The cell value still comes from accessor, transform, or formula. The hyperlink target is separate.
Basic usage
import { createExcelSchema } from "@chronicstone/typed-xlsx";
type Row = {
customerId: string;
customerName: string;
hasPortal: boolean;
};
const schema = createExcelSchema<Row>()
.column("customerName", {
accessor: "customerName",
hyperlink: (row) =>
row.hasPortal
? {
target: `https://example.com/customers/${row.customerId}`,
tooltip: "Open customer record",
}
: null,
})
.build();
Supported forms:
hyperlink: "https://example.com/..."hyperlink: { target, tooltip?, style? }hyperlink: (row, rowIndex, subRowIndex) => string | { target, tooltip?, style? } | null | undefined
Returning null or undefined means that specific cell has no hyperlink.
Link-local style overrides
Linked cells get a default hyperlink appearance:
- blue text
- underline
If you need a different look, put it directly on the hyperlink object:
import { createExcelSchema } from "@chronicstone/typed-xlsx";
const schema = createExcelSchema<{ customerId: string; customerName: string; hasPortal: boolean }>()
.column("customerName", {
accessor: "customerName",
hyperlink: (row) =>
row.hasPortal
? {
target: `https://example.com/customers/${row.customerId}`,
tooltip: "Open customer record",
style: {
font: {
color: { rgb: "7C3AED" },
underline: false,
bold: true,
},
},
}
: null,
})
.build();
That style only applies when the link exists.
Internal and external links
External links use worksheet relationships:
hyperlink: () => ({ target: "https://example.com/report/123" });
Internal workbook links use Excel locations:
hyperlink: () => ({ target: "#'Summary'!A1", tooltip: "Jump to summary" });
Notes
- hyperlinks are independent from the rendered cell value
- hyperlink targets are concrete strings at export time
- formula-based hyperlink targets are intentionally not supported
- hyperlink-local
styleis ignored when the callback returnsnullorundefined