Skip to content
Loading
0
  • 0
    thank you for responding, I tried this code but it is not possible to export only grid view data will export.I am using for Ajax Control ToolKit line chart for export to excel using one OnPreRender() but no errors are found but line chart not exporting only gridview will exporting to excel my code is.
    protected void btnExport_Click(object sender, EventArgs e)
    {
    Response.ClearContent();
    Response.Buffer = true;
    Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "MTTraining-Accuracy.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);
    grdMTPerformance.AllowPaging = false;
    grdMTPerformance.HeaderRow.Style.Add("background-color", "#FFFFFF");
    for (int i = 0; i < grdMTPerformance.HeaderRow.Cells.Count; i++)
    {
    grdMTPerformance.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");
    }
    LineChart1.Visible = true;
    LineChart1.RenderControl(htw);
    grdMTPerformance.RenderControl(htw);
    Response.Write(sw.ToString());
    Response.End();
    }
    protected override void OnPreRender(EventArgs e)
    {
    /* Verifies that the control is rendered */
    base.OnPreRender(e);
    ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
    if (scriptManager == null)
    {
    this.LineChart1.Visible = true;
    scriptManager = new ScriptManager();
    scriptManager.ID = "ToolkitScriptManager1";
    scriptManager.EnablePartialRendering = true;
    Controls.AddAt(0, scriptManager);
    }
    }
    this is i added code can you tell me how to export this line chart to excel sheet
    Thank you
    0