When export chart in c# using Chart1.SaveImage method , I got white image only.
I used below code to export chart as image , but I got as blank white screen only.
I found solution for this issue(may not be a right way) this may useful to someone who is struck on this.
I load the chart druing load_chart button click event
here ,
Its Working for me.
I used below code to export chart as image , but I got as blank white screen only.
MemoryStream stream = new MemoryStream(); Chart1.SaveImage(stream, ChartImageFormat.Jpeg); BinaryReader binrayRdr = new BinaryReader(stream); byte[] bytes1 = ((MemoryStream)stream).ToArray(); Response.Clear(); Response.ContentType = "image/png"; Response.AddHeader("Content-Disposition", "attachment; filename=HTML.png"); Response.Buffer = true; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(bytes1); Response.End();
I found solution for this issue(may not be a right way) this may useful to someone who is struck on this.
I load the chart druing load_chart button click event
here ,
MemoryStream str = new MemoryStream(); Chart1.SaveImage(str); Session["exportImage"] = str;we have separate Export button , paste the following code in this event,
byte[] bytes1 = ((MemoryStream)Session["exportImage"]).ToArray(); Response.Clear(); Response.ContentType = "image/png"; Response.AddHeader("Content-Disposition", "attachment; filename=HTML.png"); Response.Buffer = true; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(bytes1); Response.End();
Its Working for me.
No comments:
Post a Comment