将DataTable导出为带图像的Excel [英] Export DataTable to excel with images
本文介绍了将DataTable导出为带图像的Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好。
我有一个网页,其中包含要导出到Excel的数据表。数据表在每列中都包含一个图像。怎么做?
这是我的代码:
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:
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);
推荐答案
以下是行转移excel中的所有内容, -
Response.ContentType =Application / vnd.ms-excel;
谢谢
Prasanta Banerjee
http://guru-code.blogspot.com/
http://prasanta.tk /
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/
只需以下行转移excel中的所有内容, -
Response.ContentType =Application / vnd.ms-excel;
谢谢
Prasanta Banerjee
http://prasanta.tk/
Just the following line transfer everything in excel,-
Response.ContentType = "Application/vnd.ms-excel";
Thank You
Prasanta Banerjee
http://prasanta.tk/
Just以下行转移excel中的所有内容, -
Response.ContentType =Application / vnd.ms-excel;
Just the following line transfer everything in excel,-
Response.ContentType = "Application/vnd.ms-excel";
这篇关于将DataTable导出为带图像的Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文