哪个大大能给我一个完整的 能用的 导出ASP。net页面以word的形式保存下来
我在网上下载的代码都是不能用的,请各位大大帮忙 急用。。。。!
http://www.cnblogs.com/chengulv/archive/2007/06/26/796484.html
这里可以参考
protected void Button1_Click(object sender, EventArgs e)
{
Export("application/ms-word", "员工报表.doc");
}
private void Export(string FileType, string FileName)
{
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
GridView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
楼上的打印出来会有一些其他控件在里面。