Class OverGridImage

OverGridImage

表示电子表格中网格上的图片。

方法

方法返回类型简介
assignScript(functionName)OverGridImage用于为此图像分配具有指定函数名称的函数。
getAltTextDescription()String返回此图片的替代文本说明。
getAltTextTitle()String返回此图片的替代文本标题。
getAnchorCell()Range返回锚定图片的单元格。
getAnchorCellXOffset()Integer返回相对于锚点单元格的水平像素偏移量。
getAnchorCellYOffset()Integer返回相对于锚点单元格的垂直像素偏移量。
getHeight()Integer返回此图片的实际高度(以像素为单位)。
getInherentHeight()Integer返回此图片的固有高度(以像素为单位)。
getInherentWidth()Integer返回此图片的固有高度(以像素为单位)。
getScript()String返回分配给此图片的函数的名称。
getSheet()Sheet返回显示此图片的工作表。
getUrl()String获取图片的来源网址;如果网址不可用,则返回 null
getWidth()Integer返回此图片的实际宽度(以像素为单位)。
remove()void从电子表格中删除此图片。
replace(blob)OverGridImage将此图片替换为提供的 BlobSource 指定的图片。
replace(url)OverGridImage将此图片替换为来自指定网址的图片。
resetSize()OverGridImage将此图片重置为其固有尺寸。
setAltTextDescription(description)OverGridImage设置此图片的替代文本说明。
setAltTextTitle(title)OverGridImage设置此图片的替代文本标题。
setAnchorCell(cell)OverGridImage设置锚定图片的单元格。
setAnchorCellXOffset(offset)OverGridImage设置相对于锚点单元格的水平像素偏移量。
setAnchorCellYOffset(offset)OverGridImage设置相对于锚点单元格的垂直像素偏移量。
setHeight(height)OverGridImage设置此图片的实际高度(以像素为单位)。
setWidth(width)OverGridImage设置此图像的实际宽度(以像素为单位)。

详细文档

assignScript(functionName)

用于为此图像分配具有指定函数名称的函数。

参数

名称类型说明
functionNameString指定的函数的名称。此函数必须是公共顶级函数,而不是以下划线结尾的函数(如 privateFunction_)。

弃踢回攻

OverGridImage - 此图片,用于链接。

授权

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

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

getAltTextDescription()

返回此图片的替代文本说明。

弃踢回攻

String - 替代文本说明。

授权

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

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

getAltTextTitle()

返回此图片的替代文本标题。

弃踢回攻

String - 替代文本标题。

授权

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

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

getAnchorCell()

返回锚定图片的单元格。

弃踢回攻

Range - 锚点单元格。

授权

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

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

getAnchorCellXOffset()

返回相对于锚点单元格的水平像素偏移量。

弃踢回攻

Integer - 水平像素偏移量。

授权

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

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

getAnchorCellYOffset()

返回相对于锚点单元格的垂直像素偏移量。

弃踢回攻

Integer - 垂直像素偏移量。

授权

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

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

getHeight()

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

// Logs the height of all images in a spreadsheet
var images = SpreadsheetApp.getActiveSpreadsheet().getImages();
for (var i = 0; i < images.length; i++) {
  Logger.log(images[i].getHeight());
}

弃踢回攻

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

授权

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

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

getInherentHeight()

返回此图片的固有高度(以像素为单位)。

弃踢回攻

Integer - 固有高度(以像素为单位)。

授权

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

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

getInherentWidth()

返回此图片的固有高度(以像素为单位)。

弃踢回攻

Integer - 固有宽度(以像素为单位)。

授权

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

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

getScript()

返回分配给此图片的函数的名称。

弃踢回攻

String - 函数的名称。

授权

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

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

getSheet()

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

// Logs the parent sheet of all images in a spreadsheet
var images = SpreadsheetApp.getActiveSpreadsheet().getImages();
for (var i = 0; i < images.length; i++) {
  Logger.log(images[i].getSheet());
}

弃踢回攻

Sheet - 显示图片的工作表。

授权

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

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

getUrl()

获取图片的来源网址;如果网址不可用,则返回 null。如果图片是使用 API 通过网址插入的,此方法会返回在插入图片期间提供的网址。

弃踢回攻

String - 图片网址(如果有);如果图片不可用或没有来源网址,则返回 null

授权

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

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

getWidth()

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

// Logs the width of all images in a spreadsheet
var images = SpreadsheetApp.getActiveSpreadsheet().getImages();
for (var i = 0; i < images.length; i++) {
  Logger.log(images[i].getWidth());
}

弃踢回攻

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

授权

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

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

remove()

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

// Deletes all images in a spreadsheet
var images = SpreadsheetApp.getActiveSpreadsheet().getImages();
for (var i = 0; i < images.length; i++) {
  images[i].remove();
}

授权

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

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

replace(blob)

将此图片替换为提供的 BlobSource 指定的图片。支持的 blob 大小上限为 2 MB。

参数

名称类型说明
blobBlobSourceBlob 格式的新图片。

弃踢回攻

OverGridImage - 此图片,用于链接。

授权

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

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

replace(url)

将此图片替换为来自指定网址的图片。

参数

名称类型说明
urlString新图片的网址。

弃踢回攻

OverGridImage - 此图片,用于链接。

授权

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

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

resetSize()

将此图片重置为其固有尺寸。

弃踢回攻

OverGridImage - 此图片,用于链接。

授权

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

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

setAltTextDescription(description)

设置此图片的替代文本说明。

参数

名称类型说明
descriptionString图片的新替代文本说明。

弃踢回攻

OverGridImage - 此图片,用于链接。

授权

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

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

setAltTextTitle(title)

设置此图片的替代文本标题。

参数

名称类型说明
titleString图片的新替代文本标题。

弃踢回攻

OverGridImage - 此图片,用于链接。

授权

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

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

setAnchorCell(cell)

设置锚定图片的单元格。

参数

名称类型说明
cellRange新锚定单元格。

弃踢回攻

OverGridImage - 此图片,用于链接。

授权

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

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

setAnchorCellXOffset(offset)

设置相对于锚点单元格的水平像素偏移量。

参数

名称类型说明
offsetInteger新的水平像素偏移量。

弃踢回攻

OverGridImage - 此图片,用于链接。

授权

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

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

setAnchorCellYOffset(offset)

设置相对于锚点单元格的垂直像素偏移量。

参数

名称类型说明
offsetInteger新的垂直像素偏移。

弃踢回攻

OverGridImage - 此图片,用于链接。

授权

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

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

setHeight(height)

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

参数

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

弃踢回攻

OverGridImage - 用于链接的图片。

授权

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

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

setWidth(width)

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

参数

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

弃踢回攻

OverGridImage - 用于链接的图片。

授权

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

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