Class Layout

版面配置

簡報中的版面配置。

每個版面配置都會做為沿用投影片的範本,決定這些投影片內容的排列方式和樣式。

方法

方法傳回類型簡短說明
getBackground()PageBackground取得網頁的背景。
getColorScheme()ColorScheme取得與網頁相關聯的 ColorScheme
getGroups()Group[]傳回頁面上的 Group 物件清單。
getImages()Image[]傳回頁面上的 Image 物件清單。
getLayoutName()String取得版面配置的名稱。
getLines()Line[]傳回頁面上的 Line 物件清單。
getMaster()Master取得版面配置的主影格。
getObjectId()String取得網頁的專屬 ID。
getPageElementById(id)PageElement傳回網頁上有指定 ID 的 PageElement,如果不存在,則傳回 null
getPageElements()PageElement[]傳回已在網頁上算繪的 PageElement 物件清單。
getPageType()PageType取得網頁的類型。
getPlaceholder(placeholderType)PageElement傳回指定 PlaceholderType 的預留位置 PageElement 物件;如果沒有相符的預留位置,則傳回 null
getPlaceholder(placeholderType, placeholderIndex)PageElement傳回指定 PlaceholderType 和預留位置索引的預留位置 PageElement 物件;如果沒有預留位置,則傳回 null
getPlaceholders()PageElement[]傳回頁面中的預留位置 PageElement 物件清單。
getShapes()Shape[]傳回頁面上的 Shape 物件清單。
getSheetsCharts()SheetsChart[]傳回頁面上的 SheetsChart 物件清單。
getTables()Table[]傳回頁面上的 Table 物件清單。
getVideos()Video[]傳回頁面上的 Video 物件清單。
getWordArts()WordArt[]傳回頁面上的 WordArt 物件清單。
group(pageElements)Group將所有指定的網頁元素分組。
insertGroup(group)Group在頁面上插入所提供 Group 的副本。
insertImage(blobSource)Image在頁面左上角插入圖片,並使用指定映像檔 blob 的預設大小。
insertImage(blobSource, left, top, width, height)Image在網頁上插入含有指定圖片 blob 所指定位置和大小的圖片。
insertImage(image)Image在頁面上插入所提供 Image 的副本。
insertImage(imageUrl)Image在頁面左上角插入圖片,並使用提供網址的預設大小。
insertImage(imageUrl, left, top, width, height)Image在網頁上插入含有指定網址位置和大小的圖片。
insertLine(line)Line在頁面上插入所提供 Line 的副本。
insertLine(lineCategory, startConnectionSite, endConnectionSite)Line在連接兩個 connection sites 的頁面中插入一行。
insertLine(lineCategory, startLeft, startTop, endLeft, endTop)Line在頁面中插入一行。
insertPageElement(pageElement)PageElement在頁面上插入所提供 PageElement 的副本。
insertShape(shape)Shape在頁面上插入所提供 Shape 的副本。
insertShape(shapeType)Shape在頁面上插入形狀。
insertShape(shapeType, left, top, width, height)Shape在頁面上插入形狀。
insertSheetsChart(sourceChart)SheetsChart在頁面上插入 Google 試算表圖表。
insertSheetsChart(sourceChart, left, top, width, height)SheetsChart在網頁上插入 Google 試算表圖表,並提供指定的位置和大小。
insertSheetsChart(sheetsChart)SheetsChart在頁面上插入所提供 SheetsChart 的副本。
insertSheetsChartAsImage(sourceChart)Image在網頁上以 Image 格式插入 Google 試算表圖表。
insertSheetsChartAsImage(sourceChart, left, top, width, height)Image在網頁上以 Image 格式插入 Google 試算表圖表,並提供指定的位置和大小。
insertTable(numRows, numColumns)Table在頁面中插入表格。
insertTable(numRows, numColumns, left, top, width, height)Table在頁面中插入含有指定位置和大小的表格。
insertTable(table)Table在頁面上插入所提供 Table 的副本。
insertTextBox(text)Shape在網頁上插入包含所提供字串的文字方塊 Shape
insertTextBox(text, left, top, width, height)Shape在網頁上插入包含所提供字串的文字方塊 Shape
insertVideo(videoUrl)Video在頁面左上角插入採用預設大小的影片。
insertVideo(videoUrl, left, top, width, height)Video在網頁上插入含有指定位置和大小的影片。
insertVideo(video)Video在頁面上插入所提供 Video 的副本。
insertWordArt(wordArt)WordArt在頁面上插入所提供 WordArt 的副本。
remove()void移除網頁。
replaceAllText(findText, replaceText)Integer以取代文字取代所有符合搜尋文字的項目。
replaceAllText(findText, replaceText, matchCase)Integer以取代文字取代所有符合搜尋文字的項目。
selectAsCurrentPage()void在進行中的簡報中選取 Page 做為 current page selection,並移除先前的所有選取項目。

內容詳盡的說明文件

getBackground()

取得網頁的背景。

回攻員

PageBackground:網頁的背景,

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getColorScheme()

取得與網頁相關聯的 ColorScheme

回攻員

ColorScheme:網頁的色彩配置。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getGroups()

傳回頁面上的 Group 物件清單。

回攻員

Group[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getImages()

傳回頁面上的 Image 物件清單。

回攻員

Image[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getLayoutName()

取得版面配置的名稱。

回攻員

String

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getLines()

傳回頁面上的 Line 物件清單。

回攻員

Line[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getMaster()

取得版面配置的主影格。

回攻員

Master

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getObjectId()

取得網頁的專屬 ID。頁面和頁面元素使用的物件 ID 會共用相同的命名空間。

回攻員

String

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPageElementById(id)

傳回網頁上有指定 ID 的 PageElement,如果不存在,則傳回 null

參數

名稱類型說明
idString所擷取網頁元素的 ID。

回攻員

PageElement:具有指定 ID 的網頁元素。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPageElements()

傳回已在網頁上算繪的 PageElement 物件清單。

回攻員

PageElement[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPageType()

取得網頁的類型。

回攻員

PageType:網頁類型。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPlaceholder(placeholderType)

傳回指定 PlaceholderType 的預留位置 PageElement 物件;如果沒有相符的預留位置,則傳回 null

如果有多個相同類型的預留位置,則會傳回具有最低預留位置索引數量的預留位置。如果多個相符預留位置都具備相同索引,則會傳回網頁元素集合中的第一個預留位置。

var slide = SlidesApp.getActivePresentation().getSlides()[0];
var placeholder = slide.getPlaceholder(SlidesApp.PlaceholderType.CENTERED_TITLE);

參數

名稱類型說明
placeholderTypePlaceholderType

回攻員

PageElement

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPlaceholder(placeholderType, placeholderIndex)

傳回指定 PlaceholderType 和預留位置索引的預留位置 PageElement 物件;如果沒有預留位置,則傳回 null

如果多個預留位置具有相同的類型和索引,則會傳回網頁元素集合中的第一個預留位置。

var slide = SlidesApp.getActivePresentation().getSlides()[0];
var placeholder = slide.getPlaceholder(SlidesApp.PlaceholderType.CENTERED_TITLE, 0);

參數

名稱類型說明
placeholderTypePlaceholderType
placeholderIndexInteger

回攻員

PageElement

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPlaceholders()

傳回頁面中的預留位置 PageElement 物件清單。

var master = SlidesApp.getActivePresentation().getMasters()[0];
Logger.log('Number of placeholders in the master: ' + master.getPlaceholders().length);

回攻員

PageElement[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getShapes()

傳回頁面上的 Shape 物件清單。

回攻員

Shape[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getSheetsCharts()

傳回頁面上的 SheetsChart 物件清單。

回攻員

SheetsChart[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getTables()

傳回頁面上的 Table 物件清單。

回攻員

Table[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getVideos()

傳回頁面上的 Video 物件清單。

回攻員

Video[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getWordArts()

傳回頁面上的 WordArt 物件清單。

回攻員

WordArt[]

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

group(pageElements)

將所有指定的網頁元素分組。

同一個網頁上至少應包含兩個群組內的兩個網頁元素。無法將部分網頁元素 (例如 VideosTablesplaceholder Shapes) 分組。

參數

名稱類型說明
pageElementsPageElement[]要歸為一組的元素。

回攻員

Group:新的群組。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertGroup(group)

在頁面中插入所提供 Group 的副本。

在此網頁上插入元素的位置,取決於來源元素在個別網頁上的位置。

如果提供的元素是從目前簡報中複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性也會沿用已插入的元素。

如果提供的元素是從其他呈現方式複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性就會從來源呈現複製到元素中。

// Copy a group between presentations.
var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0];
var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0];
var group = otherPresentationSlide.getGroups()[0];
currentPresentationSlide.insertGroup(group); // Also available for Layout, Master, and Page.

參數

名稱類型說明
groupGroup要複製及插入的群組。

回攻員

Group:插入的群組。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertImage(blobSource)

在頁面左上角插入圖片,並使用指定映像檔 blob 的預設大小。

插入圖片時,系統會從 BlobSource 擷取圖片一次,並儲存副本,以便在簡報中顯示。圖片大小不得超過 50 MB,且不得超過 2500 萬像素,且須使用 PNG、JPEG 或 GIF 格式。

var slide = SlidesApp.getActivePresentation().getSlides()[0];
// Get the Drive image file with the given ID.
var image = DriveApp.getFileById(fileId);
slide.insertImage(image);

參數

名稱類型說明
blobSourceBlobSource圖片資料。

回攻員

Image:插入的圖片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertImage(blobSource, left, top, width, height)

在網頁上插入含有指定圖片 blob 指定位置和大小的圖片。

系統會在插入時從提供的 BlobSource 擷取圖片,並儲存副本以顯示在簡報中。圖片大小不得超過 50 MB,且不得超過 2500 萬像素,並且須使用 PNG、JPEG 或 GIF 格式。

為了維持圖片的長寬比,圖片會根據提供的大小縮放並置中。

var slide = SlidesApp.getActivePresentation().getSlides()[0];
// Get the Drive image file with the given ID.
var image = DriveApp.getFileById(fileId);
var position = {left: 0, top: 0};
var size = {width: 300, height: 100};
slide.insertImage(image, position.left, position.top, size.width, size.height);

參數

名稱類型說明
blobSourceBlobSource圖片資料。
leftNumber圖片的水平位置,點的位置是以頁面左上角為基準。
topNumber圖片的垂直位置,以網頁左上角做為測量基準。
widthNumber點的圖片寬度。
heightNumber圖片的高度。

回攻員

Image:插入的圖片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertImage(image)

在頁面中插入所提供 Image 的副本。

插入的圖片在本頁中的位置取決於來源圖片在個別網頁上的位置。

如果提供的圖片是從目前簡報中複製的預留位置,則從主要頁面或版面配置頁面沿用的屬性也會沿用插入圖片。

如果提供的圖片是從其他簡報複製而來的預留位置,則從主要頁面或版面配置頁面繼承的屬性就會從來源呈現複製到圖片中。如果複製的預留位置圖片為空白,系統就不會在目的地表示法中插入任何內容。

// Copy an image between presentations.
var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0];
var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0];
var image = otherPresentationSlide.getImages[0];
currentPresentationSlide.insertImage(image);

參數

名稱類型說明
imageImage要複製及插入的圖片。

回攻員

Image:插入的圖片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertImage(imageUrl)

在頁面左上角插入圖片,並使用提供網址的預設大小。

插入圖片時,您可以從網址擷取圖片一次,系統會儲存副本以顯示在簡報中。圖片大小不得超過 50 MB,且不得超過 2500 萬像素,且必須使用 PNG、JPEG 或 GIF 格式。

提供的網址必須可公開存取,且大小不得超過 2 KB。網址本身會與圖片一起儲存,並透過 Image.getSourceUrl() 公開。

參數

名稱類型說明
imageUrlString圖片網址。

回攻員

Image:插入的圖片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertImage(imageUrl, left, top, width, height)

在網頁上插入含有指定網址位置和大小的圖片。

插入圖片時,您可以從網址擷取圖片一次,系統會儲存副本以顯示在簡報中。圖片大小不得超過 50 MB,且不得超過 2500 萬像素,且必須使用 PNG、JPEG 或 GIF 格式。

提供的網址必須可公開存取,且大小不得超過 2 KB。網址本身會與圖片一起儲存,並透過 Image.getSourceUrl() 公開。

為了維持圖片的長寬比,圖片會根據提供的大小縮放並置中。

參數

名稱類型說明
imageUrlString圖片網址。
leftNumber圖片的水平位置,點的位置是以頁面左上角為基準。
topNumber圖片的垂直位置,以網頁左上角做為測量基準。
widthNumber點的圖片寬度。
heightNumber圖片的高度。

回攻員

Image:插入的圖片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertLine(line)

在頁面中插入所提供 Line 的副本。

在此網頁上插入元素的位置,取決於來源元素在個別網頁上的位置。

如果提供的元素是從目前簡報中複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性也會沿用已插入的元素。

如果提供的元素是從其他呈現方式複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性就會從來源呈現複製到元素中。

// Copy a line between presentations.
var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0];
var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0];
var line = otherPresentationSlide.getLines[0];
currentPresentationSlide.insertLine(line);

參數

名稱類型說明
lineLine要複製及插入的行。

回攻員

Line:插入的行。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertLine(lineCategory, startConnectionSite, endConnectionSite)

在連接兩個 connection sites 的頁面中插入一行。這個網頁必須包含兩個連線網站。

// Insert a line in the first slide of the presentation connecting two shapes.
var slide = SlidesApp.getActivePresentation().getSlides()[0];
var shape1 = slide.insertShape(SlidesApp.ShapeType.RECTANGLE);
var shape2 = slide.insertShape(SlidesApp.ShapeType.CLOUD);
slide.insertLine(
    SlidesApp.LineCategory.BENT,
    shape1.getConnectionSites()[0],
    shape2.getConnectionSites()[1]);

參數

名稱類型說明
lineCategoryLineCategory要插入的線條類別。
startConnectionSiteConnectionSite線條起點要連線的連接站。
endConnectionSiteConnectionSite線條末端要連線的連接站。

回攻員

Line:插入的行。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertLine(lineCategory, startLeft, startTop, endLeft, endTop)

在頁面中插入一行。

// Insert a line in the first slide of the presentation.
var slide = SlidesApp.getActivePresentation().getSlides()[0];
var startPoint = {left: 10, top: 10};
var endPoint = {left: 40, top: 40};
slide.insertLine(
    SlidesApp.LineCategory.STRAIGHT,
    startPoint.left,
    startPoint.top,
    endPoint.left,
    endPoint.top);

參數

名稱類型說明
lineCategoryLineCategory要插入的線條類別。
startLeftNumber線條起點的水平位置,以頁面左上角的點為測量基準。
startTopNumber線條起點的垂直位置,以頁面左上角的點為測量基準。
endLeftNumber線條終點的水平位置,以頁面左上角的點為測量單位。
endTopNumber線條終點的垂直位置,以頁面左上角的點為測量基準。

回攻員

Line:插入的行。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertPageElement(pageElement)

在頁面中插入所提供 PageElement 的副本。

在此網頁上插入元素的位置,取決於來源元素在個別網頁上的位置。

如果提供的元素是從目前簡報中複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性也會沿用已插入的元素。

如果提供的元素是從其他呈現方式複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性就會從來源呈現複製到元素中。

// Copy a page element between presentations.
var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0];
var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0];
var pageElement = otherPresentationSlide.getPageElements()[0];

// Also available for Layout, Master, and Page.
currentPresentationSlide.insertPageElement(pageElement);

參數

名稱類型說明
pageElementPageElement要複製及插入的網頁元素。

回攻員

PageElement:插入的網頁元素。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertShape(shape)

在頁面中插入所提供 Shape 的副本。

在此網頁上插入元素的位置,取決於來源元素在個別網頁上的位置。

如果提供的元素是從目前簡報中複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性也會沿用已插入的元素。

如果提供的元素是從其他呈現方式複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性就會從來源呈現複製到元素中。

// Copy a shape between presentations.
var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0];
var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0];
var shape = otherPresentationSlide.getShapes[0];
currentPresentationSlide.insertShape(shape); // Also available for Layout, Master, and Page.

參數

名稱類型說明
shapeShape要複製及插入的形狀。

回攻員

Shape:插入的形狀。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertShape(shapeType)

在頁面上插入形狀。

系統會在頁面的左上角插入預設大小的形狀。

// Insert a shape in the first slide of the presentation.
var slide = SlidesApp.getActivePresentation().getSlides()[0];

// Also available for Layout, Master, and Page.
slide.insertShape(SlidesApp.ShapeType.RECTANGLE);

參數

名稱類型說明
shapeTypeShapeType要插入的形狀類型。

回攻員

Shape:插入的形狀。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertShape(shapeType, left, top, width, height)

在頁面上插入形狀。

參數

名稱類型說明
shapeTypeShapeType要插入的形狀類型。
leftNumber形狀的水平位置,從頁面左上角測量。
topNumber形狀的垂直位置,從網頁左上角開始測量。
widthNumber形狀的寬度。
heightNumber形狀的高度。

回攻員

Shape:插入的形狀。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertSheetsChart(sourceChart)

在頁面上插入 Google 試算表圖表。

系統會在頁面左上角插入預設大小的圖表。

插入的圖表會與來源 Google 試算表圖表連結,以便更新。其他協作者也可以看到來源試算表的連結。

var sheet = SpreadsheetApp.openById('spreadsheetId').getSheets()[0];
var chart = sheet.getCharts()[0];
// Insert the spreadsheet chart in the first slide.
var slide = SlidesApp.getActivePresentation().getSlides()[0];
slide.insertSheetsChart(chart);

