图像未显示在Crystal Report上 [英] Image not showing on Crystal Report
本文介绍了图像未显示在Crystal Report上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在使用以下代码在Web项目中使用VS 2008的嵌入式Crystal报表在CrystalReport上显示图像.
在设计时,我使用了与运行时数据表"newData"具有相同架构的数据集和数据表.
Hi all,
I am using following code to display an image on a CrystalReport in my web project using embedded crystal reports of VS 2008.
At design time I used a DataSet and Data table with the same schema as the run-time DataTable ''newData''.
customerReport = new ReportDocument();
string reportPath = Server.MapPath("CrystalReport.rpt");
customerReport.Load(reportPath);
DataTable newData = new DataTable();
newData.Columns.Add("SNo", System.Type.GetType("System.String"));
newData.Columns.Add("Name", System.Type.GetType("System.String"));
newData.Columns.Add("Tele", System.Type.GetType("System.String"));
newData.Columns.Add("Image", System.Type.GetType("System.Byte[]"));
DataRow dr = newData.NewRow();
dr[0] = "Trying once";
dr[1] = "Trying Again";
dr[2] = "Still No Clue";
string picPath = Server.MapPath("EmployeeImage/SomeImage.jpg");
FileStream fs = new FileStream(picPath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] imgByte = new byte[fs.Length + 1];
imgByte = br.ReadBytes(Convert.ToInt32(fs.Length) );
dr[3] = imgByte;
newData.Rows.Add(dr);
br = null;
fs.Close();
fs = null;
customerReport.Database.Tables[0].SetDataSource(newData );
crystalReportViewer.ReportSource = customerReport;
但是,CrystalReport中没有显示图像.我确认数据表中的图像字段充满了二进制数据.
谁能帮我?
在此先感谢.
此致
GeoNav
However, no image is displayed in the CrystalReport. I confirmed that the image field in the datatable is filled with the binary data.
Can anyone help me?
Thanks in Advance.
Regards,
GeoNav
推荐答案
尝试:
1.byte[] imgByte = new byte[fs.Length];
2.customerReport.SetDataSource(newData);
请参阅以显示图像,以查看以下内容:
如何使用Visual Studio 2005在Crystal Reports中动态加载图像 [ Crystal Reports:如何在Crystal Report中显示图像 [ Crystal Reports中的图像 [
Try:
1.byte[] imgByte = new byte[fs.Length];
2.customerReport.SetDataSource(newData);
Refer, to display images, have a look at these:
How to dynamically load images in Crystal Reports using Visual Studio 2005[^]
Crystal Reports: How to Display Images in a Crystal Report[^]
Image in Crystal Reports[^]
这篇关于图像未显示在Crystal Report上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文