Exporting images to excel?

Discussion in 'ASP General' started by Paulo, Feb 8, 2008.

  1. Paulo

    Paulo Guest

    Hi, using the following code:
    <%
    Response.Buffer
    Response.AddHeader "Content-Disposition",
    "attachment;filename=Relatorio_Individual.xls"
    Response.ContentType = "application/vnd.ms-excel"
    %>
    <table width="805" border="1" cellspacing="0" cellpadding="0">
    <tr>
    <td bgcolor="#660000" align="center" colspan="5" height="19"><img
    src="imagens/logo.gif"></td>
    <td bgcolor="#660000" align="center" colspan="5" height="19">
    <font face="arial" size="3" color="#FFFFFF">
    <b>QUILOMBO - Avaliação de Desempenho - Relatório Individual</b>
    </font>
    </td>
    </tr>
    </table>

    .... here goes the rest of code, connecting db, etc...

    %>

    but the "imagens/logo.gif" doesnt show on Excel... it appears a X (just like
    when the image was not found)
    and I need it on my excel report...

    How can I do that?

    Thanks in advance!
    Paulo, Feb 8, 2008
    #1
    1. Advertising

  2. "Paulo" <> wrote in message
    news:%...
    > Hi, using the following code:
    > <%
    > Response.Buffer
    > Response.AddHeader "Content-Disposition",
    > "attachment;filename=Relatorio_Individual.xls"
    > Response.ContentType = "application/vnd.ms-excel"
    > %>
    > <table width="805" border="1" cellspacing="0" cellpadding="0">
    > <tr>
    > <td bgcolor="#660000" align="center" colspan="5" height="19"><img
    > src="imagens/logo.gif"></td>
    > <td bgcolor="#660000" align="center" colspan="5" height="19">
    > <font face="arial" size="3" color="#FFFFFF">
    > <b>QUILOMBO - Avaliação de Desempenho - Relatório Individual</b>
    > </font>
    > </td>
    > </tr>
    > </table>
    >
    > ... here goes the rest of code, connecting db, etc...
    >
    > %>
    >
    > but the "imagens/logo.gif" doesnt show on Excel... it appears a X (just

    like
    > when the image was not found)
    > and I need it on my excel report...
    >
    > How can I do that?
    >



    The problem is with the attachment keyword present in the
    Content-Disposition the document is downloaded as a file and opened as a
    file in Excel. Therefore any relative references to images will be relative
    to the folder that the file is opened from.

    Do you need to download it as a file or could you load it in-browser?
    Alternatively you could set the src attributes of the images to use full URL
    like:- http://yourserverFQDN/images/logo.gif

    Whatever the approach you use the client must have the ability to access
    that content, it isn't encoded into the file itself.

    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Feb 8, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UHJhbmF2?=

    Exporting Images to Excel/Word

    =?Utf-8?B?UHJhbmF2?=, Apr 8, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    536
    =?Utf-8?B?UHJhbmF2?=
    Apr 8, 2004
  2. Luis Esteban Valencia
    Replies:
    1
    Views:
    1,367
    Carl Prothman [MVP]
    Jan 12, 2005
  3. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,482
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  4. Doogie
    Replies:
    1
    Views:
    441
    sloan
    Nov 19, 2008
  5. unotin
    Replies:
    1
    Views:
    260
Loading...

Share This Page