Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Embed image in excelsheet

Embed image in excelsheet

Scheduled Pinned Locked Moved ASP.NET
questiongraphicssysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sidbaruah
    wrote on last edited by
    #1

    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--

    V 1 Reply Last reply
    0
    • S sidbaruah

      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--

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • V Vasudevan Deepak Kumar

        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

        S Offline
        S Offline
        sidbaruah
        wrote on last edited by
        #3

        Thanks deepak for the reply.. ill try that out..

        I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups