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。

參數

名稱類型說明
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