Convert DataGrid to Excel but include image when datagrid only has image URL RRS feed

  • Question

  • User336760158 posted

    I have some code that converts a Datagrid to Excel and it works fine

    But I now a DataGrid that includes a image . The image is genera; in the DatGrid  by using URL to a file on the server.

    When converted to Ecel the image doesnt show because the URL wont work as the  EXcel sheet is displaying on my compter

    I neeed to convert Link into .jpg file before converting to Excel


    The code i am using  is below


    private void Excel(object sender, System.EventArgs e)



    //export to excel


    Response.Buffer =


          Response.ContentType =


           Response.Charset =



    this.EnableViewState = false;


    StringWriter oStringWriter = new System.IO.StringWriter();


    HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);








    Tuesday, June 18, 2013 12:21 AM


  • User-359936451 posted

    i don't think you can send a jpg through a text writer.

    You may need to pass a link to the jpg and use Excel Macro to update the image in Spreasheet.

    Or maybe use some other method to move image to appropriate Excel cell based on the text already populated in first export.




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 18, 2013 4:25 PM