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将 Google 表格图表作为 Image 在网页上插入。
insertSheetsChartAsImage(sourceChart, left, top, width, height)Image将 Google 表格图表作为 Image 在页面上插入指定位置和 。
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 提取一次,并存储副本 以便在演示文稿内部显示图片大小必须小于 50MB,不能超过 25 百万像素,且必须采用 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 中提取一次,并将图片的副本 以便在演示文稿中显示。图片必须小于 50MB,不能 超过 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)

根据提供的网址在页面的左上角插入默认大小的图片。

插入图片即会从网址抓取一次,然后会存储一个副本以便在 演示文稿。图片必须小于 50MB,不能超过 2500 万像素, 格式为 PNG、JPEG 或 GIF 格式。

提供的网址必须可公开访问,且大小不得超过 2kB。网址本身已保存 图片,并通过 Image.getSourceUrl() 公开。

参数

名称类型说明
imageUrlString图片网址。

返回

Image - 插入的图片。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

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

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

在页面上插入具有指定位置和大小(根据提供的网址)的图片。

插入图片即会从网址抓取一次,然后会存储一个副本以便在 演示文稿。图片必须小于 50MB,不能超过 2500 万像素, 格式为 PNG、JPEG 或 GIF 格式。

提供的网址必须可公开访问,且大小不得超过 2kB。网址本身已保存 图片,并通过 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)

将 Google 表格图表作为 Image 在网页上插入。

系统会在页面左上角使用默认尺寸插入图表图片。

插入的图表图片未与 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)

将 Google 表格图表作为 Image 在页面上插入指定位置和 。

为了保持图表图片的纵横比,使用 与提供的尺寸相关联

插入的图表图片未与 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