我使用波紋管代碼導出gridview數據,但問題在於整個頁面導出爲excel。 我只想要gridview數據不是整個頁面導出。如何解決這個問題?將Gridview數據導出到ASP.NET Linq數據綁定
HtmlForm form = new HtmlForm();
Response.Clear();
Response.Buffer = true;
string filename = "GridViewExport_" + DateTime.Now.ToString() + ".xls";
Response.AddHeader("content-disposition", "attachment;filename=" + filename);
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gdvInBox.AllowPaging = false;
gdvInBox.DataBind();
form.Controls.Add(gdvInBox);
this.Controls.Add(form);
form.RenderControl(hw);
//style to format numbers to string
string style = @"<style> .textmode { mso-number-format:\@; } </style>";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
在此先感謝。
你會如何做,從用戶控制這個東西的工作一樣嗎?您無法重寫VerifyRendering – BRogers