Embed image in excelsheet
-
Hi! I have a peculiar situation. I need to export an image and a gridview control to excel. im using rendercontrol for image and datagrid, however, the image only exports it with a link to the actual location. The code snippet is : //Code starts Response.AddHeader("content-disposition", "attachment; filename=Export.xls"); Response.ContentType = "Application/vnd.ms-excel"; Response.ContentType = "Application/vnd.ms-excel"; System.IO.StringWriter strW = new System.IO.StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(strW); HtmlImage himg = new HtmlImage(); System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("Charts.aspx")); himg.Src = Server.MapPath("Charts.jpg"); himg.RenderControl(htw); HtmlTable tbl1 = new HtmlTable(); int intRows = 0; while (intRows < 23) { HtmlTableRow hrow = new HtmlTableRow(); tbl1.Rows.Add(hrow); intRows++; } tbl1.RenderControl(htw); GridView1.RenderControl(htw); Response.WriteFile(Server.MapPath("RRAT_Charts.jpg")); Response.Write(strW.ToString()); Response.End(); //code ends What i need is to embed the image on to the excelsheet. How can i do that? Any ideas? Thanks in advance!!
I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--
-
Hi! I have a peculiar situation. I need to export an image and a gridview control to excel. im using rendercontrol for image and datagrid, however, the image only exports it with a link to the actual location. The code snippet is : //Code starts Response.AddHeader("content-disposition", "attachment; filename=Export.xls"); Response.ContentType = "Application/vnd.ms-excel"; Response.ContentType = "Application/vnd.ms-excel"; System.IO.StringWriter strW = new System.IO.StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(strW); HtmlImage himg = new HtmlImage(); System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("Charts.aspx")); himg.Src = Server.MapPath("Charts.jpg"); himg.RenderControl(htw); HtmlTable tbl1 = new HtmlTable(); int intRows = 0; while (intRows < 23) { HtmlTableRow hrow = new HtmlTableRow(); tbl1.Rows.Add(hrow); intRows++; } tbl1.RenderControl(htw); GridView1.RenderControl(htw); Response.WriteFile(Server.MapPath("RRAT_Charts.jpg")); Response.Write(strW.ToString()); Response.End(); //code ends What i need is to embed the image on to the excelsheet. How can i do that? Any ideas? Thanks in advance!!
I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--
Check this out: http://www.codeproject.com/KB/COM/ComExcelImages.aspx[^]
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson -
Check this out: http://www.codeproject.com/KB/COM/ComExcelImages.aspx[^]
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson