TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

ApiOleObject

new ApiOleObject()

Class representing an OLE object.

Methods

Name Description
GetApplicationId

Returns the application ID from the current OLE object.

GetClassType

Returns a type of the ApiOleObject class.

GetData

Returns the string data from the current OLE object.

SetApplicationId

Sets the application ID to the current OLE object.

SetData

Sets the data to the current OLE object.

Example

Copy code
builder.CreateFile("pptx");
var oPresentation = Api.GetPresentation();
var oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
var oOleObject = Api.CreateOleObject("https://api.onlyoffice.com/content/img/docbuilder/examples/ole-object-image.png", 130 * 36000, 90 * 36000, "https://youtu.be/SKGz4pmnpgY", "asc.{38E022EA-AD92-45FC-B22B-49DF39746DB4}");
oOleObject.SetSize(200 * 36000, 130 * 36000);
oOleObject.SetPosition(70 * 36000, 10 * 36000);
oSlide.AddObject(oOleObject);
oOleObject.SetApplicationId("asc.{E5773A43-F9B3-4E81-81D9-CE0A132470E7}");
oOleObject.SetData("https://youtu.be/eJxpkjQG6Ew");
var sAppId = oOleObject.GetApplicationId();
var sData = oOleObject.GetData();
var sType = oOleObject.GetClassType();
var oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 213, 191), 0);
var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000);
var oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 5400000);
var oStroke = Api.CreateStroke(0, Api.CreateNoFill());
var oDrawing = Api.CreateShape("rect", 300 * 36000, 30 * 36000, oFill, oStroke);
oDrawing.SetPosition(20 * 36000, 150 * 36000);
var oDocContent = oDrawing.GetContent();
var oParagraph = oDocContent.GetElement(0);
oParagraph.AddText("The application ID for the current OLE object: " + sAppId);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The OLE object data: " + sData);
oDocContent.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Class type: " + sType);
oDocContent.Push(oParagraph);
oSlide.AddObject(oDrawing);
builder.SaveFile("pptx", "ApiOleObject.pptx");
builder.CloseFile();

Resulting document