Creating Crystal Reports Programmatically in .NET

Posted on 2004-03-26
Medium Priority
Last Modified: 2007-11-27
Is it possible to create crystal reports programmatically using VB.NET (or anything.NET) with "Crystal Reports for .NET"

Ie I want to do some kind of CreateObject for the report, create the report sections, add the fields, datasource etc and set everything else programmatically.

I've found articles covering advanced edition but want to do it with just the .NET product if possible.

Question by:xassets
  • 4
  • 3
  • 2
  • +2
LVL 42

Expert Comment

ID: 10688464

Assisted Solution

OverTheEdge earned 800 total points
ID: 10688648
  Unfortunately, Crystal Decisions is very restrictive about allowing you to create reports on the fly. They want you to buy additional licenses to do this. In fact, you have to buy a license for each machine that is going to run your application. This quickly becomes incredibly expensive and I would think that only the largest companies can afford this luxury. This applies for both the CR.NET that you get with Visual Studio as well as using the RDC that comes with CR9 and CR10. The one option you have is that if you want to run your reports using ASP.NET, then you can use the RAS components on the web server. For some reason, Crystal Decisions thinks its okay to let you build reports programmatically as long as you only do it on a web server. What's the reason for that? I have no idea. But I'm guessing its because they are trying to compete with other reporting tools that are server based and marketed towards enterprises with cash to spend.


    Brian Bischof


    A Crystal Reports.NET tutorial for programmers? Its here!
    * Covers ASP.NET and Windows Forms
    * Teaches all phases of report development
    * Alerts you to the bugs and how to get around them
    * Maps out the complex ReportDocument object model
    * Shows how to perform runtime customization
    * Demonstrates all options of connecting with ADO.NET
    * Gives complete code listings for every concept presented


Author Comment

ID: 10688759
OK this is what I typed in response to frodoman's answer....

Thanks for this.

If I'm reading this right, I need some activex component called RDC which doesn't exist in crystal .net. Do I need to buy the developer edition of crystal to get hold of the RDC ?

I'm actually not that bothered about using .NET, and would prefer to call it from vb6. I was referring to .NET just because it comes with a version of crystal. If we need to buy developer edition we will.

The article mentions that the RDC makes calls to a "Report Creation API". If this API exists in .net then I could forget the RDC and just use the API instead ? Is that possible ?


Brian: This will be a web application (with vb6 mid tier) so using ASP.NET to create the reports on the web server is not a problem.

Interesting that the Crystal sales people didn't tell me about that one, wanted me to buy advanced edition instead !

If you can offer any pointers on how to create a "hello world" crystal report on the fly that would be great.


Question you'd both probably know the answer to: Are there any compelling reasons for choosing vb6 + crystal dev edition over .NET, other than price ?

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 10698082
would appreciate answers to the above, sorry but the crystal product line is v difficult to understand

What I'm getting at is that I want an web app to compile reports "on the fly", and I want the minimum crystal product to achieve that.

I've been trying to find out how to compile a crystal report using asp.net and its not going well, I just don't know which objects to start with. Any ideas ?
LVL 42

Expert Comment

ID: 10703889
As far as I know, you'll need either developer or advanced editions to do the dynamic reporting.  I've never used other versions so I can't be certain it's not possible but the documentation I've read indicates that it isn't part of the license (even if you do manage to get the necessary components).  So, developer/advanced would be the minimum product.

If you want some good asp.net tutorials, try this site: http://www.businessobjects.com/products/dev_zone/default.asp  and download the "Underground Office Supply" sample.

Author Comment

ID: 10704029
Thanks frodoman, I'm going to double check on the asp.net licensing stuff with crystal people, but I'll also check out those links.

Can you just answer one more thing:

Instead of creating the whole report at run time, if we had a report template with a set of fields, is it possible using developer edition to hide fields, move fields and change datasource and font etc ? That may be easier to program I reckon.

LVL 42

Accepted Solution

frodoman earned 1200 total points
ID: 10704216
I've never done some of it myself (I usually go with static report or completely from scratch myself) - but I believe all of that is possible.  Certainly changing datasource - that's extremely common.  The rest of it seems like it wouldn't be a problem although it may be more work than necessary.  Depending on the situation don't forget that you can conditionally format just about everything w/in the report itself.  Often I'll create a "static" report and pass a parameter to it that will control the font size, hide extraneous fields, etc.


Author Comment

