如何在水晶报告中显示/显示图像-13 [英] How to display/show image in crystal report-13

查看:82
本文介绍了如何在水晶报告中显示/显示图像-13的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用ASP.net和vb语言在crystal report-13中显示/显示图像。使用图像字段拖放到水晶报表中,图像显示为空白。

How to display/show image in crystal report-13 using ASP.net and vb language .Using drag-drop of image field into crystal report,the image showing blank.

推荐答案

Crystal报表设计器不会仅在拖放时显示图像。它将显示何时生成报告。



以下应该有帮助,即使不是在第13行:

使用ASP.NET在Crystal Report中显示图像 [ ^ ]



有很多网上的文章也是如此。如果需要,请查看其他人并试用。
Crystal report designer will not show image just on drag-drop. It will show when report is generated.

Following should help even though not on v13:
Display Image in Crystal Report using ASP.NET[^]

There are lots of articles on web for the same. If needed, look at others and try out.


在数据库中创建一个名为 COLUMNNAME 的BLOB字段。

使用以下代码获取图像的引用

Create a BLOB field in database with a column Name COLUMNNAME.
Use the following code for getting the reference of the image
Private Function authSign(ByVal doccode As String) As DataTable
       ''here i have define a simple datatable inwhich image will recide
       Dim dt As New DataTable()
       ''object of data row
       Dim drow As DataRow
       '' add the column in table to store the image of Byte array type
       dt.Columns.Add("COLUMNNAME", 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 + "\Lab Reports\Signatures\" + doccode + ".JPG")) Then
           '' open image in file stream
           fs = New FileStream(AppDomain.CurrentDomain.BaseDirectory + "\Lab Reports\Signatures\" + doccode + ".JPG", FileMode.Open)
       Else
           '' if phot does not exist show the nophoto.jpg file
           fs = New FileStream(AppDomain.CurrentDomain.BaseDirectory + "\Lab Reports\Signatures\noSign.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 + 1) As Byte
       '' read the bytes from the binary reader
       imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)))
       drow("COLUMNNAME") = 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
       Return dt
   End Function





返回的数据表可以作为sourse传递给你的报告或你的子报告。这里我用的是子​​报告

报告名称AuthSignature.rpt在我的主报告中



Returned Datatable can be passed as a sourse to ur report or ur subreport.Here i used subreport
of report name AuthSignature.rpt in my main report

Dim report1 As New ReportDocument
       Dim auth As New DataTable
       auth.Columns.Add("COLUMNNAME", System.Type.GetType("System.Byte[]"))
       auth = authSign(OrderDtlType.t_ILS_ORDTAUTHDOCTORCODE)
       report1.Subreports("AuthSignature.rpt").SetDataSource(auth)
       CrystalReportViewer_rad.ReportSource = report1
       CrystalReportViewer_rad.DataBind()


这篇关于如何在水晶报告中显示/显示图像-13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