跳到主要内容

CreateOleObject

使用指定的参数创建 OLE 对象。

语法

expression.CreateOleObject(imageSrc, width, height, data, appId);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
imageSrc必需string要插入的图像来源(目前仅支持网络 URL 或 Base64 编码的图像)。
width必需EMU以英制度量单位表示的 OLE 对象宽度。
height必需EMU以英制度量单位表示的 OLE 对象高度。
data必需stringOLE 对象字符串数据。
appId必需string与当前 OLE 对象关联的应用程序 ID。

返回值

ApiOleObject

示例

此示例创建一个 OLE 对象并将其插入到文档中。

// Creates the ApiOleObject object and adds it to the first paragraph of the document.

// How to create an Ole object using the specified image source, width, height, Ole data, application ID and insert it into the ApiParagraph class.

let doc = Api.GetDocument();
let oleObject = Api.CreateOleObject(
'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png',
150 * 36000, 150 * 36000,
'https://youtu.be/SKGz4pmnpgY',
'asc.{38E022EA-AD92-45FC-B22B-49DF39746DB4}'
);
let paragraph = doc.GetElement(0);
paragraph.AddDrawing(oleObject);