主题:  datagrid到excel问题??

ztong

职务:普通成员
等级:1
金币:0.0
发贴:129
#12006/3/10 15:49:15
使用导出datagrid到excel,使用下面语句:

public void savetoexcel_Click(object sender, System.EventArgs e)
{
DataGridBind(); //捆绑数据库
Response.Clear();
Response.Buffer= true;
Response.Charset="gb2312";
string Date=DateTime.Now.ToString("yyyy-MM-dd";
string filename="单位填报表"+Date;
Response.AddHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(filename)+".xls";
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8";
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
DataGrid1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
}
为什么转换的只是DataGrid1的当前页,而不是所有页???
如果能够实现所有页的转换,怎么修改呢??谢谢了!!!!



ztong

职务:普通成员
等级:1
金币:0.0
发贴:129
#22006/3/17 16:02:26
大侠帮忙啊!!!!!帮帮忙啊!!!