表示电子表格中网格上方的图片。
方法
详细文档
assign
将具有指定函数名称的函数分配给此图片。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| function | String | 要指定的函数的名称。此函数必须是公共顶级函数,而不是以下划线结尾的函数,例如 private。 | 
返回
Over - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回此图片的替代文本说明。
返回
String - 替代文本说明。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回此图片的替代文本标题。
返回
String - 替代文本标题。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
get
返回相对于锚点单元格的水平像素偏移量。
返回
Integer - 水平像素偏移量。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回相对于锚定单元格的垂直像素偏移量。
返回
Integer - 垂直像素偏移量。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回此图片的实际高度(以像素为单位)。
// 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
get
返回此图片的固有高度(以像素为单位)。
返回
Integer - 固有高度(以像素为单位)。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回此图片的固有高度(以像素为单位)。
返回
Integer - 固有宽度(以像素为单位)。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回分配给此图片的函数的名称。
返回
String - 函数的名称。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回此图片显示的页面。
// 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
get
返回此图片的实际宽度(以像素为单位)。
// 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)
将此图片替换为由提供的 Blob 指定的图片。支持的 BLOB 大小上限为 2MB。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| blob | Blob | 新图片(作为 Blob)。 | 
返回
Over - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
replace(url)
将此图片替换为指定网址中的图片。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| url | String | 新图片的网址。 | 
返回
Over - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
reset
将此图片重置为其固有尺寸。
返回
Over - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置此图片的替代文本说明。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| description | String | 图片的新替代文本说明。 | 
返回
Over - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置此图片的替代文本标题。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| title | String | 图片的新替代文本标题。 | 
返回
Over - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置图片锚定的单元格。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| cell | Range | 新的锚点单元格。 | 
返回
Over - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置相对于锚点单元格的水平像素偏移量。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| offset | Integer | 新的水平像素偏移量。 | 
返回
Over - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置相对于锚点单元格的垂直像素偏移量。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| offset | Integer | 新的垂直像素偏移量。 | 
返回
Over - 此图片,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置此图片的实际高度(以像素为单位)。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| height | Integer | 所需的高度(以像素为单位)。 | 
返回
Over - 用于链接的图片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置此图片的实际宽度(以像素为单位)。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| width | Integer | 所需的宽度(以像素为单位)。 | 
返回
Over - 用于链接的图片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets