GetElement
Returns the hyperlink element using the position specified.
Syntax
expression.GetElement(nPos);
expression - A variable that represents a ApiHyperlink class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| nPos | Required | number | The position where the element which content we want to get must be located. |
Returns
Example
This example shows how to get an element from a hyperlink inside a shape.
- Code
- Result
const worksheet = Api.GetActiveSheet();
const fill = Api.CreateSolidFill(Api.RGB(160, 100, 130));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = worksheet.AddShape(
'roundRect',
Api.MillimetersToEmus(70), Api.MillimetersToEmus(20),
fill, stroke,
0, 0, 2, 0
);
const content = shape.GetContent();
const paragraph = content.GetElement(0);
const run = Api.CreateRun();
run.AddText('Visit ONLYOFFICE for developers');
paragraph.AddElement(run, 0);
const hyperlink = run.AddHyperlink('https://api.onlyoffice.com', 'ONLYOFFICE for developers');
const element = hyperlink.GetElement(0);
const classType = element ? element.GetClassType() : 'null';
worksheet.GetRange('A1').SetValue('Element class type: ' + classType);