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如果不存在匹配的占位符,则返回指定 PlaceholderTypenull 的占位符 PageElement 对象。
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)ImageImage 的形式在页面上插入具有指定位置和大小的 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)

如果不存在匹配的占位符,则返回指定 PlaceholderTypenull 的占位符 PageElement 对象。

如果存在多个相同类型的占位符,则返回占位符索引最小的占位符。如果存在多个具有相同索引的匹配占位符,则系统会从页面的页面元素集合中返回第一个占位符。

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 提取一次图片,并存储一个副本以便在演示文稿中显示。图片必须小于 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)

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