首页新闻找找看学习计划

asp.net mvc3 实现把页面列表导出execl表?求大神给完整代码,考虑服务器

0
悬赏园豆:30 [待解决问题]

asp.net mvc3 实现把页面列表导出execl表?求大神给完整代码,考虑服务器

问题补充:

求大神给个Demo

88888888888的主页 88888888888 | 初学一级 | 园豆:144
提问于:2012-12-04 15:53
< >
分享
所有回答(4)
0

看看NPOI这个库。

园子里有很多资料可供学习。

````` | 园豆:14268 (专家六级) | 2012-12-04 15:58

谢谢

支持(0) 反对(0) 88888888888 | 园豆:144 (初学一级) | 2012-12-04 16:00
0

NPOI必须的

chenping2008 | 园豆:9836 (大侠五级) | 2012-12-04 16:23
0

在服务器将数据转换为表格,然后修改一下response的minitype 直接输出即可是excel

az235 | 园豆:8283 (大侠五级) | 2012-12-04 19:00
0

用Telerik的吗?是Telerik的话,在view中加入 commands.Custom().Text("导出表格").Action("ExportCsv", "MyAddressBook", new { page = 1, orderBy = "~", filter = "~" });

控制器:

 1         public ActionResult ExportCsv(int page, string orderBy, string filter)
 2         {
 3             ClassRepository rep = new ClassRepository();
 4 
 5             IEnumerable classs = rep.GetClassOrder().AsQueryable().ToGridModel(page, 10, orderBy, string.Empty, filter).Data;
 6             MemoryStream output = new MemoryStream();
 7             StreamWriter writer = new StreamWriter(output, Encoding.UTF8);
 8 
 9 
10             writer.Write("产品名称,");
11             writer.Write("产品识别码,");
12             writer.Write("出库数量,");
13             writer.WriteLine();
14             foreach (Classes c in classs)
15             {
16                 writer.Write(c.id);
17                 writer.Write(",");
18 
19                 writer.Write("\"");
20                 writer.Write(c.classname);
21                 writer.Write("\"");
22                 writer.Write(",");
23 
24                 writer.Write("\"");
25                 writer.Write(c.classpersons);
26                 writer.Write("\"");
27                 writer.Write(",");
28 
29                 writer.WriteLine();
30             }
31 
32             writer.Flush();
33             output.Position = 0;
34 
35             return File(output, "text/comma-separated-values", "address.csv");
36         }
真假不分 | 园豆:248 (菜鸟二级) | 2013-07-26 02:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册