将数据集转换为文本文件制表符分隔文件
我有一个数据集。我想将数据集列转换为标题,将行数据转换为数据到制表符分隔的文本文件中。
我最终可以采取什么技术或者我必须手动进行循环吗?
衷心感谢, - 塞尔
I have a DataSet. I would like to convert dataset column as header and row data as data into a tab delimited text file.
Is there any technique I can do in my end or I have to do the looping manually?
Sincerely Thanks,
- Sel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
用法:
Usage:
导出到 XML 是内置的,但导出到 CSV,您可以使用以下代码 - 来自 http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/d2071fd4-8c7d-4d0e-94c3-9586df754df8/
这仅写入数据,而不写入列,您需要首先循环列标题。
编辑:更新为包含列名称...我还没有运行此操作,这是来自链接的编辑上面,所以它可能有效也可能无效,但概念就在这里
Exporting to XML is built right in, but exporting to CSV, you can use the following code - from http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/d2071fd4-8c7d-4d0e-94c3-9586df754df8/
this only writes the data, not the columns, you'll need to loop the column headers first..
Edit: Updated to include column names... I have not run this, and this is an edit from the link above, so it may or may not work, but the concept is here
请注意,您需要使用 Linq 才能使此解决方案发挥作用。将以下
using
语句添加到您的代码中:Note you will need to be using Linq for this solution to work. Add the following
using
statement to your code: