EXcel VSTO - 将列表对象传输到工作表上
我有一个 VSTO 添加,我希望实现。
我想单击一个按钮,产品、名称等列表将被放置到工作表上。
我知道我可以浏览列表中的每个单独项目,然后逐个单元格地写入此单元格,但是有没有一种方法可以将数据“转储”到工作表上?
如果这是一个非常棘手的问题,我深表歉意。
I have a VSTO add in I am looking to implement.
I would like to click a button and a list of products, names, etc would be placed onto the worksheet.
I understand that I could go through each individual item in the list and then write this cell by cell, but is there a way of literally just 'dumping' the data onto the worksheet?
Apologies if this is a really thick question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,没有简单的方法来“转储”数据。你将不得不以艰难的方式做到这一点。只需谷歌一些例子,这很简单。
http://www.google.nl/search?q=c %23+导出+数据+至+excel
Nope, there is no easy way to just 'dump' the data. You're going to have to do it the hard way. Just google for some examples, it's easy enough.
http://www.google.nl/search?q=c%23+export+data+to+excel
这取决于您的“产品、名称等列表”的来源。如果这些项目已修复,您可以使用包含这些项目的准备工作表创建模板文档。将此文档放入程序的嵌入式资源中。当您想要从此模板创建新工作表时,请将资源提取到临时文件,并使用 Excel API 将工作表从模板复制到工作文档。
听起来可能比实际情况更复杂。这里
从资源并将其写入 C# 中的磁盘
您会找到一个如何完成“从资源中提取文件到临时文件”部分的示例。
That depends on where your "list of products, names, etc" are coming from. If those items are fixed, you can create a template document with a prepared worksheet containing these items. Put this document into an embedded resource of your program. When you want to create a new worksheet from this template, extract your resource to a temporary file and use the Excel API to copy the worksheet from your template to your working document.
Sounds perhaps more complicated than it is. Here
Read a file from a resource and write it to disk in C#
you find an example how to accomplish the "extract file from resource to temporary file" part.