我有一种情况,我必须在不使用Interop(MicroSoft)的同一个excel文件中导出gridview和图表。这是我的代码
string attachment = "attachment; filename=test.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
// Create a form to contain the grid
HtmlForm frm = new HtmlForm();
gvReport.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(gvReport);
frm.RenderControl(htw);
String imagepath = "<img src='" + Server.MapPath("../Image1.png") + "' />";
Response.Output.Write("\n<html>\n<body>");
Response.Output.Write("<table width='800' align='center' style='text-align:center'");
Response.Output.Write("<tr><td colspan='10' align='center'><div align='center' style='text-align:center'>" + imagepath + "</div></td></tr>");
Response.Output.Write("</table>");
Response.Output.Write("\n</body>\n</html>");
Response.Flush();
//Response.End();
Response.Write(sw.ToString());
Response.End();
我哪里出错了?