Надстройка Office не загружается после переключения на общую среду выполнения

Я следил за настройкой надстройки Office, чтобы использовать общую среду выполнения JavaScript для настройки общей среды выполнения для надстройки Excel.

Но он не загружается

Вот мой manifest.xml

      <?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>f9459a58-57de-4427-9db6-b90ef7a6eb6c</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Contoso</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="Meekou.ExcelAddIn"/>
  <Description DefaultValue="Write your own Excel functions in TypeScript."/>
  <IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png"/>
  <HighResolutionIconUrl DefaultValue="https://localhost:3000/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://localhost:3000/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="ExecuteFunction">
                    <FunctionName>action</FunctionName>
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <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>
      <bt:Urls>
        <bt:Url id="Functions.Script.Url" DefaultValue="https://localhost:3000/dist/functions.js"/>
        <bt:Url id="Functions.Metadata.Url" DefaultValue="https://localhost:3000/dist/functions.json"/>
        <bt:Url id="Functions.Page.Url" DefaultValue="https://localhost:3000/dist/functions.html"/>
        <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>
      <bt:ShortStrings>
        <bt:String id="Functions.Namespace" DefaultValue="Meekou"/>
        <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>

Вот ошибка

      Compiled with problems:X

Error:

[tsl] ERROR in C:\Users\edward\Meekou\Meekou\Meekou.ExcelAddIn\src\taskpane\taskpane.ts(37,34)
      TS2304: Cannot find name 'add'.



Error:

[tsl] ERROR in C:\Users\edward\Meekou\Meekou\Meekou.ExcelAddIn\src\taskpane\taskpane.ts(38,34)
      TS2552: Cannot find name 'logMessage'. Did you mean 'onmessage'?



Error:

[tsl] ERROR in C:\Users\edward\Meekou\Meekou\Meekou.ExcelAddIn\src\commands\commands.ts(38,34)
      TS2304: Cannot find name 'add'.



Error:

[tsl] ERROR in C:\Users\edward\Meekou\Meekou\Meekou.ExcelAddIn\src\commands\commands.ts(39,34)
      TS2552: Cannot find name 'logMessage'. Did you mean 'onmessage'?


2 ответа

Я встретил ту же проблему. Я решил это, изменив инструкции в webpack.config.js.

// ========= Я изменил это ========= \

      <pre>
const config = {
    devtool: "source-map",
    entry: {
      polyfill: ["core-js/stable", "regenerator-runtime/runtime"],
      <b>functions: "./src/functions/functions.ts",</b>
      taskpane: "./src/taskpane/taskpane.ts",
      commands: "./src/commands/commands.ts",
},
</pre>

// ============ С этим ============= \

Все работало хорошо, когда я изменил порядок инструкций. Поместите «функции» после «панели задач».

      <pre>
const config = {
    devtool: "source-map",
    entry: {
      polyfill: ["core-js/stable", "regenerator-runtime/runtime"],
      taskpane: "./src/taskpane/taskpane.ts",
      commands: "./src/commands/commands.ts",
      <b>functions: "./src/functions/functions.ts",</b>
},
</pre>

моя версия веб-пакета 5.74.0

Надеюсь, что это поможет вам.

Внимание

Я не могу воспроизвести вашу проблему. Ваш манифест выглядит нормально.

На мой взгляд, сообщение об ошибке должно быть связано с «CustomFunctionsMetadataPlugin» (оно будет вызываться во время npm run build).

Перед компиляцией «.ts» в «.js» плагин «CustomFunctionsMetadataPlugin» добавит «связанную» логику ( CustomFunctions.associate("ADD", add)) во входной файл (например, src\functions\functions.ts).

Судя по сообщению об ошибке, я предполагаю, что «CustomFunctionsMetadataPlugin» неправильно выполнил вышеуказанные шаги на вашей стороне. Вы можете попробовать добавить логику «связать» вручную , чтобы увидеть, решена ли проблема.

Вы также можете поделиться скомпилированным файлом ( dist\function.js), так что я могу помочь сделать дополнительную проверку.

Спасибо,

Рундонг

Другие вопросы по тегам