表示电子表格中网格上方的图片。
方法
详细文档
assignScript(functionName)
将具有指定函数名称的函数分配给此映像。
参数
名称 | 类型 | 说明 |
---|---|---|
functionName | String | 指定的函数的名称。它必须是公共顶级函数,不能以下划线结尾,例如 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()
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 大小上限为 2MB。
参数
名称 | 类型 | 说明 |
---|---|---|
blob | BlobSource | 将新图片作为 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