文件导出

string HEADER = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">" +

                                         "<meta http-equiv=Content-Type content=\"text/html; charset=\"gb2312\">";

 

string FileName = "SaleInfo";

            HttpContext.Current.Response.Charset = "UTF-8"; // 或UTF-7 以防乱码

            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;

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

            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + "" + FileName + ".xls");

            Response.Write(HEADER);

 

            Response.Write(@"<head><style  type='text/css'>td{border:black thin solid;}</style> </head>");

            HttpContext.Current.Response.Write(sb.ToString());

            HttpContext.Current.Response.End();

posted @ 2012-02-29 14:22  fang_beny  阅读(191)  评论(0)    收藏  举报