我将数据从表转储到在运行时创建的excel表。我在Session["Fullpath"]
中有文件路径。我能够创建包含table1数据的excel。现在,我还有一个表table2.I我想将表table2中的数据转储到同一个excel的第二个表中。
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename= " + Session["Fullpath"]);
Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
table.RenderControl(htw);
Response.Output.Write(sw.ToString());
System.IO.File.WriteAllText(Session["Fullpath"].ToString(), sw.ToString());
Response.Flush();
Response.End();