110,533
社区成员
发帖
与我相关
我的任务
分享
Response.Clear();
Response.Buffer = true;
Response.Charset = "UTF-8";
Response.AppendHeader("Content-Disposition", "attachment;filename=FileName.xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.ContentType = "application/ms-excel";
EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("zh-CN", true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
//你要打印的结果集
string StrSQL = "";
StrSQL = this.getStrSQL();
DataSet DS = new DataSet();
DS = Cls_DB_factory._DataSet(StrSQL);
gview.DataSource = DS.Tables[0];
gview.DataBind();
gview.RenderControl(oHtmlTextWriter);
// this.GridView1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();