參數

名稱類型說明
sourceChartEmbeddedChart要插入頁面中的圖表。

回攻員

SheetsChart:頁面中插入的圖表。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertSheetsChart(sourceChart, left, top, width, height)

在網頁上插入 Google 試算表圖表,並提供指定的位置和大小。

為了維持圖表的長寬比,系統會根據所提供的大小縮放圖表並置中。

插入的圖表會與來源 Google 試算表圖表連結,以便更新。其他協作者也可以看到來源試算表的連結。

var sheet = SpreadsheetApp.openById('spreadsheetId').getSheets()[0];
var chart = sheet.getCharts()[0];
// Insert the spreadsheet chart in the first slide.
var slide = SlidesApp.getActivePresentation().getSlides()[0];
var position = {left: 0, top: 0};
var size = {width: 200, height: 200};

// Also available for Layout, Master, and Page.
slide.insertSheetsChart(
    chart,
    position.left,
    position.top,
    size.width,
    size.height);

參數

名稱類型說明
sourceChartEmbeddedChart要插入頁面中的圖表。
leftNumber圖表的水平位置,以頁面左上角做為測量基準。
topNumber圖表的垂直位置,以頁面左上角為測量基準。
widthNumber圖表的寬度,以點表示。
heightNumber圖表的高度,以點表示。

