通过Response.Write的方法输出CSV的文本文件

       StringBuilder objCSV = AnalysisLayer.LoadChargeInfoToCSVString(ViewStateFrom, ViewStateTo, GenerateSortString());
       string strFile = Server.MapPath("mygod.csv");
       Response.Clear();
       Response.Buffer = true;
       Response.Charset = "utf-8";
       Response.AppendHeader("content-disposition", "attachment;filename=VocieLog.csv");
       Response.ContentEncoding = System.Text.Encoding.Default;

       //response.contenttype指定文件类型 能为application/ms-excel || application/ms-word || application/ms-txt || application/ms-html || 或其他浏览器可直接支持文件
       Response.ContentType = "application/ms-txt";
       this.EnableViewState = false;
       Response.Write(objCSV.ToString());
       Response.End();

posted on 2010-08-04 10:28  冰危节奏  阅读(2948)  评论(0)    收藏  举报

导航