简体   繁体   English

Visual Studio 2013 Excel VSTO将WPF或Windows窗体添加到文档

[英]Visual Studio 2013 Excel VSTO Add WPF Or Windows Form To Document

I want to know how to add a WPF Form or a Regular Windows Form to an excel Spreadsheet to collect data. 我想知道如何向E​​xcel电子表格中添加WPF表单或常规Windows表单以收集数据。

For example, I want a button, when clicked to open a WPF/WF which has a couple of checkboxes, and then I want to pass those values back to the worksheet. 例如,我想要一个按钮,当单击该按钮以打开具有几个复选框的WPF / WF时,我想将这些值传递回工作表。 How would I do that? 我该怎么做?

As far as I know, there is no way to actually embed forms in a worksheet unless you were to wrap it up as an OLE object (yuck). 据我所知,除非您将其包装为OLE对象(糟糕),否则无法将表单实际嵌入工作表中。 You can however, show a dialog form to collect user input and have your VSTO AddIn populate or gather data from the excel sheet. 但是,您可以显示一个对话框表单来收集用户输入,并让VSTO AddIn填充或收集Excel工作表中的数据。 I have used this approach with ease for cryptography scenarios where sharing sensitive data requires a runtime password. 对于共享敏感数据需要运行时密码的加密方案,我已经轻松地使用了这种方法。

In case you are not limited to an Excel AddIn, you could also push/pull data from an external instance of Excel. 如果您不仅限于Excel插件,还可以从Excel的外部实例推送/拉取数据。 Let me know if any of these scenarios suit you and if you would like help with code. 让我知道这些情况是否适合您以及您是否需要代码帮助。

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

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