繁体   English   中英

图像未显示在水晶报表中

[英]Image not display in crystal report

我正在尝试在水晶报表中显示图像。 在下面的代码中,我转换文件流中的图像路径,然后通过数据表添加报表源。 但静止图像未显示

string path;
DataTable dt = new DataTable();

path = Server.MapPath("~/img/logo.jpg");   
DataColumn column = new DataColumn("Image"); //Create the column.
column.DataType = System.Type.GetType("System.Byte[]"); 
dt.Columns.Add(column);
DataRow row = dt.NewRow();
FileStream fs = new FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
Byte[] Image = new Byte[fs.Length];
fs.Read(Image, 0, Convert.ToInt32(fs.Length));
fs.Close();
row["Image"] = Image;
dt.Rows.Add(row);
dss.Tables[0].Merge(dt);
//set dataset to the report viewer.
rptDoc.SetDataSource(dss);
CrystalReportViewer1.ReportSource = rptDoc;

您只需要以字节流的形式将Image保存到数据库中,就不需要转换回以用于Crystal报表中,只需通过将其拖放到报表字段(即图像)来调用带有该图像的字段名称将显示..我曾经在C#中做到这一点。 希望它也对您有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM