将图像传递到CrystalReport [英] Passing images to a CrystalReport
本文介绍了将图像传递到CrystalReport的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用VB.net代码将图像从本地磁盘传递到Crystal报告.我已经完成了将一个图像从本地驱动器传递到Crystal报表的操作,但是问题是我想从同一驱动器传递许多图像.我正在使用下面的代码传递图像:
I am passing images from my local disk to crystal reports using VB.net code. I have completed passing one image from my local drive to crystal reports, but the issue is I want to pass many images from the same drive. I am using the code below for passing the images:
' object of data row
Dim drow As DataRow
' add the column in table to store the image of Byte array type
dt.Columns.Add("Image", System.Type.GetType("System.Byte[]"))
drow = dt.NewRow
' define the filestream object to read the image
Dim fs As FileStream
' define te binary reader to read the bytes of image
Dim br As BinaryReader
' check the existance of image
If File.Exists(AppDomain.CurrentDomain.BaseDirectory & "10157.Jpg") Then
' open image in file stream
fs = New FileStream(AppDomain.CurrentDomain.BaseDirectory & "10157.Jpg", FileMode.Open)
Else ' if phot does not exist show the nophoto.jpg file
fs = New FileStream(AppDomain.CurrentDomain.BaseDirectory & "FLYWELL.jpg", FileMode.Open)
End If
' initialise the binary reader from file streamobject
br = New BinaryReader(fs)
' define the byte array of filelength
Dim imgbyte(fs.Length) As Byte
' read the bytes from the binary reader
imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)))
drow(0) = imgbyte ' add the image in bytearray
dt.Rows.Add(drow) ' add row into the datatable
br.Close() ' close the binary reader
fs.Close() ' close the file stream
Dim rptobj As New CrystalReport1 ' object of crystal report
rptobj.SetDataSource(dt)
CrystalReportViewer1.ReportSource = rptobj 'set the report source
推荐答案
看看这些:
Crystal Reports中的图像 [ Crystal Reports:如何在Crystal Report中显示图像 [如何使用Visual Studio 2005在Crystal Reports中动态加载图像 [
Have a look at these:
Image in Crystal Reports[^]
Crystal Reports: How to Display Images in a Crystal Report[^]
How to dynamically load images in Crystal Reports using Visual Studio 2005[^]
Try them!
这篇关于将图像传递到CrystalReport的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文