I'm trying to convert a gridview to an excel report and have one small hang up. So far I've been able to create my gridview and export it to excel ok, but in my gridview I have an image. The problem is, the image won't display unless I'm connected to the Internet or if I use a relative path and have the image stored relative to the excel file. Is it possible to "embed" the image from the gridview into the excel workbook so I could give the excel workbook to anyone without needing connection to the Internet or having the images locally. I'd like it all to be one excel file.
This is the code I'm using to create the excel workbook.
Expand|Select|Wrap|Line Numbers
- Response.Clear();
- Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
- Response.Charset = "";
- Response.Cache.SetCacheability(HttpCacheability.NoCache);
- Response.ContentType = "application/excel";
- System.IO.StringWriter stringWrite = new System.IO.StringWriter();
- System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
- this.GridView1.RenderControl(htmlWrite);
- Response.Write(stringWrite.ToString());
- Response.End();
Thanks