ApiTextPr

new ApiTextPr()

Class representing the text properties.

Methods

Name Description
GetClassType

Returns a type of the ApiTextPr class.

SetBold

Sets the bold property to the text character.

SetCaps

Specifies that any lowercase characters in the text run are formatted for display only as their capital letter character equivalents.

SetDoubleStrikeout

Specifies that the contents of the run are displayed with two horizontal lines through each character displayed on the line.

SetFill

Sets the text color to the current text run.

SetFontFamily

Sets all 4 font slots with the specified font family.

SetFontSize

Sets the font size to the characters of the current text run.

SetItalic

Sets the italic property to the text character.

SetOutLine

Sets the text outline to the current text run.

SetSmallCaps

Specifies that all the small letter characters in the text run are formatted for display only as their capital letter character equivalents which are two points smaller than the actual font size specified for this text.

SetSpacing

Sets the text spacing measured in twentieths of a point.

SetStrikeout

Specifies that the contents of the run are displayed with a single horizontal line through the center of the line.

SetTextFill

Sets the text fill to the current text run.

SetUnderline

Specifies that the contents of the run are displayed along with a line appearing directly below the character (less than all the spacing above and below the characters on the line).

SetVertAlign

Specifies the alignment which will be applied to the contents of the run in relation to the default appearance of the run text:

  • "baseline" - the characters in the current text run will be aligned by the default text baseline.
  • "subscript" - the characters in the current text run will be aligned below the default text baseline.
  • "superscript" - the characters in the current text run will be aligned above the default text baseline.

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", 120 * 36000, 70 * 36000, oFill, oStroke, 0, 2 * 36000, 0, 3 * 36000);
var oDocContent = oShape.GetContent();
var oParagraph = oDocContent.GetElement(0);
var oRun = Api.CreateRun();
var oTextPr = oRun.GetTextPr();
oTextPr.SetFontSize(30);
oTextPr.SetBold(true);
oTextPr.SetCaps(true);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(128, 128, 128));
oTextPr.SetFill(oFill);
oTextPr.SetFontFamily("Comic Sans MS");
oParagraph.SetJc("left");
oRun.AddText("This is a sample text inside the shape with the font size set to 15 points using the text properties.");
oParagraph.AddElement(oRun);
var sClassType = oTextPr.GetClassType();
oRun.AddLineBreak();
oRun.AddText("Class Type = " + sClassType);
builder.SaveFile("xlsx", "ApiTextPr.xlsx");
builder.CloseFile();

Resulting document