GirdView with Image in Header, Export to Excel
-
Hello, I have a gridview which have an image in the header. When I export this image into Excel, it shows the header image in Excel document without any problem. But when I transfer the exported excel file to some other system, the header image disappears. I think, this is because the image in excel document reference to the path in my system where it physically exists, i.e. Images folder under my website folder. When I transfer the file on other system, it tries to find the image at the same path, resulting a red cross icon at the place of image. Is there any way I can insert image in excel so that it does not reference the path from where the image was originally inserted....? Following is the code I am using to export grid view to excel...
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
StringWriter StringWriter = new System.IO.StringWriter();
HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter);
gvToExport.RenderControl(HtmlTextWriter);
Response.Write(StringWriter.ToString());
Response.End();
-
Hello, I have a gridview which have an image in the header. When I export this image into Excel, it shows the header image in Excel document without any problem. But when I transfer the exported excel file to some other system, the header image disappears. I think, this is because the image in excel document reference to the path in my system where it physically exists, i.e. Images folder under my website folder. When I transfer the file on other system, it tries to find the image at the same path, resulting a red cross icon at the place of image. Is there any way I can insert image in excel so that it does not reference the path from where the image was originally inserted....? Following is the code I am using to export grid view to excel...
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
StringWriter StringWriter = new System.IO.StringWriter();
HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter);
gvToExport.RenderControl(HtmlTextWriter);
Response.Write(StringWriter.ToString());
Response.End();
No Problem in this code. May be your Image path is unknown in other system. you can try ~/images/imagename.jpg
-
No Problem in this code. May be your Image path is unknown in other system. you can try ~/images/imagename.jpg
Hello, Thanks for the reply. As I wrote in the query, the exported excel file looks for the path from where it was inserted. And when it is downloaded by client, excel fails to find referenced path for the image. I was thinking about, somehow embed the image itself in the excel so that it refer the image internally.
-
Hello, Thanks for the reply. As I wrote in the query, the exported excel file looks for the path from where it was inserted. And when it is downloaded by client, excel fails to find referenced path for the image. I was thinking about, somehow embed the image itself in the excel so that it refer the image internally.
I solved the issue by using a template excel document.