旁加载 Office 加载项以供测试Sideload Office Add-ins for testing

你可以安装 Office 外接程序以在 Windows 上运行的 Office 客户端中进行测试(通过使用共享文件夹,以将清单发布到网络文件共享)。You can install an Office Add-in for testing in an Office client running on Windows by publishing the manifest to a network file share (instructions below).

备注

如果你的外接程序项目是使用外接程序的 Yeoman 生成器的足够使用的版本,运行 npm start 时将自动在 Office 桌面客户端中旁加载外接程序。If your add-in project was created with a sufficiently recent version of the Yeoman generator for Office Add-ins, the add-in will automatically sideload in the Office desktop client when you run npm start.

本文仅适用于在 Windows 上测试 Word、Excel、PowerPoint 和 Project 加载项。This article applies only to testing Word, Excel, PowerPoint, and Project add-ins on Windows. 如果要在其他平台上进行测试或要测试 Outlook 加载项,请参阅以下主题之一以旁加载你的加载项:If you want to test on another platform or want to test an Outlook add-in, see one of the following topics to sideload your add-in:

下面的视频逐步展示了如何使用共享文件夹目录在 Office 网页版或桌面上旁加载加载项。The following video walks you through the process of sideloading your add-in on Office desktop or Office Online using a shared folder catalog.

共享文件夹Share a folder

  1. 在想要托管外接程序的 Windows 计算机上,转到你想用作共享文件夹目录的文件夹的父文件夹或驱动器号。In File Explorer on the Windows computer where you want to host your add-in, go to the parent folder, or drive letter, of the folder you want to use as your shared folder catalog.

  2. 打开要用作共享文件夹目录的文件夹的上下文菜单(右键单击该文件夹),然后选择“属性”。Open the context menu for the folder you want to use as your shared folder catalog (right-click the folder) and choose Properties.

  3. 在“属性”对话框窗口中,打开“共享”选项卡,然后选择“共享”按钮。Within the Properties dialog window, open the Sharing tab and then choose the Share button.

    已突出显示“共享”选项卡和“共享”按钮的文件夹“属性”对话框

  4. 网络访问对话框窗口中,添加你自己以及要与其共享加载项的任何其他用户和/或组。Within the Network access dialog window, add yourself and any other users and/or groups with whom you want to share your add-in. 你至少需要对该文件夹的读/写权限。You will need at least Read/Write permission to the folder. 选择要与其共享的人员后,请选择“共享”按钮。After you have finished choosing people to share with, choose the Share button.

  5. 当你看到确认你的文件夹已共享的消息时,请记下紧跟文件夹名称显示的完整网络路径。When you see confirmation that Your folder is shared, make note of the full network path that's displayed immediately following the folder name. (当你将共享文件夹指定为受信任的目录时,你需要将此值输入为**目录UR **,如本文下一节所述。)选择“完成”按钮以关闭“网络访问”对话框窗口。(You will need to enter this value as the Catalog Url when you specify the shared folder as a trusted catalog, as described in the next section of this article.) Choose the Done button to close the Network access dialog window.

    已突出显示共享路径的“网络访问”对话框

  6. 选择“关闭”按钮以关闭“属性”对话框窗口。Choose the Close button to close the Properties dialog window.

将共享文件夹指定为受信任的目录Specify the shared folder as a trusted catalog

  1. 在 Excel、Word、PowerPoint 或 Project 中打开一个新的文档。Open a new document in Excel, Word, PowerPoint, or Project.

  2. 选择“文件”**** 选项卡,然后选择“选项”****。Choose the File tab, and then choose Options.

  3. 选择“信任中心”,然后选择“信任中心设置”按钮。Choose Trust Center, and then choose the Trust Center Settings button.

  4. 选择“受信任的加载项目录”。Choose Trusted Add-in Catalogs.

  5. 在“目录 Url”框中,输入你之前共享的文件夹的完整网络路径。In the Catalog Url box, enter the full network path to the folder that you shared previously. 如果在共享文件夹时未能记下文件夹的完整网络路径,则可以从文件夹的“属性”对话框窗口中获取它,如以下屏幕截图所示。If you failed to note the folder's full network path when you shared the folder, you can get it from the folder's Properties dialog window, as shown in the following screenshot.

    已突出显示“共享”选项卡和网络路径的文件夹“属性”对话框

  6. 在“目录 Url”框中输入文件夹的完整网络路径后,选择“添加目录”按钮。After you've entered the full network path of the folder into the Catalog Url box, choose the Add catalog button.

  7. 选中新添加项目的“在菜单中显示”复选框,然后选择“确定”按钮以关闭“信任中心”对话框窗口。Select the Show in Menu check box for the newly-added item, and then choose the OK button to close the Trust Center dialog window.

    已选择目录的“信任中心”对话框

  8. 选择“确定”按钮以关闭“Word 选项”对话框窗口。Choose the OK button to close the Word Options dialog window.

  9. 关闭并重新打开 Office 应用程序,以使更改生效。Close and reopen the Office application so your changes will take effect.

旁加载加载项Sideload your add-in

  1. 放入在共享文件夹目录中进行测试的所有加载项的清单 XML 文件。Put the manifest XML file of any add-in that you are testing in the shared folder catalog. 请务必将 Web 应用程序本身部署到 Web 服务器。Note that you deploy the web application itself to a web server. 务必在清单文件的 SourceLocation 元素中指定 URL。Be sure to specify the URL in the SourceLocation element of the manifest file.

    重要

    强烈建议对加载项使用 HTTPS 终结点(尽管无需在所有加载项方案中都严格遵循此要求)。 不受 SSL (HTTPS) 保护的加载项会在使用期间生成不安全的内容警告和错误。 如果计划在 Office Online 中运行加载项或将加载项发布到 AppSource,加载项必须受 SSL 保护。 如果加载项访问外部数据和服务,它应受 SSL 保护,以保护传输中的数据。 自签名证书可用于开发和测试,但前提是证书在本地计算机上受信任。While not strictly required in all add-in scenarios, using an HTTPS endpoint for your add-in is strongly recommended. Add-ins that are not SSL-secured (HTTPS) generate unsecure content warnings and errors during use. If you plan to run your add-in in Office Online or publish your add-in to AppSource, it must be SSL-secured. If your add-in accesses external data and services, it should be SSL-secured to protect data in transit. Self-signed certificates can be used for development and testing, so long as the certificate is trusted on the local machine.

  2. 在 Excel、Word 或 PowerPoint 中,选择功能区上“插入”选项卡中的“我的加载项”。In Excel, Word, or PowerPoint, select My Add-ins on the Insert tab of the ribbon. 在 Project 中,选择功能区“Project”选项卡上的“我的加载项”。In Project, select My Add-ins on the Project tab of the ribbon.

  3. 在“Office 外接程序”对话框的顶部,选择“共享文件夹”。Choose SHARED FOLDER at the top of the Office Add-ins dialog box.

  4. 选择加载项的名称,然后选择“添加”以插入加载项。Select the name of the add-in and choose OK to insert the add-in.

另请参阅See also