回攻員

SheetsChart:頁面中插入的圖表。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertSheetsChart(sheetsChart)

在頁面中插入所提供 SheetsChart 的副本。

在此網頁上插入元素的位置,取決於來源元素在個別網頁上的位置。

如果提供的元素是從目前簡報中複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性也會沿用已插入的元素。

如果提供的元素是從其他呈現方式複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性就會從來源呈現複製到元素中。

// Copy a sheets chart between presentations.
var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0];
var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0];
var sheetsChart = otherPresentationSlide.getSheetsCharts[0];

// Also available for Layout, Master, and Page.
currentPresentationSlide.insertSheetsChart(sheetsChart);

參數

名稱類型說明
sheetsChartSheetsChart要複製及插入的工作表圖表。

回攻員

SheetsChart:插入的工作表圖表。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertSheetsChartAsImage(sourceChart)

在網頁上以 Image 格式插入 Google 試算表圖表。

系統會在頁面的左上角插入圖表圖片,並採用預設大小。

插入的圖表圖片未連結至來源 Google 試算表圖表。

var sheet = SpreadsheetApp.openById('spreadsheetId').getSheets()[0];
var chart = sheet.getCharts()[0];
// Insert the spreadsheet chart in the first slide.
var slide = SlidesApp.getActivePresentation().getSlides()[0];
slide.insertSheetsChartAsImage(chart); // Also available for Layout, Master, and Page.

