简单的导出到Excel中: 代码如下: using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Web; namespace Space { /// <summary> /// 标题:将 DataSet, DataTable 导出到 Excel /// 描述:对之前做的导出 Excel 做调整以支持对 DataSet
参考: http://blog.csdn.net/zhouqinghe24/article/details/8649346 参考下载http://www.cnblogs.com/dyllove98/archive/2013/08/06/3241515.html 参考多个sheethttp://www.cnblogs.com/jicheng/p/5961257.html 参考列表写入 1.nuget搜索安装Npoi 2.代码 public class UserInfo { public strin
public void DataTabletoExcel(DataTable dt, string path) { StreamWriter sw = new StreamWriter(path, false, Encoding.GetEncoding("gb2312")); StringBuilder sb = new StringBuilder(); for (int i = 0; i < dt.Columns.Count; i++) { sb.Append(dt.Colum