Convert Measurement in Crystal Report to CM or Inch

iirc, Crystal units are TWIPS (twentieth of a point) [], 1 twip = 1/1440 inch, they are independent of the number of pixels on the screen; to find out how many twips wide your document is, you check the page size you setup on the report (in inches let’s say, then multiply by 1440). And I’m not sure you can change this programmatically.

Anyway: if 1 inch = 1440 twips, 1 cm = 576 twips.



Copy from:

Multiple Columns In A Crystal Report

Here’s how to create a sub-report within Crystal Reports containing multiple columns. This information applies to Crystal Reports version 9, but probably also applies to other versions.

Sub-report section expert dialogue

To create a multiple-column report
1. Open the report you want to format with multiple columns.
2. On the Report menu, click Section Expert.
Tip: Another way to do this is to click the Section Expert button on the Expert Tools toolbar.
3. In the Section Expert, highlight Details, and then select Format with Multiple Columns.
A Layout tab is added to the Section Expert.
4. Click the Layout tab and set the Width you want your column to be.
Keep in mind the width of your paper when deciding your column width. For example, if you have three fields in your Details section, and they take up four inches of space, limit the width of the column to under four and a half inches so that all the field information can be seen.
5. Set the Horizontal and/or Vertical gap you want to maintain between each record in your column.
6. In the Printing Direction area, choose a direction.
7. If the report you’re formatting contains grouping, select Format Groups with multiple column.
8. Click OK.

When you preview the report, you’ll see that the field headers appear only for the first column. To have field headers for the second column, insert a text object.


Referenced by:

Image in Crystal Reports

Screenshot - ImgInReport.gif


This article will display the image in crystal report viewrBackground

Using the code

Simply open the source code in 2003.

 Collapse | Copy Code
    try { 
        // here i have define a simple datatable inwhich image will recide 

        DataTable dt = new DataTable(); 
        // object of data row 

        DataRow drow; 
        // 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 

        FileStream fs; 
        // define te binary reader to read the bytes of image 

        BinaryReader br; 
        // check the existance of image 

        if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "10157.Jpg")) { 
            // 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 + "NoPhoto.jpg", FileMode.Open); 
        // initialise the binary reader from file streamobject 

        br = new BinaryReader(fs); 
        // define the byte array of filelength 

        byte[] imgbyte = new byte[fs.Length + 1]; 
        // read the bytes from the binary reader 

        imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length))); 
        drow(0) = imgbyte; 
        // add the image in bytearray 

        // add row into the datatable 

        // close the binary reader 

        // close the file stream 

        CrystalReport1 rptobj = new CrystalReport1(); 
        // object of crystal report 

        // set the datasource of crystalreport object 

        CrystalReportViewer1.ReportSource = rptobj; 
        //set the report source 

    catch (Exception ex) { 
        // error handling 

        Interaction.MsgBox("Missing 10157.jpg or nophoto.jpg in application folder"); 
// run the application to view image in report

Remember if you are using c# the paste the above code in button click event

Points of Interest

In this article you will be also able to convert the image into byte array


In this project after clicking the button the action are performed you are free to modify as per your requirement
Feel free for any querrrrrries.

enjoy .net


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.


Referenced by:

Crystal report with Dynamic Column

The objective of this article is to provide a process which can be followed to develop a crystal report with dynamic columns using parameterized column fields and formula fields. Before going for this the developer has to decide the maximum number of columns he/she has to display and as per the no. of columns the size of the paper. The developer can define the size of the paper by selecting Printer Setup in File menu.

There are two ways to display the columns in Crystal Report dynamically. The default is using the infamous Cross Tab component and the other is using parameterized columns. But there are certain limitations to this . Where the cross tab does not provide complete control to each individual cells value, for using dynamic columns, the developer has to decide the maximum no columns in design time and all the field values should be of same data type.

Lets take an example of an yearly report where the developer has to create  such a report , when executed will display only those month values as columns , which are selected with “Total” immediately next . So the view may look like :

If the sales of products selected from Mar 2006 to May 2006.


Product Name Mar Apr May Total
Pro 1 12 89 90 191
Pro 2 20 99 70 199
Grand Total 32 188 160 390

Same way if the end results for different scenario :

  1. If date is between Jan 2006 – Aug 2006
    Product Name  Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Total
  2. If date is between Jun 2006 – Nov 2006
    Product Name  Jun  Jul  Aug  Sep  Oct  Nov  Total

Note : These instructions only work if all the attribute fields are of the same data type as they will be dynamically interchanged using a logic statement.

It seems most of the attribute fields will be of a String data type. We can create formulas in our report that will convert numbers to text using the ToText function. Then, simply use the formula instead of the database field. Or, if our organization uses Views or Queries as data source, convert the data type on that end.

Steps to create a report with dynamic columns…

1) Determine the maximum number of columns the report page can handle. Or determine the reasonable number of attributes an end user would want to see. (Consider a report with 50 columns of attributes. It would be unreadable.)

2) Create a string parameter for every attribute column on the report. Do not set the default values at this time (see next step).

3) Open Note Pad (on your desktop under accessories). Type all possible attributes starting in top right corner with one below the other (see below).


Keep in mind, these will be listed in the pick list and displayed on the report as column headings. The value “None” is important. It will be used in a logic statement, later in these instructions. Save the file (as a text file, .txt) in a shared location all users of the report can access (or on the CE server if using Enterprise).

Name the file similar to the .rpt file name combined with the word “attributes” or “parameter” so it is easy to locate.

4) Edit each parameter created in step 2 and do the following:

Click on “Set default values”.

