aspx页面导出为word代码:
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(SW);
base.Form.RenderControl(htw);
Response.Buffer = true;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/ms-word";
Response.Charset = "gb2312";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.AddHeader("Content-Disposition","attachment;filename=" + HttpUtility.UrlEncode("下载") + ".doc"));
string html = sw.ToString();
Response.Write(html);
Response.Flush();
Response.Close();