开发者

export gridview to excel error

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