【发布时间】:2009-03-26 15:05:13
【问题描述】:
这是代码:
TextWriter writer = null;
HttpResponse response = new HttpResponse(writer);
response.ClearContent();
response.AddHeader("content-disposition", "attachment;filename=" + filename + ".xls");
// response.ContentType = "application/ms-excel";
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
HtmlForm htmlForm = new HtmlForm();
GridView1.Parent.Controls.Add(htmlForm);
htmlForm.Attributes["runat"] = "server";
htmlForm.Controls.Add(GridView1);
htmlForm.RenderControl(htmlTextWriter);
response.Write(stringWriter.ToString());
如果我运行此代码,它会引发 NullReferenceException。我在业务逻辑层中使用了这些代码
【问题讨论】:
-
我理解你的问题并不难确定需要你什么
标签: c# .net asp.net excel gridview