AddElement
Adds a paragraph or a table or a blockLvl content control using its position in the document content.
Syntax
expression.AddElement(nPos, oElement);
expression
- A variable that represents a ApiDocumentContent class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
nPos | Required | number | The position where the current element will be added. | |
oElement | Required | DocumentElement | The document element which will be added at the current position. |
Returns
This method doesn't return any data.
Example
This example adds a paragraph in document content.
- Code
- Result
let worksheet = Api.GetActiveSheet();
let fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = worksheet.AddShape("flowChartOnlineStorage", 200 * 36000, 60 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
let content = shape.GetContent();
content.RemoveAllElements();
let paragraph = Api.CreateParagraph();
paragraph.AddText("We removed all elements from the shape and added a new paragraph inside it.");
content.AddElement(paragraph);
content.Push(paragraph);