Host 元素Host element

指定应在其中激活外接程序的单个 Office 应用程序类型。Specifies an individual Office application type where the add-in should activate.

重要

Host 元素的语法根据该元素是否在基本清单中或 VersionOverrides 节点中定义而不同。The Host element syntax varies depending on whether the element is defined within the basic manifest or within the VersionOverrides node. 但功能相同。However, the functionality is the same.

基本清单Basic manifest

在基本清单(在 OfficeApp 下)中定义时,主机类型由 Name 属性决定。When defined in the basic manifest (under OfficeApp), the host type is determined by the Name attribute.

属性Attributes

属性Attribute 类型Type 必需Required 说明Description
NameName stringstring 必需required Office 客户端应用程序类型的名称。The name of the type of Office client application.

名称Name

指定此外接程序面向的主机类型。Specifies the Host type targeted by this add-in. 值必须是下列值之一。The value must be one of the following.

  • Document (Word)Document (Word)
  • Database (Access)Database (Access)
  • Mailbox (Outlook)Mailbox (Outlook)
  • Notebook (OneNote)Notebook (OneNote)
  • Presentation (PowerPoint)Presentation (PowerPoint)
  • Project (Project)Project (Project)
  • Workbook (Excel)Workbook (Excel)

重要

我们不建议在 SharePoint 中创建和使用 Access Web 应用和数据库。We no longer recommend that you create and use Access web apps and databases in SharePoint. 作为一种替代方法,我们建议你使用 Microsoft PowerApps 生成适用于 Web 和移动设备的无代码业务解决方案。As an alternative, we recommend that you use Microsoft PowerApps to build no-code business solutions for web and mobile devices.

示例Example

<Hosts>
    <Host Name="Mailbox">
    </Host>
</Hosts>

VersionOverrides 节点VersionOverrides node

VersionOverrides 中定义时,主机类型由 xsi:type 属性决定。When defined in VersionOverrides, the host type is determined by the xsi:type attribute.

属性Attributes

属性Attribute 必需Required 说明Description
xsi:typexsi:type Yes 介绍应用这些设置的 Office 应用程序。Describes the Office application where these settings apply.

子元素Child elements

元素Element 必需Required 说明Description
DesktopFormFactorDesktopFormFactor Yes 定义桌面外形规格的设置。Defines the settings for the desktop form factor.
MobileFormFactorMobileFormFactor No 定义移动设备规格的设置。Defines the settings for the mobile form factor. 注意: 仅在 iOS 和 Android 上的 Outlook 中支持此元素。Note: This element is only supported in Outlook on iOS and Android.
AllFormFactorsAllFormFactors No 定义所有外形规格的设置。Defines the settings for all form factors. 仅用于 Excel 中的自定义函数。Only used by custom functions in Excel.

xsi:typexsi:type

控制包含的设置应用 (Word、Excel、PowerPoint、Outlook、OneNote) 的 Office 应用程序。Controls which Office application (Word, Excel, PowerPoint, Outlook, OneNote) where the contained settings apply. 值必须为以下值之一:The value must be one of the following:

  • Document (Word)Document (Word)
  • MailHost (Outlook)MailHost (Outlook)
  • Notebook (OneNote)Notebook (OneNote)
  • Presentation (PowerPoint)Presentation (PowerPoint)
  • Workbook (Excel)Workbook (Excel)

主机示例Host example

<Hosts>
    <Host xsi:type="MailHost">
        <!-- Host Settings -->
    </Host>
</Hosts>