Click here to Skip to main content
15,908,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

I have a web page with a datatable to be exported to Excel. The datatable contains an image in every column. How can do that?

This is my code:
C#
string strImg = Server.MapPath(dtTemp.Rows[a]["p_img"].ToString());
            System.Drawing.Image img = System.Drawing.Image.FromFile(strImg);
            MemoryStream ms = new MemoryStream();
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            bf.Serialize(ms, img);
            drTemp[5] = ms.ToArray();


PublicHelper.DataToXSL.CreateXLS(dt, strSavePath);
Posted
Updated 12-Apr-11 0:19am
v3

Just the following line transfer everything in excel,-

Response.ContentType = "Application/vnd.ms-excel";

Thank You
Prasanta Banerjee
http://guru-code.blogspot.com/
http://prasanta.tk/
 
Share this answer
 
Just the following line transfer everything in excel,-
Response.ContentType = "Application/vnd.ms-excel";

Thank You
Prasanta Banerjee
http://prasanta.tk/
 
Share this answer
 
Just the following line transfer everything in excel,-
Response.ContentType = "Application/vnd.ms-excel";
 
Share this answer
 
Your requirement can be achieved as shown in the below page.

DataTable with images to Excel
 
Share this answer
 
Comments
CHill60 24-Feb-14 7:28am    
Please don't reincarnate old questions just to drive traffic to your own article. It could be perceived as spam

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900