TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

ApiDocumentContent

new ApiDocumentContent()

Class representing a container for paragraphs and tables.

Methods

Name Description
AddElement

Adds a paragraph or a table or a blockLvl content control using its position in the document content.

GetClassType

Returns a type of the ApiDocumentContent class.

GetElement

Returns an element by its position in the document.

GetElementsCount

Returns a number of elements in the current document.

Push

Pushes a paragraph or a table to actually add it to the document.

RemoveAllElements

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

RemoveElement

Removes an element using the position specified.

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", 200 * 36000, 60 * 36000, oFill, oStroke, 0, 2 * 36000, 0, 3 * 36000);
var oDocContent = oShape.GetContent();
var oParagraph = oDocContent.GetElement(0);
oParagraph.AddText("This is paragraph #1.");
for (let nParaIncrease = 1; nParaIncrease < 5; ++nParaIncrease) {
  oParagraph = Api.CreateParagraph();
  oParagraph.AddText("This is paragraph #" + (nParaIncrease + 1) + ".");
  oDocContent.Push(oParagraph);
}
oDocContent.RemoveElement(2);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("We removed paragraph #3, check that out above.");
oDocContent.Push(oParagraph);
var sClassType = oDocContent.GetClassType();
oParagraph.AddLineBreak();
oParagraph.AddText("Class Type = " + sClassType);
oParagraph.AddLineBreak();
oParagraph.AddText("Number of elements inside the shape: " + oDocContent.GetElementsCount());
oParagraph.AddLineBreak();
builder.SaveFile("xlsx", "ApiDocumentContent.xlsx");
builder.CloseFile();

Resulting document