ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

【excel加载项开发】

2022-02-07 17:33:29  阅读:232  来源: 互联网

标签:en ReadWriteDocument 0.0 excel 开发 即可 加载


使用Visual Studio 2019 进行excel加载项开发:

1、新建项目

如果没有此功能,安装即可。

在这里插入图片描述

2、F5/启动,即可在excel里面看到任务窗格。

manifest清单详解:

<?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">

  <!-- 开始基本设置:外接程序元数据,用于所有版本的 Office(除非提供重写)。 -->

  <!-- 重要事项!ID 对于外接程序必须是唯一的,如果重复使用该清单,请确保将此 ID 改为新的 GUID。 -->
  <Id>eca64a51-6626-4b0b-8754-72ae5f888321</Id>

  <!--版本。来自应用商店的更新只有在版本变化时才会被触发。 -->
  <Version>1.0.0.0</Version>
  <ProviderName>[提供程序名称]</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <!-- 外接程序的显示名称。在应用商店中使用,出现在外接程序对话框等 Office UI 中。 -->
  <DisplayName DefaultValue="KL_小助手" />
  <Description DefaultValue="ExcelWebAddIn1"/>
  <!-- 外接程序的图标。用于安装屏幕和外接程序对话框中。 -->
  <IconUrl DefaultValue="~remoteAppUrl/Images/Button32x32.png" />

  <SupportUrl DefaultValue="http://www.contoso.com" />
  <!-- 导航时允许使用的域。例如,如果使用 ShowTaskpane,然后得到一个 href 链接,则只有在此列表上存在该域时,才允许导航。 -->
  <AppDomains>
    <AppDomain>AppDomain1</AppDomain>
    <AppDomain>AppDomain2</AppDomain>
    <AppDomain>AppDomain3</AppDomain>
  </AppDomains>
  <!--结束基本设置。 -->

  <!--开始任务窗格模式集成。如果没有 VersionOverrides 或如果 Office 客户端版本不支持外接程序命令,将使用此部分。 -->
  <Hosts>
    <Host Name="Workbook" />
  </Hosts>
  <DefaultSettings>
    <SourceLocation DefaultValue="~remoteAppUrl/Home.html" />
  </DefaultSettings>
  <!-- 结束任务窗格模式集成。  -->

  <Permissions>ReadWriteDocument</Permissions>

  <!-- 开始外接程序命令模式集成。 -->
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">

    <!-- 主机节点为必需。 -->
    <Hosts>
      <!-- 每个主机可具有不同的命令集。 -->
      <!-- Excel 主机为工作簿,文档中的 Word 主机和 PowerPoint 主机为演示文稿。 -->
      <!-- 确保重写的主机与清单顶部声明的主机相匹配。 -->
      <Host xsi:type="Workbook">
        <!-- 外形规格。当前只支持 DesktopFormFactor。 -->
        <DesktopFormFactor>
          <!--“此代码将启用可自定义的消息,在单独安装成功加载外接程序时进行显示。”-->
          <GetStarted>
            <!-- “入门”标注的标题。resid 属性指向 ShortString 资源 -->
            <Title resid="Contoso.GetStarted.Title"/>

            <!-- 入门标注的描述。ResID 指向 LongString 资源 -->
            <Description resid="Contoso.GetStarted.Description"/>

            <!-- 指向详细说明外接程序使用方法的 URL 资源。 -->
            <LearnMoreUrl resid="Contoso.GetStarted.LearnMoreUrl"/>
          </GetStarted>
          <!-- 函数文件是包含 JavaScript 的 HTML 页面,将在此页面中调用用于 ExecuteAction 的函数。             将 FunctionFile 视为代码隐藏 ExecuteFunction。 -->
          <FunctionFile resid="Contoso.DesktopFunctionFile.Url" />

          <!-- PrimaryCommandSurface 为 Office 主功能区。 -->
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <!-- 使用 OfficeTab 来扩展现有选项卡。使用 CustomTab 来创建新选项卡。 -->
            <OfficeTab id="TabHome">
              <!-- 确保为组提供唯一 ID。建议 ID 为使用公司名的命名空间。 -->
              <Group id="Contoso.Group1">
                <!-- 为组指定标签。resid 必须指向 ShortString 资源。 -->
                <Label resid="Contoso.Group1Label" />
                <!-- 图标。必需大小: 16、32、80,可选大小: 20、24、40、48、64。强烈建议为大 UX 提供所有大小。 -->
                <!-- 使用 PNG 图标。资源部分中的所有 URL 必须使用 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 控件。可以为“按钮”类型或“菜单”类型。 -->

                <!--菜单案例: -->
                <Control xsi:type="Menu" id="Contoso.Menu">
                  <Label resid="Contoso.Dropdown.Label" />
                  <Supertip>
                    <Title resid="Contoso.Dropdown.Label" />
                    <Description resid="Contoso.Dropdown.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>
                  <Items>

                    <Item id="Contoso.Menu.Item2">
                      <Label resid="Contoso.Item2.Label"/>
                      <Supertip>
                        <Title resid="Contoso.Item2.Label" />
                        <Description resid="Contoso.Item2.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>
                      <Action xsi:type="ShowTaskpane">
                        <TaskpaneId>MyTaskPaneID2</TaskpaneId>
                        <SourceLocation resid="Contoso.Toggle.Url" />
                      </Action>
                    </Item>
                    <Item id="Contoso.Menu.Item1">
                      <Label resid="Contoso.Item1.Label"/>
                      <Supertip>
                        <Title resid="Contoso.Item1.Label" />
                        <Description resid="Contoso.Item1.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>
                      <Action xsi:type="ShowTaskpane">
                        <TaskpaneId>MyTaskPaneID1</TaskpaneId>
                        <SourceLocation resid="Contoso.Taskpane.Url" />
                      </Action>
                    </Item>


                  </Items>
                </Control>
                
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>

    <!-- 你可以在主机和窗体上使用资源。 -->
    <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" />
        <bt:Url id="Contoso.Toggle.Url" DefaultValue="~remoteAppUrl/toggle.html" />
        <bt:Url id="Contoso.GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812" />
      </bt:Urls>
      <!-- ShortStrings 最大字符数==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="Contoso.Dropdown.Label"
           DefaultValue="KL_Excel助手" />
        <bt:String id="Contoso.Item1.Label"
                   DefaultValue="KL-AMAT相关查询" />
        <bt:String id="Contoso.Item2.Label"
                   DefaultValue="物料专案相关" />
      </bt:ShortStrings>
      <!-- LongStrings 最大字符数==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="Contoso.Dropdown.Tooltip"
             DefaultValue="Click to Show Options on this Menu" />
        <bt:String id="Contoso.Item1.Tooltip"
                   DefaultValue="Click to Show Taskpane1" />
        <bt:String id="Contoso.Item2.Tooltip"
                   DefaultValue="Click to Show Taskpane2" />
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
  <!-- 结束外接程序命令模式集成。 -->

</OfficeApp>

标签:en,ReadWriteDocument,0.0,excel,开发,即可,加载
来源: https://blog.csdn.net/weixin_44987713/article/details/122811963

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有