But how could you live and have no story to tell!
访问统计 original graphics

        //清除客户端当前显示
        Response.Clear();
        Response.Buffer = true;
        Response.Charset = "GB2312";
        //显示标头
        Response.AddHeader("Content-Disposition", "attachment;   filename=" + System.Web.HttpUtility.UrlEncode("文件名", System.Text.Encoding.UTF8) + ".xls");//这样的话,可以设置文件名为中文,且文件名不会乱码。其实就是将汉字转换成UTF8
        Response.ContentEncoding = System.Text.Encoding.UTF7;
       
// 如果设置为 GetEncoding("GB2312");导出的文件将会出现乱码!

        Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。    

        System.IO.StringWriter stringWrite = new System.IO.StringWriter();

        HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

        GridView1.RenderControl(htmlWrite);
        Response.Write(stringWrite.ToString());
        Response.End();

posted on 2008-07-11 14:58  nextsoft  阅读(2257)  评论(3编辑  收藏  举报