GridView导出Excel Word 等等,微软办公文档, 拖入GridView控件GridView1,绑定数据 拖入Button 控件,Text属性为 导出文档 双击· 写入以下代码 总的代码如下: Response.Clear(); Response.Buffer = true ; Response.Charset = " GB2312 " ; Response.AppendHeader( " Content-Disposition " , " attachment;filename=FileName.xls " ); // 转化为其他 后缀名改以下 Response.ContentEncoding = System.Text.Encoding.UTF7; // ;字符集格式 Response.ContentType = " application/ms-excel " ; // 转化为其他 如 excel 改为 Word StringWriter oStringWriter = new StringWriter(); HtmlTextWriter OHtmlTextWriter = new HtmlTextWriter(oStringWriter); GridView1.RenderControl(OHtmlTextWriter); Response.Output.Write(oStringWriter.ToString()); Response.Flush(); Response.End(); HTML页 < html xmlns = " http://www.w3.org/1999/xhtml " >