复制代码 代码如下:
public override void VerifyRenderingInServerForm(
Control control
)
复制代码 代码如下:
Page p=new Page();
HtmlForm form=new HtmlForm();
Grid1.EnableViewState = false;
p.EnableEventValidation = false;
p.DesignerInitialize();
form.Controls.Add(Grid1);
p.Controls.Add(form);
StringBuilder sb=new StringBuilder();
StringWriter sw=new StringWriter(sb);
p.RenderControl(sw);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
Response.Charset = "UTF-8";
Response.ContentEncoding = Encoding.Default;
Response.Write(sb.ToString());
Response.End();
新闻热点
疑难解答
图片精选