0

我一直在尝试开发和部署 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-和内容加载项

我能够创建一个共享文件夹并将其添加为 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 的常量,并带有一条注释,告诉我们将其更改为生产部署位置。教程没有提到这一点。我确实将其更改为指向我创建的用于托管插件的静态网站。这是必要的吗?

编辑:

我的清单,我用我的 azure 静态网站的 url 替换了 localhost:

<?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>
4

1 回答 1

1

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

这取决于...用于从网络共享测试的 Sideload Office 加载项文章指出以下内容:

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。您可以手动或自动更改 URL(通过使用 webpack)。

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

于 2021-12-16T21:39:16.563 回答