如果部署Excel 加载项?
按照一篇文章所说,在开发环境下测试没有问题了。
但是如何把生成的加载项部署到客户机上面?
另外 Com-Addin 和 VSTO 的Addin 差别是什么?
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Data.OleDb;
namespace AutomationAddin
{
[ClassInterface(ClassInterfaceType.AutoDual), ComVisible(true)]
public class MyFunctions
{
public MyFunctions()
{
}
public double MultiplyNTimes(double Number1, double Number2, double TimesToMultiply)
{
double result = Number1;
for (double i = 0; i < TimesToMultiply; i++)
{
result = result * Number2;
}
return result;
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type type)
{
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type));
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type), false);
}
private static string GetSubKeyName(Type type)
{
string s = @"CLSID\{" + type.GUID.ToString().ToUpper() + @"}\Programmable";
return s;
}
}
}