Document Service
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
文档
此服务允许脚本创建、访问和修改 Google 文档文件。
// Open a document by ID.
var doc = DocumentApp.openById('DOCUMENT_ID');
// Create and open a document.
doc = DocumentApp.create('Document Name');
类
属性
属性 | 类型 | 说明 |
BACKGROUND_COLOR | Enum | 元素(段落、表格等)或文档的背景颜色。 |
BOLD | Enum | 富文本的字体粗细设置。 |
BORDER_COLOR | Enum | 表格元素的边框颜色。 |
BORDER_WIDTH | Enum | 表格元素的边框宽度(以点为单位)。 |
CODE | Enum | 等式元素的代码内容。 |
FONT_FAMILY | Enum | 富文本的字体系列设置。 |
FONT_SIZE | Enum | 富文本的字体大小设置(以磅为单位)。 |
FOREGROUND_COLOR | Enum | 富文本的前景色设置。 |
HEADING | Enum | 段落元素的标题类型(例如 DocumentApp.ParagraphHeading.HEADING1 )。 |
HEIGHT | Enum | 图片元素的高度设置。 |
HORIZONTAL_ALIGNMENT | Enum | 段落元素(例如 DocumentApp.HorizontalAlignment.CENTER )的水平对齐方式。 |
INDENT_END | Enum | 段落元素的结束缩进设置(以点为单位)。 |
INDENT_FIRST_LINE | Enum | 段落元素的首行缩进设置(以点为单位)。 |
INDENT_START | Enum | 段落元素的起始缩进设置(以点为单位)。 |
ITALIC | Enum | 富文本的字体样式设置。 |
GLYPH_TYPE | Enum | 列表项元素的字形类型。 |
LEFT_TO_RIGHT | Enum | 富文本的文本方向设置。 |
LINE_SPACING | Enum | 段落元素的行间距设置倍数。 |
LINK_URL | Enum | 链接网址,适用于富文本。 |
LIST_ID | Enum | 所含列表的 ID,用于列表项元素。 |
MARGIN_BOTTOM | Enum | 段落元素的下外边距设置(以磅为单位)。 |
MARGIN_LEFT | Enum | 段落元素的左边距设置(以点为单位)。 |
MARGIN_RIGHT | Enum | 段落元素的右边距设置(以磅为单位)。 |
MARGIN_TOP | Enum | 段落元素的上外边距设置(以磅为单位)。 |
NESTING_LEVEL | Enum | 列表项嵌套级别。 |
MINIMUM_HEIGHT | Enum | 表格行元素的最小高度设置(以点为单位)。 |
PADDING_BOTTOM | Enum | 表格单元格元素的底部内边距设置(以点为单位)。 |
PADDING_LEFT | Enum | 表格单元格元素的左侧内边距设置(以点为单位)。 |
PADDING_RIGHT | Enum | 表格单元格元素的右侧内边距设置(以点为单位)。 |
PADDING_TOP | Enum | 表格单元格元素的顶部内边距设置(以点为单位)。 |
PAGE_HEIGHT | Enum | 文档的页面高度设置(以磅为单位)。 |
PAGE_WIDTH | Enum | 文档的页面宽度设置(以磅为单位)。 |
SPACING_AFTER | Enum | 段落元素的底部间距设置(以点为单位)。 |
SPACING_BEFORE | Enum | 段落元素的顶部间距设置(以点为单位)。 |
STRIKETHROUGH | Enum | 带删除线的设置,适用于富文本。 |
UNDERLINE | Enum | 下划线设置,适用于富文本。 |
VERTICAL_ALIGNMENT | Enum | 表格单元格元素的垂直对齐设置。 |
WIDTH | Enum | 表格单元格和图片元素的宽度设置。 |
方法
方法 | 返回类型 | 简介 |
appendHorizontalRule() | HorizontalRule | 创建并附加新的 HorizontalRule 。 |
appendImage(image) | InlineImage | 根据指定的图片 blob 创建并附加新的 InlineImage 。 |
appendImage(image) | InlineImage | 附加指定的 InlineImage 。 |
appendListItem(listItem) | ListItem | 附加指定的 ListItem 。 |
appendListItem(text) | ListItem | 创建并附加一个包含指定文本内容的新 ListItem 。 |
appendPageBreak() | PageBreak | 创建并附加新的 PageBreak 。 |
appendPageBreak(pageBreak) | PageBreak | 附加指定的 PageBreak 。 |
appendParagraph(paragraph) | Paragraph | 附加指定的 Paragraph 。 |
appendParagraph(text) | Paragraph | 创建并附加一个包含指定文本内容的新 Paragraph 。 |
appendTable() | Table | 创建并附加新的 Table 。 |
appendTable(cells) | Table | 用于为每个指定的字符串值附加一个新的 Table ,其中包含一个 TableCell 。 |
appendTable(table) | Table | 附加指定的 Table 。 |
clear() | Body | 清除元素的内容。 |
copy() | Body | 返回当前元素的分离的深层副本。 |
editAsText() | Text | 获取当前元素的 Text 版本,以用于修改。 |
findElement(elementType) | RangeElement | 搜索指定类型的后代元素的内容。 |
findElement(elementType, from) | RangeElement | 搜索指定类型的后代元素的内容,从
指定的 RangeElement 。 |
findText(searchPattern) | RangeElement | 使用正则表达式搜索指定文本格式的元素内容。 |
findText(searchPattern, from) | RangeElement | 搜索指定文本格式的元素内容,从指定的
搜索结果。 |
getAttributes() | Object | 检索元素的属性。 |
getChild(childIndex) | Element | 检索指定子索引处的子元素。 |
getChildIndex(child) | Integer | 检索指定子元素的子索引。 |
getHeadingAttributes(paragraphHeading) | Object | 检索提供的 ParagraphHeading 的一组属性。 |
getImages() | InlineImage[] | 检索相应区段中包含的所有 InlineImages 。 |
getListItems() | ListItem[] | 检索相应区段中包含的所有 ListItems 。 |
getMarginBottom() | Number | 检索下外边距(以点为单位)。 |
getMarginLeft() | Number | 检索左外边距(以点为单位)。 |
getMarginRight() | Number | 检索右外边距。 |
getMarginTop() | Number | 检索上外边距。 |
getNumChildren() | Integer | 检索子元素的数量。 |
getPageHeight() | Number | 检索页面高度(以点为单位)。 |
getPageWidth() | Number | 检索页面宽度(以点为单位)。 |
getParagraphs() | Paragraph[] | 检索该区段中包含的所有 Paragraphs (包括 ListItems )。 |
getParent() | ContainerElement | 获取该元素的父元素。 |
getTables() | Table[] | 检索相应区段中包含的所有 Tables 。 |
getText() | String | 检索文本字符串形式的元素内容。 |
getTextAlignment() | TextAlignment | 获取文本对齐方式。 |
getType() | ElementType | 检索元素的 ElementType 。 |
insertHorizontalRule(childIndex) | HorizontalRule | 在指定索引处创建并插入新的 HorizontalRule 。 |
insertImage(childIndex, image) | InlineImage | 在指定的图片 blob 处创建并插入 InlineImage 。
索引中。 |
insertImage(childIndex, image) | InlineImage | 在指定索引处插入给定 InlineImage 。 |
insertListItem(childIndex, listItem) | ListItem | 在指定索引处插入给定 ListItem 。 |
insertListItem(childIndex, text) | ListItem | 在指定索引处创建并插入一个新的 ListItem ,其中包含指定的
文本内容。 |
insertPageBreak(childIndex) | PageBreak | 在指定索引处创建并插入新的 PageBreak 。 |
insertPageBreak(childIndex, pageBreak) | PageBreak | 在指定索引处插入给定 PageBreak 。 |
insertParagraph(childIndex, paragraph) | Paragraph | 在指定索引处插入给定 Paragraph 。 |
insertParagraph(childIndex, text) | Paragraph | 在指定索引处创建并插入一个新的 Paragraph ,其中包含指定的
文本内容。 |
insertTable(childIndex) | Table | 在指定索引处创建并插入新的 Table 。 |
insertTable(childIndex, cells) | Table | 在指定索引处创建并插入包含指定单元格的新 Table 。 |
insertTable(childIndex, table) | Table | 在指定索引处插入给定 Table 。 |
removeChild(child) | Body | 删除指定的子元素。 |
replaceText(searchPattern, replacement) | Element | 使用常规
表达式。 |
setAttributes(attributes) | Body | 设置元素的属性。 |
setHeadingAttributes(paragraphHeading, attributes) | Body | 为提供的 ParagraphHeading 设置属性。 |
setMarginBottom(marginBottom) | Body | 设置下外边距(以点为单位)。 |
setMarginLeft(marginLeft) | Body | 设置左外边距(以点为单位)。 |
setMarginRight(marginRight) | Body | 设置右外边距(以点为单位)。 |
setMarginTop(marginTop) | Body | 设置上外边距。 |
setPageHeight(pageHeight) | Body | 设置页面高度(以点为单位)。 |
setPageWidth(pageWidth) | Body | 设置页面宽度(以点为单位)。 |
setText(text) | Body | 将内容设置为纯文本。 |
setTextAlignment(textAlignment) | Body | 设置文本对齐方式。 |
Document 类中直接访问和修改文本内容的方法会在活动标签页(在绑定到特定文档的脚本中)或第一个标签页(如果活动标签页不可用)上运行。可以更新依赖这些方法的脚本(例如 Document.getBody()
),使标签页支持下列任一方法:
- 使用第一个标签页:
Document.getTabs()[0].asDocumentTab().getBody()
- 使用所有标签页:使用
Document.getTabs()
和 Tab.getChildTabs()
遍历标签页树。针对树中的每个标签页,调用 Tab.asDocumentTab().getBody()
- 使用所选标签页:
Document.getTabs()[Document.getActiveTab().getId()].asDocumentTab().getBody()
- 使用特定标签页:
Document.getTab(TAB_ID).asDocumentTab().getBody()
如需详细了解标签页功能,请参阅使用标签页。
方法
方法
方法 | 返回类型 | 简介 |
appendHorizontalRule() | HorizontalRule | 创建并附加新的 HorizontalRule 。 |
appendImage(image) | InlineImage | 根据指定的图片 blob 创建并附加新的 InlineImage 。 |
appendImage(image) | InlineImage | 附加指定的 InlineImage 。 |
appendListItem(listItem) | ListItem | 附加指定的 ListItem 。 |
appendListItem(text) | ListItem | 创建并附加一个包含指定文本内容的新 ListItem 。 |
appendParagraph(paragraph) | Paragraph | 附加指定的 Paragraph 。 |
appendParagraph(text) | Paragraph | 创建并附加一个包含指定文本内容的新 Paragraph 。 |
appendTable() | Table | 创建并附加新的 Table 。 |
appendTable(cells) | Table | 用于为每个指定的字符串值附加一个新的 Table ,其中包含一个 TableCell 。 |
appendTable(table) | Table | 附加指定的 Table 。 |
clear() | FooterSection | 清除元素的内容。 |
copy() | FooterSection | 返回当前元素的分离的深层副本。 |
editAsText() | Text | 获取当前元素的 Text 版本,以用于修改。 |
findElement(elementType) | RangeElement | 搜索指定类型的后代元素的内容。 |
findElement(elementType, from) | RangeElement | 搜索指定类型的后代元素的内容,从
指定的 RangeElement 。 |
findText(searchPattern) | RangeElement | 使用正则表达式搜索指定文本格式的元素内容。 |
findText(searchPattern, from) | RangeElement | 搜索指定文本格式的元素内容,从指定的
搜索结果。 |
getAttributes() | Object | 检索元素的属性。 |
getChild(childIndex) | Element | 检索指定子索引处的子元素。 |
getChildIndex(child) | Integer | 检索指定子元素的子索引。 |
getImages() | InlineImage[] | 检索相应区段中包含的所有 InlineImages 。 |
getListItems() | ListItem[] | 检索相应区段中包含的所有 ListItems 。 |
getNumChildren() | Integer | 检索子元素的数量。 |
getParagraphs() | Paragraph[] | 检索该区段中包含的所有 Paragraphs (包括 ListItems )。 |
getParent() | ContainerElement | 获取该元素的父元素。 |
getTables() | Table[] | 检索相应区段中包含的所有 Tables 。 |
getText() | String | 检索文本字符串形式的元素内容。 |
getTextAlignment() | TextAlignment | 获取文本对齐方式。 |
getType() | ElementType | 检索元素的 ElementType 。 |
insertHorizontalRule(childIndex) | HorizontalRule | 在指定索引处创建并插入新的 HorizontalRule 。 |
insertImage(childIndex, image) | InlineImage | 在指定的图片 blob 处创建并插入 InlineImage 。
索引中。 |
insertImage(childIndex, image) | InlineImage | 在指定索引处插入给定 InlineImage 。 |
insertListItem(childIndex, listItem) | ListItem | 在指定索引处插入给定 ListItem 。 |
insertListItem(childIndex, text) | ListItem | 在指定索引处创建并插入一个新的 ListItem ,其中包含指定的
文本内容。 |
insertParagraph(childIndex, paragraph) | Paragraph | 在指定索引处插入给定 Paragraph 。 |
insertParagraph(childIndex, text) | Paragraph | 在指定索引处创建并插入一个新的 Paragraph ,其中包含指定的
文本内容。 |
insertTable(childIndex) | Table | 在指定索引处创建并插入新的 Table 。 |
insertTable(childIndex, cells) | Table | 在指定索引处创建并插入包含指定单元格的新 Table 。 |
insertTable(childIndex, table) | Table | 在指定索引处插入给定 Table 。 |
removeChild(child) | FooterSection | 删除指定的子元素。 |
removeFromParent() | FooterSection | 将元素从其父元素中移除。 |
replaceText(searchPattern, replacement) | Element | 使用常规
表达式。 |
setAttributes(attributes) | FooterSection | 设置元素的属性。 |
setText(text) | FooterSection | 将内容设置为纯文本。 |
setTextAlignment(textAlignment) | FooterSection | 设置文本对齐方式。 |
属性
属性 | 类型 | 说明 |
BULLET | Enum | 默认项目符号,采用圆形,填充样式。 |
HOLLOW_BULLET | Enum | 空心项目符号。 |
SQUARE_BULLET | Enum | 一个方块项目符号。 |
NUMBER | Enum | 基于数字的项目符号。 |
LATIN_UPPER | Enum | 一个大写拉丁字母项目符号。 |
LATIN_LOWER | Enum | 一个小写拉丁字母项目符号。 |
ROMAN_UPPER | Enum | 大写的罗马数字项目符号。 |
ROMAN_LOWER | Enum | 罗马数字小写项目符号。 |
方法
方法 | 返回类型 | 简介 |
appendHorizontalRule() | HorizontalRule | 创建并附加新的 HorizontalRule 。 |
appendImage(image) | InlineImage | 根据指定的图片 blob 创建并附加新的 InlineImage 。 |
appendImage(image) | InlineImage | 附加指定的 InlineImage 。 |
appendListItem(listItem) | ListItem | 附加指定的 ListItem 。 |
appendListItem(text) | ListItem | 创建并附加一个包含指定文本内容的新 ListItem 。 |
appendParagraph(paragraph) | Paragraph | 附加指定的 Paragraph 。 |
appendParagraph(text) | Paragraph | 创建并附加一个包含指定文本内容的新 Paragraph 。 |
appendTable() | Table | 创建并附加新的 Table 。 |
appendTable(cells) | Table | 用于为每个指定的字符串值附加一个新的 Table ,其中包含一个 TableCell 。 |
appendTable(table) | Table | 附加指定的 Table 。 |
clear() | HeaderSection | 清除元素的内容。 |
copy() | HeaderSection | 返回当前元素的分离的深层副本。 |
editAsText() | Text | 获取当前元素的 Text 版本,以用于修改。 |
findElement(elementType) | RangeElement | 搜索指定类型的后代元素的内容。 |
findElement(elementType, from) | RangeElement | 搜索指定类型的后代元素的内容,从
指定的 RangeElement 。 |
findText(searchPattern) | RangeElement | 使用正则表达式搜索指定文本格式的元素内容。 |
findText(searchPattern, from) | RangeElement | 搜索指定文本格式的元素内容,从指定的
搜索结果。 |
getAttributes() | Object | 检索元素的属性。 |
getChild(childIndex) | Element | 检索指定子索引处的子元素。 |
getChildIndex(child) | Integer | 检索指定子元素的子索引。 |
getImages() | InlineImage[] | 检索相应区段中包含的所有 InlineImages 。 |
getListItems() | ListItem[] | 检索相应区段中包含的所有 ListItems 。 |
getNumChildren() | Integer | 检索子元素的数量。 |
getParagraphs() | Paragraph[] | 检索该区段中包含的所有 Paragraphs (包括 ListItems )。 |
getParent() | ContainerElement | 获取该元素的父元素。 |
getTables() | Table[] | 检索相应区段中包含的所有 Tables 。 |
getText() | String | 检索文本字符串形式的元素内容。 |
getTextAlignment() | TextAlignment | 获取文本对齐方式。 |
getType() | ElementType | 检索元素的 ElementType 。 |
insertHorizontalRule(childIndex) | HorizontalRule | 在指定索引处创建并插入新的 HorizontalRule 。 |
insertImage(childIndex, image) | InlineImage | 在指定的图片 blob 处创建并插入 InlineImage 。
索引中。 |
insertImage(childIndex, image) | InlineImage | 在指定索引处插入给定 InlineImage 。 |
insertListItem(childIndex, listItem) | ListItem | 在指定索引处插入给定 ListItem 。 |
insertListItem(childIndex, text) | ListItem | 在指定索引处创建并插入一个新的 ListItem ,其中包含指定的
文本内容。 |
insertParagraph(childIndex, paragraph) | Paragraph | 在指定索引处插入给定 Paragraph 。 |
insertParagraph(childIndex, text) | Paragraph | 在指定索引处创建并插入一个新的 Paragraph ,其中包含指定的
文本内容。 |
insertTable(childIndex) | Table | 在指定索引处创建并插入新的 Table 。 |
insertTable(childIndex, cells) | Table | 在指定索引处创建并插入包含指定单元格的新 Table 。 |
insertTable(childIndex, table) | Table | 在指定索引处插入给定 Table 。 |
removeChild(child) | HeaderSection | 删除指定的子元素。 |
removeFromParent() | HeaderSection | 将元素从其父元素中移除。 |
replaceText(searchPattern, replacement) | Element | 使用常规
表达式。 |
setAttributes(attributes) | HeaderSection | 设置元素的属性。 |
setText(text) | HeaderSection | 将内容设置为纯文本。 |
setTextAlignment(textAlignment) | HeaderSection | 设置文本对齐方式。 |
属性
属性 | 类型 | 说明 |
LEFT | Enum | 左对齐选项。 |
CENTER | Enum | 居中对齐选项。 |
RIGHT | Enum | 右对齐选项。 |
JUSTIFY | Enum | 两端对齐选项。 |
属性
属性 | 类型 | 说明 |
NORMAL | Enum | 普通文本的标题选项。 |
HEADING1 | Enum | 最高标题选项。 |
HEADING2 | Enum | 第二个标题选项。 |
HEADING3 | Enum | 第三个标题选项 |
HEADING4 | Enum | 第四个标题选项。 |
HEADING5 | Enum | 第五个标题选项。 |
HEADING6 | Enum | 最低标题选项。 |
TITLE | Enum | 标题选项。 |
SUBTITLE | Enum | 副标题标题选项。 |
属性
属性 | 类型 | 说明 |
ABOVE_TEXT | Enum | 图片位于文本上方。 |
BREAK_BOTH | Enum | 图片破坏了左侧和右侧的文本。 |
BREAK_LEFT | Enum | 图片会破坏左侧的文本。 |
BREAK_RIGHT | Enum | 图片破坏了右侧的文本。 |
WRAP_TEXT | Enum | 图片被文字环绕。 |
方法
方法 | 返回类型 | 简介 |
appendHorizontalRule() | HorizontalRule | 创建并附加新的 HorizontalRule 。 |
appendImage(image) | InlineImage | 根据指定的图片 blob 创建并附加新的 InlineImage 。 |
appendImage(image) | InlineImage | 附加指定的 InlineImage 。 |
appendListItem(listItem) | ListItem | 附加指定的 ListItem 。 |
appendListItem(text) | ListItem | 创建并附加新的 ListItem 。 |
appendParagraph(paragraph) | Paragraph | 附加指定的 Paragraph 。 |
appendParagraph(text) | Paragraph | 创建并附加新的 Paragraph 。 |
appendTable() | Table | 创建并附加新的 Table 。 |
appendTable(cells) | Table | 附加一个包含指定单元格的新 Table 。 |
appendTable(table) | Table | 附加指定的 Table 。 |
clear() | TableCell | 清除元素的内容。 |
copy() | TableCell | 返回当前元素的分离的深层副本。 |
editAsText() | Text | 获取当前元素的 Text 版本,以用于修改。 |
findElement(elementType) | RangeElement | 搜索指定类型的后代元素的内容。 |
findElement(elementType, from) | RangeElement | 搜索指定类型的后代元素的内容,从
指定的 RangeElement 。 |
findText(searchPattern) | RangeElement | 使用正则表达式搜索指定文本格式的元素内容。 |
findText(searchPattern, from) | RangeElement | 搜索指定文本格式的元素内容,从指定的
搜索结果。 |
getAttributes() | Object | 检索元素的属性。 |
getBackgroundColor() | String | 检索背景颜色。 |
getChild(childIndex) | Element | 检索指定子索引处的子元素。 |
getChildIndex(child) | Integer | 检索指定子元素的子索引。 |
getColSpan() | Integer | 检索列跨度,即此单元格跨过的表格单元格的列数。 |
getLinkUrl() | String | 检索链接网址。 |
getNextSibling() | Element | 检索该元素的下一个同级元素。 |
getNumChildren() | Integer | 检索子元素的数量。 |
getPaddingBottom() | Number | 检索底部内边距(以点为单位)。 |
getPaddingLeft() | Number | 检索左侧内边距(以点为单位)。 |
getPaddingRight() | Number | 检索右侧内边距(以点为单位)。 |
getPaddingTop() | Number | 检索上内边距,以点为单位。 |
getParent() | ContainerElement | 获取该元素的父元素。 |
getParentRow() | TableRow | 检索包含当前 TableCell 的 TableRow 。 |
getParentTable() | Table | 检索包含当前 TableCell 的 Table 。 |
getPreviousSibling() | Element | 检索该元素的前一个同级元素。 |
getRowSpan() | Integer | 检索行跨度,即此单元格跨越的表单元格的行数。 |
getText() | String | 检索文本字符串形式的元素内容。 |
getTextAlignment() | TextAlignment | 获取文本对齐方式。 |
getType() | ElementType | 检索元素的 ElementType 。 |
getVerticalAlignment() | VerticalAlignment | 检索 VerticalAlignment 。 |
getWidth() | Number | 检索包含单元格的列宽(以点为单位)。 |
insertHorizontalRule(childIndex) | HorizontalRule | 在指定索引处创建并插入新的 HorizontalRule 。 |
insertImage(childIndex, image) | InlineImage | 在指定的图片 blob 处创建并插入 InlineImage 。
索引中。 |
insertImage(childIndex, image) | InlineImage | 在指定索引处插入给定 InlineImage 。 |
insertListItem(childIndex, listItem) | ListItem | 在指定索引处插入给定 ListItem 。 |
insertListItem(childIndex, text) | ListItem | 在指定索引处创建并插入新的 ListItem 。 |
insertParagraph(childIndex, paragraph) | Paragraph | 在指定索引处插入给定 Paragraph 。 |
insertParagraph(childIndex, text) | Paragraph | 在指定索引处创建并插入新的 Paragraph 。 |
insertTable(childIndex) | Table | 在指定索引处创建并插入新的 Table 。 |
insertTable(childIndex, cells) | Table | 在指定索引处创建并插入包含指定单元格的新 Table 。 |
insertTable(childIndex, table) | Table | 在指定索引处插入给定 Table 。 |
isAtDocumentEnd() | Boolean | 确定元素是否在 Document 的末尾。 |
merge() | TableCell | 将元素与前一个相同类型的同级元素合并。 |
removeChild(child) | TableCell | 删除指定的子元素。 |
removeFromParent() | TableCell | 将元素从其父元素中移除。 |
replaceText(searchPattern, replacement) | Element | 使用常规
表达式。 |
setAttributes(attributes) | TableCell | 设置元素的属性。 |
setBackgroundColor(color) | TableCell | 设置背景颜色。 |
setLinkUrl(url) | TableCell | 设置链接网址。 |
setPaddingBottom(paddingBottom) | TableCell | 设置底部内边距(以点为单位)。 |
setPaddingLeft(paddingLeft) | TableCell | 设置左侧内边距(以点为单位)。 |
setPaddingRight(paddingRight) | TableCell | 设置右侧内边距(以点为单位)。 |
setPaddingTop(paddingTop) | TableCell | 设置上内边距(以点为单位)。 |
setText(text) | TableCell | 将内容设置为纯文本。 |
setTextAlignment(textAlignment) | TableCell | 设置文本对齐方式。 |
setVerticalAlignment(alignment) | TableCell | 设置垂直对齐方式。 |
setWidth(width) | TableCell | 设置包含当前单元格的列宽(以点为单位)。 |
方法
方法 | 返回类型 | 简介 |
appendText(text) | Text | 将指定文本添加到此文本区域的末尾。 |
copy() | Text | 返回当前元素的分离的深层副本。 |
deleteText(startOffset, endOffsetInclusive) | Text | 删除一系列文本。 |
editAsText() | Text | 获取当前元素的 Text 版本,以用于修改。 |
findText(searchPattern) | RangeElement | 使用正则表达式搜索指定文本格式的元素内容。 |
findText(searchPattern, from) | RangeElement | 搜索指定文本格式的元素内容,从指定的
搜索结果。 |
getAttributes() | Object | 检索元素的属性。 |
getAttributes(offset) | Object | 检索指定字符偏移量的属性。 |
getBackgroundColor() | String | 检索背景颜色设置。 |
getBackgroundColor(offset) | String | 检索指定字符偏移量处的背景颜色。 |
getFontFamily() | String | 检索字体系列设置。 |
getFontFamily(offset) | String | 检索指定字符偏移量处的字体系列。 |
getFontSize() | Number | 检索字体大小设置。 |
getFontSize(offset) | Number | 检索指定字符偏移量处的字体大小。 |
getForegroundColor() | String | 检索前景色设置。 |
getForegroundColor(offset) | String | 检索指定字符偏移量处的前景色。 |
getLinkUrl() | String | 检索链接网址。 |
getLinkUrl(offset) | String | 检索位于指定字符偏移量的链接网址。 |
getNextSibling() | Element | 检索该元素的下一个同级元素。 |
getParent() | ContainerElement | 获取该元素的父元素。 |
getPreviousSibling() | Element | 检索该元素的前一个同级元素。 |
getText() | String | 检索文本字符串形式的元素内容。 |
getTextAlignment() | TextAlignment | 获取文本对齐方式。 |
getTextAlignment(offset) | TextAlignment | 获取单个字符的文本对齐方式。 |
getTextAttributeIndices() | Integer[] | 检索与不同文本格式的开头相对应的文本索引集
。 |
getType() | ElementType | 检索元素的 ElementType 。 |
insertText(offset, text) | Text | 在指定字符偏移量处插入指定文本。 |
isAtDocumentEnd() | Boolean | 确定元素是否在 Document 的末尾。 |
isBold() | Boolean | 检索粗体设置。 |
isBold(offset) | Boolean | 检索指定字符偏移量处的粗体设置。 |
isItalic() | Boolean | 检索斜体设置。 |
isItalic(offset) | Boolean | 检索指定字符偏移量处的斜体设置。 |
isStrikethrough() | Boolean | 检索删除线设置。 |
isStrikethrough(offset) | Boolean | 检索指定字符偏移量处的删除线设置。 |
isUnderline() | Boolean | 检索下划线设置。 |
isUnderline(offset) | Boolean | 检索指定字符偏移量处的下划线设置。 |
merge() | Text | 将元素与前一个相同类型的同级元素合并。 |
removeFromParent() | Text | 将元素从其父元素中移除。 |
replaceText(searchPattern, replacement) | Element | 使用常规
表达式。 |
setAttributes(startOffset, endOffsetInclusive, attributes) | Text | 将指定属性应用于给定的字符范围。 |
setAttributes(attributes) | Text | 设置元素的属性。 |
setBackgroundColor(startOffset, endOffsetInclusive, color) | Text | 设置指定字符范围的背景颜色。 |
setBackgroundColor(color) | Text | 设置背景颜色。 |
setBold(bold) | Text | 设置粗体设置。 |
setBold(startOffset, endOffsetInclusive, bold) | Text | 指定指定字符范围的粗体设置。 |
setFontFamily(startOffset, endOffsetInclusive, fontFamilyName) | Text | 设置指定字符范围的字体系列。 |
setFontFamily(fontFamilyName) | Text | 设置字体系列。 |
setFontSize(startOffset, endOffsetInclusive, size) | Text | 设置指定字符范围的字体大小。 |
setFontSize(size) | Text | 设置字体大小。 |
setForegroundColor(startOffset, endOffsetInclusive, color) | Text | 设置指定字符范围的前景色。 |
setForegroundColor(color) | Text | 设置前景色。 |
setItalic(italic) | Text | 设置斜体。 |
setItalic(startOffset, endOffsetInclusive, italic) | Text | 为指定字符范围设定斜体设置。 |
setLinkUrl(startOffset, endOffsetInclusive, url) | Text | 设置指定字符范围的链接网址。 |
setLinkUrl(url) | Text | 设置链接网址。 |
setStrikethrough(strikethrough) | Text | 设置删除线设置。 |
setStrikethrough(startOffset, endOffsetInclusive, strikethrough) | Text | 为指定字符范围设置删除线。 |
setText(text) | Text | 设置文本内容。 |
setTextAlignment(startOffset, endOffsetInclusive, textAlignment) | Text | 为给定字符范围设置文本对齐方式。 |
setTextAlignment(textAlignment) | Text | 设置文本对齐方式。 |
setUnderline(underline) | Text | 设置下划线设置。 |
setUnderline(startOffset, endOffsetInclusive, underline) | Text | 指定指定字符范围的下划线设置。 |
属性
属性 | 类型 | 说明 |
NORMAL | Enum | 正常的文字对齐方式。 |
SUPERSCRIPT | Enum | 上标文本对齐方式。 |
SUBSCRIPT | Enum | 下标文本对齐方式。 |
属性
属性 | 类型 | 说明 |
BOTTOM | Enum | 底部对齐选项。 |
CENTER | Enum | 居中对齐选项。 |
TOP | Enum | 顶部对齐选项。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-22。
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"没有我需要的信息"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"太复杂/步骤太多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"内容需要更新"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻译问题"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/代码问题"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"易于理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"解决了我的问题"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]
{"lastModified": "\u6700\u540e\u66f4\u65b0\u65f6\u95f4 (UTC)\uff1a2024-08-22\u3002"}
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-08-22。"]]