您是否编写此代码来创建带有两个选项卡的 Excel 电子表格?目前只做一个。
string attachment = string.Empty;
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
frm.Attributes["runat"] = "server";
attachment = "attachment; filename=MyFile.xls";
GridView1.Parent.Controls.Add(frm);
frm.Controls.Add(GridView1);
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
frm.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();