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返回相应图片所在的工作表。
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
const images = SpreadsheetApp.getActiveSpreadsheet().getImages();
for (let 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
const images = SpreadsheetApp.getActiveSpreadsheet().getImages();
for (let 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

getWidth()

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

// Logs the width of all images in a spreadsheet
const images = SpreadsheetApp.getActiveSpreadsheet().getImages();
for (let 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
const images = SpreadsheetApp.getActiveSpreadsheet().getImages();
for (let 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 大小上限为 2MB。

参数

名称类型说明
blobBlobSource以 Blob 形式表示的新映像。

返回

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

已弃用的方法