Click on “Import pick list”.

Browse to locate the text file you just created in step 3.

Click OK. The list is automatically populated with the values in the text file.

5) Create empty formulas for the detail fields. The Design will look something like this…

Row Num Product name {?Month1} {?Month2} {?Month3}{?Month4}……………………{?Total}
{rownum} {db.ProdName}
{@mon.1-Detail} {@Mon.2-Detail} {@Mon.3-Detail}………….{@Total-Detail}

Just use the Insert Fields box and create the formulas up front. Leave them empty. Place them on the Design Tab. Then use the Insert Fields box to edit them later.

6) Edit the Mon.1-Detail field. Enter the following logic…

(assuming the Stored Proc or View returning column names as ProdName Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)

if {?Month1}= “JAN” then {DB.JAN}
else if {?Month1}= “FEB” then {DB.FEB}
else if {?Month1}= “MAR” then {DB.MAR}
else if {?Month1}= “APR” then {DB.APR}
else if {?Month1}= “MAY” then {DB.MAY}
else if {?Month1}= “JUN” then {DB.JUN}
else if {?Month1}= “JUL” then {DB.JUL}
else if {?Month1}= “AUG” then {DB.AUG}
else if {?Month1}= “SEP” then {DB.SEP}
else if {?Month1}= “OCT” then {DB.OCT}
else if {?Month1}= “NOV” then {DB.NOV}
else if {?Month1}= “DEC” then {DB.DEC}
—— add the total field value if applicable
else 0;

Save the formula changes, but don’t exit the formula editor. Copy the entire logic statement, then exit.

7) Edit {@Mon.2-Detail}. Paste the logic statement from step 6 into the Formula editor. Use Find/Replace in the formula Editor to find “?Month1” and replace with “?Month2”.

Then save the change. Repeat this process for the remaining column detail formulas.

Note: Incase of Total field it will start from the second field onwards. So to display the Total value add the line below (incase if second column will be counted as the total column)

else if {?Month2}= “Total” then {@Month_Det1}

Same way for all other columns also add …..

else if {?Month3}= “Total” then {@Month_Det1} + {@Month_Det2} If 3rd will be the Total column

else if {?Month4}= “Total” then {@Month_Det1} + {@Month_Det2} + {@Month_Det3} if 4th col will be the Total and so on..

8) You may also want to add conditional formatting to supress the columns that are not used. To do this you need to edit each field in the column (header and detail).

Start with Column 1’s heading…

Right click on the parameter field, {?Column 1}.
Select Format field.
On the Common tab find Supress at the top.

Go to the right and click on the “X+2” button. Enter the following logic in the Format formula editor:

if {?Month1}=”None” then true else false;

Save, but don’t close. Copy the statement. Close the Format formula editor.

Repeat on the {@Month.1-Detail} field using the pasted statement.

Repeat on the remaining columns, but remember to change the column number in the logic.

9) To add a running total for each column select a new running total field as display below

Select the parameterized field to sum up and and in the type of summary field select Sum from the dropdown.

Repeat the same process for all the columns as displayed above and also suppress them as per the condition (Refer Sec 8 to make a conditional suppress).

How it works :

1) The column heading will display the parameter value selected by the user. It will display just as you typed it into the default value list when creating the parameter.

Example :

In the example below I am displaying the records of references  during the month of Aug and Sep 2006 including the total and grand total value.

Select Aug for the month1 parameter field

Repeat it to select Sep for month2 parameter field and Total for month3 field . And select From Date and To date as 1st Aug 2006  – 30th Sep 2006.

2) The detail section will display the corresponding attributes for each item record based on the parameter values provided at run time.

On execution of this report it will display like the below

Contribution by: Kishore Gandra , Sarika Pahurkar , Edmond Joseph

Referenced by:

Adding watermarks to Crystal Reports

Here is the latest tip from the Flexible Solutions GP Reports Newsletter: how to add a watermark to your Crystal Reports.  I am going to demonstrate with an example.

I have created a statement report, but it’s a little bland, especially when there are only a few lines of data to show:

First step is to copy the watermark image to the Page Header section. On my report I was not using the page header, so I could put the watermark there. If your report is already using the page header, you can add an additional page header by right clicking on the Page Header section and choosing Insert Section Below:

Once you insert the watermark image you may need to re-size it or reposition it lower so that it is does not show up at the top (unless that is what you want).

Now go to Report > Section Expert, click on the Page Header (if you created a new section, it will be Page Header b) under Sections and check Underlay Following Sections on the Common tab:

Click OK and go to your report Preview. I had to go back and move my watermark down some more, but here is the end result:

You can sign up for the GP Reports newsletter to get these tips monthly or you can see the archived newsletters on the Flexible Solutions News & Events page. You can also see a list of all the Crystal Reports tips published so far on my GP Reports page under Working with Crystal Reports.


Wraping field in crystal report

When you want to display long text in crystal report, and It won’t show you the whole text, you should wrap your text as below:

  2. Open The The Open The Report That You Want To Enable Word Wrap Report
  3. Right Click On The Field That You Want To Word Wrap.
  4. Select  Format Object
  5. Then Place A Check In The Box Can Grow and set the maximum line number.


Insert Watermark into Report Background

Text Watermark A common report request is the ability to add a watermark to a report indicating that it is a draft. This example will show you how to accomplish this. In order to create the watermark, create a new header section, add a text object for the watermark and select the “Underlay Following Sections” option. This allows for new header to be above the rest of the sections of the report.

  • Figure 14: The Section Expert

  • Figure 15: The watermark in the designer

  • Figure 16: Fulfillment report with draft watermark