Word JavaScript 预览 API

新的 Word JavaScript API 首先在“预览版”中引入,然后在进行足够的测试并获取用户反馈后成为特定编号要求集的一部分。

重要

请注意,以下 Word 预览 API 可能在以下平台上可用。

  • Windows 版 Word
  • Mac 版 Word

iPad 目前不支持 Word 预览 API。 但是,在 Word 网页版中也可能提供了多个 API。 有关仅在 Word 网页版中可用的 API,请参阅 仅限 Web 的 API 列表

注意

预览 API 可能会发生变更,不适合在生产环境中使用。 我们建议你仅在测试和开发环境中试用它们。 不要在生产环境或业务关键型文档中使用预览 API。

若要使用预览 API:

API 列表

下表列出了当前处于预览状态的 Word JavaScript API,但 仅在 Word 网页版中可用的 API 除外。 若要查看所有 Word JavaScript API 的完整列表, (包括预览 API 和以前发布的 API) ,请参阅 所有 Word JavaScript API

说明
正文 insertContentControl (contentControlType?: Word.ContentControlType.richText |Word.ContentControlType.plainText |Word.ContentControlType.checkBox |Word.ContentControlType.dropDownList |Word.ContentControlType.comboBox |“RichText” |“PlainText” |“CheckBox” |“DropDownList” |“ComboBox”) 使用内容控件包装 Body 对象。
边框 color 指定边框的颜色。
location 获取边框的位置。
type 指定边框的边框类型。
visible 指定边框是否可见。
width 指定边框的宽度。
BorderCollection getByLocation (borderLocation:Word.BorderLocation.top |Word.BorderLocation.left |Word.BorderLocation.bottom |Word.BorderLocation.right |Word.BorderLocation.insideHorizontal |Word.BorderLocation.insideVertical |“Top” |“Left” |“Bottom” |“Right” |“InsideHorizontal” |“InsideVertical”) 获取具有指定位置的边框。
getFirst() 获取此集合中的第一个边框。
getFirstOrNullObject () 获取此集合中的第一个边框。
getItem(index: number) 按集合中的索引获取 Border 对象。
insideBorderColor 指定内部边框的 24 位颜色。
insideBorderType 指定内部边框的边框类型。
insideBorderWidth 指定内部边框的宽度。
items 获取此集合中已加载的子项。
outsideBorderColor 指定外部边框的 24 位颜色。
outsideBorderType 指定外边框的边框类型。
outsideBorderWidth 指定外边框的宽度。
ComboBoxContentControl addListItem (displayText: string, value?: string, index?: number) 向此组合框内容控件添加新列表项,并返回 Word.ContentControlListItem 对象。
deleteAllListItems () 删除此组合框内容控件中的所有列表项。
listItems 获取组合框内容控件中列表项的集合。
ContentControl comboBoxContentControl 如果内容控件的类型为“ComboBox”,则指定与组合框相关的数据。
dropDownListContentControl 如果内容控件的类型为“DropDownList”,则指定与下拉列表相关的数据。
resetState () 重置内容控件的状态。
setState (contentControlState:Word.ContentControlState) 设置内容控件的状态。
ContentControlListItem delete() 删除列表项。
displayText 指定下拉列表或组合框内容控件的列表项的显示文本。
index 指定列表项集合中内容控件列表项的索引位置。
select() 选择列表项,并将内容控件的文本设置为列表项的值。
value 为下拉列表或组合框内容控件指定列表项的编程值。
ContentControlListItemCollection getFirst() 获取此集合中的第一个列表项。
getFirstOrNullObject () 获取此集合中的第一个列表项。
items 获取此集合中已加载的子项。
"文档" 比较 (filePath: string, documentCompareOptions?: Word.DocumentCompareOptions) 显示修订标记,以表明指定的文档与另一个文档的区别。
DocumentCompareOptions addToRecentFiles True 将文档添加到 文件菜单上最近使用的文件列表。
authorName 与比较生成的区别相关联的审阅者姓名。
compareTarget 比较的目标文档。
detectFormatChanges 真 (默认值) 进行比较以包含检测到的格式更改。
ignoreAllComparisonWarnings 真正 比较文档,而不必通知用户有问题存在。
removeDateAndTime 为 日期和时间戳信息从修订中移除返回的 文档 对象中。
removePersonalInformation 如果为 True,则从返回的 Document 对象中的注释、修订和属性对话框中删除所有用户信息。
DropDownListContentControl addListItem (displayText: string, value?: string, index?: number) 向此下拉列表内容控件添加新的列表项,并返回 Word.ContentControlListItem 对象。
deleteAllListItems () 删除此下拉列表内容控件中的所有列表项。
listItems 获取下拉列表内容控件中列表项的集合。
字段 showCodes 指定是否显示指定字段的域代码。
Font hidden 指定一个值,该值指示字体是否标记为隐藏。
InlinePicture imageFormat 获取内联图像的格式。
List getLevelFont (级别:数字) 获取列表中指定级别的项目符号、数字或图片的字体。
getLevelPicture (level: number) 获取列表中指定级别的图片的 Base64 编码字符串表示形式。
resetLevelFont (level: number, resetFontName?: boolean) 重置列表中指定级别的项目符号、数字或图片的字体。
setLevelPicture (级别: number, base64EncodedImage?: string) 在列表中的指定级别设置图片。
ListLevel 对准 指定列表级别的水平对齐方式。
font 获取一个 Font 对象,该对象表示指定对象的字符格式设置。
linkedStyle 指定链接到指定列表级别对象的样式的名称。
numberFormat 指定指定列表级别的数字格式。
numberPosition 指定指定列表级别对象的编号或项目符号) 位置 (以磅为单位。
numberStyle 指定列表级别对象的编号样式。
resetOnHigher 指定在指定的列表级别重新启动编号为 1 之前必须显示的列表级别。
startAt 指定指定列表级别对象的起始编号。
tabPosition 指定指定列表级别对象的选项卡位置。
textPosition 指定指定列表级别对象的第二行换行文本 () 的位置(以磅为单位)。
trailingCharacter 指定在指定列表级别的数字之后插入的字符。
ListLevelCollection getFirst() 获取此集合中的第一个列表级别。
getFirstOrNullObject () 获取此集合中的第一个列表级别。
items 获取此集合中已加载的子项。
ListTemplate listLevels 获取一个 ListLevels 集合,该集合代表指定 ListTemplate 的所有级别。
outlineNumbered 指定指定的 ListTemplate 对象是否为大纲编号。
Paragraph insertContentControl (contentControlType?: Word.ContentControlType.richText |Word.ContentControlType.plainText |Word.ContentControlType.checkBox |Word.ContentControlType.dropDownList |Word.ContentControlType.comboBox |“RichText” |“PlainText” |“CheckBox” |“DropDownList” |“ComboBox”) 使用内容控件包装 Paragraph 对象。
区域 insertContentControl (contentControlType?: Word.ContentControlType.richText |Word.ContentControlType.plainText |Word.ContentControlType.checkBox |Word.ContentControlType.dropDownList |Word.ContentControlType.comboBox |“RichText” |“PlainText” |“CheckBox” |“DropDownList” |“ComboBox”) 使用内容控件包装 Range 对象。
Shading foregroundPatternColor 指定对象的前景的颜色。
质地 指定对象的底纹纹理。
样式 Borders 指定一个 BorderCollection 对象,该对象代表指定样式的所有边框。
description 获取指定样式的说明。
listTemplate 获取一个 ListTemplate 对象,该对象代表指定 Style 对象的列表格式。
TableRow insertContentControl() 在行中插入内容控件。
TableStyle 对准 指定表与页边距的对齐方式。
allowBreakAcrossPage 指定用指定样式设置格式的表中的行是否跨页分隔。

仅限 Web 的 API 列表

下表列出了目前仅在 Web 上的 Word 中处于预览状态的 Word JavaScript API。 若要查看所有 Word JavaScript API 的完整列表, (包括预览 API 和以前发布的 API) ,请参阅 所有 Word JavaScript API

说明
正文 onCommentAdded 在添加新注释时发生。
onCommentChanged 更改批注或其回复时发生。
onCommentDeleted 删除批注时发生。
onCommentDeselected 在取消选择批注时发生。
onCommentSelected 在选择批注时发生。
CommentDetail id 表示此注释的 ID。
replyIds 表示对此批注的答复的 ID。
CommentEventArgs changeType 表示如何触发注释更改事件。
commentDetails 获取 CommentDetail 数组,其中包含所涉及注释的 ID 和回复 ID。
事件的源。
type 事件类型。
ContentControl onCommentAdded 在添加新注释时发生。
onCommentChanged 更改批注或其回复时发生。
onCommentDeselected 在取消选择批注时发生。
onCommentSelected 在选择批注时发生。
Paragraph onCommentAdded 在添加新注释时发生。
onCommentChanged 更改批注或其回复时发生。
onCommentDeleted 删除批注时发生。
onCommentDeselected 在取消选择批注时发生。
onCommentSelected 在选择批注时发生。
区域 onCommentAdded 在添加新注释时发生。
onCommentChanged 更改批注或其回复时发生。
onCommentDeselected 在取消选择批注时发生。
onCommentSelected 在选择批注时发生。

另请参阅