使用 FileHelpers 导出数据表
我想使用 FileHelpers 将 DataTable 的内容导出到文本分隔文件,这可能吗? 这是我到目前为止所拥有的:
// dt is a DataTable with Rows in it
DelimitedClassBuilder cb = new DelimitedClassBuilder("MyClassName", "|", dt);
Type t = cb.CreateRecordClass();
FileHelperEngine engine = new FileHelperEngine(t);
我必须将 dt 的内容转换为“MyClassName”类型的数组,但我不知道该怎么做? 我知道有一个 FileDataLink 类,但它们都不能与 DataTable (甚至 DataSet)一起使用。
I want to export the contents of a DataTable to a text delimited file using FileHelpers, is this possible? Here is what I have so far:
// dt is a DataTable with Rows in it
DelimitedClassBuilder cb = new DelimitedClassBuilder("MyClassName", "|", dt);
Type t = cb.CreateRecordClass();
FileHelperEngine engine = new FileHelperEngine(t);
I have to convert the contents of dt to an array of type "MyClassName" but I'm not sure how to do that? I know there is a FileDataLink class but none of them work with DataTable (or even a DataSet).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许你可以用这个:
Maybe you could use this: