使用HttpContext对象,导出到word。这个比较通用,也可以导出到excel等。可将整个页面(Page),或者DataGrid,DataList等控件使用RenderControl()方法到word,提示用户选择下载存放地址。 HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename); HttpContext.Current.Response.Charset = "UTF-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; HttpContext.Current.Response.ContentType = filetype; //HttpContext.Current.Response.ContentType = "application/ms-excel";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); gv.RenderControl(hw); HttpContext.Current.Response.Write(tw.ToString()); HttpContext.Current.Response.End();