高人进.把DATASET导出到EXCEL时,如何自定义页眉,页脚
string dcsql = "select * from table ";
con.Open();
DataSet dsss = new DataSet();
SqlDataAdapter dass = new SqlDataAdapter(dcsql, con.Conn);
dass.Fill(dsss);
GridView2.DataSource = dsss;
GridView2.DataBind();
this.GridView2.AllowPaging = false;
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312 ";
Response.AppendHeader( "Content-Disposition ", "attachment;filename=Excel( "+DateTime.Now.ToShortDateString()+ ").xls ");
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.ContentType = "application/ms-excel ";
this.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);
this.GridView2.RenderControl(oHtmlTextWriter);
Response.Output.Write(oStringWriter.ToString());
Response.Flush();
Response.End();
这个是导出的方法,由于数据量很大,麻烦高人看看,导出的时候如何设置页眉和页脚
------解决方案--------------------解决方法看这个
http://www.wsoft.net/Index/Catalog53/225.aspx
在写入二维数组的时候加上你要的东西