Hyperlink support on a
TXLSXWorksheet. Each
entry anchors a single cell to an external URL. SaveAs emits a
<hyperlinks> block in the worksheet plus a matching
xl/worksheets/_rels/sheetN.xml.rels file; Open resolves
the relationship targets back into the collection. Declared in
lxHandleX.
TXLSXHyperlink declaration
type
TXLSXHyperlink = class
constructor Create(ARow, ACol: Integer; const AUrl, ADisplay, ATooltip: WideString);
function IsInternal: Boolean; // True when Location is set and Url is empty
property Row: Integer;
property Col: Integer;
property Url: WideString; // External URL (mutually exclusive with Location)
property Location: WideString; // Internal anchor, e.g. "Sheet2!A1"
property Display: WideString;
property Tooltip: WideString;
end;
TXLSXHyperlink members
| Row, Col |
1-based cell anchor coordinates. |
| Url |
External URL. Written to sheetN.xml.rels
with TargetMode="External". |
| Display |
Optional display text shown by Excel in place of the
URL. Maps to the display attribute on
<hyperlink>. |
| Tooltip |
Optional tooltip shown when the user hovers the
cell. Maps to the tooltip attribute on
<hyperlink>. |
TXLSXHyperlinks declaration
type
TXLSXHyperlinks = class
function Add(ARow, ACol: Integer; const AUrl: WideString): Integer; overload;
function Add(ARow, ACol: Integer; const AUrl, ADisplay: WideString): Integer; overload;
function Add(ARow, ACol: Integer; const AUrl, ADisplay, ATooltip: WideString): Integer; overload;
// Internal hyperlink — Location overload. No rels relationship.
function AddInternal(ARow, ACol: Integer; const ALocation, ADisplay, ATooltip: WideString): Integer;
procedure Clear;
property Count: Integer;
property Items[Index: Integer]: TXLSXHyperlink; default;
end;
TXLSXHyperlinks members
| Add(Row, Col, Url) |
Adds a hyperlink with just a URL. Returns the new
entry index. |
| Add(Row, Col, Url, Display) |
Adds a hyperlink with an explicit display text. |
| Add(Row, Col, Url, Display, Tooltip) |
Adds a hyperlink with both display text and tooltip. |
| AddInternal(Row, Col, Location, Display, Tooltip) |
Adds an internal anchor hyperlink — jumps to a
Sheet!Cell location (e.g.
"Sheet2!A1") elsewhere in the workbook. No worksheet
rels relationship is generated; the <hyperlink>
element carries an inline location attribute. Use
Worksheet.AddHyperlinkToCell(...) for the typical
shortcut. |
| Count |
Number of hyperlinks on the worksheet. |
| Items[Index] |
Hyperlink at the given 0-based index. Declared as
the default property. |
| Clear |
Removes and frees every hyperlink. |
Example
var
ws: TXLSXWorksheet;
begin
ws := Workbook.Sheets.Add('Links');
ws.Cells.Item[1, 1].Value := 'losLab';
ws.AddHyperlink(1, 1, 'https://www.loslab.com',
'losLab home', 'Open in browser');
// Equivalent through the collection:
ws.Hyperlinks.Add(2, 1, 'https://www.anthropic.com');
end;
See also