ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 导出到Excel的操作

导出到Excel的操作

原创 Linux操作系统 作者:iDotNetSpace 时间:2009-11-06 11:15:30 0 删除 编辑
 1
 2        DataTable dt = wad.GetToExcel(lblcode.Text);
 3        StringWriter sw = new StringWriter();
 4        
 5        sw.WriteLine("代号,货品编码,货品名称,单位,净需求量,采购量,供应商,下单日期,到货日期,采购员,报关,状态,采购订单号");
 6        foreach (DataRow item in dt.Rows)
 7        { 
 8            //string state = (OPSState)Convert.ToInt32(item["imgstate"]);
 9            sw.WriteLine(item["code"] + "," + item["goodscode"] + "," +
10                item["goodsname"] + "," + item["unit"] + "," +
11                item["netdemand"] + "," + item["shoppingnum"] + "," +
12                item["tradername"] + "," + item["orderdate"] + "," +
13                item["arrivaldate"] + "," + item["buyername"] + "," +
14                item["ifcustoms"] + "," + (OPSState)Convert.ToInt32(item["imgstate"]) + "," +
15                item["ordercode"] );
16        }

17        Response.AddHeader("Content-Disposition", "attachment;   filename=test.csv");
18        Response.ContentType = "application/ms-excel";
19        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
20        Response.Write(sw);
21        sw.Close();
22        Response.End();

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-618271/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: ASP.NET中Memcached
下一篇: Http Handler 介绍
请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    2376
  • 访问量
    5765891