我有动态创建的表,其中有一些数据行和一个MS Chart。 如何将该表格发送到excel,包括图表。
我正在使用fallowing代码导出,但无法呈现图表。
protected void btnGetExcelReport_Click(object sender, EventArgs e)
{
Table tblDealsRep = new Table();
tblDealsRep = (Table)Session["tblReport"];
if (tblDealsRep.Rows.Count > 0)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=LeadsReport.xls");
Response.ContentType = "application/ms-excel";
string k = GetGridViewHtml(tblDealsRep);
Response.Write(k);
Response.End();
}
}
public string GetGridViewHtml(Control c)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
c.RenderControl(hw);
return sw.ToString();
}