How to display images in the crystal report?

zhaozj2021-02-16  60

Usually we want to display text and digital data in the crystal report. Sometimes, the database will contain image data and we also want to use it in the crystal report. There are many ways to display data-driven images in the report.

The first to make sure the image has sufficient size and quality. It is meaningless to try to display high quality large image as a simplified picture in the report. Create an image you can display with an image editor to create an image you can display in a suitable resolution and size.

The format of the image is also very important. Although BMP is a fairly universal format, it needs to take huge space. Therefore, it is desirable to convert the image to a compression format similar to JPG or GIF. Crystal reports support all these formats.

The problem to be solved is how to put the image into a crystal statement. In the past, we used the only answer to use the database path. However, there are many other ways. Let us look at the three ways ...

1. Database Solution: It is easy to implement, but it takes a very large disk space.

You can store image data in the database field. These fields are called OLE fields in Microsoft Access, while Oracle and SQL Server call them as a BLOB (Binary Large Object) field.

An example of this technology is the Xtreme instance database provided by the Crystal Report. In the "Employee" table, there is a field containing the employee photo, the name is "employee photo". You only need to insert these fields into the report, which is the same as the other field.

Ok, you can directly link the image field to the database data. In a bad side, these images will occupy a considerable database space. This means they have adverse effects on performance and storage.

2. Developer Solution: The function is limited and a developer is needed.

In some crystal report books, we have read a crystal report viewer with programming languages ​​(such as: Visual Basic). In the program, you can capture events like "Formatting Festival" and then change the OLE object in the report to load different images.

A good side, this allows you to loosen the coupling data and image. In a bad side, this requires development complex procedures, and it can only be used with specific reports. We are considering developing this viewer until you encounter the following two techniques. Recently, we have heard that these formatting events in the Crystal Report 9 will not be available.

3. Drive Solution: Quick and flexible third-party products.

There is a great feature in Crystal Reports 8 and 9 that you can use COM data sources. This means you can create a recordset using the program code and then use it as a data source of the report.

We develop CViewImage (http://www.crystalkeen.com/tools/cview.htm), a COM data source that can read three fields (identifiers, descriptions, and image file names) from any ODBC table . The COM data source will create a fourth field that contains images corresponding to the file name. Use it in the sub-report to display the image.

The biggest advantage of the program is that the entire recordset is loaded, so it can quickly load and process images, and it is also flexible for use in those images and database fields. It only needs an ODBC data source.

In a bad side, it needs some initialization settings to locate the image, but we have made the drive enough, so you can support multiple configurations. We can even create an expansion version to include all the fields in the table. Let us know if this is valuable.

4. Distribution Solution: Installing UFL (User Ribbon) is both simple and cheap.

Another solution is to export to HTML, using our SMTP user function library (http://www.crystalkeen.com/tools/mailfunctionlibrary_smtp.htm). We also have some other user function libraries that can be sent to Outlook, XML, or disk files. Some people refer to this "reporting pulse", where your report engine uses a function library to generate a variety of output files. At present, we have an SMTP library to embed an image in an HTML message when the report is processed. This is a standard feature of our SMTP library.

转载请注明原文地址:https://www.9cbs.com/read-22451.html

New Post(0)