TXLSXHyperlink 宣告
TXLSXHyperlink 宣告. Each
entry anchors a single cell to an external URL. SaveAs emits a
<hyperlinks> External URL. Written 到
xl/worksheets/_rels/sheetN.xml.rels 檔案;Open 會把 relationship 目標解析回集合。宣告於
lxHandleX1-基於 儲存格 anchor coordinates
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;
Display
| Row, Col | attribute on |
| Url | Optional display 文字 shown 透過 Excel 在 place 的 URL. Maps 到 sheetN.xml.rels
attribute on TargetMode="External" |
| Display | Optional display text shown by Excel in place of the
URL. Maps to the display Optional tooltip shown 當 user hovers 儲存格. Maps 到
<hyperlink> |
| Tooltip | Optional tooltip shown when the user hovers the
cell. Maps to the tooltip Optional tooltip shown 當 user hovers 儲存格. Maps 到
<hyperlink> |
TXLSXHyperlinks 成員
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;
只加入 URL 的超連結。回傳新的項目索引
| Add(Row, Col, Url) | Adds a hyperlink attribute on just a URL. 傳回 the new
entry index |
| Add(Row, Col, Url, Display) | 加入含明確顯示文字的超連結 |
| Add(Row, Col, Url, Display, Tooltip) | Add(External URL. Written 到, Display, attribute on, attribute on) |
| AddInternal(Row, Col, Location, Display, Tooltip) | AddInternal(External URL. Written 到, Location, attribute on, attribute on)
Sheet!Cell AddInternal(External URL. Written 到, Location, attribute on, attribute on)
"Sheet2!A1") elsewhere in the workbook. No worksheet
rels relationship is generated; the <hyperlink>
元素會帶有內嵌 location 屬性。一般情況請改用 Worksheet.AddHyperlinkToCell(...) location IndexOfCell(External URL. Written 到)
Worksheet.AddHyperlinkToCell(...) for the typical
shortcut |
| IndexOfCell(Row, Col) | 傳回 the 0-based index of the hyperlink anchored
at the 1-based cell coordinate, or -1 when the cell has
no hyperlink |
| FindAt(Row, Col) | 傳回 the hyperlink object anchored at the cell,
or nil 刪除錨定於該儲存格的超連結並回傳 True;若找不到對應超連結則回傳 False |
| DeleteAt(Row, Col) | Deletes the hyperlink anchored at the cell and
returns True刪除錨點位於包含端點的 1 起始儲存格範圍內的每個超連結,並回傳已移除的數量。可接受反向座標 False when no matching
hyperlink exists |
| DeleteInRange(Row1, Col1, Row2, Col2) | 刪除錨點落在指定範圍內(含端點、以 1 為起始)的所有超連結,並回傳刪除的數量。座標前後顛倒也接受 |
| Delete(Index) | Deletes the hyperlink at the specified 0-based
collection index |
| Count | 指定 0 起始索引處的超連結。宣告為預設屬性 |
| Items[Index] | Hyperlink at the given 0-based index. Declared as
the default property |
| Clear | 移除並釋放所有超連結 |
另請參閱
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;
TXLSXWorksheet