ASP.NET数据库导入Excel

来源:互联网 发布:大数据采集与管理专业 编辑:程序博客网 时间:2024/05/20 07:37

                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();

原创粉丝点击