表示电子表格中网格上方的图片。
方法
详细文档
assignScript(functionName)
将具有指定函数名称的函数分配给此映像。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
function | String | 所指定函数的名称。这必须是一个公共顶级函数,而不是以英文下划线结尾的函数,例如 private。 |
返回
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()
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。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
blob | Blob | 以 Blob 形式表示的新映像。 |
返回
OverGridImage - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
replace(url)
将此图片替换为指定网址中的图片。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
url | String | 新图片的网址。 |
返回
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)
为相应图片设置替代文本说明。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
description | String | 图片的新替代文本说明。 |
返回
OverGridImage - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setAltTextTitle(title)
为相应图片设置替代文本标题。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
title | String | 图片的新替代文本标题。 |
返回
OverGridImage - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setAnchorCell(cell)
设置图片锚定的单元格。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
cell | Range | 新的锚定单元格。 |
返回
OverGridImage - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setAnchorCellXOffset(offset)
设置相对于锚定单元格的水平像素偏移量。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
offset | Integer | 新的水平像素偏移量。 |
返回
OverGridImage - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setAnchorCellYOffset(offset)
设置相对于锚定单元格的垂直像素偏移量。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
offset | Integer | 新的垂直像素偏移量。 |
返回
OverGridImage - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setHeight(height)
以像素为单位设置此图片的实际高度。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
height | Integer | 所需的高度(以像素为单位)。 |
返回
OverGridImage - 用于链式调用的图片。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setWidth(width)
设置相应图片的实际宽度(以像素为单位)。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
width | Integer | 所需的宽度(以像素为单位)。 |
返回
OverGridImage - 用于链式调用的图片。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets