locked
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.Clear();

    Response.Buffer =

    true;

          Response.ContentType =

    "application/vnd.ms-excel";

           Response.Charset =

    "";

         

    this.EnableViewState = false;

           System.IO.

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

            System.Web.UI.

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

           

    //this.ClearControls(GridView1);

           MyDataGrid.RenderControl(oHtmlTextWriter);

            Response.Write(oStringWriter.ToString());

            Response.End();

        }

     

    Tuesday, June 18, 2013 12:21 AM

Answers

  • 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