ExcelFile.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
Namespace: FlexCel.Core
public abstract void LoopHyperLinks(TXlsCellRange range, Boolean fullyInside, Action<THyperLink, TXlsCellRange> action)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
range | TXlsCellRange | Range of cells for which you want to retrieve the links. | |
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. |
|
action | Action<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(new TXlsCellRange("B3"), false,
(hyperlink, range) =>
{
if (hyperlink != null) DoSomething(hyperlink.Text);
}
);
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.