如何为我的 excel 加载项设置功能区图标
How to set ribbon icon for my excel add-in
我已经为 excel 功能区的按钮设置了图标。但它仍然显示默认图像:
<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="Excely.SheetExplorer.Group">
<!-- Label for your group. resid must point to a ShortString resource. -->
<Label resid="Excely.GroupLabel" />
<!-- 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="Excely.tpicon_16x16" />
<bt:Image size="32" resid="Excely.tpicon_32x32" />
<bt:Image size="80" resid="Excely.tpicon_80x80" />
</Icon>
<!-- Control. It can be of type "Button" or "Menu". -->
<Control xsi:type="Button" id="Excely.TaskpaneButton">
<Label resid="Excely.TaskpaneButton.Label" />
<Supertip>
<!-- ToolTip title. resid must point to a ShortString resource. -->
<Title resid="Excely.TaskpaneButton.Label" />
<!-- ToolTip description. resid must point to a LongString resource. -->
<Description resid="Excely.TaskpaneButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Excely.tpicon_16x16" />
<bt:Image size="32" resid="Excely.tpicon_32x32" />
<bt:Image size="80" resid="Excely.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>ShowMainMenu</TaskpaneId>
<!-- Provide a URL resource id for the location that will be displayed on the task pane. -->
<SourceLocation resid="Excely.Taskpane.Url" />
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
我应该在哪里设置色带的图像?
更新: 我发现问题不是来自清单设置。如果我将 Web 项目配置从 Local IIS
更改为 IIS Express
,则图标工作正常。但是当它设置为 Local IIS
时会出现默认图标!
您提供的清单部分仅显示您创建的 resid 名称。在您未显示的清单的 Resources 部分中,您需要使用图标文件的 URL 定义这些 resid 值。
此外,除非您清除 Office 缓存,否则对按钮图标的更改有时不会生效。参见 Clear the Office Cache。
我已经为 excel 功能区的按钮设置了图标。但它仍然显示默认图像:
<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="Excely.SheetExplorer.Group">
<!-- Label for your group. resid must point to a ShortString resource. -->
<Label resid="Excely.GroupLabel" />
<!-- 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="Excely.tpicon_16x16" />
<bt:Image size="32" resid="Excely.tpicon_32x32" />
<bt:Image size="80" resid="Excely.tpicon_80x80" />
</Icon>
<!-- Control. It can be of type "Button" or "Menu". -->
<Control xsi:type="Button" id="Excely.TaskpaneButton">
<Label resid="Excely.TaskpaneButton.Label" />
<Supertip>
<!-- ToolTip title. resid must point to a ShortString resource. -->
<Title resid="Excely.TaskpaneButton.Label" />
<!-- ToolTip description. resid must point to a LongString resource. -->
<Description resid="Excely.TaskpaneButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Excely.tpicon_16x16" />
<bt:Image size="32" resid="Excely.tpicon_32x32" />
<bt:Image size="80" resid="Excely.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>ShowMainMenu</TaskpaneId>
<!-- Provide a URL resource id for the location that will be displayed on the task pane. -->
<SourceLocation resid="Excely.Taskpane.Url" />
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
我应该在哪里设置色带的图像?
更新: 我发现问题不是来自清单设置。如果我将 Web 项目配置从 Local IIS
更改为 IIS Express
,则图标工作正常。但是当它设置为 Local IIS
时会出现默认图标!
您提供的清单部分仅显示您创建的 resid 名称。在您未显示的清单的 Resources 部分中,您需要使用图标文件的 URL 定义这些 resid 值。
此外,除非您清除 Office 缓存,否则对按钮图标的更改有时不会生效。参见 Clear the Office Cache。