簡體   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