Office AddIn按钮的图标不会显示

时间:2016-10-19 16:19:59

标签: manifest office-addins

这是清单主机

的摘录
<ExtensionPoint xsi:type="PrimaryCommandSurface">
    <CustomTab id="MyTab">
        <Group id="Raporty.GroupPabcd">
            <Label resid="Raporty.GroupPabcd.Label" />
            <Icon>
                <bt:Image resid="Raporty.Icon1_16" size="16" />
                <bt:Image resid="Raporty.Icon1_20" size="20" />
                <bt:Image resid="Raporty.Icon1_24" size="24" />
                <bt:Image resid="Raporty.Icon1_32" size="32" />
                <bt:Image resid="Raporty.Icon1_40" size="40" />
                <bt:Image resid="Raporty.Icon1_48" size="48" />
                <bt:Image resid="Raporty.Icon1_64" size="64" />
                <bt:Image resid="Raporty.Icon1_80" size="80" />
            </Icon>

            <Control xsi:type="Button" id="RaportPabcd.Button">
                <Label resid="RaportPabcd.Button.Label" />
                <Supertip>
                    <Title resid="RaportPabcd.Button.Label" />
                    <Description resid="RaportPabcd.Button.Tooltip" />
                </Supertip>
                <Icon>
                    <bt:Image resid="Raporty.Icon1_16" size="16" />
                    <bt:Image resid="Raporty.Icon1_20" size="20" />
                    <bt:Image resid="Raporty.Icon1_24" size="24" />
                    <bt:Image resid="Raporty.Icon1_32" size="32" />
                    <bt:Image resid="Raporty.Icon1_40" size="40" />
                    <bt:Image resid="Raporty.Icon1_48" size="48" />
                    <bt:Image resid="Raporty.Icon1_64" size="64" />
                    <bt:Image resid="Raporty.Icon1_80" size="80" />
                </Icon>

                <Action xsi:type="ShowTaskpane">
                    <TaskpaneId>ButtonId1</TaskpaneId>
                    <SourceLocation resid="Contoso.Taskpane.Url" />
                </Action>
            </Control>

        </Group>
        <Label resid="Raporty.Tab.Label" />
    </CustomTab>
</ExtensionPoint>

以及资源

<Resources>
    <bt:Images>
        <bt:Image id="Raporty.Icon1_16" DefaultValue="~remoteAppUrl/Images/ReportIcons/report_1_16.png" />
        <bt:Image id="Raporty.Icon1_20" DefaultValue="~remoteAppUrl/Images/ReportIcons/report_1_20.png" />
        <bt:Image id="Raporty.Icon1_24" DefaultValue="~remoteAppUrl/Images/ReportIcons/report_1_24.png" />
        <bt:Image id="Raporty.Icon1_32" DefaultValue="~remoteAppUrl/Images/ReportIcons/report_1_32.png" />
        <bt:Image id="Raporty.Icon1_40" DefaultValue="~remoteAppUrl/Images/ReportIcons/report_1_40.png" />
        <bt:Image id="Raporty.Icon1_48" DefaultValue="~remoteAppUrl/Images/ReportIcons/report_1_48.png" />
        <bt:Image id="Raporty.Icon1_64" DefaultValue="~remoteAppUrl/Images/ReportIcons/report_1_64.png" />
        <bt:Image id="Raporty.Icon1_80" DefaultValue="~remoteAppUrl/Images/ReportIcons/report_1_80.png" />
    </bt:Images>
</Resources>

问题是该按钮显示默认图标

enter image description here

我尝试直接在浏览器中访问该图片(例如http://localhost/ExcelWebWeb/Images/ReportIcons/report_1_32.png)并且确实显示了

我查看了IIS日志,看看Excel应用程序是否查询了图像,但事实并非如此。我只能看到从本地浏览器到图标的访问日志,而addin只查询html / js文件(对于TaskPane)而不查询按钮的图像。

3 个答案:

答案 0 :(得分:1)

我有同样的问题,但找到了解决方案。请将以下内容添加到manifest.xml文件中:

<Version>1.0.0.0</Version>
<ProviderName>abc</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="abc" />
<IconUrl DefaultValue="~remoteAppUrl/Images/add-in-icon-lo-res.png"/>
<HighResolutionIconUrl DefaultValue="~remoteAppUrl/Images/add-in-icon-hi-res.png"/>

图像分辨率应为Iconurls 64 x 64像素,png为8位深度,HighResolutionIconUrl为128 x 128像素

答案 1 :(得分:0)

尝试替换&#39; ~remoteAppUrl&#39; with localhost:[端口号]。发布应用程序时,需要将其更改为主机和端口号

答案 2 :(得分:-1)

<CustomTab id="MyTab">
        <Group id="Raporty.MyTab.GroupPabcd">
            <Label resid="Raporty.MyTab.GroupPabcd.Label" />
......

            <Label resid="Raporty.MyTab.TabLabel" />

这是清单的核心代码。