如何DataTable中导出到Excel [英] How to export DataTable to Excel

查看:865
本文介绍了如何DataTable中导出到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在C#中导出数据表到Excel?我使用Windows窗体。在数据表 DataGridView的控制有关。我有出口记录的数据表到Excel中。

How can I export a DataTable to Excel in C#? I am using Windows Forms. The DataTable is associated with a DataGridView control. I have to export records of DataTable to Excel.

推荐答案

我会建议 ClosedXML -

您可以将一个DataTable到Excel工作表的一些的非常的可读code:

You can turn a DataTable into an Excel worksheet with some very readable code:

XLWorkbook wb = new XLWorkbook();
DataTable dt = GetDataTableOrWhatever();
wb.Worksheets.Add(dt,"WorksheetName");

开发商响应和有益的。该项目积极发展,该文档是一流的。

The developer is responsive and helpful. The project is actively developed, and the documentation is superb.

这篇关于如何DataTable中导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