使用 C# 创建 Excel 加载项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2020234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating add-in for Excel using C#
提问by Sambhaji
I want to use C# class methods in Excel. Can anybody guid me how to do it ? The C# component will be excel add-in. How to create setup for this addin, so that I just need to give setup to user which will install add-in at client's machine. User should not need to do any other steps like registering the C# dll.
我想在 Excel 中使用 C# 类方法。有人可以指导我怎么做吗?C# 组件将是 excel 插件。如何为此插件创建安装程序,以便我只需要向将在客户端计算机上安装插件的用户提供安装程序。用户不需要执行任何其他步骤,例如注册 C# dll。
采纳答案by Richard Ev
You will need to create a new Visual Studio project of type Excel 2007 Add-In (or Excel 2003 Add-In). The option for this can be found (in Visual Studio 2008) at:
您将需要创建一个 Excel 2007 加载项(或 Excel 2003 加载项)类型的新 Visual Studio 项目。可以在以下位置找到此选项(在 Visual Studio 2008 中):
New Project dialog -> Project types -> Visual C# -> Office
New Project dialog -> Project types -> Visual C# -> Office
This Add-In will need to be installed on the target machine(s).
该插件需要安装在目标机器上。
The Add-In will be able to hook into the Excel object model and therefore access any loaded spreadsheets etc.
插件将能够连接到 Excel 对象模型,从而访问任何加载的电子表格等。
The Add-In will also be able to add buttons to the Excel toolbar/ribbon.
加载项还可以将按钮添加到 Excel 工具栏/功能区。
回答by James Bloomer
Try looking at VSTO, there's a section explicitly for Excel
尝试查看VSTO,有一个明确用于 Excel 的部分
回答by Adam Ralph
You can create Excel projects within Visual Studio (previously known as Excel VSTO projects) or you can use a third party library such as ExcelDna.
您可以在 Visual Studio 中创建 Excel 项目(以前称为 Excel VSTO 项目),也可以使用第三方库,例如 ExcelDna。
回答by Govert
(Disclaimer: I develop the Excel-Dna library.)
(免责声明:我开发了 Excel-Dna 库。)
You should have a look at Excel-Dna - http://exceldna.codeplex.com. The library allows managed assemblies written in C#, VB.NET or F# to expose high-performance user-defined functions (UDFs) and macros to Excel through the native .xll interface. The project is open-source and freely allows commercial use.
你应该看看 Excel-Dna - http://exceldna.codeplex.com。该库允许使用 C#、VB.NET 或 F# 编写的托管程序集通过本机 .xll 接口向 Excel 公开高性能用户定义函数 (UDF) 和宏。该项目是开源的,可以自由地用于商业用途。
With Excel-Dna you can create a single .xll add-in file that the user can open as an add-in without any further installation or registration. Excel-Dna add-ins can expose RTD servers and customized Ribbons for Excel 2007 and Excel 2010 without additional registration, so you need no extra setup program.
使用 Excel-Dna,您可以创建单个 .xll 加载项文件,用户无需进一步安装或注册即可将其作为加载项打开。Excel-Dna 加载项无需额外注册即可为 Excel 2007 和 Excel 2010 公开 RTD 服务器和自定义功能区,因此您无需额外的安装程序。