是否可以在C#中编写将在Excel中运行的ActiveX控件?

时间:2023-02-12 21:03:08

I have been searching on the web for some example code on how we can write a custom ActiveX Control for use in Excel using .NET but so far I have found old articles suggesting that it is not supported.

我一直在网上搜索一些关于如何使用.NET编写自定义ActiveX控件以便在Excel中使用的示例代码,但到目前为止,我发现旧文章暗示它不受支持。

The application we are building uses Excel as a report writer so we which to add some custom controls to the worksheets to provide a richer experience. From the research I have done so far it appears that some ActiveX Controls can only be hosted in IE and hence I need to ensure that any approach taken works with Excel as a host.

我们正在构建的应用程序使用Excel作为报表编写器,因此我们可以在工作表中添加一些自定义控件以提供更丰富的体验。从我迄今为止所做的研究看来,一些ActiveX控件只能在IE中托管,因此我需要确保所采用的任何方法都适用于Excel作为主机。

The link http://www.codeproject.com/KB/miscctrl/exposingdotnetcontrols.aspx mentions the following:

链接http://www.codeproject.com/KB/miscctrl/exposingdotnetcontrols.aspx提到以下内容:

CAVEAT: As this support has been dropped from Beta2 of .NET, don't blame me if it fries your PC or toasts the cat.

CAVEAT:由于这种支持已经从.NET的Beta2中删除了,如果它炸掉你的PC或者给猫加油,不要怪我。

Can anybody give me an indication if it is possible using .NET 1.1 and if so to any pointers on best practices?

任何人都可以给我一个指示是否有可能使用.NET 1.1,如果可以的话,是否有关于最佳实践的指示?

3 个解决方案

#1


3  

Andrew Whitechapel writes about managed controls as ActiveX controls in Office documents. You can read his article here:

Andrew Whitechapel将托管控件写为Office文档中的ActiveX控件。你可以在这里阅读他的文章:

Using Managed Controls as ActiveX Controls

将托管控件用作ActiveX控件

#2


0  

I would thought that you're out of luck, but did find this:

我以为你运气不好,但确实发现了这个:

http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx

Gives me the willies... but it might just right for you.

给了我一些意志......但它可能适合你。

#3


0  

Further information on creating ActiveX Controls using C# can be found below although these articles seem to use IE as a Hosting Container not Excel.

有关使用C#创建ActiveX控件的更多信息可以在下面找到,尽管这些文章似乎使用IE作为托管容器而不是Excel。

http://www.ondotnet.com/pub/a/dotnet/2003/01/20/winformshosting.html

http://www.codeproject.com/KB/miscctrl/exposingdotnetcontrols.aspx

#1


3  

Andrew Whitechapel writes about managed controls as ActiveX controls in Office documents. You can read his article here:

Andrew Whitechapel将托管控件写为Office文档中的ActiveX控件。你可以在这里阅读他的文章:

Using Managed Controls as ActiveX Controls

将托管控件用作ActiveX控件

#2


0  

I would thought that you're out of luck, but did find this:

我以为你运气不好,但确实发现了这个:

http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx

Gives me the willies... but it might just right for you.

给了我一些意志......但它可能适合你。

#3


0  

Further information on creating ActiveX Controls using C# can be found below although these articles seem to use IE as a Hosting Container not Excel.

有关使用C#创建ActiveX控件的更多信息可以在下面找到,尽管这些文章似乎使用IE作为托管容器而不是Excel。

http://www.ondotnet.com/pub/a/dotnet/2003/01/20/winformshosting.html

http://www.codeproject.com/KB/miscctrl/exposingdotnetcontrols.aspx