2.ManifestXML 清单详解

<!--Office 外接程序清单中的根元素-->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
  xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
  <!--指定 Office 外接程序的唯一 ID 为 GUID-->
  <Id>b973fc4e-41bc-4ef1-b86e-7efc598d572f</Id>
  <!--指定 Office 外接程序的版本-->
  <Version>1.0.0.0</Version>
  <!--指定开发此 Office 外接程序的个人或公司的名称为不超过 125 个字符的字符串-->
  <ProviderName>Contoso</ProviderName>
  <!--指定外接程序中的字符串使用的区域设置的默认区域性名称。-->
  <DefaultLocale>en-US</DefaultLocale>
  <!--指定 Office 外接程序的名称为最长 125 个字符的字符串。-->
  <DisplayName DefaultValue="Addin1"/>
  <!--指定 Office 外接程序的说明为不超过 250 个字符的字符串-->
  <Description DefaultValue="A template to get started."/>
  <!--指定用于表示插入 UX 和 Office 应用商店中的 Office 外接程序的图像的 URL-->
  <IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png"/>
  <!--指定用于表示插入 UX 中的 Office 外接程序和高 DPI 屏幕上的 Office 应用商店的图像的 URL-->
  <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-80.png"/>
  <!--指定提供外接程序支持信息的页面的 URL-->
  <SupportUrl DefaultValue="https://www.contoso.com/help"/>
  <!--列出 SourceLocation 您的 Office 外接程序将使用且应受 office 信任的任何域(除了元素中指定的域)。 这使域中的页面可以调用来自加载项中的 Iframe 的 Office.js Api,并具有其他效果。 对于每个其他域,指定 AppDomain 元素-->
  <AppDomains>
    <AppDomain>https://www.contoso.com</AppDomain>
  </AppDomains>
  <!--指定将在其中激活 Office 外接程序的 Office 客户端应用程序。包含 Host 元素及其设置的集合-->
  <!--当该元素被包括在 VersionOverrides(#versionoverrides) 节点中时,它将替代清单中父级部分中的 Hosts 元素-->
  <Hosts>
    <Host Name="Workbook"/>
  </Hosts>
  <!--指定内容或任务窗格外接程序的默认源位置和其他默认设置,可以包含SourceLocation,RequestedWidth,RequestedHeight-->
  <DefaultSettings>
    <!--将 Office 外接程序的源文件位置指定为一个长度介于1到2018个字符之间的 URL。 源位置必须是 HTTPS 地址,而非文件路径-->
    <SourceLocation DefaultValue="https://localhost:3000/taskpane.html"/>
  </DefaultSettings>
  <!--指定 Office 外接程序的 API 访问级别;您应基于最少特权的原则请求权限-->
  <Permissions>ReadWriteDocument</Permissions>
  <!--版本架构-->
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <!--指定 Office 应用程序的集合。 "子主机" 元素将覆盖清单父部分中的 Hosts 元素-->
    <Hosts>
      <!--说明主机及其设置-->
      <Host xsi:type="Workbook">
        <!--指定对桌面外形规格的外接程序的设置。 桌面外形规格包括 web、Windows 和 Mac 上的 Office。 除了 " 资源 " 节点外,它还包含桌面外形规格的所有外接程序信息。-->
        <!--每个 DesktopFormFactor 定义都包含 FunctionFile 元素和一个或多个 ExtensionPoint 元素。 有关详细信息,请参阅 FunctionFile 元素 和 ExtensionPoint 元素。-->
        <DesktopFormFactor>
          <!--定义在 Word、Excel 或 PowerPoint 中安装外接程序时显示的标注-->
          <GetStarted>
            <!--定义外接程序公开功能的位置-->
            <Title resid="GetStarted.Title"/>
            <!--包含 JavaScript 函数的文件的 URL-->
            <Description resid="GetStarted.Description"/>
            <!--指向详细说明外接程序的页面的 URL-->
            <LearnMoreUrl resid="GetStarted.LearnMoreUrl"/>
          </GetStarted>
          <!--执行 JavaScript 函数而不是显示 UI 的外接程序命令-->
          <!--执行 JavaScript 函数的键盘快捷方式-->
          <FunctionFile resid="Commands.Url"/>
          <!--定义 Office UI 中加载项公开功能的位置。 ExtensionPoint 元素是 AllFormFactors、DesktopFormFactor 或 MobileFormFactor 的子元素-->
          <!--PrimaryCommandSurface - Office 中的功能区-->
          <!--ContextMenu - Office UI 中右键单击时出现的快捷菜单-->
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <!--将命令添加到默认功能区选项卡-->
            <OfficeTab id="TabHome">
              <!--将按钮组添加到命令界面-->
              <Group id="CommandsGroup">
                <!--在上下文窗口中指定外接程序的标签-->
                <Label resid="CommandsGroup.Label"/>
                <!--必需。指定将在小型设备上使用或在显示过多按钮的情况下使用的组图标。resid 属性必须设置为 Image 元素的 id 属性的值。Image 元素是 Images 元素的子元素,而 Images 元素是 Resources 元素的子元素。size 属性给出图像的大小(以像素为单位)。要求三种图像大小:16、32 和 80。也同样支持五种可选大小:20、24、40、48 和 64-->
                <Icon>
                  <bt:Image size="16" resid="Icon.16x16"/>
                  <bt:Image size="32" resid="Icon.32x32"/>
                  <bt:Image size="80" resid="Icon.80x80"/>
                </Icon>
                <!--将按钮添加到命令界面-->
                <Control xsi:type="Button" id="TaskpaneButton">
                  <!--在上下文窗口中指定外接程序的标签-->
                  <Label resid="TaskpaneButton.Label"/>
                  <!--定义丰富的工具提示(标题和说明)。它由“按钮”或“菜单”控件使用-->
                  <Supertip>
                    <!--supertip 的文本-->
                    <Title resid="TaskpaneButton.Label"/>
                    <!--supertip 的说明-->
                    <Description resid="TaskpaneButton.Tooltip"/>
                  </Supertip>
                  <!--必需。指定将在小型设备上使用或在显示过多按钮的情况下使用的组图标。resid 属性必须设置为 Image 元素的 id 属性的值。Image 元素是 Images 元素的子元素,而 Images 元素是 Resources 元素的子元素。size 属性给出图像的大小(以像素为单位)。要求三种图像大小:16、32 和 80。也同样支持五种可选大小:20、24、40、48 和 64-->
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16"/>
                    <bt:Image size="32" resid="Icon.32x32"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <!--指定当用户选择按钮或菜单控件时要执行的操作-->
                  <!--type:ExecuteFunction or ShowTaskpane -->
                  <Action xsi:type="ShowTaskpane">
                    <!--指定任务窗格容器的 ID-->
                    <TaskpaneId>ButtonId1</TaskpaneId>
                    <!--指定该操作的源文件位置-->
                    <SourceLocation resid="Taskpane.Url"/>
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <!--包含图标、字符串以及 VersionOverrides 节点的 URL。清单元素通过使用资源的 id 来指定资源。这有助于将清单的大小保持在可管理的范围,尤其是当资源具有不同区域设置的版本时。id 在清单内必须是唯一的且最多可包含 32 个字符-->
    <Resources>
      <!--提供指向图标图像的 HTTPS URL-->
      <bt:Images>
        <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
        <bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
        <bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
      </bt:Images>
      <!--提供 HTTPS URL 位置。一个 URL 最多可包含 2048 个字符-->
      <bt:Urls>
        <bt:Url id="GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812"/>
        <bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html"/>
        <bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
      </bt:Urls>
      <!--Label 和 Title 元素的文本。每个 String 最多可包含 125 个字符-->
      <bt:ShortStrings>
        <bt:String id="GetStarted.Title" DefaultValue="Get started with your sample add-in!"/>
        <bt:String id="CommandsGroup.Label" DefaultValue="Commands Group"/>
        <bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
      </bt:ShortStrings>
      <!--Description 属性的文本。每个 String 最多可包含 250 个字符-->
      <bt:LongStrings>
        <bt:String id="GetStarted.Description" DefaultValue="Your sample add-in loaded succesfully. Go to the HOME tab and click the 'Show Taskpane' button to get started."/>
        <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane"/>
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容