DataTable dt = wad.GetToExcel(lblcode.Text);
StringWriter sw = new StringWriter();
sw.WriteLine("代号,货品编码,货品名称,单位,净需求量,采购量,供应商,下单日期,到货日期,采购员,报关,状态,采购订单号");
foreach (DataRow item in dt.Rows)
{
//string state = (OPSState)Convert.ToInt32(item["imgstate"]);
sw.WriteLine(item["code"] "," item["goodscode"] ","
item["goodsname"] "," item["unit"] ","
item["netdemand"] "," item["shoppingnum"] ","
item["tradername"] "," item["orderdate"] ","
item["arrivaldate"] "," item["buyername"] ","
item["ifcustoms"] "," (OPSState)Convert.ToInt32(item["imgstate"]) ","
item["ordercode"] );
}
Response.AddHeader("Content-Disposition", "attachment; filename=test.csv");
Response.ContentType = "application/ms-excel";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.Write(sw);
sw.Close();
Response.End();