开发者

export gridview to excel error

开发者 https://www.devze.com 2023-01-29 13:40 出处:网络
dear all, i tried the code below to make the export to excel, but not working correctly i used this thread

dear all, i tried the code below to make the export to excel, but not working correctly i used this thread lin开发者_JAVA技巧k text

HtmlForm form = new HtmlForm(); 
string attachment = "attachment; filename=Patients.xls"; 
Response.ClearContent(); 
Response.AddHeader("content-disposition", attachment); 
Response.ContentType = "application/ms-excel"; 
StringWriter stw = new StringWriter(); 
HtmlTextWriter htextw = new HtmlTextWriter(stw); 
form.Controls.Add(gridview1); 
this.Controls.Add(form); 
form.RenderControl(htextw); 
Response.Write(stw.ToString()); 
Response.End(); 


did you try add to the aspx page directive

EnableEventValidation ="false" 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号