Class Drawing

绘图

表示在电子表格中的工作表上绘制的内容。

方法

方法返回类型简介
getContainerInfo()ContainerInfo获取有关绘图在工作表中位置的信息。
getHeight()Integer返回此绘图的实际高度(以像素为单位)。
getOnAction()String返回附加到此绘图的宏的名称。
getSheet()Sheet返回显示此绘图的工作表。
getWidth()Integer返回此绘图的实际宽度(以像素为单位)。
getZIndex()Number返回此绘图的 Z-index。
remove()void从电子表格中删除此绘图。
setHeight(height)Drawing设置此绘图的实际高度(以像素为单位)。
setOnAction(macroName)Drawing用于为此绘图分配一个宏函数。
setPosition(anchorRowPos, anchorColPos, offsetX, offsetY)Drawing设置绘图在工作表中的显示位置。
setWidth(width)Drawing设置此绘图的实际宽度(以像素为单位)。
setZIndex(zIndex)Drawing设置此绘图的 Z-index。

详细文档

getContainerInfo()

获取有关绘图在工作表中位置的信息。

弃踢回攻

ContainerInfo - 包含绘图容器位置的对象。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getHeight()

返回此绘图的实际高度(以像素为单位)。

// Logs the height of all drawings in a sheet
var drawings = SpreadsheetApp.getActiveSheet().getDrawings();
for (var i = 0; i < drawings.length; i++) {
  Logger.log(drawings[i].getHeight());
}

弃踢回攻

Integer - 绘图的高度(以像素为单位)。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getOnAction()

返回附加到此绘图的宏的名称。

// Logs the macro name of all drawings on the active sheet.
var drawings = SpreadsheetApp.getActiveSheet().getDrawings();
for (var i = 0; i < drawings.length; i++) {
  Logger.log(drawings[i].getOnAction());
}

弃踢回攻

String - 附加到此绘图的宏名称。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSheet()

返回显示此绘图的工作表。

// Logs the parent sheet of all drawings on the active sheet.
var drawings = SpreadsheetApp.getActiveSheet().getDrawings();
for (var i = 0; i < drawings.length; i++) {
  Logger.log(drawings[i].getSheet());
}

弃踢回攻

Sheet - 绘图所在的工作表。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getWidth()

返回此绘图的实际宽度(以像素为单位)。

// Logs the width of all drawings in a sheet
var drawings = SpreadsheetApp.getActiveSheet().getDrawings();
for (var i = 0; i < drawings.length; i++) {
  Logger.log(drawings[i].getWidth());
}

弃踢回攻

Integer - 绘图的宽度(以像素为单位)。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getZIndex()

返回此绘图的 Z-index。

// Logs the z-index of all drawings on the active sheet.
var drawings = SpreadsheetApp.getActiveSheet().getDrawings();
for (var i = 0; i < drawings.length; i++) {
  Logger.log(drawings[i].getZIndex());
}

弃踢回攻

Number - 此绘图的 Z-index。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

remove()

从电子表格中删除此绘图。对绘制的任何进一步操作都会导致脚本错误。

// Deletes all drawings from the active sheet.
var drawings = SpreadsheetApp.getActiveSheet().getDrawings();
for (var i = 0; i < drawings.length; i++) {
  drawings[i].remove();
}

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setHeight(height)

设置此绘图的实际高度(以像素为单位)。

参数

名称类型说明
heightInteger所需的高度(以像素为单位)。

弃踢回攻

Drawing - 此绘图,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setOnAction(macroName)

用于为此绘图分配一个宏函数。

参数

名称类型说明
macroNameString宏函数的名称。

弃踢回攻

Drawing - 此绘图,用于链接。


setPosition(anchorRowPos, anchorColPos, offsetX, offsetY)

设置绘图在工作表中的显示位置。锚点行和列位置索引从 1 开始计数。

参数

名称类型说明
anchorRowPosInteger绘图的上端会锚定在此行中。
anchorColPosInteger绘图的上边缘固定在此列中。
offsetXInteger相对于单元格角落的水平偏移量(以像素为单位)。
offsetYInteger相对于单元格角落的垂直偏移量(以像素为单位)。

弃踢回攻

Drawing - 此绘图,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setWidth(width)

设置此绘图的实际宽度(以像素为单位)。

参数

名称类型说明
widthInteger所需宽度(以像素为单位)。

弃踢回攻

Drawing - 此绘图,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setZIndex(zIndex)

设置此绘图的 Z-index。

参数

名称类型说明
zIndexNumber此绘图的 Z-index。

弃踢回攻

Drawing - 此绘图,用于链接。