如何将 AjaxToolkit 控制线图导出到 Excel

How to export AjaxToolkit control linechart to Excel

在应用程序中,我有网格视图和 Ajax 工具包控制线图,我需要将网格视图和线图导出到 excel sheet(打开 office/Libra 办公室)。我在导出按钮中尝试了一些代码,但导出网格视图时发生了什么,但折线图未导出到 excel。我的页面是这样的 [my chart image]
通过单击导出按钮,只有网格视图将导出到 excel,而不是折线图,它不会 export.what 我需要的是图表应该导出到 excel。怎么做

我试过的代码是:
.aspx:

 <cc1:LineChart ID="LineChart1" runat="server" ChartHeight="300"  ChartWidth="900" ChartType="Basic" ChartTitleColor="#0E426C" Visible="true" CategoryAxisLineColor="#D08AD9" ValueAxisLineColor="#D08AD9" BaseLineColor="#A156AB"></cc1:LineChart>

.cs:

 protected void btnExport_Click(object sender, EventArgs e)
    {

        Response.ClearContent();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "filename.xls"));
        Response.ContentType = "application/ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw); 
        base.OnPreRender(e);
        ScriptManager sm = ScriptManager.GetCurrent(Page);
        sm.RegisterScriptControl(LineChart1);
        LineChart1.Visible = true;          
       for (int i = 0; i < grdview1.HeaderRow.Cells.Count; i++)
        {
           grdview1.HeaderRow.Cells[i];
        }
        grdview1.RenderControl(htw);
        LineChart1.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();        
    }

public override void VerifyRenderingInServerForm(Control control)
    {
        /* Verifies that the control is rendered */
    }

我添加了 OnPreRender() 用于注册脚本管理器控件

    protected override void OnPreRender(EventArgs e)
    {
        /* Verifies that the control is rendered */
        base.OnPreRender(e);
        ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);

        if (scriptManager == null)
        {

            scriptManager = new ScriptManager();

            scriptManager.ID = "ScriptManager1";

            scriptManager.EnablePartialRendering = true;

            Controls.AddAt(0, scriptManager);

        }
    }

谁能帮我看看如何导出折线图。

谢谢

不,您不能导出折线图。