OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
667 stars 94 forks source link

Excel Addin ContextMenu icon not show up #4212

Open Edward-Zhou opened 6 months ago

Edward-Zhou commented 6 months ago

I am trying to implement Context menu for Excel.

Here is my test 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>2f6f8f81-0fe3-42e4-9c4e-c93a53ea5894</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Contoso</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="test"/>
  <Description DefaultValue="A template to get started."/>
  <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>
  <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">
        <DesktopFormFactor>
          <GetStarted>
            <Title resid="GetStarted.Title"/>
            <Description resid="GetStarted.Description"/>
            <LearnMoreUrl resid="GetStarted.LearnMoreUrl"/>
          </GetStarted>
          <FunctionFile resid="Commands.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>
          <ExtensionPoint xsi:type="ContextMenu">
            <OfficeMenu id="ContextMenuText">
              <Control xsi:type="Menu" id="myMenuID1">
                <Label resid="myMenuID1" />
                <Supertip>
                  <Title resid="myMenuID1" />
                  <Description resid="residToolTip" />
                </Supertip>
                <Icon>
                  <bt:Image size="16" resid="icon1_16x16" />
                  <bt:Image size="32" resid="icon1_32x32" />
                  <bt:Image size="80" resid="icon1_80x80" />
                </Icon>
                <Items>
                  <Item id="myMenuItemID">
                    <Label resid="myMenuID12"/>
                    <Supertip>
                      <Title resid="myMenuID12" />
                      <Description resid="residToolTip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="icon1_16x16" />
                      <bt:Image size="32" resid="icon1_32x32" />
                      <bt:Image size="80" resid="icon1_80x80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="residUnitConverterUrl" />
                    </Action>
                  </Item>
                </Items>
              </Control>
            </OfficeMenu>
          </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:Image id="icon1_16x16" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/images/wikipedia_32x32.png"></bt:Image>
        <bt:Image id="icon1_32x32" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/images/wikipedia_32x32.png"></bt:Image>
        <bt:Image id="icon1_80x80" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/images/wikipedia_32x32.png"></bt:Image>

      </bt:Images>
      <bt:Urls>
        <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:Url id="residDesktopFuncUrl" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/Wikipedia_dev.html"></bt:Url>
        <bt:Url id="residUnitConverterUrl" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/Wikipedia_dev.html"></bt:Url>

      </bt:Urls>
      <bt:ShortStrings>
        <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:String id="myMenuID1" DefaultValue="Wikipedia Menu1"></bt:String>
        <bt:String id="myMenuID12" DefaultValue="Wikipedia Button1"></bt:String>
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="GetStarted.Description" DefaultValue="1Your 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="1Click to Show a Taskpane"/>
        <bt:String id="residToolTip" DefaultValue="1Wikipedia Tooltip"></bt:String>
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>

After running, I load the manifest.xml from Office Excel online. only Text show up, no icon, and the description and title show in two lines. image How to make it achieve like Copy Link which show icon and sub item only show title withou description.

AkhileshShah-MS commented 6 months ago

Hi @Edward-Zhou , Thanks for reaching out. Looping in @penglongzhaochina to help with the issue Thanks!

zhenhuangMSFT commented 5 months ago

Hi @Edward-Zhou, have you checked this sample for reference? https://github.com/OfficeDev/Office-Add-in-Commands/blob/master/Excel/Manifest/ExcelAddinWithCommandsOnDataTab.xml If it still does not work, please let us know.

Edward-Zhou commented 5 months ago

@zhenhuangMSFT Have you tried above xml? does it work on your excel online?

Wolfran commented 3 months ago

Hello, I have the same issue, tested and compare manifest from attached url - nothing changed. It happens both for Button and Menu Control element.

Any help will be appreciated. Thanks

(Edit) Adding a screen from issue with wikipedia manifest (https://github.com/OfficeDev/office-js/issues/3431): image

shanshanzheng-dev commented 2 months ago

@zhenhuangMSFT Have you tried above xml? does it work on your excel online?

Hi @Edward-Zhou Sorry for slow response. I try your manifest.xml and only can see this image

shanshanzheng-dev commented 2 months ago

Hello, I have the same issue, tested and compare manifest from attached url - nothing changed. It happens both for Button and Menu Control element.

Any help will be appreciated. Thanks

(Edit) Adding a screen from issue with wikipedia manifest (#3431): image

Hi @Wolfran Sorry for response. I try this wikipedia manifest.xml. seem I can repro this issue. We'll be looking into this. Thanks.

shanshanzheng-dev commented 2 months ago

Hi @Edward-Zhou Thanks for your message. We'll be looking into this issue. And we will report back here if we have a suggestion for you.