您的位置:首页 > 编程语言 > ASP

ASP.NET数据库导入Excel

2010-03-09 18:21 323 查看
StringWriter sw = new StringWriter();

sw.WriteLine("访问购买率");

sw.WriteLine("排行/t商品名称/t人气指数/t购买次数/t访问购买率");

int i = 0;

foreach (ProductSaleInfo productSale in productSaleList)

{

i = i + 1;

sw.WriteLine(i.ToString() + "/t" + productSale.Name.ToString() + "/t" + productSale.ViewCount.ToString() + "/t" + productSale.SaleCount.ToString() + "/t" + XWXCommon.ProductBuyRate(productSale.ViewCount.ToString(), productSale.SaleCount.ToString()));

}

sw.Close();

Response.Clear();

Response.Buffer = true;

Response.Charset = "GB2312";

Response.AppendHeader("Content-Disposition", "attachment;filename=visit_sold.xls");

Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");

Response.ContentType = "application/ms-excel";

Response.Write(sw);

Response.End();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: