跳到主要内容

AddDrawing

将分离的绘图对象(例如 ApiDrawing.Copy 返回的副本)添加到工作表的指定锚点。

备注

此功能仅在 ONLYOFFICE Docs 付费版本中可用。

语法

expression.AddDrawing(oDrawing, nFromCol, nColOffset, nFromRow, nRowOffset);

expression - 表示 ApiWorksheet 类的变量。

参数

名称必需/可选数据类型默认值描述
oDrawing必需ApiDrawing要添加的绘图对象。
nFromCol必需number绘图左上角将放置的列号。
nColOffset必需EMU从 nFromCol 列到绘图左上角的偏移量,以英制度量单位测量。
nFromRow必需number绘图左上角将放置的行号。
nRowOffset必需EMU从 nFromRow 行到绘图左上角的偏移量,以英制度量单位测量。

返回值

boolean

示例

在电子表格中将分离的绘图放置到工作表的所选单元格锚点。

// How do I attach a copied drawing to a sheet at a specific cell anchor in a spreadsheet?

// Take a drawing returned by Copy and add it to the sheet next to the original in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = worksheet.AddShape("flowChartOnlineStorage", 60 * 36000, 35 * 36000, fill, stroke, 0, 2 * 36000, 2, 3 * 36000);

let copyDrawing = shape.Copy();
worksheet.AddDrawing(copyDrawing, 4, 2 * 36000, 2, 3 * 36000);