Word JavaScript API 1.1 中的新增功能

WordApi 1.1 是 Word JavaScript API 的第一个要求集。 这是Word 2016支持的唯一Word API 要求集。

API 列表

下表列出了 Word JavaScript API 要求集 1.1 中的 API。 若要查看 Word JavaScript API 要求集 1.1 支持的所有 API 的 API 参考文档,请参阅要求集 1.1 中的 Word API

说明
正文 clear() 清除 对象的内容 Body
contentControls 获取正文中富文本内容控件对象的集合。
font 获取正文的文本格式。
getHtml() 获取 对象的 HTML 表示形式 Body
getOoxml() 获取对象的 OOXML (Office Open XML) 表示形式 Body
inlinePictures 获取正文中的 对象的集合 InlinePicture
insertBreak (breakType: Word。BreakType |“Page” |“下一步” |“SectionNext” |“SectionContinuous” |“SectionEven” |“SectionOdd” |“Line”,insertLocation:Word。InsertLocation.start |Word。InsertLocation.end |“Start” |“End”) 在主文档的指定位置插入分隔符。
insertContentControl (contentControlType?: Word。ContentControlType.richText |Word。ContentControlType.plainText |Word。ContentControlType.checkBox |Word。ContentControlType.dropDownList |Word。ContentControlType.comboBox |Word。ContentControlType.buildingBlockGallery |Word。ContentControlType.datePicker |Word。ContentControlType.repeatingSection |Word。ContentControlType.picture |Word。ContentControlType.group |“RichText” |“PlainText” |“CheckBox” |“DropDownList” |“ComboBox” |“BuildingBlockGallery” |“DatePicker” |“RepeatingSection” |“图片” |“Group”) Body使用内容控件包装 对象。
insertFileFromBase64 (base64File: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将文档插入到正文中的指定位置。
insertHtml (html: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 在指定位置插入 HTML。
insertOoxml (ooxml: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 在指定位置插入 OOXML。
insertParagraph (paragraphText: string, insertLocation: Word。InsertLocation.start |Word。InsertLocation.end |“Start” |“End”) 在指定位置插入段落。
insertText (text: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将文本插入到正文中的指定位置。
paragraphs 获取正文中的 对象的集合 Paragraph
parentContentControl 获取包含正文的内容控件。
search (searchText: string, searchOptions?: Word。SearchOptions |{ ignorePunct?: boolean ignoreSpace?: boolean matchCase?: boolean matchPrefix?: boolean matchSuffix?: boolean matchWholeWord?: boolean matchWildcards?: boolean }) 对对象范围 Body 使用指定的搜索选项执行搜索。
选择 (selectionMode?: Word。SelectionMode) 选择正文并在 Word UI 中进行浏览。
style 指定正文的样式名称。
text 获取正文的文本。
ContentControl 外观 指定内容控件的外观。
cannotDelete 指定一个值,该值指示用户是否可以删除内容控件。
cannotEdit 指定一个值,该值指示用户是否可以编辑内容控件的内容。
clear() 清除内容控件的内容。
color 指定内容控件的颜色。
contentControls 获取内容控件中对象的集合 ContentControl
delete (keepContent:布尔) 删除内容控件及其内容。
font 获取内容控件的文本格式。
getHtml() 获取 对象的 HTML 表示形式 ContentControl
getOoxml() 获取对象的 Office Open XML (OOXML) 表示形式 ContentControl
id 获取表示内容控件标识符的整数。
inlinePictures 获取内容控件中对象的集合 InlinePicture
insertBreak (breakType: Word。BreakType |“Page” |“下一步” |“SectionNext” |“SectionContinuous” |“SectionEven” |“SectionOdd” |“Line”,insertLocation:Word。InsertLocation.start |Word。InsertLocation.end |Word。InsertLocation.before |Word。InsertLocation.after |“Start” |“End” |“Before” |“After”) 在主文档的指定位置插入分隔符。
insertFileFromBase64 (base64File: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将文档插入到位于指定位置的内容控件中。
insertHtml (html: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将 HTML 插入到内容控件中的指定位置。
insertOoxml (ooxml: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将 OOXML 插入到指定位置的内容控件中。
insertParagraph (paragraphText: string, insertLocation: Word。InsertLocation.start |Word。InsertLocation.end |Word。InsertLocation.before |Word。InsertLocation.after |“Start” |“End” |“Before” |“After”) 在指定位置插入段落。
insertText (text: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将文本插入到内容控件中的指定位置。
paragraphs 获取内容控件中对象的集合 Paragraph
parentContentControl 获取包含此内容控件的内容控件。
placeholderText 指定内容控件的占位符文本。
removeWhenEdited 指定一个值,该值指示内容控件在编辑后是否将其删除。
search (searchText: string, searchOptions?: Word。SearchOptions |{ ignorePunct?: boolean ignoreSpace?: boolean matchCase?: boolean matchPrefix?: boolean matchSuffix?: boolean matchWholeWord?: boolean matchWildcards?: boolean }) 对对象范围 ContentControl 使用指定的搜索选项执行搜索。
选择 (selectionMode?: Word。SelectionMode) 选择内容控件。
style 指定内容控件的样式名称。
标记 指定用于标识内容控件的标记。
text 获取内容控件的文本。
title 指定内容控件的标题。
type 获取内容控件的类型。
ContentControlCollection getById(id: number) 按其标识符获取内容控件。
getByTag(tag: string) 获取具有指定标记的内容控件。
getByTitle(title: string) 获取具有指定标题的内容控件。
getItem (ID:数字) 按 ID 获取内容控件。
items 获取此集合中已加载的子项。
"文档" body 获取 Body 主文档的 对象。
contentControls 获取文档中对象的 ContentControl 集合。
getSelection () 获取文档的当前选定内容。
save (saveBehavior?: Word。SaveBehavior,fileName?: string) 保存文档。
保存 指示是否已保存在文档中所做的更改。
sections 获取文档中对象的 Section 集合。
Font bold 指定字体是否为粗体。
color 指定字体的颜色。
doubleStrikeThrough 指定字体是否具有双删除线。
highlightColor 指定突出显示颜色。
italic 指定字体是否斜体。
名称 指定字体的名称。
size 指定字号(以磅为单位)。
strikeThrough 指定字体是否具有删除线。
subscript 指定字体是否为下标。
superscript 指定字体是否为上标。
underline 指定字体的下划线类型。
InlinePicture altTextDescription 指定表示与内联图像关联的可选文本的字符串。
altTextTitle 指定包含内联图像标题的字符串。
getBase64ImageSrc () 获取内联图像的 Base64 编码字符串表示形式。
height 指定描述内联图像高度的数字。
hyperlink 指定图像上的超链接。
insertContentControl() 使用富文本内容控件封装嵌入式图像。
lockAspectRatio 指定一个值,该值指示内联图像在调整大小时是否保留其原始比例。
parentContentControl 获取包含嵌入式图像的内容控件。
width 指定描述内联图像宽度的数字。
InlinePictureCollection items 获取此集合中已加载的子项。
Paragraph 对准 指定段落的对齐方式。
clear() 清除 对象的内容 Paragraph
contentControls 获取段落中对象的集合 ContentControl
delete() 从文档中删除段落及其内容。
firstLineIndent 指定第一行或悬挂缩进的值(以磅为单位)。
font 获取段落的文本格式。
getHtml() 获取 对象的 HTML 表示形式 Paragraph
getOoxml() 获取对象的 Office Open XML (OOXML) 表示形式 Paragraph
inlinePictures 获取段落中对象的集合 InlinePicture
insertBreak (breakType: Word。BreakType |“Page” |“下一步” |“SectionNext” |“SectionContinuous” |“SectionEven” |“SectionOdd” |“Line”,insertLocation:Word。InsertLocation.before |Word。InsertLocation.after |“Before” |“After”) 在主文档的指定位置插入分隔符。
insertContentControl (contentControlType?: Word。ContentControlType.richText |Word。ContentControlType.plainText |Word。ContentControlType.checkBox |Word。ContentControlType.dropDownList |Word。ContentControlType.comboBox |Word。ContentControlType.buildingBlockGallery |Word。ContentControlType.datePicker |Word。ContentControlType.repeatingSection |Word。ContentControlType.picture |Word。ContentControlType.group |“RichText” |“PlainText” |“CheckBox” |“DropDownList” |“ComboBox” |“BuildingBlockGallery” |“DatePicker” |“RepeatingSection” |“图片” |“Group”) Paragraph使用内容控件包装 对象。
insertFileFromBase64 (base64File: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将文档插入到指定位置的段落中。
insertHtml (html: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将 HTML 插入到段落中的指定位置。
insertInlinePictureFromBase64 (base64EncodedImage: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将图片插入到段落中的指定位置。
insertOoxml (ooxml: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将 OOXML 插入到指定位置的段落中。
insertParagraph (paragraphText: string, insertLocation: Word。InsertLocation.before |Word。InsertLocation.after |“Before” |“After”) 在指定位置插入段落。
insertText (text: string, insertLocation: Word。InsertLocation.replace |Word。InsertLocation.start |Word。InsertLocation.end |“Replace” |“Start” |“End”) 将文本插入到段落中的指定位置。
leftIndent 指定段落的左缩进值(以磅为单位)。
lineSpacing 指定指定段落的行距(以磅为单位)。
lineUnitAfter 指定段落后网格线中的间距量。
lineUnitBefore 指定段落前的网格线间距量。
outlineLevel 指定段落的大纲级别。
parentContentControl 获取包含段落的内容控件。
rightIndent 指定段落的右缩进值(以磅为单位)。
search (searchText: string, searchOptions?: Word。SearchOptions |{ ignorePunct?: boolean ignoreSpace?: boolean matchCase?: boolean matchPrefix?: boolean matchSuffix?: boolean matchWholeWord?: boolean matchWildcards?: boolean }) 对对象范围 Paragraph 使用指定的搜索选项执行搜索。
选择 (selectionMode?: Word。SelectionMode) 选择并在 Word UI 中导航到段落。
spaceAfter 指定段落后的间距(以磅为单位)。
spaceBefore 指定段落前的间距(以磅为单位)。
style 指定段落的样式名称。
text 获取段落的文本。
ParagraphCollection items 获取此集合中已加载的子项。
区域 clear() 清除 对象的内容 Range
contentControls 获取区域中对象的 ContentControl 集合。
delete() 从文档中删除区域及其内容。
font 获取区域的文本格式。
getHtml() 获取 对象的 HTML 表示形式 Range
getOoxml() 获取 对象的 OOXML 表示形式 Range
insertBreak (breakType: Word。BreakType |“Page” |“下一步” |“SectionNext” |“SectionContinuous” |“SectionEven” |“SectionOdd” |“Line”,insertLocation:Word。InsertLocation.before |Word。InsertLocation.after |“Before” |“After”) 在主文档的指定位置插入分隔符。
insertContentControl (contentControlType?: Word。ContentControlType.richText |Word。ContentControlType.plainText |Word。ContentControlType.checkBox |Word。ContentControlType.dropDownList |Word。ContentControlType.comboBox |Word。ContentControlType.buildingBlockGallery |Word。ContentControlType.datePicker |Word。ContentControlType.repeatingSection |Word。ContentControlType.picture |Word。ContentControlType.group |“RichText” |“PlainText” |“CheckBox” |“DropDownList” |“ComboBox” |“BuildingBlockGallery” |“DatePicker” |“RepeatingSection” |“图片” |“Group”) Range使用内容控件包装 对象。
insertFileFromBase64 (base64File: string, insertLocation: Word。InsertLocation |“Replace” |“Start” |“End” |“Before” |“After”) 在指定位置插入 document。
insertHtml (html: string, insertLocation: Word。InsertLocation |“Replace” |“Start” |“End” |“Before” |“After”) 在指定位置插入 HTML。
insertOoxml (ooxml: string, insertLocation: Word。InsertLocation |“Replace” |“Start” |“End” |“Before” |“After”) 在指定位置插入 OOXML。
insertParagraph (paragraphText: string, insertLocation: Word。InsertLocation.before |Word。InsertLocation.after |“Before” |“After”) 在指定位置插入段落。
insertText (text: string, insertLocation: Word。InsertLocation |“Replace” |“Start” |“End” |“Before” |“After”) 在指定位置插入文本。
paragraphs 获取区域中对象的 Paragraph 集合。
parentContentControl 获取当前支持的内容控件,该控件包含 区域。
search (searchText: string, searchOptions?: Word。SearchOptions |{ ignorePunct?: boolean ignoreSpace?: boolean matchCase?: boolean matchPrefix?: boolean matchSuffix?: boolean matchWholeWord?: boolean matchWildcards?: boolean }) 对对象范围 Range 使用指定的搜索选项执行搜索。
选择 (selectionMode?: Word。SelectionMode) 选择并在 Word UI 中导航到区域。
style 指定区域的样式名称。
text 获取区域的文本。
RangeCollection items 获取此集合中已加载的子项。
SearchOptions ignorePunct 如果提供,则指定是否忽略单词之间的所有标点符号。
ignoreSpace 如果提供,则指定是否忽略单词之间的所有空格。
matchCase 如果提供,则指定是否执行区分大小写的搜索。
matchPrefix 如果提供,则指定是否匹配以搜索字符串开头的单词。
matchSuffix 如果提供,则指定是否匹配以搜索字符串结尾的单词。
matchWholeWord 如果提供,则指定是否仅查找整个单词,而不查找作为较大单词的一部分的文本。
matchWildcards 如果提供,则指定是否将使用特殊搜索运算符执行搜索。
Section body 获取 Body 节的 对象。
getFooter (类型:Word。HeaderFooterType) 获取节的页脚之一。
getHeader (类型:Word。HeaderFooterType) 获取节的标头之一。
SectionCollection items 获取此集合中已加载的子项。

另请参阅