參數

名稱類型說明
sourceChartEmbeddedChart要插入頁面中的圖表。

回攻員

Image:在頁面中插入的圖表圖片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertSheetsChartAsImage(sourceChart, left, top, width, height)

在網頁上以 Image 格式插入 Google 試算表圖表,並提供指定的位置和大小。

為了維持圖表圖片的長寬比,系統會配合提供的大小縮放圖片並置中。

插入的圖表圖片並未與來源 Google 試算表圖表建立連結。

var sheet = SpreadsheetApp.openById('spreadsheetId').getSheets()[0];
var chart = sheet.getCharts()[0];
// Insert the spreadsheet chart in the first slide.
var slide = SlidesApp.getActivePresentation().getSlides()[0];
var position = {left: 0, top: 0};
var size = {width: 200, height: 200};

// Also available for Layout, Master, and Page.
slide.insertSheetsChartAsImage(
    chart,
    position.left,
    position.right,
    size.width,
    size.height);

參數

名稱類型說明
sourceChartEmbeddedChart要插入頁面中的圖表。
leftNumber圖表的水平位置,以頁面左上角做為測量基準。
topNumber圖表的垂直位置,以頁面左上角為測量基準。
widthNumber圖表的寬度,以點表示。
heightNumber圖表的高度,以點表示。

回攻員

Image:在頁面中插入的圖表圖片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertTable(numRows, numColumns)

在頁面中插入表格。

表格會置中顯示在頁面中央,預設大小和平均分配的列高和欄寬。

參數

名稱類型說明
numRowsInteger資料表中的資料列數。
numColumnsInteger表格中的欄數。

回攻員

Table:插入的資料表。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertTable(numRows, numColumns, left, top, width, height)

在頁面中插入含有指定位置和大小的表格。

列和欄會平均分配給建立的資料表。

參數

名稱類型說明
numRowsInteger資料表中的資料列數。
numColumnsInteger表格中的欄數。
leftNumber表格的水平位置,從頁面左上角測量。
topNumber表格的垂直位置,從網頁左上角開始測量。
widthNumber表格的寬度。
heightNumber表格的最小高度。算繪資料表的實際高度取決於文字字型大小等因素。

回攻員

Table:插入的資料表。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertTable(table)

在頁面中插入所提供 Table 的副本。

在此網頁上插入元素的位置,取決於來源元素在個別網頁上的位置。

如果提供的元素是從目前簡報中複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性也會沿用已插入的元素。

如果提供的元素是從其他呈現方式複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性就會從來源呈現複製到元素中。

// Copy a table between presentations.
var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0];
var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0];
var table = otherPresentationSlide.getTables[0];
currentPresentationSlide.insertTable(table); // Also available for Layout, Master, and Page.

參數

名稱類型說明
tableTable要複製及插入的資料表。

回攻員

Table:插入的資料表。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertTextBox(text)

在網頁上插入包含所提供字串的文字方塊 Shape

系統會在網頁的左上角插入預設大小的文字方塊形狀。

// Insert text box with "Hello" on the first slide of presentation.
var slide = SlidesApp.getActivePresentation().getSlides()[0];
slide.insertTextBox('Hello'); // Also available for Layout, Master, and Page.

參數

名稱類型說明
textString文字方塊形狀應包含的字串。

回攻員

