如何将集合列表导出到Excel工作簿中已存在的工作表中 [英] How do i export a collection list to an already existing worksheet in an excel workbook
本文介绍了如何将集合列表导出到Excel工作簿中已存在的工作表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我有一个包含数据的收集列表,我想将收集列表中的数据导出到已经存在的excel文件中的工作表中.我该怎么做?
Hi guys i have a collection list that contains data, i want to export the data in the collection list to a sheet in an already existing excel file. How do i do that?
推荐答案
EPPlus [ ^ ]是一个不错的库,随附的示例向您展示了如何执行此操作.
最好的问候
Espen Harlinn
EPPlus[^] is a nice library, and the accompanying examples shows you how to do this.
Best regards
Espen Harlinn
我将使用Sheet.UsedRange,然后使用硬代码找出是否要添加单元格.您没有给我们太多代码来进行操作,::
在此处查看示例:
http://support.microsoft.com/kb/302084 [
I would use Sheet.UsedRange and then hard code to find out were you want to add the cells. You dont give us much code to go on so,:
See sample here:
http://support.microsoft.com/kb/302084[^]
Good luck
如果您想替换现有数据,则需要执行以下步骤:
1)创建MS Excel应用程序的实例.如何?您可以使用互操作 [ ^ ]或 OLE自动化 [ CopyFromRecordset [关闭 [SaveChanges:=True
的="New Window"> ^ ]方法
就这样!祝你好运;)
例子:
使用C#打开和导航Excel [ http://csharp.net-informations.com/excel/csharp-open-excel.htm [^ ]
如果您想向现有集合中添加一些数据,请告诉我.
If you would like to replace existing data, you need to go through these steps:
1) Create the instance of MS Excel application. How? You can use Interop[^] or OLE Automation[^].
2) Open existing workbook,
3) Clear existing data,
4) Export data from your application, usingfor .. next
loop or CopyFromRecordset[^] method for Range object. Personally, i preferCopyFromRecordset
because it''s quick ;)
5) Save and close the workbook. Use Close[^] method with parameterSaveChanges:=True
That''s all! Good luck ;)
Examples:
Opening and Navigating Excel with C#[^]
http://csharp.net-informations.com/excel/csharp-open-excel.htm[^]
If you would like to add some data in to existing collection, please let me know.
这篇关于如何将集合列表导出到Excel工作簿中已存在的工作表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文