TXlsFile.LoopHyperLinks Method
Loops over the list of existing hyperlinks in the active sheet which are at least partially contained in range, and executes action for each one of those links. This can be faster than looping over all hyperlinks in a page if you have thousands, since this method uses spatial indexing.
Remarks
The list of links that will be returned is frozen at the start of the method. If you add new links in the anonymous method "action", this method won't loop over those new links.
Syntax
Unit: FlexCel.XlsAdapter
procedure TXlsFile.LoopHyperLinks(const range: TXlsCellRange; const fullyInside: Boolean; const action: TProc<THyperLink, TXlsCellRange>); override;
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
const | range | TXlsCellRange | Range of cells for which you want to retrieve the links. |
const | fullyInside | Boolean | If true, only those links that are fully inside the range will be returned. If false, links which have only a part inside but also a part outside will be returned too. |
const | action | TProc<THyperLink, TXlsCellRange> | Actions to be applied to every link at least partially included in range. |
Examples
The following example will find if there is an hyperlink at cell B3, and if there is some, call DoSomething with the link text.
xls.LoopHyperLinks(TXlsCellRange.Create('B3'), false,
procedure (hyperlink: THyperLink; range: TXlsCellRange)
begin
if hyperlink.HasValue then
DoSomething(hyperlink.Text);
end);
Remember that while this method is efficient because the search is indexed, if you want to find for example all links in a column, it is faster to do a single call to LoopHyperLinks(B1:B10) than to call LoopHyperLinks(B1) to get the link at B1, then LoopHyperLinks(B2) for B2 and so on.