Shape:插入的文字方塊形狀。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertTextBox(text, left, top, width, height)

在網頁上插入包含所提供字串的文字方塊 Shape

// Insert text box with "Hello" on the first slide of presentation. This text box is a square
// with a length of 10 points on each side.
var slide = SlidesApp.getActivePresentation().getSlides()[0];
slide.insertTextBox('Hello', 0, 0, 10, 10); // Also available for Layout, Master, and Page.

參數

名稱類型說明
textString文字方塊形狀應包含的字串。
leftNumber文字方塊形狀的水平位置 (從頁面左上角測量)。
topNumber文字方塊形狀的垂直位置 (從頁面左上角測量)。
widthNumber文字方塊形狀的寬度。
heightNumber文字方塊形狀的高度。

回攻員

Shape:插入的文字方塊形狀。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertVideo(videoUrl)

在頁面左上角插入採用預設大小的影片。

目前僅支援 YouTube 影片。

參數

名稱類型說明
videoUrlString要插入的影片網址。

回攻員

Video:插入的影片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertVideo(videoUrl, left, top, width, height)

在網頁上插入含有指定位置和大小的影片。

目前僅支援 YouTube 影片。

參數

名稱類型說明
videoUrlString要插入的影片網址。
leftNumber影片的水平位置,以頁面左上角做為測量基準。
topNumber影片的垂直位置,以網頁左上角做為測量基準。
widthNumber影片的寬度,以點為單位。
heightNumber影片的高度。

回攻員

Video:插入的影片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertVideo(video)

在頁面中插入所提供 Video 的副本。

在此網頁上插入元素的位置,取決於來源元素在個別網頁上的位置。

如果提供的元素是從目前簡報中複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性也會沿用已插入的元素。

如果提供的元素是從其他呈現方式複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性就會從來源呈現複製到元素中。

// Copy a video between presentations.
var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0];
var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0];
var video = otherPresentationSlide.getVideos[0];
currentPresentationSlide.insertVideo(video); // Also available for Layout, Master, and Page.

參數

名稱類型說明
videoVideo要複製及插入的影片。

回攻員

Video:插入的影片。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

insertWordArt(wordArt)

在頁面中插入所提供 WordArt 的副本。

在此網頁上插入元素的位置,取決於來源元素在個別網頁上的位置。

如果提供的元素是從目前簡報中複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性也會沿用已插入的元素。

如果提供的元素是從其他呈現方式複製而來的預留位置,從主要頁面或版面配置頁面沿用的屬性就會從來源呈現複製到元素中。

// Copy a word art between presentations.
var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0];
var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0];
var wordArt = otherPresentationSlide.getWordArts[0];

// Also available for Layout, Master, and Page.
currentPresentationSlide.insertWordArt(wordArt);

參數

名稱類型說明
wordArtWordArt要複製及插入的群組。

回攻員

WordArt — 插入的文字藝術。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

remove()

移除網頁。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

replaceAllText(findText, replaceText)

以取代文字取代所有符合搜尋文字的項目。搜尋不區分大小寫。

參數

名稱類型說明
findTextString要尋找的文字。
replaceTextString要取代相符文字的文字。

回攻員

Integer:變更的重複次數

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

replaceAllText(findText, replaceText, matchCase)

以取代文字取代所有符合搜尋文字的項目。

參數

名稱類型說明
findTextString要尋找的文字。
replaceTextString要取代相符文字的文字。
matchCaseBoolean如果值為 true,則搜尋會區分大小寫;如果值為 false,則搜尋不區分大小寫。

回攻員

Integer:變更的重複次數

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

selectAsCurrentPage()

在進行中的簡報中選取 Page 做為 current page selection,並移除先前的所有選取項目。

指令碼只有在指令碼繫結至簡報時,才能存取執行指令碼的使用者選取項目。

// Select the first slide as the current page selection and replace any previous selection.
var slide = SlidesApp.getActivePresentation().getSlides()[0];
slide.selectAsCurrentPage(); // Also available for Layout, Master, and Page.

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations