【问题标题】:Deploy, host and sideload Excel Office Addin - Error loading add-ins部署、托管和旁加载 Excel Office 插件 - 加载插件时出错
【发布时间】:2022-01-19 21:35:07
【问题描述】:

我一直在尝试开发和部署 Excel Office 插件,但遇到了一些问题。

我按照您网站上发布的教程创建了一个办公室插件。我已经确认我可以在调试中运行插件(来自我的 Visual Studio 代码)。所以下一步是托管和部署插件。

我首先按照这里的说明进行操作:https://docs.microsoft.com/en-us/office/dev/add-ins/publish/publish-add-in-vs-code 我能够在 Azure 静态网站上发布它,当我在那里浏览时,我可以看到它说“请旁加载您的加载项以查看应用程序正文”。到目前为止一切顺利。

接下来,我按照这里的步骤操作:https://docs.microsoft.com/en-us/office/dev/add-ins/testing/create-a-network-shared-folder-catalog-for-task-pane-and-content-add-ins

我能够创建一个共享文件夹并将其添加为 Excel 中的受信任目录。当我打开 Excel 时,我可以在“我的插件”的共享文件夹部分看到我的插件。我可以点击它。

但是,当我单击它以将其加载到 Excel 中时,我的 Excel 中的状态栏会显示“加载加载项时出错”,并且没有什么可做的。它不再为我提供工作日志。加载 office 插件的最后一步失败。

我相信我已正确遵循教程中的所有说明,包括将 manifest.xml 文件中的引用从 localhost 更改为静态网站的 url。

我有几个问题...

  1. 我按照上面那两个教程的顺序是正确的吗?换句话说,我的流程有问题吗?

  2. 提到的步骤之一是将清单文件复制/粘贴到我创建的共享文件夹中。我在粘贴 manifest.xml 吗?还是我的 dist 文件夹中的 manifest.prod.xml?在这两种情况下,我都遇到了无法在 Excel 中正确加载它的相同错误。

  3. 它提到将 localhost 的所有引用替换为 manifest.xml 文件中静态网站的 URL。我注意到在 excel 插件项目的根文件夹中还有一个名为 webpack.config.js 的文件,该文件有一个名为 urlProd 的常量,并带有一条注释,告诉我们将其更改为生产部署位置。教程没有提到这一点。我确实将其更改为指向我创建的用于托管插件的静态网站。有必要吗?

编辑:

我的清单,我已将 localhost 替换为我的 azure 静态网站的 url:

<?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">
  <Id>5a711560-c5ed-4c07-8020-39460e56846b</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Contoso</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="MyCustomFunctions"/>
  <Description DefaultValue="Write your own Excel functions in TypeScript."/>
  <IconUrl DefaultValue="https://[static.website.url.on.azure]/assets/icon-32.png"/>
  <HighResolutionIconUrl DefaultValue="https://[static.website.url.on.azure]/assets/icon-64.png"/>
  <SupportUrl DefaultValue="https://www.contoso.com/help"/>
  <AppDomains>
    <AppDomain>https://www.contoso.com</AppDomain>
  </AppDomains>
  <Hosts>
    <Host Name="Workbook"/>
  </Hosts>
  <Requirements>
    <Sets DefaultMinVersion="1.1">
      <Set Name="SharedRuntime" MinVersion="1.1"/>
    </Sets>
  </Requirements>
  <DefaultSettings>
    <SourceLocation DefaultValue="https://[static.website.url.on.azure]/taskpane.html"/>
  </DefaultSettings>
  <Permissions>ReadWriteDocument</Permissions>
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Hosts>
      <Host xsi:type="Workbook">
            <Runtimes>
        <Runtime resid="Taskpane.Url" lifetime="long" />
      </Runtimes>
        <AllFormFactors>
          <ExtensionPoint xsi:type="CustomFunctions">
            <Script>
              <SourceLocation resid="Functions.Script.Url"/>
            </Script>
            <Page>
              <SourceLocation resid="Taskpane.Url"/>
            </Page>
            <Metadata>
              <SourceLocation resid="Functions.Metadata.Url"/>
            </Metadata>
            <Namespace resid="Functions.Namespace"/>
          </ExtensionPoint>
        </AllFormFactors>
        <DesktopFormFactor>
          <GetStarted>
            <Title resid="GetStarted.Title"/>
            <Description resid="GetStarted.Description"/>
            <LearnMoreUrl resid="GetStarted.LearnMoreUrl"/>
          </GetStarted>
          <FunctionFile resid="Taskpane.Url"/>
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <OfficeTab id="TabHome">
              <Group id="CommandsGroup">
                <Label resid="CommandsGroup.Label"/>
                <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>
                    <Title resid="TaskpaneButton.Label"/>
                    <Description resid="TaskpaneButton.Tooltip"/>
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16"/>
                    <bt:Image size="32" resid="Icon.32x32"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <TaskpaneId>ButtonId1</TaskpaneId>
                    <SourceLocation resid="Taskpane.Url"/>
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="Icon.16x16" DefaultValue="https://[static.website.url.on.azure]/assets/icon-16.png"/>
        <bt:Image id="Icon.32x32" DefaultValue="https://[static.website.url.on.azure]/assets/icon-32.png"/>
        <bt:Image id="Icon.80x80" DefaultValue="https://[static.website.url.on.azure]/assets/icon-80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="Functions.Script.Url" DefaultValue="https://[static.website.url.on.azure]/dist/functions.js"/>
        <bt:Url id="Functions.Metadata.Url" DefaultValue="https://[static.website.url.on.azure]/dist/functions.json"/>
        <bt:Url id="Functions.Page.Url" DefaultValue="https://[static.website.url.on.azure]/dist/functions.html"/>
        <bt:Url id="GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812"/>
        <bt:Url id="Commands.Url" DefaultValue="https://[static.website.url.on.azure]/commands.html"/>
        <bt:Url id="Taskpane.Url" DefaultValue="https://[static.website.url.on.azure]/taskpane.html"/>
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="Functions.Namespace" DefaultValue="CONTOSO"/>
        <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>
      <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>

【问题讨论】:

  • 您的清单看起来如何?
  • @EugeneAstafiev 感谢您的回复,我已在上面的编辑中添加了我的清单。
  • 它应该在两个地方都能正常工作 - 远程 url 或共享文件夹。
  • 我猜这个错误仍然在manifest中,请你按照这篇文章看看你的manfiest有什么问题:docs.microsoft.com/en-us/office/dev/add-ins/testing/…
  • @MSFT-Jipyua 我完成了上述步骤并收到消息“清单有效。”请让我知道是否还有其他需要检查的地方。谢谢。

标签: excel office-js office-addins excel-web-addins


【解决方案1】:

我按照上面那两个教程的顺序是正确的吗?换句话说,我的流程有问题吗?

这取决于...Sideload Office Add-ins for testing from a network share 文章声明如下:

Deployment by network share is not supported for production add-ins.

而且你还可以满足以下语句:

This deployment option is intended to be used when you have completed development and testing on a localhost and want to test the add-in from a non-local server or cloud account.

因此,可以使用共享文件夹在 Windows 上旁加载加载项。

但您似乎已经将清单文件发布到 Azure 中的静态存储。因此,您可以使用它在 Excel 中旁加载加载项 - 只需使用清单的 URL 在 Excel 中添加加载项。

提到的步骤之一是将清单文件复制/粘贴到我创建的共享文件夹中。我在粘贴 manifest.xml 吗?还是我的 dist 文件夹中的 manifest.prod.xml?在这两种情况下,我都遇到了无法在 Excel 中正确加载它的相同错误。

您的 dist 文件夹中的 manifest.prod.xml 已上传到 Azure 中的静态存储,因此您可以参考它而不是使用共享文件夹。选择哪种方式取决于您 - 使用服务器上的共享文件夹或托管文件。但是,您需要注意清单文件中使用的 URL - 它们应该指向加载项的文件。

它提到将 localhost 的所有引用替换为 manifest.xml 文件中静态网站的 URL。我注意到在 excel 插件项目的根文件夹中还有一个名为 webpack.config.js 的文件,该文件有一个名为 urlProd 的常量,并带有一条注释,告诉我们将其更改为生产部署位置。教程没有提到这一点。我确实将其更改为指向我创建的用于托管插件的静态网站。有必要吗?

教程可能有些陈旧,可能无法反映开发人员可用的所有信息。使用 Yeoman 生成器创建的项目骨架会不时更新,您可能会获得开箱即用的新功能。

如果您将urlProd 常量设置为有效的 URL,那么您可以在构建项目后(在生产模式下)从 dist 文件夹中的 manifest.prod.xml 文件中获取正确设置的 URL。

清单文件与其他加载项文件一起上传到 Azure 静态网站。要使用该清单文件安装加载项,它应该指向生产 URL。您可以手动或自动(通过使用 webpack)更改 URL。

此外,除了在 SourceLocation 元素中指定的域之外,AppDomain 元素还指定了 Office 应该信任的其他域。

【讨论】:

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