ID: 10704264
Ok thanks for the confirmation

I've found that you can indeed use RAS from ASP.NET, but haven't quite got through to the hello world stage yet. I'll raise another question about that if needed.

Expert Comment

ID: 10995723
Hi xassets,
              I am looking for the same kind of stuff , for that you were a month back.
I have to create a web report designer that is end user will be able to create/design reports using web browser from anywhere in the world and other people can view that report.
             User interface will be in .net.
             Also I don't know about licensesing for the same ( Crystal Report )
             Any kind of help, suggestion will be a light for me.
            I look forward to hear from you.
             Thanks in advance

Expert Comment

ID: 10995831
Hi navinkaush

Crystal licensing is pretty nasty. I think they're overly greedy and therefore leaving room for competitors to jump in. If you ask Crystal which product, they will always come back and say "advanced edition" no matter what.

For the time being crystal is a good option even so.

You can design RPT files within .NET at design time, but not at run time, and you can issue reports to aspx applications from a server. The server can PDF the reports and you can then call back the report using a url to a pdf file generated by crystal. If its a busy server then crystal will start throwing exceptions just to make you buy a server license.

If you want to design reports at run time, you have to get the advanced edition which has to be bought for you AND for each client. That can be a lot of money.

The actual export to pdf is easy :

        ''The path/location where the exported file will be saved
        Dim exportFilePath As String = Application.StartupPath + "\exported.pdf"

        ''Create an instance of the Chart report
        crReportDocument = New Chart()

        ''Set the options for saving the exported file to disk
        crDiskFileDestinationOptions = New DiskFileDestinationOptions()
        crDiskFileDestinationOptions.DiskFileName = exportFilePath

        ''Set the exporting information
        crExportOptions = crReportDocument.ExportOptions
        With crExportOptions
            .DestinationOptions = crDiskFileDestinationOptions
            .ExportDestinationType = ExportDestinationType.DiskFile
            .ExportFormatType = ExportFormatType.PortableDocFormat
        End With

        ''Export the report

        ''Display a message letting the user know the export is complete
        MessageBox.Show("Report exported to: '" & exportFilePath & "'")


Expert Comment

ID: 11002196
Yes, I got your point. Just tell me one thing, when we will give the creating/designing of report at run time through programming in asp.net page and finally report will run at server then why they will charge for each client. Client is just using browser and we don't know how many user can use it. it is open to world.
 Also , please tell me the possiblity of creating report at run-time. I got some documents that shows it is possible to create report at run time, I am going through those documents. But if you have some knowledge of creating report at run-time . please share with me.

Expert Comment

ID: 11003068
Here's crystals licensing statement from their web site
For each internal application that you build, the reporting component can be deployed on a single processor. To deploy the reporting component on additional processors and increase reporting throughout, additional licenses are required.

You may not under any circumstances deploy an application to access the reporting component on more than one processor by combining additional Crystal Reports licenses. To deploy the reporting component on additional processors or servers, processor-based expansion licensing is available.

If you build web applications that will be redistributed, sold or deployed to a third party, you must purchase a copy of Crystal Reports Developer or Advanced Developer for each company you redistribute to.

However, if you build your app using crystal reports with .net, you dont have to pay it unless you want the "increased reporting throughput". Not many apps produce 3 reports per second. Again from the crystal web site for .net lic:

A customized Crystal Reports designer is fully integrated within Microsoft Visual Studio .NET and Borland C#Builder for powerful—yet easy—report design. You may use the integrated designer to create an unlimited number of reports for use within your .NET applications.

For a fully functional, stand-alone designer, as well as over 50 new features and enhancements, upgrade to Crystal Reports 10 Advanced Edition. Reports you create with Crystal Reports 10 Advanced Edition can be used within your .NET application. Best of all, a new, more scalable deployment license comes standard with Advanced Edition.

--- and ---

You may use a single instance of the bundled reporting component for as many applications as you like within a single multi-processor server. You may not increase the scalability of this component by deploying it in a web farm. To increase scalability to meet your production requirements, upgrade to Crystal Reports 10 Developer or Advanced Edition. Learn more  

To redistribute a server or web application that uses the bundled reporting component outside your own organization to third parties, written authorization from Crystal is required. You can get authorization by registering your application online at no extra cost. Register your application


Its all here


I dont think its possible to create a report at run time without advanced edition. Please let me know if you find that I'm wrong !


Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question