cancel
Showing results for 
Search instead for 
Did you mean: 

Call C# Class in assembly from Crystal Report

Former Member
0 Kudos

Can I create a utility class in C# VS2008 and call it from the report?

We have some reports that currently call a common function in a prg in VFP. We are rewriting in C# and using Crystal Reports. We would like to change that to a VS2008 class called from many Crystal reportsu2026

Is this possible? If so, does the class have to exist in the same assembly?

Using VS2008 and the Express version of Crystal Reports that is included.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Yes, you can do this. The first step is that the class should have a public method which returns a dataset object. Crystal Reports can easily report off of datasets. Once you have this assembly compiled into a separate DLL, you can create a new report and reference the DLL by going into the Database Expert and under the Create New Connections node, find ADO.NET. Find the path to your DLL and select the class.

Before clicking the Finish button, you need to tell Crystal Reports that the DLL has a method which returns a DataSet. Click the Use DataSet from Class checkbox. This causes a new dropdown box to appear which lists the methods in the class that return a dataset.

When you run the report in your aplication, it will call the DLL, refernce the class you specified and get the DataSet object from it. Then it prints the data from this dataset.

This might be a bit confusing, so feel free to post a follow up question if you need more details on one of the steps. I hope this helps.

Former Member
0 Kudos

Thank you for your response. However, I am not referring to returning a dataset, but a value based on the results of a function. The majority of the data for the report is already filled and passed to the report. I would like to have the value in one field determined by the return value of that function.

I know that Crystal can access separate assemblies as long as they return a dataset, but not entities (I've tested that and they have to access a stub class in the same assembly that is derived from the entity class in the external assembly).

However, in this case, I want to just call a class from Crystal and return a value for one field on each line in the report...

Edited by: tch on Aug 25, 2008 2:19 AM

Former Member
0 Kudos

Oh I see. Yes, Crystal can referene a custom .NET DLL via a formula. This is a bit involved to get it set up properly, so I"m going to point you to the CR online help file you need.

http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf

Download this file and go to page 389.

I think this is what you are looking for!

Brian

former_member200290
Contributor
0 Kudos

Brian's reply is probably what you need, the custom UFL should fit your needs.

There is one other way to call a .NET class from a Crystal Report and that is through a custom add-in. Where the custom UFL is called during the report generation, the custom add-in is only called at runtime and is to create custom tools to modify the report, common tasks like adding letter-heads and corperate logos.

You can find a paper on this here:

https://boc.sdn.sap.com/node/6011

Trevor

Former Member
0 Kudos

Is this still possible with Crystal Reports 2008?

former_member208657
Active Contributor
0 Kudos

Yes it is. Check the [Crystal Reports .NET Developer Guide|http://help.sap.com/businessobject/product_guides/boexir31/en/crsdk_net_dg_12_en.chm]

- Tutorials

- Other Tutorials

- Tutorial: Creating a User Function Library

Former Member
0 Kudos

Thanks!

former_member183750
Active Contributor
0 Kudos

The distribution of these DLLs tends to be a bit tricky. See [this|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_dev/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] note for details.

Ludek

Answers (1)

Answers (1)

Former Member
0 Kudos

Thank you. I'll research it!