简体   繁体   English

将Excel工作簿合并到VSTO Excel加载项中

[英]Incorporate an Excel workbook in a VSTO Excel Add-In

Am rewriting an Excel VBA Add-In as a VSTO Excel Add-In (and switching to C#). 正在将Excel VBA外接程序重写为VSTO Excel外接程序(并切换到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). 在VBA版本中,我有可用于存储公式等的工作表,并且通常处理数据(当调用外接程序时,这些数据将从活动工作表中复制进来)。 With VSTO there is no equivalent .xlam workbook with worksheets to store such formulas. 使用VSTO,没有等效的.xlam工作簿和工作表来存储此类公式。 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. 我曾尝试嵌入这样的工作簿,但正在努力访问它,然后像在VBA中一样使用它。

In traditional VBA code, your code is part of a workbook and hence you could use to "store" some config. 在传统的VBA代码中,您的代码是工作簿的一部分,因此您可以用来“存储”某些配置。 In an add-in, there is no such thing. 在外接程序中,没有这样的东西。 It is application level and hence no specific document is available. 它是应用程序级别,因此没有特定的文档。

a) You could store the formulas as XML or something and do what you want with them a)您可以将公式存储为XML或其他格式,然后对它们进行所需的操作

b) It seems like what you want is not an add-in, but a document level customization. b)似乎您想要的不是外接程序,而是文档级别的自定义。 If you do that, your "code" is attached to a particular document. 如果这样做,您的“代码”将附加到特定文档。 There you could potentially use a "template" worksheet or even customize the sheets, look and feel, formulas, add ranges, whatever you need. 在那里,您可能会使用“模板”工作表,甚至可以自定义工作表,外观,公式,添加范围,无论您需要什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM