【问题标题】:Excel 2016 command add-in only working properly on Excel OnlineExcel 2016 命令加载项仅在 Excel Online 上正常工作
【发布时间】:2016-08-08 17:16:39
【问题描述】:

我编写了一个 Excel 2016 任务窗格加载项,它可以在在线和桌面上完美运行。但是,现在我正在尝试将其转换为命令加载项,我偶然发现了一个关于此 manifest 的非常奇怪的部署问题:

<?xml version="1.0" encoding="UTF-8"?>
<!--Created:325c27b6-9566-4641-a1c6-175f0039f620-->
<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" 
>
  <!--BasicSettings-->
  <Id>bcb30953-453a-4cbb-93c3-f3d289de0ee3</Id>
  <Version>1.1.5.6</Version>
  <ProviderName>My Corporation</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="MyAddin" />
  <Description DefaultValue="My addin's description"/>
  <IconUrl DefaultValue="https://i.imgur.com/MPuvMiq.png" />
  <HighResolutionIconUrl DefaultValue="https://i.imgur.com/MPuvMiq.png" />
  <SupportUrl DefaultValue="https://google.com" />
  <!-- http://dev.office.com/reference/add-ins/office-add-in-requirement-sets -->
  <Permissions>ReadWriteDocument</Permissions>
  <!--EndBasicSettings-->



  <!--BeginTaskpaneMode-->
  <Hosts>
    <Host Name="Workbook" />
  </Hosts>
  <DefaultSettings>
    <SourceLocation DefaultValue="https://odsample.azurewebsites.net/Pages/Home.aspx" />
  </DefaultSettings>
  <!--EndTaskpaneMode-->



  <!--BeginAddinCommandsMode-->
  <!-- https://github.com/OfficeDev/Office-Add-in-Commands-Samples/blob/master/Tools/XSD/TaskPaneAppVersionOverridesV1_0.xsd -->
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Description resid="MyAddin.Description" />
    <Hosts>
      <Host xsi:type="Workbook">
        <DesktopFormFactor>
          <GetStarted>
            <Title resid="MyAddin.Title"/>                  
            <Description resid="MyAddin.Description"/>              
            <LearnMoreUrl resid="MyAddin.LearnMore"/>
          </GetStarted>
          <FunctionFile resid="MyAddin.FunctionFile" />
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <CustomTab id="MyAddin" >
              <Group id="MyAddin.Tab1.Group1">
                <Label resid="MyAddin.Tab1.Group1.Label" />
                <Icon>
                  <bt:Image size="16" resid="MyAddin.Tab1.Group1.Icon.16" />
                  <bt:Image size="32" resid="MyAddin.Tab1.Group1.Icon.32" />
                  <bt:Image size="80" resid="MyAddin.Tab1.Group1.Icon.80" />
                </Icon>
                <Control xsi:type="Button" id="MyAddin.Tab1.Group1.RunFunctionButton">
                  <Label resid="MyAddin.Tab1.Group1.RunFunctionButton.Label" />
                  <Supertip>
                    <Title resid="MyAddin.Tab1.Group1.RunFunctionButton.Title" />
                    <Description resid="MyAddin.Tab1.Group1.RunFunctionButton.Description" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="MyAddin.Tab1.Group1.RunFunctionButton.Icon.16" />
                    <bt:Image size="32" resid="MyAddin.Tab1.Group1.RunFunctionButton.Icon.32" />
                    <bt:Image size="80" resid="MyAddin.Tab1.Group1.RunFunctionButton.Icon.80" />
                  </Icon>
                  <Action xsi:type="ExecuteFunction">
                    <FunctionName>writeText</FunctionName>
                  </Action>
                </Control>
              </Group>
              <Label resid="MyAddin.Tab1.Label"/><!-- order is important-->
            </CustomTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="MyAddin.Tab1.Group1.Icon.16" DefaultValue="https://i.imgur.com/FkSShX9.png" />
        <bt:Image id="MyAddin.Tab1.Group1.Icon.32" DefaultValue="https://i.imgur.com/FkSShX9.png" />
        <bt:Image id="MyAddin.Tab1.Group1.Icon.80" DefaultValue="https://i.imgur.com/FkSShX9.png" />
        <bt:Image id="MyAddin.Tab1.Group1.RunFunctionButton.Icon.16" DefaultValue="https://i.imgur.com/qDujiX0.png" />
        <bt:Image id="MyAddin.Tab1.Group1.RunFunctionButton.Icon.32" DefaultValue="https://i.imgur.com/qDujiX0.png" />
        <bt:Image id="MyAddin.Tab1.Group1.RunFunctionButton.Icon.80" DefaultValue="https://i.imgur.com/qDujiX0.png" />
      </bt:Images>
      <bt:Urls>
        <bt:Url id="MyAddin.LearnMore" DefaultValue="https://commandsimple.azurewebsites.net/FunctionFile.html" />
        <bt:Url id="MyAddin.FunctionFile" DefaultValue="https://commandsimple.azurewebsites.net/FunctionFile.html" />
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="MyAddin.Title" DefaultValue="MyAddin" />
        <bt:String id="MyAddin.Tab1.Label" DefaultValue="MyAddin" />
        <bt:String id="MyAddin.Tab1.Group1.Label" DefaultValue="Execute Function" />
        <bt:String id="MyAddin.Tab1.Group1.RunFunctionButton.Label" DefaultValue="Execute Function" />
        <bt:String id="MyAddin.Tab1.Group1.RunFunctionButton.Title" DefaultValue="Execute Function" />
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="MyAddin.Description" DefaultValue="MyAddin's description" />
        <bt:String id="MyAddin.Tab1.Group1.RunFunctionButton.Description" DefaultValue="Click to Execute Function" />
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
  <!--EndAddinCommandsMode--> 
</OfficeApp>

,主要基于official command addin example。这个清单可以完美地导入 Excel Online 以进行测试,并在功能区上显示预期的命令组。但是,它无法在 Excel 的桌面版本中导入,因为在单击“插入”=>“我的插件”=>“共享文件夹”后根本没有显示任何插件(我存储清单以用于测试目的),据我目前的理解,这是由于某种失败的验证。

经过长时间的反复试验,我很确定应该归咎于 xml 命名空间和模式定义。然而,我仍然在挣扎。

我已经检查过,如果我将 &lt;VersionOverrides&gt; 更改为 &lt;VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"&gt;(注意额外的尾随 /1.0),那么我可以在线和桌面上部署清单,但是它们都回退到任务窗格版本(据我了解是由于&lt;VersionOverrides&gt; 部分因畸形而被省略。

在类似的question 中,问题在于未完成命名空间的声明,接受的答案选择使用&lt;OfficeApp xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0&gt;(注意额外的/1.0) and`。使用此配置时,我得到了添加-in 按预期在线工作(命令加载项),但甚至无法在桌面上加载。

同样,我确定这不是版本问题,因此这个question 不适用,因为我运行的是Version: 16.0.7070.2033,理论上符合要求。

正如我所说,我真的很难弄清楚如何解决这个问题。所以,任何帮助都将不胜感激(我太累了,我可能错过了一些明显的东西)。谢谢

【问题讨论】:

  • 该示例在 Desktop Excel 中是否适合您?
  • 我刚刚使用上述示例进行了检查,但没有运气。它在桌面版中没有出现,更奇怪的是,它在 Office Online 上提示版本不兼容消息。顺便说一句,我还在另一位同事的电脑上测试了我的清单,但它也不起作用。
  • 我刚刚也进行了测试,this 其他官方示例加载项完美运行,无论是在线还是离线,都可以按预期显示功能区上的控件。现在真的很困惑:-/。
  • 对于原始示例,您至少需要将“文档”主机更改为“工作簿”
  • @MichaelSaunders 你是对的。第一个插件 mentioned 旨在用于 Office Word,而不是 Excel。我完全错过了。但无论如何,AFAIK 我的清单已正确调整,并且还坚持使用其他加载项示例。

标签: excel ms-office office365 office-addins office-js


【解决方案1】:

似乎可以使用的id 属性的长度有限制。坚持使用 32 个字符的字符串为我解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多