在excel中集成c#代码
问题描述:
大家好,
我有一个excel文件,其中包含许多不同但非常相似的用户形式
当我点击一个单元格时在我的工作表中,将根据单元格文本打开一个特定的用户窗体。
我想知道是否有办法将ex#form添加到excel,这将表现为用户形式?
由于视觉工作室界面更简单,更通用,然后vb ...
谢谢
Hi all,
I have an excel file with many different, but very similar, userforms
When i click on a cell in my worksheet a specific userform will open according to the cell text.
I wanted to know if there is a way to add a c# form to excel which will behave as a userform?
Since the visual studio interface is much simpler and a lot more generic then vb...
Thanks
答
您有一些可能性:
1)实际上Excel(以及几乎所有Office应用程序)都支持加载项。因此,您可以创建遗留的Excel加载项。有几个教程,但这不是最简单的。
2)另一个有趣的方法: http:/ /exceldna.codeplex.com/ [ ^ ]
3)你可以从excel vba调用托管代码,但它不是最明智的代码,因为vba以一种相当不确定的方式运行。从这里开始: http://richnewman.wordpress.com/2007/04/15/a-beginner%E2%80%99s-guide-to-calling-a-net-library-from-excel/ [ ^ ]
4) Interop Forms Toolkit [ ^ ]也许是另一种考虑因素。
You have some possibilities:
1) Actually Excel (and practically all Office application) support Add-ins. Thus you could make a legacy excel add-in. There are several tutorials out there, but this is not the simplest one.
2) An other interesting approach: http://exceldna.codeplex.com/[^]
3) You can call managed code from excel vba, but it is not the wisest one, since vba runs in a rather undeterministic way. Start here: http://richnewman.wordpress.com/2007/04/15/a-beginner%E2%80%99s-guide-to-calling-a-net-library-from-excel/[^]
4) Interop Forms Toolkit[^] might be also an alternative to consider.