问题描述
我想在excel右键菜单中添加一些菜单。我找到了这个文档
https://docs.microsoft.com/zh-cn/office/dev/add-ins/develop/create-addin-commands#see-also
我已经成功添加了一个菜单
但是我只能添加一个,如果在“ OfficeMenu”标签中添加另一个“ control”标签,则只能显示一个
这是我的xml代码
<?xml version="1.0" encoding="UTF-8"?>
<!--Created:ce44715c-8c4e-446b-879c-ea9ebe0f09c8-->
<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">
<!-- Begin Basic Settings: Add-in metadata,used for all versions of Office unless override provided. -->
<!-- IMPORTANT! Id must be unique for your add-in,if you reuse this manifest ensure that you change this id to a new GUID. -->
<Id>6951b52f-9d06-4a07-bb09-490aea96e010</Id>
<!--Version. Updates from the store only get triggered if there is a version change. -->
<Version>1.0.0.0</Version>
<ProviderName>[Provider name]</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
<DisplayName DefaultValue="ExcelWebAddIn1" />
<Description DefaultValue="ExcelWebAddIn1"/>
<!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
<IconUrl DefaultValue="~remoteAppUrl/Images/Button32x32.png" />
<SupportUrl DefaultValue="http://www.contoso.com" />
<!-- Domains that will be allowed when navigating. For example,if you use ShowTaskpane and then have an href link,navigation will only be allowed if the domain is on this list. -->
<AppDomains>
<AppDomain>AppDomain1</AppDomain>
<AppDomain>AppDomain2</AppDomain>
<AppDomain>AppDomain3</AppDomain>
</AppDomains>
<!--End Basic Settings. -->
<!--Begin TaskPane Mode integration. This section is used if there are no VersionOverrides or if the Office client version does not support add-in commands. -->
<Hosts>
<Host Name="Workbook" />
</Hosts>
<DefaultSettings>
<SourceLocation DefaultValue="~remoteAppUrl/Home.html?v=1.2" />
</DefaultSettings>
<!-- End TaskPane Mode integration. -->
<Permissions>ReadWriteDocument</Permissions>
<!-- Begin Add-in Commands Mode integration. -->
<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
<!-- The Hosts node is required. -->
<Hosts>
<!-- Each host can have a different set of commands. -->
<!-- Excel host is Workbook,Word host is Document,and PowerPoint host is Presentation. -->
<!-- Make sure the hosts you override match the hosts declared in the top section of the manifest. -->
<Host xsi:type="Workbook">
<!-- Form factor. Currently only DesktopFormFactor is supported. -->
<DesktopFormFactor>
<!--"This code enables a customizable message to be displayed when the add-in is loaded successfully upon individual install."-->
<GetStarted>
<!-- Title of the Getting Started callout. The resid attribute points to a ShortString resource -->
<Title resid="Contoso.GetStarted.Title"/>
<!-- Description of the Getting Started callout. resid points to a LongString resource -->
<Description resid="Contoso.GetStarted.Description"/>
<!-- Points to a URL resource which details how the add-in should be used. -->
<LearnMoreUrl resid="Contoso.GetStarted.LearnMoreUrl"/>
</GetStarted>
<!-- Function file is a HTML page that includes the JavaScript where functions for ExecuteAction will be called.
Think of the FunctionFile as the code behind ExecuteFunction. -->
<FunctionFile resid="Contoso.DesktopFunctionFile.Url" />
<!-- PrimaryCommandSurface is the main Office Ribbon. -->
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<!-- Use OfficeTab to extend an existing Tab. Use CustomTab to create a new tab. -->
<OfficeTab id="TabHome">
<!-- Ensure you provide a unique id for the group. Recommendation for any IDs is to namespace using your company name. -->
<Group id="Contoso.Group1">
<!-- Label for your group. resid must point to a ShortString resource. -->
<Label resid="Contoso.Group1Label" />
<!-- Icons. Required sizes 16,32,80,optional 20,24,40,48,64. Strongly recommended to provide all sizes for great UX. -->
<!-- Use PNG icons. All URLs on the resources section must use HTTPS. -->
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<!-- Control. It can be of type "Button" or "Menu". -->
<Control xsi:type="Button" id="Contoso.TaskpaneButton">
<Label resid="Contoso.TaskpaneButton.Label" />
<Supertip>
<!-- ToolTip title. resid must point to a ShortString resource. -->
<Title resid="Contoso.TaskpaneButton.Label" />
<!-- ToolTip description. resid must point to a LongString resource. -->
<Description resid="Contoso.TaskpaneButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<!-- This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFunction or ShowTaskpane. -->
<Action xsi:type="ShowTaskpane">
<TaskpaneId>ButtonId1</TaskpaneId>
<!-- Provide a URL resource id for the location that will be displayed on the task pane. -->
<SourceLocation resid="Contoso.Taskpane.Url" />
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
<ExtensionPoint xsi:type="ContextMenu">
<!--The id of the menu specifies the existing context menu being extended-->
<!--ContextMenuCell (Excel) and ContextMenuText (Word) are currently supported-->
<OfficeMenu id="ContextMenuCell">
<Control xsi:type="Menu" id="Contoso.TestMenu3">
<Label resid="mymenu2" />
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTipFunc" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<Items>
<Item id="myfunc1">
<Label resid="myfuncID1"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTipFunc" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<!--TaskPaneId is required. It is currently not used by the framework but it will be in a future iteration -->
<FunctionName>writeTextFormula</FunctionName>
</Action>
</Item>
</Items>
</Control>
<Control xsi:type="Menu" id="Contoso.TestMenu2">
<Label resid="mymenu1" />
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<Items>
<Item id="myitem1">
<Label resid="myitemID1"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<!--TaskPaneId is required. It is currently not used by the framework but it will be in a future iteration -->
<FunctionName>writeTextType</FunctionName>
</Action>
</Item>
<Item id="myitem2">
<Label resid="myitemID2"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<!--TaskPaneId is required. It is currently not used by the framework but it will be in a future iteration -->
<FunctionName>writeTextType</FunctionName>
</Action>
</Item>
<Item id="myitem3">
<Label resid="myitemID3"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<!--TaskPaneId is required. It is currently not used by the framework but it will be in a future iteration -->
<FunctionName>writeTextType</FunctionName>
</Action>
</Item>
<Item id="myitem4">
<Label resid="myitemID4"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<!--TaskPaneId is required. It is currently not used by the framework but it will be in a future iteration -->
<FunctionName>writeTextType</FunctionName>
</Action>
</Item>
<Item id="myitem5">
<Label resid="myitemID5"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<!--TaskPaneId is required. It is currently not used by the framework but it will be in a future iteration -->
<FunctionName>writeTextType</FunctionName>
</Action>
</Item>
</Items>
</Control>
</OfficeMenu>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<!-- You can use resources across hosts and form factors. -->
<Resources>
<bt:Images>
<bt:Image id="Contoso.tpicon_16x16" DefaultValue="~remoteAppUrl/Images/Button16x16.png" />
<bt:Image id="Contoso.tpicon_32x32" DefaultValue="~remoteAppUrl/Images/Button32x32.png" />
<bt:Image id="Contoso.tpicon_80x80" DefaultValue="~remoteAppUrl/Images/Button80x80.png" />
</bt:Images>
<bt:Urls>
<bt:Url id="Contoso.DesktopFunctionFile.Url" DefaultValue="~remoteAppUrl/Functions/FunctionFile.html" />
<bt:Url id="Contoso.Taskpane.Url" DefaultValue="~remoteAppUrl/Home.html?v=1.2" />
<bt:Url id="Contoso.GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812" />
</bt:Urls>
<!-- ShortStrings max characters==125. -->
<bt:ShortStrings>
<bt:String id="Contoso.TaskpaneButton.Label" DefaultValue="Show Taskpane" />
<bt:String id="Contoso.Group1Label" DefaultValue="Commands Group" />
<bt:String id="Contoso.GetStarted.Title" DefaultValue="Get started with your sample add-in!" />
<bt:String id="residLabel" DefaultValue="Get Data">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="mymenu1" DefaultValue="类型">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="mymenu2" DefaultValue="函数">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myitemID1" DefaultValue="int">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myitemID2" DefaultValue="list">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myitemID3" DefaultValue="dict">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myitemID4" DefaultValue="tuple">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myitemID5" DefaultValue="str">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myfuncID1" DefaultValue="distinct">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myfuncID2" DefaultValue="len">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myfuncID3" DefaultValue="map">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myfuncID4" DefaultValue="partial">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
<bt:String id="myfuncID5" DefaultValue="ref">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons" />
</bt:String>
</bt:ShortStrings>
<!-- LongStrings max characters==250. -->
<bt:LongStrings>
<bt:String id="Contoso.TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane" />
<bt:String id="Contoso.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="residToolTip" DefaultValue="Multiple Buttons Tooltip">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons Tooltip" />
</bt:String>
<bt:String id="residToolTipFunc" DefaultValue="MultipleF Buttons Tooltip">
<bt:Override Locale="ja-jp" Value="JA-JP Multiple Buttons Tooltip" />
</bt:String>
</bt:LongStrings>
</Resources>
</VersionOverrides>
<!-- End Add-in Commands Mode integration. -->
</OfficeApp>
这是实际结果
enter image description here
仅底部菜单
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)