跳到主要内容

AddImage

使用指定的参数向当前工作表添加图像。

语法

expression.AddImage(sImageSrc, nWidth, nHeight, nFromCol, nColOffset, nFromRow, nRowOffset);

expression - 表示 ApiWorksheet 类的变量。

参数

名称必需/可选数据类型默认值描述
sImageSrc必需string要插入的图像来源(目前仅支持网络 URL 或 Base64 编码的图像)。
nWidth必需EMU以英制度量单位表示的图像宽度。
nHeight必需EMU以英制度量单位表示的图像高度。
nFromCol必需number图像起始位置所在的列号。
nColOffset必需EMU从 nFromCol 列到图像左侧的偏移量,以英制单位测量。
nFromRow必需number图像起始位置所在的行号。
nRowOffset必需EMU从 nFromRow 行到图像上部的偏移量,以英制单位测量。

返回值

ApiImage

示例

此示例使用指定的参数向工作表添加图像。

// How to add an image to the worksheet specifying its url and size.

// Insert an image to the worksheet.

let worksheet = Api.GetActiveSheet();
worksheet.AddImage("https://static.onlyoffice.com/assets/docs/samples/img/presentation_sky.png", 60 * 36000, 35 * 36000, 0, 2 * 36000, 0, 3 * 36000);