.net Table 导出Excel

             Table table = new Table();
            Response.ClearContent();
            Response.Buffer = true; 
            Response.Charset = "GB2312"; 
            Response.AppendHeader("Content-Disposition", "attachment;filename=FileName1.xls");
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "application/excel"; 
            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
            table.RenderControl(oHtmlTextWriter);
            Response.Write(oStringWriter.ToString());
            Response.Flush();
            Response.End(); 
posted @ 2013-03-05 18:15  文艺流浪汉  阅读(272)  评论(0编辑  收藏  举报