Hyperlink-ondersteuning op een
TXLSXWorksheet. Elk
item verankert één cel aan een externe URL. SaveAs schrijft een
<hyperlinks>-blok in het werkblad plus een bijbehorend
xl/worksheets/_rels/sheetN.xml.rels-bestand; Open lost
de relationship-doelen weer op in de verzameling. Gedeclareerd 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
constructor Create;
destructor Destroy; override;
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;
function IndexOfCell(ARow, ACol: Integer): Integer;
function FindAt(ARow, ACol: Integer): TXLSXHyperlink;
function DeleteAt(ARow, ACol: Integer): Boolean;
function DeleteInRange(ARow1, ACol1, ARow2, ACol2: Integer): Integer;
procedure Delete(Index: 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 en 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. Gebruiken
Worksheet.AddHyperlinkToCell(...) for the typical
shortcut |
| IndexOfCell(Row, Col) |
Retourneert de 0-based index van de hyperlink die verankerd is
op de 1-based celcoördinaat, of -1 wanneer de cel geen
hyperlink heeft |
| FindAt(Row, Col) |
Retourneert het hyperlinkobject dat aan de cel verankerd is,
of nil wanneer er geen hyperlink is |
| DeleteAt(Row, Col) |
Verwijdert de hyperlink die aan de cel verankerd is en
geeft True terug; geeft False terug wanneer geen overeenkomende
hyperlink bestaat |
| DeleteInRange(Row1, Col1, Row2, Col2) |
Verwijdert elke hyperlink waarvan het anker binnen het
inclusieve 1-based celbereik ligt en geeft het aantal verwijderde terug. Omgekeerde
coördinaten worden geaccepteerd |
| Delete(Index) |
Deletes the hyperlink at the specified 0-based
collection index |
| Count |
Number of hyperlinks on the worksheet |
| Items[Index] |
Hyperlink at the given 0-based index. Declared as
the default eigenschap |
| Clear |
Removes en frees every hyperlink |
Voorbeeld
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.loslab.com/docs');
if ws.Hyperlinks.FindAt(1, 1) <> nil then
ws.Hyperlinks.DeleteInRange(1, 1, 2, 1);
end;
Zie ook