您的位置:首页 > 其它

NPOI导出Excel表功能实现(多个工作簿)

2010-03-08 11:26 225 查看

NPOI简介:http://www.cnblogs.com/tonyqus/archive/2009/03/16/1409966.html
NPOI官网:http://npoi.codeplex.com/

实例下载:http://files.cnblogs.com/zhengjuzhuan/NPOIHelper.rar

Excel生成操作类:

代码
//导出数据列 实现根据添加顺序导出列
StarTech.NPOI.NPOIHelper.ListColumnsName = new SortedList(new StarTech.NPOI.NoSort());
StarTech.NPOI.NPOIHelper.ListColumnsName.Add("MemberName", "姓名");
StarTech.NPOI.NPOIHelper.ListColumnsName.Add("username", "账号");
StarTech.NPOI.NPOIHelper.ListColumnsName.Add("starttime", "登陆时间");
StarTech.NPOI.NPOIHelper.ListColumnsName.Add("lasttime", "在线到期时间");
StarTech.NPOI.NPOIHelper.ListColumnsName.Add("state", "状态");
Response.Clear();
Response.BufferOutput = false;
Response.ContentEncoding = System.Text.Encoding.UTF8;
string filename = HttpUtility.UrlEncode(DateTime.Now.ToString("在线用户yyyyMMdd"));
Response.AddHeader("Content-Disposition", "attachment;filename=" + filename + ".xls");
Response.ContentType = "application/ms-excel";
StarTech.NPOI.NPOIHelper.ExportExcel(dtSource, Response.OutputStream);
Response.Close();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: