如何部署Excel XLL加载项并在Excel中自动注册该加载项 [英] How to deploy an Excel XLL Add-In and automatically register the Add-In in Excel

查看:1130
本文介绍了如何部署Excel XLL加载项并在Excel中自动注册该加载项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用ExcelDNA和C#开发了一个Excel XLL.我到了要开始测试部署的地步,但是找不到很多可以提供实际可行步骤的信息.

我的项目被开发为具有ExcelDna引用的类库.在.dna文件中,我具有下面的代码,该代码会将所有资源打包到XLL的打包版本中(即Pack ="true"属性).

<DnaLibrary Name="ExcelXLL" RuntimeVersion="v4.0" Language="C#">
  <ExternalLibrary Path="ExcelXLL.dll" LoadFromBytes="false" Pack="true" />

我想将打包的XLL部署到路径中的目标计算机:

%APPDATA%\Microsoft\AddIns

为了自动在Excel中注册XLL,我需要添加一个注册表项,该注册表项取决于用户拥有的Excel版本.

例如,在我的计算机(运行Excel 2007 32位的Windows 7 64位)上,我需要将注册表项添加到以下路径:

HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Options\

密钥将是类型REG_SZ,名称为OPEN(或OPEN1,OPEN2等),其值 /R"ExcelXLL-packed.xll"

我有2个问题.首先是确定用户必须获取正确路径的Excel版本,第二是确定我需要创建的正确OPEN版本(例如,如果用户已经具有OPEN,OPEN1和OPEN2,则我会创建一个OPEN3密钥).

我正在尝试使用Setup and Deployment项目或InstallShield LE项目进行安装,并且无法确定如何执行此操作.有谁知道该怎么做或更好的方法呢?

我对此进行了大量研究,并研究了几个Windows安装程序.

在Package and Deployment和InstallShield LE中,我可以通过将安装程序类放入我的类库中并将工程输出与安装捆绑在一起来使安装/卸载工作.在这种方法中,我使用安装程序类来处理插入/删除注册表项.我遇到的问题是,用户必须先卸载再运行新的安装(无更新功能).

我下载了Setup Factory演示版本,可以安装/更新,但是无法进行框架检查(演示中未提供).另外,卸载也会失败(尽管我可以通过一些进一步的调查来使它起作用).

我对使用WiX安装程序很感兴趣,但是想知道是否有人提供了如何使用WiX执行部署的示例.我还想知道是否需要使用安装程序类,或者是否有其他方法来处理对HKCU \ Software \ Microsoft \ Office [Version] .0 \ Excel \ Options下的OPEN [n]键的搜索.如果要使用项目输出来启用安装程序类,则需要有2个单独的目标目录(对于基本项目输出,在Program Files下一个,对于打包的XLL,在%appdata%\ Microsoft \ AddIns下一个.)/p>

非常感谢您的帮助.

谢谢

解决方案

使用IsWix和Wix 3.7,我能够解决此问题.

有关如何注册组件的有用链接如下:

用于生成C#类以处理Windows Installer自定义操作: http://blogs.msdn.com/b/jschaffe/archive/2012/10/23/creating-wix-custom-actions-in-c-and-passing-parameters.aspx

用于将CustomAction.config文件的属性设置为Content WIX自定义为.Net Framework 4.0构建的操作不起作用?解决方法?

有关WiX的常识(非常重要)

<DnaLibrary Name="ExcelXLL" RuntimeVersion="v4.0" Language="C#">
  <ExternalLibrary Path="ExcelXLL.dll" LoadFromBytes="false" Pack="true" />

I would like to deploy the packed XLL to the target machine in the path:

%APPDATA%\Microsoft\AddIns

In order to automatically register the XLL with Excel, I need to add a registry key that depends on the version of Excel that the user has.

For instance, on my computer (Windows 7 64 bit running Excel 2007 32-bit), I would need to add a registry key to the following path:

HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Options\

The key would be type REG_SZ with the name OPEN (or OPEN1, OPEN2, etc.) and the value /R "ExcelXLL-packed.xll"

I have 2 problems though. The first is in determining which version of Excel that the user has to get the correct path and the 2nd is to determine the correct OPEN version that I need to create (for example, if the user already has OPEN, OPEN1, and OPEN2 then I would create an OPEN3 key).

I am trying to do the installation using either the Setup and Deployment project or a InstallShield LE project and cannot determine how to go about this. Does anyone know how to do this or a better way of doing it?

EDIT 1:

I have done a great deal of research on this and have looked at several windows installers.

In the Package and Deployment and InstallShield LE, I can get the install/uninstall to work by putting an installer class into my class library and bundling project output with the install. In this approach, I handle inserting/removing the registry key using the installer class. The problem that I have is that the user must uninstall first before running a new install (no update capability).

I downloaded the Setup Factory demo version and can get install/update to work but cannot do the framework check (not shipped with the demo). Also, the uninstall fails (though I may be able to get this to work with some more investigation).

I am interested in using the WiX installer, but would like to know if anyone has a sample of how to perform the deployment using WiX. I would also like to know if I need to use the installer class or if there is a different way to handle the search for the OPEN[n] key under HKCU\Software\Microsoft\Office[Version].0\Excel\Options. If I were to use the project output to enable the installer class, then I need to have 2 separate target directories (one under Program Files for the basic project output and one under %appdata%\Microsoft\AddIns for the packed XLL).

Any help is greatly appreciated.

Thanks,

Lee

解决方案

Using IsWix and Wix 3.7, I was able to resolve this.

Useful links for how to register the components are as follows:

For generating a C# class to handle Windows Installer Custom Actions: http://www.codeproject.com/Articles/132918/Creating-Custom-Action-for-WIX-Written-in-Managed?fid=1599130&df=90&mpp=25&noise=3&prof=False&sort=Position&view=Quick&spc=Relaxed&select=4131367&fr=1#xx0xx

http://blogs.msdn.com/b/jschaffe/archive/2012/10/23/creating-wix-custom-actions-in-c-and-passing-parameters.aspx

For setting the property of the CustomAction.config file to Content WIX Custom Actions built for .Net Framework 4.0 does not work? Ways to resolve?

EDIT 1:

For general knowledge on WiX (Very important) http://channel9.msdn.com/blogs/scobleizer/wix-team-the-most-used-piece-of-software-at-microsoft-and-its-open-source#Page=2

这篇关于如何部署Excel XLL加载项并在Excel中自动注册该加载项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