Incorporate an Excel workbook in a VSTO Excel Add-In

时间:2016-07-11 22:35:24

标签: c# excel excel-vba vsto vba

Am rewriting an Excel VBA Add-In as a VSTO Excel Add-In (and switching to C#). In the VBA version I have worksheets available to store formulas etc., and generally manipulate the data (which will have been copied in from the active worksheet when the add-in was invoked). With VSTO there is no equivalent .xlam workbook with worksheets to store such formulas. So I'm trying to figure out how to store/access such a "helper" workbook. I do realize I could build the formulas in code, but storing them in spreadsheet(s) makes it much more maintainable. I've tried embedding such a workbook but am struggling to access it and then use it like I could in VBA.

1 个答案:

答案 0 :(得分:0)

在传统的VBA代码中,您的代码是工作簿的一部分,因此您可以使用"存储"一些配置。在加载项中,没有这样的东西。它是应用程序级别,因此没有可用的特定文档。

a)您可以将公式存储为XML或其他内容并使用它们执行所需的操作

b)看起来你想要的不是加载项,而是文档级自定义。如果你这样做,你的代码"附在特定文件上。在那里你可以使用"模板"工作表甚至可以自定义工作表,外观,公式,添加范围,以及您需要的任何内容。