TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

ApiParagraph

new ApiParagraph()

Class representing a paragraph.

Methods

Name Description
AddElement

Adds an element to the current paragraph.

AddLineBreak

Adds a line break to the current position and starts the next element from a new line.

AddTabStop

Adds a tab stop to the current paragraph.

AddText

Adds some text to the current paragraph.

Copy

Creates a paragraph copy. Ingnore comments, footnote references, complex fields.

Delete

Deletes the current paragraph.

GetClassType

Returns a type of the ApiParagraph class.

GetElement

Returns a paragraph element using the position specified.

GetElementsCount

Returns a number of elements in the current paragraph.

GetIndFirstLine

Returns the paragraph first line indentation.

GetIndLeft

Returns the paragraph left side indentation.

GetIndRight

Returns the paragraph right side indentation.

GetJc

Returns the paragraph contents justification.

GetNext

Returns the next paragraph.

GetParaPr

Returns the paragraph properties.

GetPrevious

Returns the previous paragraph.

GetSpacingAfter

Returns the spacing after value of the current paragraph.

GetSpacingBefore

Returns the spacing before value of the current paragraph.

GetSpacingLineRule

Returns the paragraph line spacing rule.

GetSpacingLineValue

Returns the paragraph line spacing value.

RemoveAllElements

Removes all the elements from the current paragraph. When all the elements are removed from the paragraph, a new empty run is automatically created. If you want to add content to this run, use the ApiParagraph#GetElement method.

RemoveElement

Removes an element using the position specified. If the element you remove is the last paragraph element (i.e. all the elements are removed from the paragraph), a new empty run is automatically created. If you want to add content to this run, use the ApiParagraph#GetElement method.

SetBullet

Sets the bullet or numbering to the current paragraph.

SetIndFirstLine

Sets the paragraph first line indentation.

SetIndLeft

Sets the paragraph left side indentation.

SetIndRight

Sets the paragraph right side indentation.

SetJc

Sets the paragraph contents justification.

SetSpacingAfter

Sets the spacing after the current paragraph. If the value of the isAfterAuto parameter is true, then any value of the nAfter is ignored. If isAfterAuto parameter is not specified, then it will be interpreted as false.

SetSpacingBefore

Sets the spacing before the current paragraph. If the value of the isBeforeAuto parameter is true, then any value of the nBefore is ignored. If isBeforeAuto parameter is not specified, then it will be interpreted as false.

SetSpacingLine

Sets the paragraph line spacing. If the value of the sLineRule parameter is either "atLeast" or "exact", then the value of nLine will be interpreted as twentieths of a point. If the value of the sLineRule parameter is "auto", then the value of the nLine parameter will be interpreted as 240ths of a line.

SetTabs

Specifies a sequence of custom tab stops which will be used for any tab characters in the current paragraph. Warning: The lengths of aPos array and aVal array MUST BE equal to each other.

Example

Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
var oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
var oStroke = Api.CreateStroke(0, Api.CreateNoFill());
var oShape = oWorksheet.AddShape("flowChartOnlineStorage", 130 * 36000, 60 * 36000, oFill, oStroke, 0, 2 * 36000, 0, 3 * 36000);
var oDocContent = oShape.GetContent();
var oParagraph = oDocContent.GetElement(0);
var oRun = Api.CreateRun();
oRun.AddText("Number of paragraph elements at this point: ");
oRun.AddTabStop();
oRun.AddText("" + oParagraph.GetElementsCount());
oRun.AddLineBreak();
oParagraph.AddElement(oRun);
oRun = oParagraph.GetElement(1);
oRun.SetBold(true);
oParagraph.AddLineBreak();
oParagraph.AddText("This is a paragraph with the text in it aligned by the center. ");
oParagraph.SetJc("center");
var oParagraph1 = Api.CreateParagraph();
oParagraph1.AddText("This is just a sample text. After it a tab stop will be added.");
oParagraph1.AddTabStop();
oParagraph1.AddText("This is the text which starts after the tab stop.");
oParagraph1.AddText("These sentences are used to add lines for demonstrative purposes.");
oParagraph1.SetIndFirstLine(1440);
oDocContent.Push(oParagraph1);
var oParagraph2 = Api.CreateParagraph();
var nIndFirstLine = oParagraph1.GetIndFirstLine();
oParagraph2.AddText("First line indent: " + nIndFirstLine);
oDocContent.Push(oParagraph2);
var oParagraph3 = Api.CreateParagraph();
var sClassType = oParagraph3.GetClassType();
oParagraph3.AddLineBreak();
oParagraph3.AddText("Class Type = " + sClassType);
oDocContent.Push(oParagraph3);
var oNextParagraph = oParagraph2.GetNext();
oNextParagraph.SetBold(true);
var oPreviousParagraph = oParagraph3.GetPrevious();
oPreviousParagraph.SetItalic(true);
builder.SaveFile("xlsx", "ApiParagraph.xlsx");
builder.CloseFile();

Resulting document