1
Answer

Not Exporting Ajax ControlToolkit Linechart to excel asp.net

Kk

Kk

8y
335
1
In my application i have Ajax Toolkit control linechart i need to  linechart to excel sheet(open office/Libra office). i tried some code in export button but what happens line chart is not export to excel.what i need is chart should be export to excel. how to do this.
 I am using one method OnPreRender()
I tried code is:
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 */
 }

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);
 }
 }

can anyone tell me how to export Ajax Control Toolkit using line chart to excel
Thank you

 
 
 
Answers (1)