GetElementsCount
Returns a number of elements in the current paragraph.
Syntax
expression.GetElementsCount();
expression - A variable that represents a ApiParagraph class.
Parameters
This method doesn't have any parameters.
Returns
number
Example
Count the number of elements inside a paragraph in a spreadsheet.
// How do I check how many pieces of content a paragraph holds in a spreadsheet?
// Track the element count before and after adding a text run to a paragraph in a spreadsheet.
let worksheet = Api.GetActiveSheet();
let fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = worksheet.AddShape("flowChartOnlineStorage", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
let content = shape.GetContent();
let paragraph = content.GetElement(0);
paragraph.RemoveAllElements();
let run = Api.CreateRun();
run.AddText("Number of paragraph elements at this point: ");
run.AddTabStop();
run.AddText("" + paragraph.GetElementsCount());
run.AddLineBreak();
paragraph.AddElement(run);
run.AddText("Number of paragraph elements after we added a text run: ");
run.AddTabStop();
run.AddText("" + paragraph.GetElementsCount());