Skip to main content

IsEmpty

Returns true if the paragraph has no content elements (only the paragraph end mark).

Syntax​

expression.IsEmpty();

expression - A variable that represents an ApiParagraph class.

Parameters​

This method doesn't have any parameters.

Returns​

boolean

Example​

Check whether the current paragraph has no content elements.

// Verify that a newly created paragraph reports as empty.

// Confirm the empty state changes once text is added.

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 = Api.CreateParagraph();
let emptyBefore = paragraph.IsEmpty();
paragraph.AddText("This is a sample text.");
let emptyAfter = paragraph.IsEmpty();
content.Push(paragraph);
let resultParagraph = Api.CreateParagraph();
resultParagraph.AddText("The paragraph was empty before adding text: " + emptyBefore + ". After adding text: " + emptyAfter + ".");
content.Push(resultParagraph);